[Mesa-dev] [PATCH 10/10] glsl: Fix return value of glGetProgramResourceiv of GL_BLOCK_INDEX.
Kenneth Graunke
kenneth at whitecape.org
Thu Mar 31 18:53:43 UTC 2016
According to Timothy, block_index is an index into the
BufferInterfaceBlocks array. We want to return an index into the
UniformBlocks or ShaderStorageBlocks array, as that's what everything
else expects.
Fixes several dEQP-GLES31.functional tests:
- program_interface_query.uniform.block_index.block_array
- program_interface_query.uniform.block_index.named_block
- program_interface_query.uniform.block_index.unnamed_block
- program_interface_query.uniform.random.10
- program_interface_query.uniform.random.15
- program_interface_query.uniform.random.22
- program_interface_query.uniform.random.24
- program_interface_query.uniform.random.26
- program_interface_query.uniform.random.28
- program_interface_query.uniform.random.3
- program_interface_query.uniform.random.31
- program_interface_query.uniform.random.38
- program_interface_query.uniform.random.5
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94116
Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
src/mesa/main/shader_query.cpp | 30 ++++++++++++++++++++++++++++--
1 file changed, 28 insertions(+), 2 deletions(-)
diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp
index 4650a5c..fb0f723 100644
--- a/src/mesa/main/shader_query.cpp
+++ b/src/mesa/main/shader_query.cpp
@@ -1153,10 +1153,36 @@ _mesa_program_resource_prop(struct gl_shader_program *shProg,
default:
goto invalid_operation;
}
- case GL_BLOCK_INDEX:
+ case GL_BLOCK_INDEX: {
VALIDATE_TYPE_2(GL_UNIFORM, GL_BUFFER_VARIABLE);
- *val = RESOURCE_UNI(res)->block_index;
+
+ if (RESOURCE_UNI(res)->block_index == -1) {
+ *val = -1;
+ } else {
+ struct gl_uniform_block **list;
+ unsigned list_length;
+
+ if (res->Type == GL_UNIFORM) {
+ list = shProg->UniformBlocks;
+ list_length = shProg->NumUniformBlocks;
+ } else {
+ assert(res->Type == GL_BUFFER_VARIABLE);
+ list = shProg->ShaderStorageBlocks;
+ list_length = shProg->NumShaderStorageBlocks;
+ }
+
+ struct gl_uniform_block *block =
+ &shProg->BufferInterfaceBlocks[RESOURCE_UNI(res)->block_index];
+
+ for (unsigned i = 0; i < list_length; i++) {
+ if (list[i] == block) {
+ *val = i;
+ break;
+ }
+ }
+ }
return 1;
+ }
case GL_ARRAY_STRIDE:
VALIDATE_TYPE_2(GL_UNIFORM, GL_BUFFER_VARIABLE);
*val = RESOURCE_UNI(res)->array_stride;
--
2.7.4
More information about the mesa-dev
mailing list