Merge branch 'master' into gallium-sampler-view
[mesa.git] / src / gallium / drivers / softpipe / sp_state_fs.c
index b7ed4441b4363ab0c5f665b36f354f5f267dfe8c..2b089c2831642108d13fd71528d4c5abaa12703b 100644 (file)
 #include "sp_context.h"
 #include "sp_state.h"
 #include "sp_fs.h"
+#include "sp_buffer.h"
 
 #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 +46,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 +63,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;
 }
 
@@ -154,14 +164,14 @@ softpipe_delete_vs_state(struct pipe_context *pipe, void *vs)
    FREE( state );
 }
 
-
-
 void
 softpipe_set_constant_buffer(struct pipe_context *pipe,
                              uint shader, uint index,
-                             struct pipe_buffer *buf)
+                             struct pipe_buffer *constants)
 {
    struct softpipe_context *softpipe = softpipe_context(pipe);
+   unsigned size = constants ? constants->size : 0;
+   const void *data = constants ? softpipe_buffer(constants)->data : NULL;
 
    assert(shader < PIPE_SHADER_TYPES);
    assert(index == 0);
@@ -169,11 +179,18 @@ softpipe_set_constant_buffer(struct pipe_context *pipe,
    draw_flush(softpipe->draw);
 
    /* note: reference counting */
-   pipe_buffer_reference(&softpipe->constants[shader], buf);
+   pipe_buffer_reference(&softpipe->constants[shader][index], constants);
 
+   if(shader == PIPE_SHADER_VERTEX) {
+      draw_set_mapped_constant_buffer(softpipe->draw, PIPE_SHADER_VERTEX, index,
+                                      data, size);
+   }
+
+   softpipe->mapped_constants[shader][index] = data;
    softpipe->dirty |= SP_NEW_CONSTANTS;
 }
 
+
 void *
 softpipe_create_gs_state(struct pipe_context *pipe,
                          const struct pipe_shader_state *templ)