<div dir="ltr">I don't know OpenGL very much, but can uniforms be more than 10? So you can have "[24]" where you will need +4, not +3. </div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Mar 30, 2013 at 3:22 AM, Haixia Shi <span dir="ltr"><<a href="mailto:hshi@chromium.org" target="_blank">hshi@chromium.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">If the active uniform is an array, then the length of the uniform name should<br>
include the three extra characters for the "[0]" suffix, which is required by<br>
the GL 4.2 spec to be appended to the uniform name in glGetActiveUniform().<br>
<br>
This avoids the situation where the output buffer does not have enough space<br>
to hold the "[0]" suffix, resulting in an incomplete array specification like<br>
"foobar[0".<br>
<br>
Change-Id: Icd58cd6a73c9de7bbe5659d757b8009021846019<br>
Signed-off-by: Haixia Shi <<a href="mailto:hshi@chromium.org">hshi@chromium.org</a>><br>
Reviewed-by: Stéphane Marchesin <<a href="mailto:marcheu@chromium.org">marcheu@chromium.org</a>><br>
---<br>
src/mesa/main/shaderapi.c | 5 ++++-<br>
1 file changed, 4 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c<br>
index be69467..68767f4 100644<br>
--- a/src/mesa/main/shaderapi.c<br>
+++ b/src/mesa/main/shaderapi.c<br>
@@ -519,8 +519,11 @@ get_programiv(struct gl_context *ctx, GLuint<br>
program, GLenum pname, GLint *param<br>
<br>
for (i = 0; i < shProg->NumUserUniformStorage; i++) {<br>
/* Add one for the terminating NUL character.<br>
+ * However if the uniform is an array, then add three extra characters<br>
+ * for the appended "[0]" suffix, in addition to the terminating NUL.<br>
*/<br>
- const GLint len = strlen(shProg->UniformStorage[i].name) + 1;<br>
+ const GLint len = strlen(shProg->UniformStorage[i].name) + 1 +<br>
+ ((shProg->UniformStorage[i].array_elements != 0) ? 3 : 0);<br>
<br>
if (len > max_len)<br>
max_len = len;<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.8.1.3<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div>