summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2012-07-23 11:05:11 -0700
committerEric Anholt <[email protected]>2012-08-07 13:54:50 -0700
commit300315fe69ba275dda8a4786783c2bdd007d0758 (patch)
treebd20d2f1cbbbaa42efd346a3c98a199759e93d3b
parentaf3fc6bb2836ce545c624bce2b47c3fd8cf4f9fa (diff)
glsl: Fix glGetActiveUniformsiv(GL_UNIFORM_BLOCK_INDEX).
Previously, we were returning the index into the UniformBlocks of one of the linked shaders, when it's supposed to be the program global index. Fixes piglit getactiveuniformsiv-uniform_block_index. Reviewed-by: Kenneth Graunke <[email protected]>
-rw-r--r--src/glsl/link_uniforms.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/glsl/link_uniforms.cpp b/src/glsl/link_uniforms.cpp
index 1c975863c0d..4f21a416c15 100644
--- a/src/glsl/link_uniforms.cpp
+++ b/src/glsl/link_uniforms.cpp
@@ -223,7 +223,8 @@ public:
this->shader_shadow_samplers = 0;
}
- void set_and_process(struct gl_shader *shader,
+ void set_and_process(struct gl_shader_program *prog,
+ struct gl_shader *shader,
ir_variable *var)
{
ubo_var = NULL;
@@ -231,7 +232,16 @@ public:
struct gl_uniform_block *block =
&shader->UniformBlocks[var->uniform_block];
- ubo_block_index = var->uniform_block;
+ ubo_block_index = -1;
+ for (unsigned i = 0; i < prog->NumUniformBlocks; i++) {
+ if (!strcmp(prog->UniformBlocks[i].Name,
+ shader->UniformBlocks[var->uniform_block].Name)) {
+ ubo_block_index = i;
+ break;
+ }
+ }
+ assert(ubo_block_index != -1);
+
ubo_var_index = var->location;
ubo_var = &block->Uniforms[var->location];
ubo_byte_offset = ubo_var->Offset;
@@ -598,7 +608,7 @@ link_assign_uniform_locations(struct gl_shader_program *prog)
if (strncmp("gl_", var->name, 3) == 0)
continue;
- parcel.set_and_process(prog->_LinkedShaders[i], var);
+ parcel.set_and_process(prog, prog->_LinkedShaders[i], var);
}
prog->_LinkedShaders[i]->active_samplers = parcel.shader_samplers_used;