mesa: Refactor getting a uniform's name to a helper function
authorIan Romanick <ian.d.romanick@intel.com>
Fri, 14 Dec 2012 22:59:11 +0000 (14:59 -0800)
committerIan Romanick <ian.d.romanick@intel.com>
Sat, 19 Jan 2013 01:35:33 +0000 (17:35 -0800)
We currently have a bug in this code, and I don't want to fix it in two
places.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/main/uniform_query.cpp
src/mesa/main/uniforms.c
src/mesa/main/uniforms.h

index efff8f381f1d8d3485e831e916f2c594c696bf89..ec08ed48b40b5d614a283cc93947be3ec86d26b4 100644 (file)
@@ -59,7 +59,7 @@ _mesa_GetActiveUniform(GLhandleARB program, GLuint index,
    const struct gl_uniform_storage *const uni = &shProg->UniformStorage[index];
 
    if (nameOut) {
-      _mesa_copy_string(nameOut, maxLength, length, uni->name);
+      _mesa_get_uniform_name(uni, maxLength, length, nameOut);
    }
 
    if (size) {
index 77b195edbc39d137988d82dcd3d2bdeccdd28a55..edb44777f6bd6782b41c4e072ed6622005b4add5 100644 (file)
@@ -795,7 +795,15 @@ _mesa_GetActiveUniformName(GLuint program, GLuint uniformIndex,
    }
 
    if (uniformName) {
-      _mesa_copy_string(uniformName, bufSize, length,
-                       shProg->UniformStorage[uniformIndex].name);
+      _mesa_get_uniform_name(& shProg->UniformStorage[uniformIndex],
+                             bufSize, length, uniformName);
    }
 }
+
+void
+_mesa_get_uniform_name(const struct gl_uniform_storage *uni,
+                       GLsizei maxLength, GLsizei *length,
+                       GLchar *nameOut)
+{
+   _mesa_copy_string(nameOut, maxLength, length, uni->name);
+}
index 287d7106bb6e43fa18fadf6935b5900ec9693b08..f17503121c8a961fa1f0ba5b19a11fcf5ae1b443 100644 (file)
@@ -213,6 +213,11 @@ _mesa_sampler_uniforms_are_valid(const struct gl_shader_program *shProg,
 extern const struct gl_program_parameter *
 get_uniform_parameter(struct gl_shader_program *shProg, GLint index);
 
+extern void
+_mesa_get_uniform_name(const struct gl_uniform_storage *uni,
+                       GLsizei maxLength, GLsizei *length,
+                       GLchar *nameOut);
+
 struct gl_builtin_uniform_element {
    const char *field;
    int tokens[STATE_LENGTH];