Mesa (9.1): ACTIVE_UNIFORM_MAX_LENGTH should include 3 extra characters for arrays.

Ian Romanick idr at kemper.freedesktop.org
Fri May 10 20:43:46 UTC 2013


Module: Mesa
Branch: 9.1
Commit: 627e2669ab3f70176b06e1f598bb4e478f5378ad
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=627e2669ab3f70176b06e1f598bb4e478f5378ad

Author: Haixia Shi <hshi at chromium.org>
Date:   Mon Apr  1 13:24:55 2013 -0700

ACTIVE_UNIFORM_MAX_LENGTH should include 3 extra characters for arrays.

If the active uniform is an array, then the length of the uniform name should
include the three extra characters for the "[0]" suffix, which is required by
the GL 4.2 spec to be appended to the uniform name in glGetActiveUniform().

This avoids the situation where the output buffer does not have enough space
to hold the "[0]" suffix, resulting in an incomplete array specification like
"foobar[0".

NOTE: This is a candidate for the 9.1 branch.

Change-Id: I41e87ba347a7169eec8c575596cc3416adbe0728
Signed-off-by: Haixia Shi <hshi at chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu at chromium.org>
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
(cherry picked from commit bc0cc2944ff13549df8276b856acc79254c5db07)

---

 src/mesa/main/shaderapi.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index be69467..2c307e7 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -518,9 +518,11 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname, GLint *param
       GLint max_len = 0;
 
       for (i = 0; i < shProg->NumUserUniformStorage; i++) {
-	 /* Add one for the terminating NUL character.
+	 /* Add one for the terminating NUL character for a non-array, and
+	  * 4 for the "[0]" and the NUL for an array.
 	  */
-	 const GLint len = strlen(shProg->UniformStorage[i].name) + 1;
+	 const GLint len = strlen(shProg->UniformStorage[i].name) + 1 +
+	     ((shProg->UniformStorage[i].array_elements != 0) ? 3 : 0);
 
 	 if (len > max_len)
 	    max_len = len;




More information about the mesa-commit mailing list