[Piglit] [PATCH] Accept array uniform names with or without [0] from glGetActiveUniform

Ian Romanick idr at freedesktop.org
Fri Dec 14 16:54:08 PST 2012


From: Ian Romanick <ian.d.romanick at intel.com>

This is required by OpenGL ES 3.0 and desktop OpenGL 4.2.  Previous
version were ambiguous.

Previously these tests failed on NVIDIA's closed-source driver (version
304.64) with the error messages:

    0: f1 loc=0 size=1 type=0x1406
    1: f2 loc=1 size=1 type=0x1406
    2: s.a loc=2 size=1 type=0x1406
    3: s.b loc=3 size=1 type=0x1406
    4: s.c loc=4 size=1 type=0x1406
    5: s.d loc=5 size=1 type=0x1406
    6: v[0] loc=6 size=3 type=0x8b52
    getuniform-02: wrong type for 'v' (found 0x8b52, expected 0x1406)

and

    Unexpected max active uniform length (saw 9, expected 6)
    Unexpected active uniform length (saw 8, expected 5) for "color[0]"

With these changes, both tests pass.

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
 tests/shaders/getuniform-02.c                |  6 +++++-
 tests/shaders/glsl-getactiveuniform-length.c | 23 ++++++++++++++++++-----
 2 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/tests/shaders/getuniform-02.c b/tests/shaders/getuniform-02.c
index 5d77403..8572432 100644
--- a/tests/shaders/getuniform-02.c
+++ b/tests/shaders/getuniform-02.c
@@ -109,7 +109,11 @@ piglit_init(int argc, char **argv)
          printf("%d: %s loc=%d size=%d type=0x%x\n", i, name, loc, size, type);
       }
 
-      if (strcmp(name, "v") == 0) {
+      /* OpenGL ES 3.0 and OpenGL 4.2 require that the "[0]" be appended to
+       * the name.  Earlier versions of the spec are ambiguous.  Accept either
+       * name.
+       */
+      if (strcmp(name, "v") == 0 || strcmp(name, "v[0]") == 0) {
          expectedType = GL_FLOAT_VEC4_ARB;
          expectedSize = 3;
       }
diff --git a/tests/shaders/glsl-getactiveuniform-length.c b/tests/shaders/glsl-getactiveuniform-length.c
index 1be8c77..446ee51 100644
--- a/tests/shaders/glsl-getactiveuniform-length.c
+++ b/tests/shaders/glsl-getactiveuniform-length.c
@@ -61,6 +61,13 @@ piglit_init(int argc, char **argv)
 	char *name;
 	GLsizei size;
 
+	/* OpenGL ES 3.0 and OpenGL 4.2 require that the "[0]" be appended to
+	 * the name.  Earlier versions of the spec are ambiguous.  Accept
+	 * either name.
+	 */
+	const size_t scalar_length = strlen("color");
+	const size_t array_length = strlen("color[0]");
+
 	piglit_require_gl_version(20);
 
 	vs = piglit_compile_shader(GL_VERTEX_SHADER,
@@ -78,9 +85,11 @@ piglit_init(int argc, char **argv)
 	 */
 
 	glGetProgramiv(prog, GL_ACTIVE_UNIFORM_MAX_LENGTH, &len);
-	if (len != strlen("color") + 1) {
+	if (len != (scalar_length + 1) && len != (array_length + 1)) {
 		printf("Unexpected max active uniform length "
-		       "(saw %d, expected %lu)\n", len, (unsigned long) strlen("color") + 1);
+		       "(saw %d, expected %lu or %lu)\n", len,
+		       (unsigned long) scalar_length,
+		       (unsigned long) array_length);
 		pass = GL_FALSE;
 	}
 
@@ -91,10 +100,14 @@ piglit_init(int argc, char **argv)
 	 */
 	name = malloc(len);
 	glGetActiveUniform(prog, 0, len + 20, &ret_len, &size, &type, name);
-	if (ret_len != strlen("color")) {
+
+	if (ret_len != scalar_length && ret_len != array_length) {
 		printf("Unexpected active uniform length "
-		       "(saw %d, expected %lu) for \"%s\"\n",
-		       ret_len, (unsigned long) strlen("color"), name);
+		       "(saw %d, expected %lu or %lu) for \"%s\"\n",
+		       ret_len,
+		       (unsigned long) scalar_length,
+		       (unsigned long) array_length,
+		       name);
 		pass = GL_FALSE;
 	}
 
-- 
1.7.11.7



More information about the Piglit mailing list