Mesa (mesa_7_5_branch): glsl: fix bug in sampler array indexing

Brian Paul brianp at kemper.freedesktop.org
Wed Aug 26 17:56:15 UTC 2009


Module: Mesa
Branch: mesa_7_5_branch
Commit: 04d170794a22d93d58afeb5d0930e06f85964f9a
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=04d170794a22d93d58afeb5d0930e06f85964f9a

Author: Brian Paul <brianp at vmware.com>
Date:   Wed Aug 26 11:39:24 2009 -0600

glsl: fix bug in sampler array indexing

Need to add the 'offset' parameter when indexing the parameter array.
Before, if we were setting arrays of samplers, we were actually only
setting the 0th sampler's value.

Because of how progs/glsl/samplers.c is constructed, this wasn't showing
up as a failure in the samplers_array output.

---

 src/mesa/shader/shader_api.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c
index 14da974..95b7490 100644
--- a/src/mesa/shader/shader_api.c
+++ b/src/mesa/shader/shader_api.c
@@ -1624,7 +1624,6 @@ set_program_uniform(GLcontext *ctx, struct gl_program *program,
 
    if (param->Type == PROGRAM_SAMPLER) {
       /* This controls which texture unit which is used by a sampler */
-      GLuint texUnit, sampler;
       GLint i;
 
       /* data type for setting samplers must be int */
@@ -1639,8 +1638,9 @@ set_program_uniform(GLcontext *ctx, struct gl_program *program,
        * common thing...
        */
       for (i = 0; i < count; i++) {
-         sampler = (GLuint) program->Parameters->ParameterValues[index + i][0];
-         texUnit = ((GLuint *) values)[i];
+         GLuint sampler =
+            (GLuint) program->Parameters->ParameterValues[index + offset + i][0];
+         GLuint texUnit = ((GLuint *) values)[i];
 
          /* check that the sampler (tex unit index) is legal */
          if (texUnit >= ctx->Const.MaxTextureImageUnits) {
@@ -1651,6 +1651,10 @@ set_program_uniform(GLcontext *ctx, struct gl_program *program,
 
          /* This maps a sampler to a texture unit: */
          if (sampler < MAX_SAMPLERS) {
+#if 0
+            _mesa_printf("Set program %p sampler %d '%s' to unit %u\n",
+                         program, sampler, param->Name, texUnit);
+#endif
             program->SamplerUnits[sampler] = texUnit;
          }
       }




More information about the mesa-commit mailing list