gallium: Enable multiple constant buffers for vertex and geometry shaders.
authorMichal Krol <michal@vmware.com>
Mon, 25 Jan 2010 11:36:50 +0000 (12:36 +0100)
committerMichal Krol <michal@vmware.com>
Thu, 28 Jan 2010 13:07:53 +0000 (14:07 +0100)
27 files changed:
src/gallium/auxiliary/draw/draw_context.c
src/gallium/auxiliary/draw/draw_context.h
src/gallium/auxiliary/draw/draw_gs.c
src/gallium/auxiliary/draw/draw_gs.h
src/gallium/auxiliary/draw/draw_private.h
src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c
src/gallium/auxiliary/draw/draw_vs.c
src/gallium/auxiliary/draw/draw_vs.h
src/gallium/auxiliary/draw/draw_vs_aos.c
src/gallium/auxiliary/draw/draw_vs_aos.h
src/gallium/auxiliary/draw/draw_vs_aos_machine.c
src/gallium/auxiliary/draw/draw_vs_exec.c
src/gallium/auxiliary/draw/draw_vs_llvm.c
src/gallium/auxiliary/draw/draw_vs_ppc.c
src/gallium/auxiliary/draw/draw_vs_sse.c
src/gallium/auxiliary/draw/draw_vs_varient.c
src/gallium/drivers/cell/ppu/cell_draw_arrays.c
src/gallium/drivers/i915/i915_context.c
src/gallium/drivers/llvmpipe/lp_state_fs.c
src/gallium/drivers/nv04/nv04_vbo.c
src/gallium/drivers/nv10/nv10_vbo.c
src/gallium/drivers/nv20/nv20_vbo.c
src/gallium/drivers/nv40/nv40_draw.c
src/gallium/drivers/r300/r300_render.c
src/gallium/drivers/softpipe/sp_draw_arrays.c
src/gallium/drivers/svga/svga_swtnl_draw.c
src/mesa/state_tracker/st_draw_feedback.c

index 16390438323ae2a8d1992b5744f031f27c378e8d..a52b93e12298e5255ba50c3d547b4d0c79ce1eef 100644 (file)
@@ -234,17 +234,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);
    }
 }
 
index 8a64c06efcda2a728ed33ebd99d9efaf22b40d82..acd81b9712d89a18969b6eeca5bb003f51af5ca2 100644 (file)
@@ -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);
 
 
 /***********************************************************************
index c3cc365a8d9c98a6e69fe6a86697582a3a42aae2..96be5dba0b3d9d21c33647c51b9c7166756fcdb3 100644 (file)
@@ -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)
index d6a97d9c4effd4d5695d4d10494d3f844ca3b752..e055c8a05c2966240479bc0405d7f19a7308ca35 100644 (file)
@@ -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);
index ef49e575366f356ec74165ba36989a75a3a06397..ecb17cbbe2fe1114340b2940d2adb8eb6eea193c 100644 (file)
@@ -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 );
 
 /*******************************************************************************
index 2c996e730872b581c67d802aab404e63d94ce2b1..56b69354b21503ae82034d9f310036a132aab063 100644 (file)
@@ -163,7 +163,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);
@@ -171,7 +171,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);
@@ -248,7 +248,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);
@@ -257,7 +257,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);
@@ -328,7 +328,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);
@@ -337,7 +337,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);
index e03ac8c2291aeac84c78fed0db02742e4a1b6150..120b976d9f4661c48c3c523f26d7479b86208b5e 100644 (file)
 
 
 
-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);
 }
index 00036cfe68ba7d15026a766046137c0d2abb96aa..6bd3683d39b0a36cc91f24f764180e72b8599c21 100644 (file)
@@ -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 );
index 1aaae4ab7a4eed74924f4953d83557cb1ad82086..4d73de413d99c5b0c53651d981de81a169cabbfd 100644 (file)
@@ -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;
 
index 2cf72ddf7b152150662a5dec5d4dd2921a900493..eefc0974649ebfb726a97ff9682ad618f180ea18 100644 (file)
@@ -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 ? */
 };
index 3240e3745ddc1f5d4ca358400e55364001c9c2ef..0eda414ee6ae27f6beb4b9e0e0773afd1fcdacb0 100644 (file)
@@ -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)
 {
 }
 
index 3f7a5ca14b4bef51bf7bf4b9eba878269ded2063..652c8446543a6a7ecd84623dd97e671307ed586a 100644 (file)
@@ -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);
index b3535c0e48e944038763538672fae1ad21733b1e..e8e72f06eca9ca31a1f16b08fac24613c86c4a25 100644 (file)
@@ -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);
 }
 
 
index da9f3e3d35c2b05b7a8347f27c06565ff97d167c..9952b40fcc094a650efe458cbf58148995665c5e 100644 (file)
@@ -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 */
index 702051387acb875fe2365d02f39f0872a893e188..297013dc74c8e56bbf2a7ec0ec194c7d9f2def9c 100644 (file)
@@ -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,
index b87a465f6bed5ced6cca731eb4d07862f782c307..5ed706cb4ff01d15079ab958301b2a3ddb579382 100644 (file)
@@ -147,7 +147,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);
@@ -210,7 +210,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);
index 0a4da8ecc8534174aee15b7fe3a0b046d30edcfd..c674d0be63382f1a8cdfb2b4aa74657bc5f9ce3b 100644 (file)
@@ -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);
 }
index 4c5ff37ca8472cf6c63dadeb8073089802085929..a0c80d022867e1d06636bc0e287acf04c554adff 100644 (file)
@@ -81,7 +81,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)));
index 70e2a082cc02835fd29f23df50b476b2549af23f..0cb335fe27a4c8b671945bf88b6ece9934c1d85f 100644 (file)
@@ -731,7 +731,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);
    }
 
index 348477181455a45260580fc8419e16021e144a2e..2db61d894123b111e0618a43349ca9c565baaf9d 100644 (file)
@@ -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]);
 
index 9180c72c9b09f4041859e1a7bf99679643d006bd..da5c93f081458d4d46c3b4641226153b16375072 100644 (file)
@@ -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]);
 
index 52991a0d85621a1106befb9825208be3c98fc662..6dc9538901363a98f6cd026b0dcebf9b89bc0343 100644 (file)
@@ -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]);
 
index d826f8c2f5fee0380b33e5f37d3cc91da8c3d4c8..a2fd5f6c02fed75d086e8b72f38a1f0e345fd999 100644 (file)
@@ -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);
        }
 
index bcb37071491c3d0816cda5d3d88c81460d56ffa9..95b7cb5fa49d1a4ee6e2e92f38107aeeb0cb94b3 100644 (file)
@@ -462,6 +462,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));
@@ -506,6 +507,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));
index cbb9631fa5356867ff3941d5c2706efa26bb40a9..06b97ab7c98f27d05d80b98238e324370682c62f 100644 (file)
@@ -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;
index 0ae58c7d9deb4497e8afbf2052731e47ff11ac00..5e6e30c7dfb503d1321b804e5f2b2593706ad9eb 100644 (file)
@@ -89,7 +89,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);
    }
index dd27a1e3a885817723b2d93182f2f690c34c1b51..cdaee2a353e637915cad55b8b567d41d9adc2e9c 100644 (file)
@@ -241,7 +241,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);