Mesa (master): glsl: signal that the program needs to be re-translated when samplers change

Brian Paul brianp at kemper.freedesktop.org
Wed Aug 26 20:52:15 UTC 2009


Module: Mesa
Branch: master
Commit: babb5ba9a977d23ddae828521401eae312bdb619
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=babb5ba9a977d23ddae828521401eae312bdb619

Author: Brian Paul <brianp at vmware.com>
Date:   Wed Aug 26 14:29:50 2009 -0600

glsl: signal that the program needs to be re-translated when samplers change

---

 src/mesa/shader/shader_api.c |   19 +++++++++++++++----
 1 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c
index 95b7490..c36fc27 100644
--- a/src/mesa/shader/shader_api.c
+++ b/src/mesa/shader/shader_api.c
@@ -1624,6 +1624,7 @@ 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 */
+      GLboolean changed = GL_FALSE;
       GLint i;
 
       /* data type for setting samplers must be int */
@@ -1655,13 +1656,23 @@ set_program_uniform(GLcontext *ctx, struct gl_program *program,
             _mesa_printf("Set program %p sampler %d '%s' to unit %u\n",
                          program, sampler, param->Name, texUnit);
 #endif
-            program->SamplerUnits[sampler] = texUnit;
+            if (program->SamplerUnits[sampler] != texUnit) {
+               program->SamplerUnits[sampler] = texUnit;
+               changed = GL_TRUE;
+            }
          }
       }
 
-      _mesa_update_shader_textures_used(program);
-
-      FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+      if (changed) {
+         /* When a sampler's value changes it usually requires rewriting
+          * a GPU program's TEX instructions since there may not be a
+          * sampler->texture lookup table.  We signal this with the
+          * ProgramStringNotify() callback.
+          */
+         FLUSH_VERTICES(ctx, _NEW_TEXTURE | _NEW_PROGRAM);
+         _mesa_update_shader_textures_used(program);
+         ctx->Driver.ProgramStringNotify(ctx, program->Target, program);
+      }
    }
    else {
       /* ordinary uniform variable */




More information about the mesa-commit mailing list