[Piglit] [PATCH] Test that all vertex shader inputs are enumerated by GetActiveAttrib(). This includes built-ins such as gl_InstanceID and gl_VertexID.

Nicholas Mack nichmack at gmail.com
Fri Sep 27 12:21:41 PDT 2013


---
 tests/all.tests                                    |   2 +
 tests/spec/gl-3.2/CMakeLists.gl.txt                |   1 +
 .../gl-3.2/get-active-attrib-returns-all-inputs.c  | 117 +++++++++++++++++++++
 3 files changed, 120 insertions(+)
 create mode 100644 tests/spec/gl-3.2/get-active-attrib-returns-all-inputs.c

diff --git a/tests/all.tests b/tests/all.tests
index 2d6a52e..153fe9e 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -750,6 +750,8 @@ spec['!OpenGL 3.2/layered-rendering/clear-depth'] = concurrent_test('gl-3.2-laye
 spec['!OpenGL 3.2/layered-rendering/framebuffertexture-buffer-textures'] = concurrent_test('gl-3.2-layered-rendering-framebuffertexture-buffer-textures')
 spec['!OpenGL 3.2/layered-rendering/readpixels'] = concurrent_test('gl-3.2-layered-rendering-readpixels')
 
+spec['!OpenGL/get-active-attrib-returns-all-inputs'] = concurrent_test('gl-get-active-attrib-returns-all-inputs')
+
 spec['!OpenGL 3.3/minmax'] = concurrent_test('gl-3.3-minmax')
 spec['!OpenGL 3.3/required-renderbuffer-attachment-formats'] = concurrent_test('gl-3.0-required-renderbuffer-attachment-formats 33')
 spec['!OpenGL 3.3/required-sized-texture-formats'] = concurrent_test('gl-3.0-required-sized-texture-formats 33')
diff --git a/tests/spec/gl-3.2/CMakeLists.gl.txt b/tests/spec/gl-3.2/CMakeLists.gl.txt
index 9fc0a75..224f6fd 100644
--- a/tests/spec/gl-3.2/CMakeLists.gl.txt
+++ b/tests/spec/gl-3.2/CMakeLists.gl.txt
@@ -9,6 +9,7 @@ link_libraries (
 	${OPENGL_glu_LIBRARY}
 )
 
+piglit_add_executable (gl-get-active-attrib-returns-all-inputs get-active-attrib-returns-all-inputs.c)
 piglit_add_executable (gl-3.2-minmax minmax.c)
 piglit_add_executable (gl-3.2-clear-no-buffers clear-no-buffers.c)
 piglit_add_executable (gl-3.2-get-buffer-parameter-i64v get-buffer-parameter-i64v.c)
diff --git a/tests/spec/gl-3.2/get-active-attrib-returns-all-inputs.c b/tests/spec/gl-3.2/get-active-attrib-returns-all-inputs.c
new file mode 100644
index 0000000..fe48b79
--- /dev/null
+++ b/tests/spec/gl-3.2/get-active-attrib-returns-all-inputs.c
@@ -0,0 +1,117 @@
+/**
+ * Copyright © 2013 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.
+ */
+
+/**
+ * Test that built-in vertex input variables are enumerated by GetActiveAttrib()
+ *
+ * This is not explicitly stated in any specs before 4.3 core but it seems to
+ * be clarified in later specs
+ *
+ * From GL 4.3 core spec, section 11.1.1 (Vertex Attributes):
+ * "For GetActiveAttrib, all active vertex shader input variables are
+ *  enumerated, including the special built-in inputs gl_VertexID and
+ *  gl_InstanceID."
+ *
+ * From GL 4.3 core spec, section F.5 (Change Log for Released Specifications):
+ * "Specify in section 11.1.1 that special built-in inputs and outputs such as
+ *  gl_VertexID should be enumerated in the PROGRAM_INPUT and PROGRAM_OUTPUT
+ *  interfaces, as well as the legacy function GetActiveAttrib. Add spec
+ *  language counting the built-ins gl_VertexID and gl_InstanceID against the
+ *  active attribute limit (Bug 9201)."
+ */
+
+#include "piglit-util-gl-common.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_compat_version = 31;
+        config.supports_gl_core_version = 31;
+
+	config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+static const char *vstext =
+	"#version 140\n"
+	"in vec4 piglit_vertex;\n"
+	"flat out int instID;\n"
+	"flat out int vertID;\n"
+	"void main() {\n"
+	"	gl_Position = piglit_vertex;\n"
+	"	instID = gl_InstanceID;\n"
+	"	vertID = gl_VertexID;\n"
+	"}\n";
+
+static const char *fstext =
+	"#version 140\n"
+	"flat in int instID;\n"
+	"flat in int vertID;\n"
+	"out vec4 color;\n"
+	"void main() {\n"
+	"	color = vec4(instID + vertID);\n"
+	"}\n";
+
+static GLuint prog;
+const int bufSize = 100;
+
+void
+piglit_init(int argc, char **argv)
+{
+	bool pass = true;
+	int i = 0;
+	int numAttribs = 0;
+	GLsizei length;
+	GLint size;
+	GLenum type;
+	GLchar name[bufSize];
+
+	prog = piglit_build_simple_program(vstext, fstext);
+
+	glLinkProgram(prog);
+	if(!piglit_link_check_status(prog)) {
+		glDeleteProgram(prog);
+		piglit_report_result(PIGLIT_FAIL);
+	}
+
+	glGetProgramiv(prog, GL_ACTIVE_ATTRIBUTES, &numAttribs);
+	if(numAttribs <= 1) {
+		printf("The number of active attributes is %d.\n", numAttribs);
+		for(i = 0; i < numAttribs; i++) {
+			glGetActiveAttrib(prog, i, bufSize, &length, &size,
+					  &type, name);
+			printf("\tAttrib %d is %s.\n", i, name);
+		}
+		printf("Also expected to see gl_InstanceID and gl_VertexID.\n");
+		pass = false;
+	}
+	pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
+
+	piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
+}
+
+enum piglit_result
+piglit_display(void)
+{
+	/* UNREACHABLE */
+	return PIGLIT_FAIL;
+}
-- 
1.8.3.1



More information about the Piglit mailing list