OSDN Git Service

mesa: Only update sampler uniforms that are used by the shader stage
authorIan Romanick <ian.d.romanick@intel.com>
Thu, 10 Nov 2011 20:32:35 +0000 (12:32 -0800)
committerIan Romanick <ian.d.romanick@intel.com>
Wed, 16 Nov 2011 16:37:44 +0000 (08:37 -0800)
commit010dc29283cfc7791a29ba8a0570d8f7f9edef05
treea81453c4c296ad3d6f482bf573ed785e63c244a2
parentf6a50c0b1ff620d1b721968144a56452c0bd6d85
mesa: Only update sampler uniforms that are used by the shader stage

Previously a vertex shader that used no samplers would get updated (by
calling the driver's ProgramStringNotify) when a sampler in the
fragment shader was updated.  This was discovered while investigating
some spurious code generation for shaders in Cogs.  The behavior in
Cogs is especially pessimal because it ping-pongs sampler uniform
settings:

    glUniform1i(sampler1, 0);
    glUniform1i(sampler2, 1);
    draw();
    glUniform1i(sampler1, 1);
    glUniform1i(sampler2, 0);
    draw();
    glUniform1i(sampler1, 0);
    glUniform1i(sampler2, 1);
    draw();
    // etc.

ProgramStringNotify is still too big of a hammer.  Applications like
Cogs will still defeat the shader cache.  A lighter-weight mechanism
that can work with the shader cache is needed.  However, this patch at
least restores the previous behavior.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/main/uniform_query.cpp