[Piglit] [PATCH] ARB_explicit_uniform_location: test inactive uniform interaction

Tapani Pälli tapani.palli at intel.com
Mon Mar 24 03:52:47 PDT 2014


Test has a shader with only one uniform which is not used. Test checks
that uniform gets its defined explicit location and that there are no
errors generated when glUniform is called to update its value.

Test test does not pass with GTX 660 running the Nvidia proprietary
driver for Linux version 319.32 because the uniform does not get the
location.

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

diff --git a/tests/all.py b/tests/all.py
index 3de200e..a34f4ea 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -1936,6 +1936,7 @@ add_shader_test_dir(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')
+add_plain_test(arb_explicit_uniform_location, 'arb_explicit_uniform_location-inactive-uniform')
 
 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 945c80d..1a8488c 100644
--- a/tests/spec/arb_explicit_uniform_location/CMakeLists.gl.txt
+++ b/tests/spec/arb_explicit_uniform_location/CMakeLists.gl.txt
@@ -12,3 +12,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)
+piglit_add_executable (arb_explicit_uniform_location-inactive-uniform inactive-uniform.c)
diff --git a/tests/spec/arb_explicit_uniform_location/inactive-uniform.c b/tests/spec/arb_explicit_uniform_location/inactive-uniform.c
new file mode 100644
index 0000000..6636d0d
--- /dev/null
+++ b/tests/spec/arb_explicit_uniform_location/inactive-uniform.c
@@ -0,0 +1,97 @@
+/*
+ * 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 inactive-uniform.c
+ *
+ * Tests that inactive uniform gets explicit location defined in the
+ * shader and glGetUniformLocation and glUniform work as specified.
+ *
+ * The GL_ARB_explicit_uniform_location spec says:
+ *
+ *     "No two default-block uniform variables in the program can have
+ *     the same location, even if they are unused, otherwise a compiler
+ *     or linker error will be generated."
+ *
+ * note also in the Issues section:
+ *
+ *     "What happens if Uniform* is called with an explicitly defined
+ *     uniform location, but that uniform is deemed inactive by the
+ *     linker?
+ *
+ *     RESOLVED: The call is ignored for inactive uniform variables and
+ *     no error is generated."
+ */
+#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"
+	"layout(location = 7) uniform float var;\n"
+	"void main() {\n"
+		"gl_FragColor = vec4(1.0, 0.0, 1.0, 1.0);\n"
+	"}";
+
+void
+piglit_init(int argc, char **argv)
+{
+	GLuint prog;
+
+	piglit_require_extension("GL_ARB_explicit_uniform_location");
+
+	prog = piglit_build_simple_program(vs_text, fs_text);
+
+	/* verify that inactive variable explicit location is set */
+	if (glGetUniformLocation(prog, "var") != 7)
+		piglit_report_result(PIGLIT_FAIL);
+
+	glUseProgram(prog);
+
+	/* verify that glUniform1f does not generate error when
+         * using inactive uniform with explicit location */
+	glUniform1f(7, 0.1);
+
+	if (!piglit_check_gl_error(GL_NO_ERROR))
+		piglit_report_result(PIGLIT_FAIL);
+
+	glDeleteProgram(prog);
+	piglit_report_result(PIGLIT_PASS);
+}
-- 
1.8.3.1



More information about the Piglit mailing list