[Piglit] [PATCH 2/7] ARB_explicit_uniform_location: test sequential array elements

Tapani Pälli tapani.palli at intel.com
Thu Mar 13 05:41:44 PDT 2014


Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
---
 tests/all.py                                       |   1 +
 .../CMakeLists.gl.txt                              |   1 +
 .../arb_explicit_uniform_location/array-elements.c | 107 +++++++++++++++++++++
 3 files changed, 109 insertions(+)
 create mode 100644 tests/spec/arb_explicit_uniform_location/array-elements.c

diff --git a/tests/all.py b/tests/all.py
index 25ec0ea..03202cd 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -1926,6 +1926,7 @@ import_glsl_parser_tests(arb_explicit_uniform_location,
                          [''])
 add_plain_test(arb_explicit_uniform_location, 'arb_explicit_uniform_location-minmax')
 add_plain_test(arb_explicit_uniform_location, 'arb_explicit_uniform_location-boundaries')
+add_plain_test(arb_explicit_uniform_location, 'arb_explicit_uniform_location-array-elements')
 
 arb_texture_buffer_object = Group()
 spec['ARB_texture_buffer_object'] = arb_texture_buffer_object
diff --git a/tests/spec/arb_explicit_uniform_location/CMakeLists.gl.txt b/tests/spec/arb_explicit_uniform_location/CMakeLists.gl.txt
index 57e90f0..481922e 100644
--- a/tests/spec/arb_explicit_uniform_location/CMakeLists.gl.txt
+++ b/tests/spec/arb_explicit_uniform_location/CMakeLists.gl.txt
@@ -11,3 +11,4 @@ link_libraries (
 
 piglit_add_executable (arb_explicit_uniform_location-minmax minmax.c)
 piglit_add_executable (arb_explicit_uniform_location-boundaries loc-minmax.c)
+piglit_add_executable (arb_explicit_uniform_location-array-elements array-elements.c)
diff --git a/tests/spec/arb_explicit_uniform_location/array-elements.c b/tests/spec/arb_explicit_uniform_location/array-elements.c
new file mode 100644
index 0000000..a82dc46
--- /dev/null
+++ b/tests/spec/arb_explicit_uniform_location/array-elements.c
@@ -0,0 +1,107 @@
+/*
+ * Copyright © 2014 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 array-elements.c
+ *
+ *  Tests that array elements get sequential locations.
+ *
+ *  https://www.opengl.org/registry/specs/ARB/explicit_uniform_location.txt
+ *
+ *  Specification states : "Individual elements of a uniform array are assigned
+ *                          consecutive locations with the first element taking
+ *                          location <location>."
+ */
+#include "piglit-util-gl-common.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_compat_version = 20;
+	config.window_visual = PIGLIT_GL_VISUAL_RGB;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+enum piglit_result
+piglit_display(void)
+{
+	return PIGLIT_FAIL;
+}
+
+const char v_sha[] =
+"vec4 vertex;\n"
+"void main() {\n"
+"gl_Position = vertex;\n"
+"}";
+
+const char fshader_main[] =
+"#extension GL_ARB_explicit_uniform_location: require\n"
+"layout(location = %d) uniform float r;\n"
+"layout(location = %d) uniform float g;\n"
+"layout(location = %d) uniform float a[%d];\n"
+"layout(location = %d) uniform float b;\n"
+"void main() {\n"
+"gl_FragColor = vec4(r, g, b, a[%d]);\n"
+"}";
+
+#define VERIFY_LOC(uni, loc)\
+	if (glGetUniformLocation(prog, uni) != loc)\
+		piglit_report_result(PIGLIT_FAIL);
+
+static bool
+test()
+{
+	GLuint prog;
+
+        char f_sha[512];
+	int array_size = 16;
+	unsigned i, array_loc = 3;
+
+	snprintf(f_sha, 512, fshader_main,
+		1, /* r */
+		2, /* g */
+		array_loc, /* a */
+		array_size, /* array len */
+		42, /* b */
+                array_size - 1); /* array access */
+
+	prog = piglit_build_simple_program(v_sha, f_sha);
+
+        /* loop through array elements and verify that
+         * locations are sequential
+         */
+	for (i = 0; i < array_size; i++) {
+		char element[8];
+		snprintf(element, 16, "a[%d]", i);
+		VERIFY_LOC(element, array_loc + i);
+        }
+
+	glDeleteProgram(prog);
+	return true;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+	piglit_require_extension("GL_ARB_explicit_uniform_location");
+	piglit_report_result(test() ? PIGLIT_PASS : PIGLIT_FAIL);
+}
-- 
1.8.3.1



More information about the Piglit mailing list