Mesa (master): mesa: Add support for glGetUniformIndices().

Eric Anholt anholt at kemper.freedesktop.org
Fri Jul 20 17:50:58 UTC 2012


Module: Mesa
Branch: master
Commit: acfbdfcbc8263cc0ace3468457a209dd80da017e
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=acfbdfcbc8263cc0ace3468457a209dd80da017e

Author: Eric Anholt <eric at anholt.net>
Date:   Fri Apr 27 15:37:49 2012 -0700

mesa: Add support for glGetUniformIndices().

This is a single entrypoint that maps from a series of names to the
indices of those names within the active uniforms list.  Each index is
like glGetUniformLocation()'s return value, except that it doesn't
encode an array offset.

Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

---

 src/mesa/main/uniforms.c |   35 +++++++++++++++++++++++++++++++++++
 1 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c
index 2a048a5..9ed5d7e 100644
--- a/src/mesa/main/uniforms.c
+++ b/src/mesa/main/uniforms.c
@@ -524,6 +524,38 @@ _mesa_GetUniformLocationARB(GLhandleARB programObj, const GLcharARB *name)
    return _mesa_uniform_merge_location_offset(index, offset);
 }
 
+static void GLAPIENTRY
+_mesa_GetUniformIndices(GLuint program,
+			GLsizei uniformCount,
+			const GLchar * const *uniformNames,
+			GLuint *uniformIndices)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   GLsizei i;
+   struct gl_shader_program *shProg;
+
+   if (!ctx->Extensions.ARB_uniform_buffer_object) {
+      _mesa_error(ctx, GL_INVALID_OPERATION, "glGetUniformIndices");
+      return;
+   }
+
+   shProg = _mesa_lookup_shader_program_err(ctx, program,
+					    "glGetUniformIndices");
+   if (!shProg)
+      return;
+
+   if (uniformCount < 0) {
+      _mesa_error(ctx, GL_INVALID_VALUE,
+		  "glGetUniformIndices(uniformCount < 0)");
+      return;
+   }
+
+   for (i = 0; i < uniformCount; i++) {
+      unsigned offset;
+      uniformIndices[i] = _mesa_get_uniform_location(ctx, shProg,
+						     uniformNames[i], &offset);
+   }
+}
 
 /**
  * Plug in shader uniform-related functions into API dispatch table.
@@ -582,5 +614,8 @@ _mesa_init_shader_uniform_dispatch(struct _glapi_table *exec)
    SET_GetnUniformuivARB(exec, _mesa_GetnUniformuivARB);
    SET_GetnUniformdvARB(exec, _mesa_GetnUniformdvARB); /* GL 4.0 */
 
+   /* GL_ARB_uniform_buffer_object / GL 3.1 */
+   SET_GetUniformIndices(exec, _mesa_GetUniformIndices);
+
 #endif /* FEATURE_GL */
 }




More information about the mesa-commit mailing list