softpipe: rework to use the llvmpipe winsys
[mesa.git] / src / gallium / drivers / softpipe / sp_state_fs.c
index c88e213751092320e127ff2c9523ddf8b29d9026..cd0e905bc990c6c2fb23d8d046847622d06db0eb 100644 (file)
@@ -28,6 +28,7 @@
 #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"
@@ -163,26 +164,35 @@ 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 < PIPE_MAX_CONSTANT_BUFFERS);
+   assert(index == 0);
+
+   if(softpipe->constants[shader][index] == constants)
+      return;
 
    draw_flush(softpipe->draw);
 
    /* note: reference counting */
-   pipe_buffer_reference(&softpipe->constants[shader][index], buf);
+   pipe_buffer_reference(&softpipe->constants[shader][index], constants);
+
+   if(shader == PIPE_SHADER_VERTEX) {
+      draw_set_mapped_constant_buffer(softpipe->draw, PIPE_SHADER_VERTEX, 0,
+                                      data, size);
+   }
 
    softpipe->dirty |= SP_NEW_CONSTANTS;
 }
 
+
 void *
 softpipe_create_gs_state(struct pipe_context *pipe,
                          const struct pipe_shader_state *templ)