diff options
author | Brian Paul <[email protected]> | 2008-11-06 15:04:11 -0700 |
---|---|---|
committer | Brian Paul <[email protected]> | 2008-11-06 15:04:11 -0700 |
commit | 2f1a29654a94a4194fa452e8049c4db67629e545 (patch) | |
tree | c0a27757b4cb02c4c4ad40913922796842bb80bf /src/mesa/shader/shader_api.c | |
parent | 678f80b347801d925c07a774faee1ed3f716de15 (diff) |
mesa: update the shader programs->TexturesUsed array at link time
If an application never calls glUniform() to set sampler variable values
they'll remain 0 (the default value/unit).
Now call _mesa_update_shader_textures_used() at link time in case glUniform()
is never called. program->TextureUsed[] will then be correct for state
validation.
Diffstat (limited to 'src/mesa/shader/shader_api.c')
-rw-r--r-- | src/mesa/shader/shader_api.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c index 468fbd7ed2d..7af502a84cb 100644 --- a/src/mesa/shader/shader_api.c +++ b/src/mesa/shader/shader_api.c @@ -1417,10 +1417,22 @@ _mesa_use_program(GLcontext *ctx, GLuint program) /** - * Update the vertex and fragment program's TexturesUsed arrays. + * Update the vertex/fragment program's TexturesUsed array. + * + * This needs to be called after glUniform(set sampler var) is called. + * A call to glUniform(samplerVar, value) causes a sampler to point to a + * particular texture unit. We know the sampler's texture target + * (1D/2D/3D/etc) from compile time but the sampler's texture unit is + * set by glUniform() calls. + * + * So, scan the program->SamplerUnits[] and program->SamplerTargets[] + * information to update the prog->TexturesUsed[] values. + * Each value of TexturesUsed[unit] is one of zero, TEXTURE_1D_INDEX, + * TEXTURE_2D_INDEX, TEXTURE_3D_INDEX, etc. + * We'll use that info for state validation before rendering. */ -static void -update_textures_used(struct gl_program *prog) +void +_mesa_update_shader_textures_used(struct gl_program *prog) { GLuint s; @@ -1546,7 +1558,7 @@ set_program_uniform(GLcontext *ctx, struct gl_program *program, /* This maps a sampler to a texture unit: */ program->SamplerUnits[sampler] = texUnit; - update_textures_used(program); + _mesa_update_shader_textures_used(program); FLUSH_VERTICES(ctx, _NEW_TEXTURE); } |