[Piglit] [PATCH] arb_shader_objects: Test glGetUniformLocation on an array of struct of array

Ian Romanick idr at freedesktop.org
Wed Sep 7 11:53:24 PDT 2011


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

Currently Mesa fails to get the location of array elements embedded in
a structure.
---
 tests/all.tests                                    |    2 +
 tests/spec/arb_shader_objects/CMakeLists.gl.txt    |    1 +
 .../getuniformlocation-array-of-struct-of-array.c  |  105 ++++++++++++++++++++
 3 files changed, 108 insertions(+), 0 deletions(-)
 create mode 100644 tests/spec/arb_shader_objects/getuniformlocation-array-of-struct-of-array.c

diff --git a/tests/all.tests b/tests/all.tests
index 931e0d3..fb1e2e6 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -888,6 +888,8 @@ arb_shader_objects = Group()
 spec['ARB_shader_objects'] = arb_shader_objects
 arb_shader_objects['getuniform'] = PlainExecTest(['arb_shader_objects-getuniform', '-auto'])
 arb_shader_objects['getuniform'].runConcurrent = True
+arb_shader_objects['getuniformlocation-array-of-struct-of-array'] = PlainExecTest(['arb_shader_objects-getuniformlocation-array-of-struct-of-array', '-auto'])
+arb_shader_objects['getuniformlocation-array-of-struct-of-array'].runConcurrent = True
 
 # Group ARB_explicit_attrib_location
 arb_explicit_attrib_location = Group()
diff --git a/tests/spec/arb_shader_objects/CMakeLists.gl.txt b/tests/spec/arb_shader_objects/CMakeLists.gl.txt
index 03b3f61..3e7fd4b 100644
--- a/tests/spec/arb_shader_objects/CMakeLists.gl.txt
+++ b/tests/spec/arb_shader_objects/CMakeLists.gl.txt
@@ -12,3 +12,4 @@ link_libraries (
 )
 
 add_executable (arb_shader_objects-getuniform getuniform.c)
+add_executable (arb_shader_objects-getuniformlocation-array-of-struct-of-array getuniformlocation-array-of-struct-of-array.c)
diff --git a/tests/spec/arb_shader_objects/getuniformlocation-array-of-struct-of-array.c b/tests/spec/arb_shader_objects/getuniformlocation-array-of-struct-of-array.c
new file mode 100644
index 0000000..2b89a0a
--- /dev/null
+++ b/tests/spec/arb_shader_objects/getuniformlocation-array-of-struct-of-array.c
@@ -0,0 +1,105 @@
+/*
+ * Copyright © 2011 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+/**
+ * \file getattriblocation-conventional.c
+ * Verify that glGetAttribLocation on a conventional attribute returns -1.
+ *
+ * \author Ian Romanick
+ */
+
+#include "piglit-util.h"
+
+int piglit_width = 100, piglit_height = 100;
+int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
+
+static const char *vs_code =
+	"struct S { mat4 m; vec4 v[10]; };\n"
+	"uniform S s[10];\n"
+	"uniform int i, j;\n"
+	"void main() { gl_Position = s[i].m * s[i].v[j]; }\n"
+	;
+
+enum piglit_result
+piglit_display(void)
+{
+	return PIGLIT_FAIL;
+}
+
+void piglit_init(int argc, char **argv)
+{
+	GLint vert;
+	GLint prog;
+	GLint loc;
+	char name[256];
+	bool pass;
+	unsigned i;
+	unsigned j;
+
+	piglit_require_vertex_shader();
+	vert = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_code);
+	prog = piglit_link_simple_program(vert, 0);
+
+	/* From page 80 of the OpenGL 2.1 spec:
+	 *
+	 *     "A valid name cannot be a structure, an array of structures, or
+	 *     any portion of a single vector or a matrix."
+	 */
+	snprintf(name, sizeof(name), "s", i);
+	loc = piglit_GetUniformLocation(prog, name);
+	printf("%s location = %d (should be -1)\n", name, loc);
+
+	pass = (loc == -1);
+
+	for (i = 0; i < 10; i++) {
+		/* From page 80 of the OpenGL 2.1 spec:
+		 *
+		 *     "A valid name cannot be a structure, an array of
+		 *     structures, or any portion of a single vector or a
+		 *     matrix."
+		 */
+		snprintf(name, sizeof(name), "s[%d]", i);
+		loc = piglit_GetUniformLocation(prog, name);
+		printf("%s location = %d (should be -1)\n", name, loc);
+
+		pass = (loc == -1) && pass;
+
+
+		snprintf(name, sizeof(name), "s[%d].m", i);
+		loc = piglit_GetUniformLocation(prog, name);
+		printf("%s location = %d (should not be -1)\n", name, loc);
+
+		pass = (loc != -1) && pass;
+
+		for (j = 0; j < 10; j++) {
+			snprintf(name, sizeof(name), "s[%d].v[%d]", i, j);
+			loc = piglit_GetUniformLocation(prog, name);
+			printf("%s location = %d (should not be -1)\n",
+			       name, loc);
+
+			pass = (loc != -1) && pass;
+		}
+	}
+
+	piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
+}
-- 
1.7.4.4



More information about the Piglit mailing list