#include "sp_context.h"
#include "sp_state.h"
+#include "sp_fs.h"
#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pipe/p_inlines.h"
#include "pipe/p_winsys.h"
-#include "pipe/draw/draw_context.h"
#include "pipe/p_shader_tokens.h"
-#include "pipe/llvm/gallivm.h"
-#include "pipe/tgsi/util/tgsi_dump.h"
-#include "pipe/tgsi/exec/tgsi_sse2.h"
+#include "draw/draw_context.h"
+#include "tgsi/tgsi_dump.h"
+#include "tgsi/tgsi_scan.h"
void *
const struct pipe_shader_state *templ)
{
struct softpipe_context *softpipe = softpipe_context(pipe);
- struct sp_fragment_shader_state *state;
-
- /* Decide whether we'll be codegenerating this shader and if so do
- * that now.
- */
-
- state = CALLOC_STRUCT(sp_fragment_shader_state);
- if (!state)
- return NULL;
-
- state->shader = *templ;
-
- if (softpipe->dump_fs) {
- tgsi_dump(state->shader.tokens, 0);
+ struct sp_fragment_shader *state;
+
+ /* debug */
+ if (softpipe->dump_fs)
+ tgsi_dump(templ->tokens, 0);
+
+ /* codegen */
+ state = softpipe_create_fs_llvm( softpipe, templ );
+ if (!state) {
+ state = softpipe_create_fs_sse( softpipe, templ );
+ if (!state) {
+ state = softpipe_create_fs_exec( softpipe, templ );
+ }
}
-#ifdef MESA_LLVM
- state->llvm_prog = 0;
+ assert(state);
-#if 0
- if (!gallivm_global_cpu_engine()) {
- gallivm_cpu_engine_create(state->llvm_prog);
- }
- else
- gallivm_cpu_jit_compile(gallivm_global_cpu_engine(), state->llvm_prog);
-#endif
-
-#elif defined(__i386__) || defined(__386__)
- if (softpipe->use_sse) {
- x86_init_func( &state->sse2_program );
- tgsi_emit_sse2_fs( state->shader.tokens, &state->sse2_program );
- }
-#endif
+ /* get/save the summary info for this shader */
+ tgsi_scan_shader(templ->tokens, &state->info);
return state;
}
{
struct softpipe_context *softpipe = softpipe_context(pipe);
- softpipe->fs = (struct sp_fragment_shader_state *) fs;
+ softpipe->fs = (struct sp_fragment_shader *) fs;
softpipe->dirty |= SP_NEW_FS;
}
void
softpipe_delete_fs_state(struct pipe_context *pipe, void *fs)
{
- struct sp_fragment_shader_state *state = fs;
-
-#if defined(__i386__) || defined(__386__)
- x86_release_func( &state->sse2_program );
-#endif
+ struct sp_fragment_shader *state = fs;
- FREE( state );
+ assert(fs != softpipe_context(pipe)->fs);
+
+ state->delete( state );
}
const struct pipe_shader_state *templ)
{
struct softpipe_context *softpipe = softpipe_context(pipe);
- struct sp_vertex_shader_state *state;
+ struct sp_vertex_shader *state;
- state = CALLOC_STRUCT(sp_vertex_shader_state);
+ state = CALLOC_STRUCT(sp_vertex_shader);
if (state == NULL ) {
return NULL;
}
- state->shader = *templ;
-
- state->draw_data = draw_create_vertex_shader(softpipe->draw,
- &state->shader);
+ state->draw_data = draw_create_vertex_shader(softpipe->draw, templ);
if (state->draw_data == NULL) {
FREE( state );
return NULL;
{
struct softpipe_context *softpipe = softpipe_context(pipe);
- softpipe->vs = (const struct sp_vertex_shader_state *)vs;
+ softpipe->vs = (const struct sp_vertex_shader *)vs;
- draw_bind_vertex_shader(softpipe->draw, softpipe->vs->draw_data);
+ draw_bind_vertex_shader(softpipe->draw,
+ (softpipe->vs ? softpipe->vs->draw_data : NULL));
softpipe->dirty |= SP_NEW_VS;
}
{
struct softpipe_context *softpipe = softpipe_context(pipe);
- struct sp_vertex_shader_state *state =
- (struct sp_vertex_shader_state *)vs;
+ struct sp_vertex_shader *state =
+ (struct sp_vertex_shader *)vs;
draw_delete_vertex_shader(softpipe->draw, state->draw_data);
FREE( state );
assert(index == 0);
/* note: reference counting */
- pipe_buffer_reference(ws,
+ winsys_buffer_reference(ws,
&softpipe->constants[shader].buffer,
- buf->buffer);
- softpipe->constants[shader].size = buf->size;
+ buf ? buf->buffer : NULL);
+ softpipe->constants[shader].size = buf ? buf->size : 0;
softpipe->dirty |= SP_NEW_CONSTANTS;
}