mesa: Use a new, more specific hook for shader uniform changes.
authorKenneth Graunke <kenneth@whitecape.org>
Wed, 22 Aug 2012 07:43:14 +0000 (00:43 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Sat, 25 Aug 2012 19:01:10 +0000 (12:01 -0700)
Gallium drivers and i965 don't require special notification when
sampler uniforms change.  They simply see the _NEW_TEXTURE and adjust
their indirection tables.  These drivers don't want ProgramStringNotify:
it simply causes pointless recompiles.

Unfortunately, i915 still requires shader recompiles and needs
ProgramStringNotify.  Rather than trying to fix that, simply change the
hook to a new, more specific one: ShaderUniformChange.  On i915, this
translates to ProgramStringNotify; others simply ignore it.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
src/mesa/drivers/dri/i915/i915_fragprog.c
src/mesa/main/dd.h
src/mesa/main/ff_fragment_shader.cpp
src/mesa/main/uniform_query.cpp

index 5b7e93ecc409dc2f18355ba96f0ab1dbb98dce2f..7a6e0673678746cf3308f0090ab544476766c021 100644 (file)
@@ -1303,6 +1303,13 @@ i915ProgramStringNotify(struct gl_context * ctx,
    return true;
 }
 
+static void
+i915SamplerUniformChange(struct gl_context *ctx,
+                         GLenum target, struct gl_program *prog)
+{
+   i915ProgramStringNotify(ctx, target, prog);
+}
+
 void
 i915_update_program(struct gl_context *ctx)
 {
@@ -1456,4 +1463,5 @@ i915InitFragProgFuncs(struct dd_function_table *functions)
    functions->DeleteProgram = i915DeleteProgram;
    functions->IsProgramNative = i915IsProgramNative;
    functions->ProgramStringNotify = i915ProgramStringNotify;
+   functions->SamplerUniformChange = i915SamplerUniformChange;
 }
index a91e8083f219f986569f71c783daa78d70705109..e6a1e68cb25637eed22957ef504c874f7ad98dfa 100644 (file)
@@ -399,6 +399,13 @@ struct dd_function_table {
    GLboolean (*ProgramStringNotify)(struct gl_context *ctx, GLenum target, 
                                     struct gl_program *prog);
 
+   /**
+    * Notify driver that the sampler uniforms for the current program have
+    * changed.  On some drivers, this may require shader recompiles.
+    */
+   void (*SamplerUniformChange)(struct gl_context *ctx, GLenum target,
+                                struct gl_program *prog);
+
    /** Query if program can be loaded onto hardware */
    GLboolean (*IsProgramNative)(struct gl_context *ctx, GLenum target, 
                                struct gl_program *prog);
index f743ce109fd5ac8d8105d991f9c6d47f769fb693..e850d47dd80bdfcc81c848d896840f4058397677 100644 (file)
@@ -1363,7 +1363,8 @@ create_new_program(struct gl_context *ctx, struct state_key *key)
    _mesa_associate_uniform_storage(ctx, p.shader_program, fp->Parameters);
 
    _mesa_update_shader_textures_used(p.shader_program, fp);
-   (void) ctx->Driver.ProgramStringNotify(ctx, fp->Target, fp);
+   if (ctx->Driver.SamplerUniformChange)
+      ctx->Driver.SamplerUniformChange(ctx, fp->Target, fp);
 
    if (!p.shader_program->LinkStatus)
       _mesa_problem(ctx, "Failed to link fixed function fragment shader: %s\n",
index 816c2779cf355ec058178702f8a61e729905b5fe..bddb8f95e147eccfdd2c2edbf12d07dd542fc017 100644 (file)
@@ -809,7 +809,8 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg,
                   sizeof(shProg->SamplerUnits));
 
            _mesa_update_shader_textures_used(shProg, prog);
-           (void) ctx->Driver.ProgramStringNotify(ctx, prog->Target, prog);
+            if (ctx->Driver.SamplerUniformChange)
+              ctx->Driver.SamplerUniformChange(ctx, prog->Target, prog);
         }
       }
    }