summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2009-02-11 09:12:34 -0700
committerBrian Paul <brianp@vmware.com>2009-02-11 09:17:22 -0700
commit2b4f0216bf757f63c0e76eb3a9a59a486ce63051 (patch)
tree12f8803e11c0319427b9764f2f434b2ba1fd8912 /src
parent234f03e90ab718f5b16300a91bac477ccbabf36c (diff)
glsl: allow setting arrays of samplers in set_program_uniform()
Arrays of sampler vars haven't been tested much and might actually be broken. Will need to be revisited someday. Another fix for bug 20056.
Diffstat (limited to 'src')
-rw-r--r--src/mesa/shader/shader_api.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c
index e738cde791..013e912e5d 100644
--- a/src/mesa/shader/shader_api.c
+++ b/src/mesa/shader/shader_api.c
@@ -1603,27 +1603,36 @@ 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 */
- if (type != GL_INT || count != 1) {
+ if (type != GL_INT) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glUniform(only glUniform1i can be used "
"to set sampler uniforms)");
return;
}
- sampler = (GLuint) program->Parameters->ParameterValues[index][0];
- texUnit = ((GLuint *) values)[0];
+ /* XXX arrays of samplers haven't been tested much, but it's not a
+ * common thing...
+ */
+ for (i = 0; i < count; i++) {
+ sampler = (GLuint) program->Parameters->ParameterValues[index + i][0];
+ texUnit = ((GLuint *) values)[i];
+
+ /* check that the sampler (tex unit index) is legal */
+ if (texUnit >= ctx->Const.MaxTextureImageUnits) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glUniform1(invalid sampler/tex unit index)");
+ return;
+ }
- /* check that the sampler (tex unit index) is legal */
- if (texUnit >= ctx->Const.MaxTextureImageUnits) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "glUniform1(invalid sampler/tex unit index)");
- return;
+ /* This maps a sampler to a texture unit: */
+ if (sampler < MAX_SAMPLERS) {
+ program->SamplerUnits[sampler] = texUnit;
+ }
}
- /* This maps a sampler to a texture unit: */
- program->SamplerUnits[sampler] = texUnit;
_mesa_update_shader_textures_used(program);
FLUSH_VERTICES(ctx, _NEW_TEXTURE);