mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 00:58:05 +02:00
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.
(cherry picked from master, commit 2b4f0216bf)
This commit is contained in:
parent
46f8b62d5f
commit
5f74a66132
1 changed files with 19 additions and 10 deletions
|
|
@ -1567,27 +1567,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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue