[Piglit] [PATCH 4/4] Interface Blocks: Test how interface block members are accessed from API

Nicholas Mack nichmack at gmail.com
Fri Sep 27 11:28:53 PDT 2013


---
 tests/all.tests                                    |   1 +
 tests/spec/glsl-1.50/execution/CMakeLists.gl.txt   |   1 +
 .../interface-blocks-api-access-members.c          | 141 +++++++++++++++++++++
 3 files changed, 143 insertions(+)
 create mode 100644 tests/spec/glsl-1.50/execution/interface-blocks-api-access-members.c

diff --git a/tests/all.tests b/tests/all.tests
index 2d6a52e..e5a590c 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -950,6 +950,7 @@ import_glsl_parser_tests(spec['glsl-1.50'],
 add_shader_test_dir(spec['glsl-1.50'],
 		    os.path.join(testsDir, 'spec', 'glsl-1.50'),
 		    recursive=True)
+spec['glsl-1.50']['execution']['interface-blocks-api-access-members'] = concurrent_test('glsl-1.50-interface-blocks-api-access-members')
 spec['glsl-1.50']['execution']['get-active-attrib-array'] = concurrent_test('glsl-1.50-get-active-attrib-array')
 spec['glsl-1.50']['execution']['vs-input-arrays'] = concurrent_test('glsl-1.50-vs-input-arrays')
 for draw in ['', 'indexed']:
diff --git a/tests/spec/glsl-1.50/execution/CMakeLists.gl.txt b/tests/spec/glsl-1.50/execution/CMakeLists.gl.txt
index 67a5e00..b1bf6e5 100644
--- a/tests/spec/glsl-1.50/execution/CMakeLists.gl.txt
+++ b/tests/spec/glsl-1.50/execution/CMakeLists.gl.txt
@@ -12,3 +12,4 @@ ${OPENGL_glu_LIBRARY}
 
 piglit_add_executable (glsl-1.50-vs-input-arrays vs-input-arrays.c)
 piglit_add_executable (glsl-1.50-get-active-attrib-array get-active-attrib-array.c)
+piglit_add_executable (glsl-1.50-interface-blocks-api-access-members interface-blocks-api-access-members.c)
diff --git a/tests/spec/glsl-1.50/execution/interface-blocks-api-access-members.c b/tests/spec/glsl-1.50/execution/interface-blocks-api-access-members.c
new file mode 100644
index 0000000..af48dfa
--- /dev/null
+++ b/tests/spec/glsl-1.50/execution/interface-blocks-api-access-members.c
@@ -0,0 +1,141 @@
+/**
+ * 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 the syntax for accessing interface block members through the API
+ *
+ * From the GLSL 1.50 core spec, section 4.3.7 (Interface Blocks):
+ * "Outside the shading language (i.e., in the API), members are similarly
+ *  identified except the block name is always used in place of the instance
+ *  name (API accesses are to interfaces, not to shaders). If there is no
+ *  instance name, then the API does not use the block name to access a member,
+ *  just the member name."
+ *
+ * "For blocks declared as arrays, the array index must also be included when
+ *  accessing members"
+ */
+
+#include "piglit-util-gl-common.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_compat_version = 32;
+	config.supports_gl_core_version = 32;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+static const char *vstext =
+	"#version 150\n"
+	"in vec4 vertex;\n"
+	"void main()\n"
+	"{\n"
+	"	gl_Position = vertex;\n"
+	"}\n";
+
+static const char *gstext =
+	"#version 150\n"
+	"layout(points) in;\n"
+	"layout(points, max_vertices = 3) out;\n"
+	"out NoInst {\n"
+	"	float a;\n"
+	"	vec3 b;\n"
+	"};\n"
+	"out WithInst {\n"
+	"	float c;\n"
+	"	vec3 d;\n"
+	"} inst;\n"
+	"out WithInstArray {\n"
+	"	float e;\n"
+	"	vec3 f;\n"
+	"} instArray[3];\n"
+	"void main()\n"
+	"{\n"
+	"	a = 1.0;\n"
+	"	b = vec3(2.0);\n"
+	"	inst.c = 3.0;\n"
+	"	inst.d = vec3(4.0);\n"
+	"	for(int i = 0; i < 3; i++) {\n"
+	"		instArray[i].e = 5.0 + 2 * i;\n"
+	"		instArray[i].f = vec3(6.0 + 2 * i);\n"
+	"	}\n"
+	"}\n";
+
+static GLuint prog;
+
+static const char *varyings[] = { "a", "b",
+				  //should not accept just "c", "d"
+				  "WithInst.c", "WithInst.d",
+				  //should not accept just "e", "f",
+				  "WithInstArray[0].e", "WithInstArray[0].f",
+				  "WithInstArray[1].e", "WithInstArray[1].f",
+				  "WithInstArray[2].e", "WithInstArray[2].f"
+				};
+
+void
+piglit_init(int argc, char **argv)
+{
+	bool pass = true;
+	GLuint vs = 0, gs = 0;
+	int i;
+
+	prog = glCreateProgram();
+	vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vstext);
+	gs = piglit_compile_shader_text(GL_GEOMETRY_SHADER, gstext);
+	glAttachShader(prog, vs);
+	glAttachShader(prog, gs);
+	glTransformFeedbackVaryings(prog, ARRAY_SIZE(varyings), varyings,
+					GL_INTERLEAVED_ATTRIBS);
+	glLinkProgram(prog);
+	if(!piglit_link_check_status(prog)){
+		glDeleteProgram(prog);
+		piglit_report_result(PIGLIT_FAIL);
+	}
+
+	glUseProgram(prog);
+
+	for(i = 0; i < 8; i++) {
+		char varName[50];
+		GLsizei nameLength = 0, varSize = 0;
+		GLenum varType = GL_NONE;
+		glGetTransformFeedbackVarying(  prog,
+						i,
+						sizeof(varName),
+						&nameLength,
+						&varSize,
+						&varType,
+						varName);
+		printf("Name: %s\t\tType: %s\n",
+			varName, piglit_get_gl_enum_name(varType));
+	}
+
+	pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
+
+	piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
+}
+
+enum piglit_result
+piglit_display(void)
+{
+	/* DIES IN A FIRE */
+	return PIGLIT_FAIL;
+}
-- 
1.8.3.1



More information about the Piglit mailing list