[Piglit] [PATCH] GL 1.50: Test that UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER is accepted by GetActiveUniformBlockiv()

Nicholas Mack nichmack at gmail.com
Wed Aug 28 10:56:59 PDT 2013


---
 tests/spec/glsl-1.50/CMakeLists.gl.txt             |  13 +++
 tests/spec/glsl-1.50/CMakeLists.txt                |   1 +
 .../query-uniform-block-referenced-by-gs.c         | 124 +++++++++++++++++++++
 3 files changed, 138 insertions(+)
 create mode 100644 tests/spec/glsl-1.50/CMakeLists.gl.txt
 create mode 100644 tests/spec/glsl-1.50/query-uniform-block-referenced-by-gs.c

diff --git a/tests/spec/glsl-1.50/CMakeLists.gl.txt b/tests/spec/glsl-1.50/CMakeLists.gl.txt
new file mode 100644
index 0000000..aad78f6
--- /dev/null
+++ b/tests/spec/glsl-1.50/CMakeLists.gl.txt
@@ -0,0 +1,13 @@
+include_directories(
+	${GLEXT_INCLUDE_DIR}
+	${OPENGL_INCLUDE_PATH}
+)
+
+link_libraries (
+	piglitutil_${piglit_target_api}
+	${OPENGL_gl_LIBRARY}
+	${OPENGL_glu_LIBRARY}
+)
+
+piglit_add_executable (query-uniform-block-referenced-by-gs
+			query-uniform-block-referenced-by-gs.c)
diff --git a/tests/spec/glsl-1.50/CMakeLists.txt b/tests/spec/glsl-1.50/CMakeLists.txt
index bb76f08..e4126fc 100644
--- a/tests/spec/glsl-1.50/CMakeLists.txt
+++ b/tests/spec/glsl-1.50/CMakeLists.txt
@@ -1 +1,2 @@
 add_subdirectory (execution)
+piglit_include_target_api()
diff --git a/tests/spec/glsl-1.50/query-uniform-block-referenced-by-gs.c b/tests/spec/glsl-1.50/query-uniform-block-referenced-by-gs.c
new file mode 100644
index 0000000..76bbd15
--- /dev/null
+++ b/tests/spec/glsl-1.50/query-uniform-block-referenced-by-gs.c
@@ -0,0 +1,124 @@
+/**
+ * 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 UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER is accepted by
+ * GetActiveUniformBlockiv()
+ *
+ * Section 2.11.4(Uniform Variables) of OpenGL 3.2 Core says:
+ * "Information about an active uniform block can be queried by calling
+ *	void GetActiveUniformBlockiv( uint program,
+ *				      uint uniformBlockIndex,
+ *				      enum pname, int *params );
+ *  If pname is UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER,
+ *  UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER, or
+ *  UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER, then a boolean value indicating
+ *  whether the uniform block identified by uniformBlockIndex is referenced by
+ *  the vertex, geometry, or fragment programming stages of program,
+ *  respectively, is returned."
+ *
+ */
+
+#include "piglit-util-gl-common.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_compat_version = 32;
+        config.supports_gl_core_version = 32;
+
+	config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+static const char *vstext =
+	"#version 150\n"
+	"in vec3 vert1;\n"
+	"out vec3 vert;\n"
+	"void main() {\n"
+	"	gl_Position = vec4(vert1, 1.);\n"
+	"	vert = vert1;\n"
+	"}\n";
+
+static const char *gstext =
+	"#version 150\n"
+	"layout(triangles) in;\n"
+	"layout(triangles, max_vertices=3) out;\n"
+	"in vec3 vert[];\n"
+	"uniform block {\n"
+	"	vec4 a;\n"
+	"	float b;\n"
+	"	vec2 c;\n"
+	"} uBlock;\n"
+	"void main() {\n"
+	"	uBlock.a = vec4(2.);\n"
+	"	uBlock.b = 3.3;\n"
+	"	uBlock.c = vec2(1., .5);\n"
+	"	for(int i = 0; i < 3; i++) {\n"
+	"		gl_Position = vec4(vert[i], 1.);\n"
+	"		EmitVertex();\n"
+	"	}\n"
+	"}\n";
+
+static const char *fstext =
+	"#version 150\n"
+	"void main() {\n"
+	"	gl_FragColor = vec4(1.);\n"
+	"}\n";
+
+static GLuint prog;
+
+void
+piglit_init(int argc, char **argv)
+{
+	bool pass = true;
+	GLuint vs = 0, gs = 0, fs = 0;
+	GLint param = 0;
+
+	prog = glCreateProgram();
+	vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vstext);
+	gs = piglit_compile_shader_text(GL_GEOMETRY_SHADER, gstext);
+	fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fstext);
+	glAttachShader(prog, vs);
+	glAttachShader(prog, gs);
+	glAttachShader(prog, fs);
+	glLinkProgram(prog);
+	if(!piglit_link_check_status(prog)){
+		glDeleteProgram(prog);
+		piglit_report_result(PIGLIT_FAIL);
+	}
+
+	/* test GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER */
+	glGetActiveUniformBlockiv(prog, 0,
+				GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER,
+				&param);
+	if(param == 0) 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)
+{
+	return PIGLIT_FAIL;
+}
-- 
1.8.3.1



More information about the Piglit mailing list