summaryrefslogtreecommitdiff
path: root/tests/spec/arb_explicit_uniform_location
diff options
context:
space:
mode:
authorTapani Pälli <tapani.palli@intel.com>2014-03-12 13:55:03 +0200
committerTapani Pälli <tapani.palli@intel.com>2014-03-17 08:07:39 +0200
commit385e8f3b9322aedd48f3e61e1cf5e8b85524de7a (patch)
treea0d1d7acedb3bc6312f2e429a75c37a0149e8eda /tests/spec/arb_explicit_uniform_location
parentfe08c72746c371ba6cabf8bccf9c141616b15f74 (diff)
ARB_explicit_uniform_location: test sequential array elements
v2: set values directly to shader, simplify overall (Topi) fix style issues, use asprintf (Anuj) v3: more cleanups (Topi, Ian) Signed-off-by: Tapani Pälli <tapani.palli@intel.com> Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
Diffstat (limited to 'tests/spec/arb_explicit_uniform_location')
-rw-r--r--tests/spec/arb_explicit_uniform_location/CMakeLists.gl.txt1
-rw-r--r--tests/spec/arb_explicit_uniform_location/array-elements.c88
2 files changed, 89 insertions, 0 deletions
diff --git a/tests/spec/arb_explicit_uniform_location/CMakeLists.gl.txt b/tests/spec/arb_explicit_uniform_location/CMakeLists.gl.txt
index e871ca16a..945c80d01 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-boundaries.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 000000000..c80323305
--- /dev/null
+++ b/tests/spec/arb_explicit_uniform_location/array-elements.c
@@ -0,0 +1,88 @@
+/*
+ * 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.
+ *
+ * The GL_ARB_explicit_uniform_location spec says:
+ * "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;
+}
+
+static const char vs_text[] =
+ "vec4 vertex;\n"
+ "void main() {\n"
+ "gl_Position = vertex;\n"
+ "}";
+
+static const char fs_text[] =
+ "#extension GL_ARB_explicit_uniform_location: require\n"
+ "#define ARRAY_SIZE 16\n"
+ "layout(location = 1) uniform float r;\n"
+ "layout(location = 2) uniform float g;\n"
+ "layout(location = 3) uniform float a[ARRAY_SIZE];\n"
+ "layout(location = 19) uniform float b;\n"
+ "void main() {\n"
+ "gl_FragColor = vec4(r, g, b, a[ARRAY_SIZE - 1]);\n"
+ "}";
+
+void
+piglit_init(int argc, char **argv)
+{
+ GLuint prog, i;
+
+ piglit_require_extension("GL_ARB_explicit_uniform_location");
+
+ prog = piglit_build_simple_program(vs_text, fs_text);
+
+ /* verify that locations are sequential */
+ for (i = 0; i < 16; i++) {
+ char *element;
+ if (asprintf(&element, "a[%d]", i) == -1)
+ piglit_report_result(PIGLIT_FAIL);
+
+ if (glGetUniformLocation(prog, element) != 3 + i)
+ piglit_report_result(PIGLIT_FAIL);
+
+ free(element);
+ }
+
+ glDeleteProgram(prog);
+ piglit_report_result(PIGLIT_PASS);
+}