Mesa (master): mesa: Refactor getting a uniform's name to a helper function

Ian Romanick idr at kemper.freedesktop.org
Sat Jan 19 01:36:39 UTC 2013


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

Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Fri Dec 14 14:59:11 2012 -0800

mesa: Refactor getting a uniform's name to a helper function

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 at intel.com>
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

---

 src/mesa/main/uniform_query.cpp |    2 +-
 src/mesa/main/uniforms.c        |   12 ++++++++++--
 src/mesa/main/uniforms.h        |    5 +++++
 3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp
index efff8f3..ec08ed4 100644
--- a/src/mesa/main/uniform_query.cpp
+++ b/src/mesa/main/uniform_query.cpp
@@ -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) {
diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c
index 77b195e..edb4477 100644
--- a/src/mesa/main/uniforms.c
+++ b/src/mesa/main/uniforms.c
@@ -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);
+}
diff --git a/src/mesa/main/uniforms.h b/src/mesa/main/uniforms.h
index 287d710..f175031 100644
--- a/src/mesa/main/uniforms.h
+++ b/src/mesa/main/uniforms.h
@@ -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];




More information about the mesa-commit mailing list