draw: Remove dead code.
[mesa.git] / src / gallium / drivers / softpipe / sp_state_fs.c
index 22f82b1a4296c9dce5d5e0be3b4fc442e054c46b..c88e213751092320e127ff2c9523ddf8b29d9026 100644 (file)
@@ -31,6 +31,7 @@
 
 #include "pipe/p_defines.h"
 #include "util/u_memory.h"
+#include "util/u_inlines.h"
 #include "draw/draw_context.h"
 #include "draw/draw_vs.h"
 #include "tgsi/tgsi_dump.h"
@@ -44,6 +45,7 @@ softpipe_create_fs_state(struct pipe_context *pipe,
 {
    struct softpipe_context *softpipe = softpipe_context(pipe);
    struct sp_fragment_shader *state;
+   unsigned i;
 
    /* debug */
    if (softpipe->dump_fs) 
@@ -60,6 +62,13 @@ softpipe_create_fs_state(struct pipe_context *pipe,
    /* get/save the summary info for this shader */
    tgsi_scan_shader(templ->tokens, &state->info);
 
+   for (i = 0; i < state->info.num_properties; ++i) {
+      if (state->info.properties[i].name == TGSI_PROPERTY_FS_COORD_ORIGIN)
+         state->origin_lower_left = state->info.properties[i].data[0];
+      else if (state->info.properties[i].name == TGSI_PROPERTY_FS_COORD_PIXEL_CENTER)
+        state->pixel_center_integer = state->info.properties[i].data[0];
+   }
+
    return state;
 }
 
@@ -69,7 +78,14 @@ softpipe_bind_fs_state(struct pipe_context *pipe, void *fs)
 {
    struct softpipe_context *softpipe = softpipe_context(pipe);
 
-   softpipe->fs = (struct sp_fragment_shader *) fs;
+   draw_flush(softpipe->draw);
+
+   if (softpipe->fs == fs)
+      return;
+
+   draw_flush(softpipe->draw);
+
+   softpipe->fs = fs;
 
    softpipe->dirty |= SP_NEW_FS;
 }
@@ -152,16 +168,17 @@ softpipe_delete_vs_state(struct pipe_context *pipe, void *vs)
 void
 softpipe_set_constant_buffer(struct pipe_context *pipe,
                              uint shader, uint index,
-                             const struct pipe_constant_buffer *buf)
+                             struct pipe_buffer *buf)
 {
    struct softpipe_context *softpipe = softpipe_context(pipe);
 
    assert(shader < PIPE_SHADER_TYPES);
-   assert(index == 0);
+   assert(index < PIPE_MAX_CONSTANT_BUFFERS);
+
+   draw_flush(softpipe->draw);
 
    /* note: reference counting */
-   pipe_buffer_reference(&softpipe->constants[shader].buffer,
-                        buf ? buf->buffer : NULL);
+   pipe_buffer_reference(&softpipe->constants[shader][index], buf);
 
    softpipe->dirty |= SP_NEW_CONSTANTS;
 }
@@ -177,6 +194,10 @@ softpipe_create_gs_state(struct pipe_context *pipe,
    if (state == NULL )
       goto fail;
 
+   /* debug */
+   if (softpipe->dump_gs)
+      tgsi_dump(templ->tokens, 0);
+
    /* copy shader tokens, the ones passed in will go away.
     */
    state->shader.tokens = tgsi_dup_tokens(templ->tokens);
@@ -221,6 +242,7 @@ softpipe_delete_gs_state(struct pipe_context *pipe, void *gs)
    struct sp_geometry_shader *state =
       (struct sp_geometry_shader *)gs;
 
-   draw_delete_geometry_shader(softpipe->draw, state->draw_data);
+   draw_delete_geometry_shader(softpipe->draw,
+                               (state) ? state->draw_data : 0);
    FREE(state);
 }