[Piglit] [Patch V2] ARB_explicit_uniform_location: test inactive uniform interaction

Tapani Pälli tapani.palli at intel.com
Fri Mar 28 04:37:48 PDT 2014


Test has a shader with only one uniform which is not used. Test checks
that there is no error when glUniform1f is called to update its value.

Test passes on GTX 660 running the Nvidia proprietary driver for Linux,
version 319.32.

v2: remove test for glGetUniformLocation, this test tests only
    glUniform call interaction

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

diff --git a/tests/all.py b/tests/all.py
index a86b556..d4431fe 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -1959,6 +1959,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..5b37eba
--- /dev/null
+++ b/tests/spec/arb_explicit_uniform_location/inactive-uniform.c
@@ -0,0 +1,93 @@
+/*
+ * 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 glUniform works as specified for inactive uniform with
+ * explicit location. This is notably also the only uniform in the shader,
+ * which can be special case in the linker.
+ *
+ * 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);
+
+	glUseProgram(prog);
+
+	/* verify that glUniform1f does not generate error */
+	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