Mesa (master): mesa: Add implementation of glGetUniformBlockIndex().
Eric Anholt
anholt at kemper.freedesktop.org
Fri Jul 20 17:51:00 UTC 2012
Module: Mesa
Branch: master
Commit: ddc88fbf510ee8ba35b974cc21c595e96d115cc8
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ddc88fbf510ee8ba35b974cc21c595e96d115cc8
Author: Eric Anholt <eric at anholt.net>
Date: Tue May 1 14:07:43 2012 -0700
mesa: Add implementation of glGetUniformBlockIndex().
Now that we finally have a list of uniform blocks in the linked shader
program, we can tell what their indices are.
Fixes piglit GL_ARB_uniform_buffer_object/getuniformblockindex.
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
---
src/mesa/main/uniforms.c | 27 +++++++++++++++++++++++++++
1 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c
index 1cec592..ccbd753 100644
--- a/src/mesa/main/uniforms.c
+++ b/src/mesa/main/uniforms.c
@@ -524,6 +524,32 @@ _mesa_GetUniformLocationARB(GLhandleARB programObj, const GLcharARB *name)
return _mesa_uniform_merge_location_offset(index, offset);
}
+static GLuint GLAPIENTRY
+_mesa_GetUniformBlockIndex(GLuint program,
+ const GLchar *uniformBlockName)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLuint i;
+ struct gl_shader_program *shProg;
+
+ if (!ctx->Extensions.ARB_uniform_buffer_object) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glGetUniformBlockIndex");
+ return GL_INVALID_INDEX;
+ }
+
+ shProg = _mesa_lookup_shader_program_err(ctx, program,
+ "glGetUniformBlockIndex");
+ if (!shProg)
+ return GL_INVALID_INDEX;
+
+ for (i = 0; i < shProg->NumUniformBlocks; i++) {
+ if (!strcmp(shProg->UniformBlocks[i].Name, uniformBlockName))
+ return i;
+ }
+
+ return GL_INVALID_INDEX;
+}
+
static void GLAPIENTRY
_mesa_GetUniformIndices(GLuint program,
GLsizei uniformCount,
@@ -615,6 +641,7 @@ _mesa_init_shader_uniform_dispatch(struct _glapi_table *exec)
SET_GetnUniformdvARB(exec, _mesa_GetnUniformdvARB); /* GL 4.0 */
/* GL_ARB_uniform_buffer_object / GL 3.1 */
+ SET_GetUniformBlockIndex(exec, _mesa_GetUniformBlockIndex);
SET_GetUniformIndices(exec, _mesa_GetUniformIndices);
SET_GetActiveUniformsiv(exec, _mesa_GetActiveUniformsiv);
More information about the mesa-commit
mailing list