Mesa (gallium-multiple-constant-buffers): gallium: Enable multiple constant buffers for vertex and geometry shaders.

Michał Król michal at kemper.freedesktop.org
Mon Jan 25 05:55:48 PST 2010


Module: Mesa
Branch: gallium-multiple-constant-buffers
Commit: a6201ae55f1e8bef6ad173d25a9bef0447d3b309
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a6201ae55f1e8bef6ad173d25a9bef0447d3b309

Author: Michal Krol <michal at vmware.com>
Date:   Mon Jan 25 12:36:50 2010 +0100

gallium: Enable multiple constant buffers for vertex and geometry shaders.

---

 src/gallium/auxiliary/draw/draw_context.c          |   11 +++--
 src/gallium/auxiliary/draw/draw_context.h          |   10 +++--
 src/gallium/auxiliary/draw/draw_gs.c               |   14 ++++--
 src/gallium/auxiliary/draw/draw_gs.h               |    2 +-
 src/gallium/auxiliary/draw/draw_private.h          |   28 +++++++-----
 .../auxiliary/draw/draw_pt_fetch_shade_pipeline.c  |   12 +++---
 src/gallium/auxiliary/draw/draw_vs.c               |   40 ++++++++++-------
 src/gallium/auxiliary/draw/draw_vs.h               |    8 ++-
 src/gallium/auxiliary/draw/draw_vs_aos.c           |   10 +++-
 src/gallium/auxiliary/draw/draw_vs_aos.h           |    2 +-
 src/gallium/auxiliary/draw/draw_vs_aos_machine.c   |   14 ++++--
 src/gallium/auxiliary/draw/draw_vs_exec.c          |    6 ++-
 src/gallium/auxiliary/draw/draw_vs_llvm.c          |    5 +-
 src/gallium/auxiliary/draw/draw_vs_ppc.c           |    4 +-
 src/gallium/auxiliary/draw/draw_vs_sse.c           |    4 +-
 src/gallium/auxiliary/draw/draw_vs_varient.c       |    4 +-
 src/gallium/drivers/cell/ppu/cell_draw_arrays.c    |    2 +-
 src/gallium/drivers/i915/i915_context.c            |    2 +-
 src/gallium/drivers/llvmpipe/lp_state_fs.c         |    2 +-
 src/gallium/drivers/nv04/nv04_vbo.c                |    2 +-
 src/gallium/drivers/nv10/nv10_vbo.c                |    1 +
 src/gallium/drivers/nv20/nv20_vbo.c                |    2 +-
 src/gallium/drivers/nv40/nv40_draw.c               |    2 +-
 src/gallium/drivers/r300/r300_render.c             |    2 +
 src/gallium/drivers/softpipe/sp_draw_arrays.c      |   48 ++++++++++++--------
 src/gallium/drivers/svga/svga_swtnl_draw.c         |    2 +-
 src/mesa/state_tracker/st_draw_feedback.c          |    2 +-
 27 files changed, 146 insertions(+), 95 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c
