Mesa (master): mesa: Add support for GL_ARB_ubo's glGetActiveUniformName().

Eric Anholt anholt at kemper.freedesktop.org
Tue Jul 31 19:21:42 UTC 2012


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

Author: Eric Anholt <eric at anholt.net>
Date:   Thu Jun 21 14:58:58 2012 -0700

mesa: Add support for GL_ARB_ubo's glGetActiveUniformName().

This is like a stripped-down version of glGetActiveUniform that just
returns the name, since the other return values (type and size) of
that function are now meant to be handled with
glGetActiveUniformsiv().

Fixes piglit ARB_uniform_buffer_object/getactiveuniformname

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

---

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

diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c
index 6652251..b5aaa1b 100644
--- a/src/mesa/main/uniforms.c
+++ b/src/mesa/main/uniforms.c
@@ -752,6 +752,44 @@ _mesa_GetActiveUniformBlockName(GLuint program,
    }
 }
 
+static void GLAPIENTRY
+_mesa_GetActiveUniformName(GLuint program, GLuint uniformIndex,
+			   GLsizei bufSize, GLsizei *length,
+			   GLchar *uniformName)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_shader_program *shProg;
+
+   if (!ctx->Extensions.ARB_uniform_buffer_object) {
+      _mesa_error(ctx, GL_INVALID_OPERATION, "glGetActiveUniformBlockiv");
+      return;
+   }
+
+   if (bufSize < 0) {
+      _mesa_error(ctx, GL_INVALID_VALUE,
+		  "glGetActiveUniformName(bufSize %d < 0)",
+		  bufSize);
+      return;
+   }
+
+   ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+   shProg = _mesa_lookup_shader_program_err(ctx, program, "glGetActiveUniformName");
+
+   if (!shProg)
+      return;
+
+   if (uniformIndex >= shProg->NumUserUniformStorage) {
+      _mesa_error(ctx, GL_INVALID_VALUE, "glGetActiveUniform(index)");
+      return;
+   }
+
+   if (uniformName) {
+      _mesa_copy_string(uniformName, bufSize, length,
+			shProg->UniformStorage[uniformIndex].name);
+   }
+}
+
 /**
  * Plug in shader uniform-related functions into API dispatch table.
  */
@@ -815,6 +853,7 @@ _mesa_init_shader_uniform_dispatch(struct _glapi_table *exec)
    SET_GetActiveUniformsiv(exec, _mesa_GetActiveUniformsiv);
    SET_GetActiveUniformBlockiv(exec, _mesa_GetActiveUniformBlockiv);
    SET_GetActiveUniformBlockName(exec, _mesa_GetActiveUniformBlockName);
+   SET_GetActiveUniformName(exec, _mesa_GetActiveUniformName);
    SET_UniformBlockBinding(exec, _mesa_UniformBlockBinding);
 
 #endif /* FEATURE_GL */




More information about the mesa-commit mailing list