On 03/29/2013 06:22 PM, Haixia Shi wrote:
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().

Do we have a piglit test for this?

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".

Please add the following line to the commit message:

NOTE: This is a candidate for the 9.1 branch.

Change-Id: Icd58cd6a73c9de7bbe5659d757b8009021846019
Signed-off-by: Haixia Shi <h...@chromium.org>
Reviewed-by: Stéphane Marchesin <marc...@chromium.org>

One minor nit below, but you can take it or leave it.  Either way:

Reviewed-by: Ian Romanick <ian.d.roman...@intel.com>

---
  src/mesa/main/shaderapi.c | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index be69467..68767f4 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -519,8 +519,11 @@ get_programiv(struct gl_context *ctx, GLuint
program, GLenum pname, GLint *param

        for (i = 0; i < shProg->NumUserUniformStorage; i++) {
         /* Add one for the terminating NUL character.
+         * However if the uniform is an array, then add three extra characters
+         * for the appended "[0]" suffix, in addition to the terminating NUL.
          */
-        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);

Maybe:

      /* 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) +
         ((shProg->UniformStorage[i].array_elements != 0) ? 4 : 1);


         if (len > max_len)
            max_len = len;


_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to