index e90dfc5..0382999 100644
--- a/src/gallium/auxiliary/draw/draw_context.c
+++ b/src/gallium/auxiliary/draw/draw_context.c
@@ -237,17 +237,20 @@ draw_set_mapped_vertex_buffer(struct draw_context *draw,
 void
 draw_set_mapped_constant_buffer(struct draw_context *draw,
                                 unsigned shader_type,
+                                unsigned slot,
                                 const void *buffer,
                                 unsigned size )
 {
    debug_assert(shader_type == PIPE_SHADER_VERTEX ||
                 shader_type == PIPE_SHADER_GEOMETRY);
+   debug_assert(slot < PIPE_MAX_CONSTANT);
+
    if (shader_type == PIPE_SHADER_VERTEX) {
-      draw->pt.user.vs_constants = buffer;
-      draw_vs_set_constants( draw, (const float (*)[4])buffer, size );
+      draw->pt.user.vs_constants[slot] = buffer;
+      draw_vs_set_constants(draw, slot, buffer, size);
    } else if (shader_type == PIPE_SHADER_GEOMETRY) {
-      draw->pt.user.gs_constants = buffer;
-      draw_gs_set_constants( draw, (const float (*)[4])buffer, size );
+      draw->pt.user.gs_constants[slot] = buffer;
+      draw_gs_set_constants(draw, slot, buffer, size);
    }
 }
 
diff --git a/src/gallium/auxiliary/draw/draw_context.h b/src/gallium/auxiliary/draw/draw_context.h
index 8a64c06..acd81b9 100644
--- a/src/gallium/auxiliary/draw/draw_context.h
+++ b/src/gallium/auxiliary/draw/draw_context.h
@@ -151,10 +151,12 @@ void draw_set_mapped_element_buffer( struct draw_context *draw,
 void draw_set_mapped_vertex_buffer(struct draw_context *draw,
                                    unsigned attr, const void *buffer);
 
-void draw_set_mapped_constant_buffer(struct draw_context *draw,
-                                     unsigned shader_type,
-                                     const void *buffer,
-                                     unsigned size );
+void
+draw_set_mapped_constant_buffer(struct draw_context *draw,
+                                unsigned shader_type,
+                                unsigned slot,
+                                const void *buffer,
+                                unsigned size);
 
 
 /***********************************************************************
diff --git a/src/gallium/auxiliary/draw/draw_gs.c b/src/gallium/auxiliary/draw/draw_gs.c
index c3cc365..96be5db 100644
--- a/src/gallium/auxiliary/draw/draw_gs.c
+++ b/src/gallium/auxiliary/draw/draw_gs.c
@@ -69,9 +69,11 @@ void draw_gs_destroy( struct draw_context *draw )
    tgsi_exec_machine_destroy(draw->gs.machine);
 }
 
-void draw_gs_set_constants( struct draw_context *draw,
-                            const float (*constants)[4],
-                            unsigned size )
+void
+draw_gs_set_constants(struct draw_context *draw,
+                      unsigned slot,
+                      const void *constants,
+                      unsigned size)
 {
 }
 
@@ -291,7 +293,7 @@ draw_geometry_fetch_outputs(struct draw_geometry_shader *shader,
 void draw_geometry_shader_run(struct draw_geometry_shader *shader,
                               const float (*input)[4],
                               float (*output)[4],
-                              const float (*constants)[4],
+                              const void *constants[PIPE_MAX_CONSTANT],
                               unsigned count,
                               unsigned input_stride,
                               unsigned vertex_size)
@@ -302,7 +304,9 @@ void draw_geometry_shader_run(struct draw_geometry_shader *shader,
    unsigned num_primitives = count/num_vertices;
    unsigned inputs_from_vs = 0;
 
-   machine->Consts[0] = constants;
+   for (i = 0; i < PIPE_MAX_CONSTANT; i++) {
+      machine->Consts[i] = constants[i];
+   }
 
    for (i = 0; i < shader->info.num_inputs; ++i) {
       if (shader->info.input_semantic_name[i] != TGSI_SEMANTIC_PRIMID)
diff --git a/src/gallium/auxiliary/draw/draw_gs.h b/src/gallium/auxiliary/draw/draw_gs.h
index d6a97d9..e055c8a 100644
--- a/src/gallium/auxiliary/draw/draw_gs.h
+++ b/src/gallium/auxiliary/draw/draw_gs.h
@@ -62,7 +62,7 @@ struct draw_geometry_shader {
 void draw_geometry_shader_run(struct draw_geometry_shader *shader,
                               const float (*input)[4],
                               float (*output)[4],
-                              const float (*constants)[4],
+                              const void *constants[PIPE_MAX_CONSTANT],
                               unsigned count,
                               unsigned input_stride,
                               unsigned output_stride);
diff --git a/src/gallium/auxiliary/draw/draw_private.h b/src/gallium/auxiliary/draw/draw_private.h
index ef49e57..ecb17cb 100644
--- a/src/gallium/auxiliary/draw/draw_private.h
+++ b/src/gallium/auxiliary/draw/draw_private.h
@@ -153,8 +153,8 @@ struct draw_context
          const void *vbuffer[PIPE_MAX_ATTRIBS];
          
          /** constant buffer (for vertex/geometry shader) */
-         const void *vs_constants;
-         const void *gs_constants;
+         const void *vs_constants[PIPE_MAX_CONSTANT];
+         const void *gs_constants[PIPE_MAX_CONSTANT];
       } user;
 
       boolean test_fse;         /* enable FSE even though its not correct (eg for softpipe) */
@@ -202,10 +202,10 @@ struct draw_context
       struct aos_machine *aos_machine; 
 
 
-      const float (*aligned_constants)[4];
+      const void *aligned_constants[PIPE_MAX_CONSTANT];
 
-      const float (*aligned_constant_storage)[4];
-      unsigned const_storage_size;
+      const void *aligned_constant_storage[PIPE_MAX_CONSTANT];
+      unsigned const_storage_size[PIPE_MAX_CONSTANT];
 
 
       struct translate *fetch;
@@ -256,9 +256,11 @@ void draw_vs_destroy( struct draw_context *draw );
 void draw_vs_set_viewport( struct draw_context *, 
                            const struct pipe_viewport_state * );
 
-void draw_vs_set_constants( struct draw_context *,
-                            const float (*constants)[4],
-                            unsigned size );
+void
+draw_vs_set_constants(struct draw_context *,
+                      unsigned slot,
+                      const void *constants,
+                      unsigned size);
 
 
 
@@ -266,9 +268,13 @@ void draw_vs_set_constants( struct draw_context *,
  * Geometry shading code:
  */
 boolean draw_gs_init( struct draw_context *draw );
-void draw_gs_set_constants( struct draw_context *,
-                            const float (*constants)[4],
-                            unsigned size );
+
+void
+draw_gs_set_constants(struct draw_context *,
+                      unsigned slot,
+                      const void *constants,
+                      unsigned size);
+
 void draw_gs_destroy( struct draw_context *draw );
 
 /*******************************************************************************
diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c
index 23da556..12145e2 100644
--- a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c
+++ b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c
@@ -164,7 +164,7 @@ static void fetch_pipeline_run( struct draw_pt_middle_end *middle,
       vshader->run_linear(vshader,
                           (const float (*)[4])pipeline_verts->data,
                           (      float (*)[4])pipeline_verts->data,
-                          (const float (*)[4])draw->pt.user.vs_constants,
+                          draw->pt.user.vs_constants,
                           fetch_count,
                           fpme->vertex_size,
                           fpme->vertex_size);
@@ -172,7 +172,7 @@ static void fetch_pipeline_run( struct draw_pt_middle_end *middle,
          draw_geometry_shader_run(gshader,
                                   (const float (*)[4])pipeline_verts->data,
                                   (      float (*)[4])pipeline_verts->data,
-                                  (const float (*)[4])draw->pt.user.gs_constants,
+                                  draw->pt.user.gs_constants,
                                   fetch_count,
                                   fpme->vertex_size,
                                   fpme->vertex_size);
@@ -249,7 +249,7 @@ static void fetch_pipeline_linear_run( struct draw_pt_middle_end *middle,
       shader->run_linear(shader,
 			 (const float (*)[4])pipeline_verts->data,
 			 (      float (*)[4])pipeline_verts->data,
-			 (const float (*)[4])draw->pt.user.vs_constants,
+                         draw->pt.user.vs_constants,
 			 count,
 			 fpme->vertex_size,
 			 fpme->vertex_size);
@@ -258,7 +258,7 @@ static void fetch_pipeline_linear_run( struct draw_pt_middle_end *middle,
          draw_geometry_shader_run(geometry_shader,
                                   (const float (*)[4])pipeline_verts->data,
                                   (      float (*)[4])pipeline_verts->data,
-                                  (const float (*)[4])draw->pt.user.gs_constants,
+                                  draw->pt.user.gs_constants,
                                   count,
                                   fpme->vertex_size,
                                   fpme->vertex_size);
@@ -329,7 +329,7 @@ static boolean fetch_pipeline_linear_run_elts( struct draw_pt_middle_end *middle
       shader->run_linear(shader,
 			 (const float (*)[4])pipeline_verts->data,
 			 (      float (*)[4])pipeline_verts->data,
-			 (const float (*)[4])draw->pt.user.vs_constants,
+                         draw->pt.user.vs_constants,
 			 count,
 			 fpme->vertex_size,
 			 fpme->vertex_size);
@@ -338,7 +338,7 @@ static boolean fetch_pipeline_linear_run_elts( struct draw_pt_middle_end *middle
          draw_geometry_shader_run(geometry_shader,
                                   (const float (*)[4])pipeline_verts->data,
                                   (      float (*)[4])pipeline_verts->data,
-                                  (const float (*)[4])draw->pt.user.gs_constants,
+                                  draw->pt.user.gs_constants,
                                   count,
                                   fpme->vertex_size,
                                   fpme->vertex_size);
diff --git a/src/gallium/auxiliary/draw/draw_vs.c b/src/gallium/auxiliary/draw/draw_vs.c
index e03ac8c..120b976 100644
--- a/src/gallium/auxiliary/draw/draw_vs.c
+++ b/src/gallium/auxiliary/draw/draw_vs.c
@@ -48,24 +48,27 @@
 
 
 
-void draw_vs_set_constants( struct draw_context *draw,
-                            const float (*constants)[4],
-                            unsigned size )
+void
+draw_vs_set_constants(struct draw_context *draw,
+                      unsigned slot,
+                      const void *constants,
+                      unsigned size)
 {
    if (((uintptr_t)constants) & 0xf) {
-      if (size > draw->vs.const_storage_size) {
-         if (draw->vs.aligned_constant_storage)
-            align_free((void *)draw->vs.aligned_constant_storage);
-         draw->vs.aligned_constant_storage = align_malloc( size, 16 );
+      if (size > draw->vs.const_storage_size[slot]) {
+         if (draw->vs.aligned_constant_storage[slot]) {
+            align_free((void *)draw->vs.aligned_constant_storage[slot]);
+         }
+         draw->vs.aligned_constant_storage[slot] = align_malloc(size, 16);
       }
-      memcpy( (void*)draw->vs.aligned_constant_storage,
-              constants, 
-              size );
-      constants = draw->vs.aligned_constant_storage;
+      memcpy((void *)draw->vs.aligned_constant_storage[slot],
+             constants,
+             size);
+      constants = draw->vs.aligned_constant_storage[slot];
    }
-      
-   draw->vs.aligned_constants = constants;
-   draw_vs_aos_machine_constants( draw->vs.aos_machine, constants );
+
+   draw->vs.aligned_constants[slot] = constants;
+   draw_vs_aos_machine_constants(draw->vs.aos_machine, slot, constants);
 }
 
 
@@ -182,6 +185,8 @@ draw_vs_init( struct draw_context *draw )
 void
 draw_vs_destroy( struct draw_context *draw )
 {
+   uint i;
+
    if (draw->vs.fetch_cache)
       translate_cache_destroy(draw->vs.fetch_cache);
 
@@ -191,8 +196,11 @@ draw_vs_destroy( struct draw_context *draw )
    if (draw->vs.aos_machine)
       draw_vs_aos_machine_destroy(draw->vs.aos_machine);
 
-   if (draw->vs.aligned_constant_storage)
-      align_free((void*)draw->vs.aligned_constant_storage);
+   for (i = 0; i < PIPE_MAX_CONSTANT; i++) {
+      if (draw->vs.aligned_constant_storage[i]) {
+         align_free((void *)draw->vs.aligned_constant_storage[i]);
+      }
+   }
 
    tgsi_exec_machine_destroy(draw->vs.machine);
 }
diff --git a/src/gallium/auxiliary/draw/draw_vs.h b/src/gallium/auxiliary/draw/draw_vs.h
index 00036cf..6bd3683 100644
--- a/src/gallium/auxiliary/draw/draw_vs.h
+++ b/src/gallium/auxiliary/draw/draw_vs.h
@@ -132,7 +132,7 @@ struct draw_vertex_shader {
    void (*run_linear)( struct draw_vertex_shader *shader,
 		       const float (*input)[4],
 		       float (*output)[4],
-		       const float (*constants)[4],
+                      const void *constants[PIPE_MAX_CONSTANT],
 		       unsigned count,
 		       unsigned input_stride,
 		       unsigned output_stride );
@@ -212,8 +212,10 @@ static INLINE int draw_vs_varient_key_compare( const struct draw_vs_varient_key
 struct aos_machine *draw_vs_aos_machine( void );
 void draw_vs_aos_machine_destroy( struct aos_machine *machine );
 
-void draw_vs_aos_machine_constants( struct aos_machine *machine,
-                                    const float (*constants)[4] );
+void
+draw_vs_aos_machine_constants(struct aos_machine *machine,
+                              unsigned slot,
+                              const void *constants);
 
 void draw_vs_aos_machine_viewport( struct aos_machine *machine,
                                    const struct pipe_viewport_state *viewport );
diff --git a/src/gallium/auxiliary/draw/draw_vs_aos.c b/src/gallium/auxiliary/draw/draw_vs_aos.c
index 1aaae4a..4d73de4 100644
--- a/src/gallium/auxiliary/draw/draw_vs_aos.c
+++ b/src/gallium/auxiliary/draw/draw_vs_aos.c
@@ -2114,11 +2114,14 @@ static void PIPE_CDECL vaos_run_elts( struct draw_vs_varient *varient,
 {
    struct draw_vs_varient_aos_sse *vaos = (struct draw_vs_varient_aos_sse *)varient;
    struct aos_machine *machine = vaos->draw->vs.aos_machine;
+   unsigned i;
 
    if (0) debug_printf("%s %d\n", __FUNCTION__, count);
 
    machine->internal[IMM_PSIZE][0] = vaos->draw->rasterizer->point_size;
-   machine->constants = vaos->draw->vs.aligned_constants;
+   for (i = 0; i < PIPE_MAX_CONSTANT; i++) {
+      machine->constants[i] = vaos->draw->vs.aligned_constants[i];
+   }
    machine->immediates = vaos->base.vs->immediates;
    machine->buffer = vaos->buffer;
 
@@ -2135,12 +2138,15 @@ static void PIPE_CDECL vaos_run_linear( struct draw_vs_varient *varient,
 {
    struct draw_vs_varient_aos_sse *vaos = (struct draw_vs_varient_aos_sse *)varient;
    struct aos_machine *machine = vaos->draw->vs.aos_machine;
+   unsigned i;
 
    if (0) debug_printf("%s %d %d const: %x\n", __FUNCTION__, start, count, 
                        vaos->base.key.const_vbuffers);
 
    machine->internal[IMM_PSIZE][0] = vaos->draw->rasterizer->point_size;
-   machine->constants = vaos->draw->vs.aligned_constants;
+   for (i = 0; i < PIPE_MAX_CONSTANT; i++) {
+      machine->constants[i] = vaos->draw->vs.aligned_constants[i];
+   }
    machine->immediates = vaos->base.vs->immediates;
    machine->buffer = vaos->buffer;
 
diff --git a/src/gallium/auxiliary/draw/draw_vs_aos.h b/src/gallium/auxiliary/draw/draw_vs_aos.h
index 2cf72dd..eefc097 100644
--- a/src/gallium/auxiliary/draw/draw_vs_aos.h
+++ b/src/gallium/auxiliary/draw/draw_vs_aos.h
@@ -122,7 +122,7 @@ struct aos_machine {
    ushort fpucntl;              /* one of FPU_* above */
 
    const float (*immediates)[4];     /* points to shader data */
-   const float (*constants)[4];      /* points to draw data */
+   const void *constants[PIPE_MAX_CONSTANT]; /* points to draw data */
 
    const struct aos_buffer *buffer; /* points to ? */
 };
diff --git a/src/gallium/auxiliary/draw/draw_vs_aos_machine.c b/src/gallium/auxiliary/draw/draw_vs_aos_machine.c
index 3240e37..0eda414 100644
--- a/src/gallium/auxiliary/draw/draw_vs_aos_machine.c
+++ b/src/gallium/auxiliary/draw/draw_vs_aos_machine.c
@@ -219,10 +219,12 @@ static void PIPE_CDECL populate_lut( struct aos_machine *machine,
 }
 
 
-void draw_vs_aos_machine_constants( struct aos_machine *machine,
-                                    const float (*constants)[4] )
+void
+draw_vs_aos_machine_constants(struct aos_machine *machine,
+                              unsigned slot,
+                              const void *constants)
 {
-   machine->constants = constants;
+   machine->constants[slot] = constants;
 
    {
       unsigned i;
@@ -307,8 +309,10 @@ void draw_vs_aos_machine_viewport( struct aos_machine *machine,
 {
 }
 
-void draw_vs_aos_machine_constants( struct aos_machine *machine,
-                                    const float (*constants)[4] )
+void
+draw_vs_aos_machine_constants(struct aos_machine *machine,
+                              unsigned slot,
+                              const void *constants)
 {
 }
 
diff --git a/src/gallium/auxiliary/draw/draw_vs_exec.c b/src/gallium/auxiliary/draw/draw_vs_exec.c
index 3f7a5ca..652c844 100644
--- a/src/gallium/auxiliary/draw/draw_vs_exec.c
+++ b/src/gallium/auxiliary/draw/draw_vs_exec.c
@@ -85,7 +85,7 @@ static void
 vs_exec_run_linear( struct draw_vertex_shader *shader,
 		    const float (*input)[4],
 		    float (*output)[4],
-		    const float (*constants)[4],
+                   const void *constants[PIPE_MAX_CONSTANT],
 		    unsigned count,
 		    unsigned input_stride,
 		    unsigned output_stride )
@@ -95,7 +95,9 @@ vs_exec_run_linear( struct draw_vertex_shader *shader,
    unsigned int i, j;
    unsigned slot;
 
-   machine->Consts[0] = constants;
+   for (i = 0; i < PIPE_MAX_CONSTANT; i++) {
+      machine->Consts[i] = constants[i];
+   }
 
    for (i = 0; i < count; i += MAX_TGSI_VERTICES) {
       unsigned int max_vertices = MIN2(MAX_TGSI_VERTICES, count - i);
diff --git a/src/gallium/auxiliary/draw/draw_vs_llvm.c b/src/gallium/auxiliary/draw/draw_vs_llvm.c
index b3535c0..e8e72f0 100644
--- a/src/gallium/auxiliary/draw/draw_vs_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_vs_llvm.c
@@ -64,7 +64,7 @@ static void
 vs_llvm_run_linear( struct draw_vertex_shader *base,
 		   const float (*input)[4],
 		   float (*output)[4],
-		   const float (*constants)[4],
+                   const void *constants[PIPE_MAX_CONSTANT],
 		   unsigned count,
 		   unsigned input_stride,
 		   unsigned output_stride )
@@ -74,7 +74,8 @@ vs_llvm_run_linear( struct draw_vertex_shader *base,
 
    gallivm_cpu_vs_exec(shader->llvm_prog, shader->machine,
                        input, base->info.num_inputs, output, base->info.num_outputs,
-                       constants, count, input_stride, output_stride);
+                       (const float (*)[4])constants[0],
+                       count, input_stride, output_stride);
 }
 
 
diff --git a/src/gallium/auxiliary/draw/draw_vs_ppc.c b/src/gallium/auxiliary/draw/draw_vs_ppc.c
index da9f3e3..9952b40 100644
--- a/src/gallium/auxiliary/draw/draw_vs_ppc.c
+++ b/src/gallium/auxiliary/draw/draw_vs_ppc.c
@@ -85,7 +85,7 @@ static void
 vs_ppc_run_linear( struct draw_vertex_shader *base,
 		   const float (*input)[4],
 		   float (*output)[4],
-		   const float (*constants)[4],
+                  const void *constants[PIPE_MAX_CONSTANT],
 		   unsigned count,
 		   unsigned input_stride,
 		   unsigned output_stride )
@@ -125,7 +125,7 @@ vs_ppc_run_linear( struct draw_vertex_shader *base,
        */
       shader->func(inputs_soa, outputs_soa, temps_soa,
 		   (float (*)[4]) shader->base.immediates,
-		   (float (*)[4]) constants,
+                   (const float (*)[4])constants[0],
                    ppc_builtin_constants);
 
       /* convert (up to) four output verts from SoA back to AoS format */
diff --git a/src/gallium/auxiliary/draw/draw_vs_sse.c b/src/gallium/auxiliary/draw/draw_vs_sse.c
index 7020513..297013d 100644
--- a/src/gallium/auxiliary/draw/draw_vs_sse.c
+++ b/src/gallium/auxiliary/draw/draw_vs_sse.c
@@ -83,7 +83,7 @@ static void
 vs_sse_run_linear( struct draw_vertex_shader *base,
 		   const float (*input)[4],
 		   float (*output)[4],
-		   const float (*constants)[4],
+                  const void *constants[PIPE_MAX_CONSTANT],
 		   unsigned count,
 		   unsigned input_stride,
 		   unsigned output_stride )
@@ -112,7 +112,7 @@ vs_sse_run_linear( struct draw_vertex_shader *base,
       /* run compiled shader
        */
       shader->func(machine,
-		   constants,
+                   (const float (*)[4])constants[0],
 		   shader->base.immediates,
                    input,
                    base->info.num_inputs,
diff --git a/src/gallium/auxiliary/draw/draw_vs_varient.c b/src/gallium/auxiliary/draw/draw_vs_varient.c
index 9f40030..29fb5ed 100644
--- a/src/gallium/auxiliary/draw/draw_vs_varient.c
+++ b/src/gallium/auxiliary/draw/draw_vs_varient.c
@@ -148,7 +148,7 @@ static void PIPE_CDECL vsvg_run_elts( struct draw_vs_varient *varient,
    vsvg->base.vs->run_linear( vsvg->base.vs, 
                               temp_buffer,
                               temp_buffer,
-                              (const float (*)[4])vsvg->base.vs->draw->pt.user.vs_constants,
+                             vsvg->base.vs->draw->pt.user.vs_constants,
                               count,
                               temp_vertex_stride, 
                               temp_vertex_stride);
@@ -211,7 +211,7 @@ static void PIPE_CDECL vsvg_run_linear( struct draw_vs_varient *varient,
    vsvg->base.vs->run_linear( vsvg->base.vs, 
                               temp_buffer,
                               temp_buffer,
-                              (const float (*)[4])vsvg->base.vs->draw->pt.user.vs_constants,
+                             vsvg->base.vs->draw->pt.user.vs_constants,
                               count,
                               temp_vertex_stride, 
                               temp_vertex_stride);
diff --git a/src/gallium/drivers/cell/ppu/cell_draw_arrays.c b/src/gallium/drivers/cell/ppu/cell_draw_arrays.c
index 0a4da8e..c674d0b 100644
--- a/src/gallium/drivers/cell/ppu/cell_draw_arrays.c
+++ b/src/gallium/drivers/cell/ppu/cell_draw_arrays.c
@@ -59,7 +59,7 @@ cell_map_constant_buffers(struct cell_context *sp)
       }
    }
 
-   draw_set_mapped_constant_buffer(sp->draw, PIPE_SHADER_VERTEX,
+   draw_set_mapped_constant_buffer(sp->draw, PIPE_SHADER_VERTEX, 0,
                                    sp->mapped_constants[PIPE_SHADER_VERTEX],
                                    sp->constants[PIPE_SHADER_VERTEX]->size);
 }
diff --git a/src/gallium/drivers/i915/i915_context.c b/src/gallium/drivers/i915/i915_context.c
index 89feead..bd16fb8 100644
--- a/src/gallium/drivers/i915/i915_context.c
+++ b/src/gallium/drivers/i915/i915_context.c
@@ -84,7 +84,7 @@ i915_draw_range_elements(struct pipe_context *pipe,
    }
 
 
-   draw_set_mapped_constant_buffer(draw, PIPE_SHADER_VERTEX,
+   draw_set_mapped_constant_buffer(draw, PIPE_SHADER_VERTEX, 0,
                                    i915->current.constants[PIPE_SHADER_VERTEX],
                                    (i915->current.num_user_constants[PIPE_SHADER_VERTEX] * 
                                       4 * sizeof(float)));
diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c
index 9f4bbef..a5f6891 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_fs.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c
@@ -733,7 +733,7 @@ llvmpipe_set_constant_buffer(struct pipe_context *pipe,
    }
 
    if(shader == PIPE_SHADER_VERTEX) {
-      draw_set_mapped_constant_buffer(llvmpipe->draw, PIPE_SHADER_VERTEX,
+      draw_set_mapped_constant_buffer(llvmpipe->draw, PIPE_SHADER_VERTEX, 0,
                                       data, size);
    }
 
diff --git a/src/gallium/drivers/nv04/nv04_vbo.c b/src/gallium/drivers/nv04/nv04_vbo.c
index 3484771..2db61d8 100644
--- a/src/gallium/drivers/nv04/nv04_vbo.c
+++ b/src/gallium/drivers/nv04/nv04_vbo.c
@@ -45,7 +45,7 @@ void nv04_draw_elements( struct pipe_context *pipe,
 		draw_set_mapped_element_buffer(draw, 0, NULL);
 	}
 
-	draw_set_mapped_constant_buffer(draw, PIPE_SHADER_VERTEX,
+	draw_set_mapped_constant_buffer(draw, PIPE_SHADER_VERTEX, 0,
 					nv04->constbuf[PIPE_SHADER_VERTEX],
 					nv04->constbuf_nr[PIPE_SHADER_VERTEX]);
 
diff --git a/src/gallium/drivers/nv10/nv10_vbo.c b/src/gallium/drivers/nv10/nv10_vbo.c
index 9180c72..da5c93f 100644
--- a/src/gallium/drivers/nv10/nv10_vbo.c
+++ b/src/gallium/drivers/nv10/nv10_vbo.c
@@ -46,6 +46,7 @@ void nv10_draw_elements( struct pipe_context *pipe,
 
 	draw_set_mapped_constant_buffer(draw,
                                         PIPE_SHADER_VERTEX,
+                                        0,
 					nv10->constbuf[PIPE_SHADER_VERTEX],
 					nv10->constbuf_nr[PIPE_SHADER_VERTEX]);
 
diff --git a/src/gallium/drivers/nv20/nv20_vbo.c b/src/gallium/drivers/nv20/nv20_vbo.c
index 52991a0..6dc9538 100644
--- a/src/gallium/drivers/nv20/nv20_vbo.c
+++ b/src/gallium/drivers/nv20/nv20_vbo.c
@@ -45,7 +45,7 @@ void nv20_draw_elements( struct pipe_context *pipe,
 		draw_set_mapped_element_buffer(draw, 0, NULL);
 	}
 
-	draw_set_mapped_constant_buffer(draw, PIPE_SHADER_VERTEX,
+	draw_set_mapped_constant_buffer(draw, PIPE_SHADER_VERTEX, 0,
 					nv20->constbuf[PIPE_SHADER_VERTEX],
 					nv20->constbuf_nr[PIPE_SHADER_VERTEX]);
 
diff --git a/src/gallium/drivers/nv40/nv40_draw.c b/src/gallium/drivers/nv40/nv40_draw.c
index d826f8c..a2fd5f6 100644
--- a/src/gallium/drivers/nv40/nv40_draw.c
+++ b/src/gallium/drivers/nv40/nv40_draw.c
@@ -271,7 +271,7 @@ nv40_draw_elements_swtnl(struct pipe_context *pipe,
 		map = pipe_buffer_map(pscreen,
 				      nv40->constbuf[PIPE_SHADER_VERTEX],
 				      PIPE_BUFFER_USAGE_CPU_READ);
-		draw_set_mapped_constant_buffer(nv40->draw, PIPE_SHADER_VERTEX,
+		draw_set_mapped_constant_buffer(nv40->draw, PIPE_SHADER_VERTEX, 0,
                                                 map, nr);
 	}
 
diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c
index 90de062..f48b897 100644
--- a/src/gallium/drivers/r300/r300_render.c
+++ b/src/gallium/drivers/r300/r300_render.c
@@ -404,6 +404,7 @@ void r300_swtcl_draw_arrays(struct pipe_context* pipe,
 
     draw_set_mapped_constant_buffer(r300->draw,
 				    PIPE_SHADER_VERTEX,
+                                    0,
 				    r300->shader_constants[PIPE_SHADER_VERTEX].constants,
 				    r300->shader_constants[PIPE_SHADER_VERTEX].count *
                 (sizeof(float) * 4));
@@ -448,6 +449,7 @@ void r300_swtcl_draw_range_elements(struct pipe_context* pipe,
 
     draw_set_mapped_constant_buffer(r300->draw,
 				    PIPE_SHADER_VERTEX,
+                                    0,
             r300->shader_constants[PIPE_SHADER_VERTEX].constants,
             r300->shader_constants[PIPE_SHADER_VERTEX].count *
                 (sizeof(float) * 4));
diff --git a/src/gallium/drivers/softpipe/sp_draw_arrays.c b/src/gallium/drivers/softpipe/sp_draw_arrays.c
index cbb9631..06b97ab 100644
--- a/src/gallium/drivers/softpipe/sp_draw_arrays.c
+++ b/src/gallium/drivers/softpipe/sp_draw_arrays.c
@@ -49,7 +49,7 @@ static void
 softpipe_map_constant_buffers(struct softpipe_context *sp)
 {
    struct pipe_winsys *ws = sp->pipe.winsys;
-   uint i, vssize, gssize;
+   uint i;
 
    for (i = 0; i < PIPE_SHADER_TYPES; i++) {
       uint j;
@@ -63,22 +63,22 @@ softpipe_map_constant_buffers(struct softpipe_context *sp)
       }
    }
 
-   if (sp->constants[PIPE_SHADER_VERTEX][0])
-      vssize = sp->constants[PIPE_SHADER_VERTEX][0]->size;
-   else
-      vssize = 0;
-
-   if (sp->constants[PIPE_SHADER_GEOMETRY][0])
-      gssize = sp->constants[PIPE_SHADER_GEOMETRY][0]->size;
-   else
-      gssize = 0;
-
-   draw_set_mapped_constant_buffer(sp->draw, PIPE_SHADER_VERTEX,
-                                   sp->mapped_constants[PIPE_SHADER_VERTEX][0],
-                                   vssize);
-   draw_set_mapped_constant_buffer(sp->draw, PIPE_SHADER_GEOMETRY,
-                                   sp->mapped_constants[PIPE_SHADER_GEOMETRY][0],
-                                   gssize);
+   for (i = 0; i < PIPE_MAX_CONSTANT; i++) {
+      if (sp->constants[PIPE_SHADER_VERTEX][i]) {
+         draw_set_mapped_constant_buffer(sp->draw,
+                                         PIPE_SHADER_VERTEX,
+                                         i,
+                                         sp->mapped_constants[PIPE_SHADER_VERTEX][i],
+                                         sp->constants[PIPE_SHADER_VERTEX][i]->size);
+      }
+      if (sp->constants[PIPE_SHADER_GEOMETRY][i]) {
+         draw_set_mapped_constant_buffer(sp->draw,
+                                         PIPE_SHADER_GEOMETRY,
+                                         i,
+                                         sp->mapped_constants[PIPE_SHADER_GEOMETRY][i],
+                                         sp->constants[PIPE_SHADER_GEOMETRY][i]->size);
+      }
+   }
 }
 
 
@@ -93,8 +93,18 @@ softpipe_unmap_constant_buffers(struct softpipe_context *sp)
     */
    draw_flush(sp->draw);
 
-   draw_set_mapped_constant_buffer(sp->draw, PIPE_SHADER_VERTEX, NULL, 0);
-   draw_set_mapped_constant_buffer(sp->draw, PIPE_SHADER_GEOMETRY, NULL, 0);
+   for (i = 0; i < PIPE_MAX_CONSTANT; i++) {
+      draw_set_mapped_constant_buffer(sp->draw,
+                                      PIPE_SHADER_VERTEX,
+                                      i,
+                                      NULL,
+                                      0);
+      draw_set_mapped_constant_buffer(sp->draw,
+                                      PIPE_SHADER_GEOMETRY,
+                                      i,
+                                      NULL,
+                                      0);
+   }
 
    for (i = 0; i < PIPE_SHADER_TYPES; i++) {
       uint j;
diff --git a/src/gallium/drivers/svga/svga_swtnl_draw.c b/src/gallium/drivers/svga/svga_swtnl_draw.c
index 7655121..4ba02a1 100644
--- a/src/gallium/drivers/svga/svga_swtnl_draw.c
+++ b/src/gallium/drivers/svga/svga_swtnl_draw.c
@@ -90,7 +90,7 @@ svga_swtnl_draw_range_elements(struct svga_context *svga,
                             PIPE_BUFFER_USAGE_CPU_READ);
       assert(map);
       draw_set_mapped_constant_buffer(
-         draw, PIPE_SHADER_VERTEX,
+         draw, PIPE_SHADER_VERTEX, 0,
          map,
          svga->curr.cb[PIPE_SHADER_VERTEX]->size);
    }
diff --git a/src/mesa/state_tracker/st_draw_feedback.c b/src/mesa/state_tracker/st_draw_feedback.c
index a05d6dd..35d1c5a 100644
--- a/src/mesa/state_tracker/st_draw_feedback.c
+++ b/src/mesa/state_tracker/st_draw_feedback.c
@@ -242,7 +242,7 @@ st_feedback_draw_vbo(GLcontext *ctx,
    mapped_constants = pipe_buffer_map(pipe->screen,
                                       st->state.constants[PIPE_SHADER_VERTEX],
                                       PIPE_BUFFER_USAGE_CPU_READ);
-   draw_set_mapped_constant_buffer(st->draw, PIPE_SHADER_VERTEX,
+   draw_set_mapped_constant_buffer(st->draw, PIPE_SHADER_VERTEX, 0,
                                    mapped_constants,
                                    st->state.constants[PIPE_SHADER_VERTEX]->size);
 



More information about the mesa-commit mailing list