[Piglit] [PATCH v3 1/5] arb_gpu_shader5: add some compiler tests for stream qualifier

Samuel Iglesias Gonsalvez siglesias at igalia.com
Wed Aug 20 07:30:33 PDT 2014


Signed-off-by: Samuel Iglesias Gonsalvez <siglesias at igalia.com>
---
 tests/all.py                                       |   1 +
 tests/spec/arb_gpu_shader5/compiler/CMakeLists.txt |   3 +-
 .../compiler/stream-qualifier/CMakeLists.gl.txt    |  12 ++
 .../compiler/stream-qualifier/CMakeLists.txt       |   1 +
 .../correct-multiple-layout-qualifier-stream.geom  |  40 +++++
 .../incorrect-in-layout-qualifier-stream.geom      |  19 ++
 ...ect-multiple-block-layout-qualifier-stream.geom |  32 ++++
 ...incorrect-negative-layout-qualifier-stream.geom |  24 +++
 .../stream-qualifier/stream_value_too_large.c      | 192 +++++++++++++++++++++
 9 files changed, 323 insertions(+), 1 deletion(-)
 create mode 100644 tests/spec/arb_gpu_shader5/compiler/stream-qualifier/CMakeLists.gl.txt
 create mode 100644 tests/spec/arb_gpu_shader5/compiler/stream-qualifier/CMakeLists.txt
 create mode 100644 tests/spec/arb_gpu_shader5/compiler/stream-qualifier/correct-multiple-layout-qualifier-stream.geom
 create mode 100644 tests/spec/arb_gpu_shader5/compiler/stream-qualifier/incorrect-in-layout-qualifier-stream.geom
 create mode 100644 tests/spec/arb_gpu_shader5/compiler/stream-qualifier/incorrect-multiple-block-layout-qualifier-stream.geom
 create mode 100644 tests/spec/arb_gpu_shader5/compiler/stream-qualifier/incorrect-negative-layout-qualifier-stream.geom
 create mode 100644 tests/spec/arb_gpu_shader5/compiler/stream-qualifier/stream_value_too_large.c

diff --git a/tests/all.py b/tests/all.py
index 33b1e28..69cedd5 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -1869,6 +1869,7 @@ add_concurrent_test(arb_gpu_shader5, 'arb_gpu_shader5-minmax')
 add_concurrent_test(arb_gpu_shader5, 'arb_gpu_shader5-invocation-id')
 add_concurrent_test(arb_gpu_shader5, 'arb_gpu_shader5-invocations_count_too_large')
 add_concurrent_test(arb_gpu_shader5, 'arb_gpu_shader5-xfb-streams')
+add_concurrent_test(arb_gpu_shader5, 'arb_gpu_shader5-stream_value_too_large')
 
 arb_shader_subroutine = {}
 spec['ARB_shader_subroutine'] = arb_shader_subroutine
diff --git a/tests/spec/arb_gpu_shader5/compiler/CMakeLists.txt b/tests/spec/arb_gpu_shader5/compiler/CMakeLists.txt
index 4a012b9..ec80122 100644
--- a/tests/spec/arb_gpu_shader5/compiler/CMakeLists.txt
+++ b/tests/spec/arb_gpu_shader5/compiler/CMakeLists.txt
@@ -1 +1,2 @@
-piglit_include_target_api()
\ No newline at end of file
+add_subdirectory (stream-qualifier)
+piglit_include_target_api()
diff --git a/tests/spec/arb_gpu_shader5/compiler/stream-qualifier/CMakeLists.gl.txt b/tests/spec/arb_gpu_shader5/compiler/stream-qualifier/CMakeLists.gl.txt
new file mode 100644
index 0000000..11b3110
--- /dev/null
+++ b/tests/spec/arb_gpu_shader5/compiler/stream-qualifier/CMakeLists.gl.txt
@@ -0,0 +1,12 @@
+include_directories(
+	${GLEXT_INCLUDE_DIR}
+	${OPENGL_INCLUDE_PATH}
+)
+
+link_libraries (
+	piglitutil_${piglit_target_api}
+	${OPENGL_gl_LIBRARY}
+	${OPENGL_glu_LIBRARY}
+)
+
+piglit_add_executable (arb_gpu_shader5-stream_value_too_large stream_value_too_large.c)
diff --git a/tests/spec/arb_gpu_shader5/compiler/stream-qualifier/CMakeLists.txt b/tests/spec/arb_gpu_shader5/compiler/stream-qualifier/CMakeLists.txt
new file mode 100644
index 0000000..144a306
--- /dev/null
+++ b/tests/spec/arb_gpu_shader5/compiler/stream-qualifier/CMakeLists.txt
@@ -0,0 +1 @@
+piglit_include_target_api()
diff --git a/tests/spec/arb_gpu_shader5/compiler/stream-qualifier/correct-multiple-layout-qualifier-stream.geom b/tests/spec/arb_gpu_shader5/compiler/stream-qualifier/correct-multiple-layout-qualifier-stream.geom
new file mode 100644
index 0000000..46c0644
--- /dev/null
+++ b/tests/spec/arb_gpu_shader5/compiler/stream-qualifier/correct-multiple-layout-qualifier-stream.geom
@@ -0,0 +1,40 @@
+// [config]
+// expect_result: pass
+// glsl_version: 1.50
+// require_extensions: GL_ARB_gpu_shader5
+// check_link: false
+// [end config]
+//
+// ARB_gpu_shader5 spec says:
+//   "A default stream number may be declared at global
+//    scope by qualifying interface qualifier out as in this example:
+//
+//          layout(stream = 1) out;
+//
+//    The stream number specified in such a declaration replaces any previous
+//    default and applies to all subsequent block and variable declarations
+//    until a new default is established.  The initial default stream number is
+//    zero."
+//
+// Tests for multiple declarations of layout qualifier 'stream'.
+//
+
+#version 150
+#extension GL_ARB_gpu_shader5 : enable
+
+layout(points) in;
+layout(points) out;
+
+out vec4 var1;
+layout(stream=1) out;
+out vec4 var2;
+layout(stream=2) out vec3 var3;
+
+layout(stream=3) out Block1 {
+	float var4;
+	layout(stream=3) vec4 var5;
+};
+
+void main()
+{
+}
diff --git a/tests/spec/arb_gpu_shader5/compiler/stream-qualifier/incorrect-in-layout-qualifier-stream.geom b/tests/spec/arb_gpu_shader5/compiler/stream-qualifier/incorrect-in-layout-qualifier-stream.geom
new file mode 100644
index 0000000..5907639
--- /dev/null
+++ b/tests/spec/arb_gpu_shader5/compiler/stream-qualifier/incorrect-in-layout-qualifier-stream.geom
@@ -0,0 +1,19 @@
+// [config]
+// expect_result: fail
+// glsl_version: 1.50
+// require_extensions: GL_ARB_gpu_shader5
+// check_link: false
+// [end config]
+//
+// Tests for invalid input layout qualifiers.
+//
+
+#version 150
+#extension GL_ARB_gpu_shader5 : enable
+
+layout(points, stream=1) in;
+layout(triangle_strip, max_vertices=3) out;
+
+void main()
+{
+}
diff --git a/tests/spec/arb_gpu_shader5/compiler/stream-qualifier/incorrect-multiple-block-layout-qualifier-stream.geom b/tests/spec/arb_gpu_shader5/compiler/stream-qualifier/incorrect-multiple-block-layout-qualifier-stream.geom
new file mode 100644
index 0000000..6cf554d
--- /dev/null
+++ b/tests/spec/arb_gpu_shader5/compiler/stream-qualifier/incorrect-multiple-block-layout-qualifier-stream.geom
@@ -0,0 +1,32 @@
+// [config]
+// expect_result: fail
+// glsl_version: 1.50
+// require_extensions: GL_ARB_gpu_shader5
+// check_link: false
+// [end config]
+//
+// ARB_gpu_shader5 spec says:
+//   "A block member may be declared with a stream
+//    qualifier, but the specified stream must match the stream
+//    associated with the containing block."
+//
+// Tests for multiple declarations of layout qualifier 'stream' for
+// block's fields.
+//
+
+#version 150
+#extension GL_ARB_gpu_shader5 : enable
+
+layout(points) in;
+layout(triangle_strip, max_vertices=3) out;
+
+out Block1 { // By default, it uses stream = 0
+	layout(stream=1) vec4 var1; // Wrong: different than block's stream value
+	layout(stream=5) vec4 var2; // Wrong: different than block's stream value
+	layout(stream=0) vec4 var3; // Valid
+	vec4 var4; // Valid
+};
+
+void main()
+{
+}
diff --git a/tests/spec/arb_gpu_shader5/compiler/stream-qualifier/incorrect-negative-layout-qualifier-stream.geom b/tests/spec/arb_gpu_shader5/compiler/stream-qualifier/incorrect-negative-layout-qualifier-stream.geom
new file mode 100644
index 0000000..6b873b0
--- /dev/null
+++ b/tests/spec/arb_gpu_shader5/compiler/stream-qualifier/incorrect-negative-layout-qualifier-stream.geom
@@ -0,0 +1,24 @@
+// [config]
+// expect_result: fail
+// glsl_version: 1.50
+// require_extensions: GL_ARB_gpu_shader5
+// check_link: false
+// [end config]
+//
+// Test to detect negative value of layout qualifier 'stream'
+//
+// From ARB_gpu_shader5 spec:
+//
+// "If an implementation supports <N> vertex streams, the
+//     individual streams are numbered 0 through <N>-1"
+//
+
+#version 150
+#extension GL_ARB_gpu_shader5 : enable
+
+layout(points) in;
+layout(points, stream=-2, max_vertices=3) out;
+
+void main()
+{
+}
diff --git a/tests/spec/arb_gpu_shader5/compiler/stream-qualifier/stream_value_too_large.c b/tests/spec/arb_gpu_shader5/compiler/stream-qualifier/stream_value_too_large.c
new file mode 100644
index 0000000..32d3bd3
--- /dev/null
+++ b/tests/spec/arb_gpu_shader5/compiler/stream-qualifier/stream_value_too_large.c
@@ -0,0 +1,192 @@
+/*
+ * Copyright (c) 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 stream_value_too_large.c
+ *
+ * Test that exceeding the implementation's maximum streams
+ * value (GL_MAX_VERTEX_STREAMS) results in a compile
+ * error.
+ *
+ * From the ARB_gpu_shader5 specification:
+ *
+ * "If an implementation supports <N> vertex streams, the
+ *  individual streams are numbered 0 through <N>-1"
+ *
+ */
+
+#include "piglit-util-gl.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_compat_version = 32;
+	config.supports_gl_core_version = 32;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+enum piglit_result
+piglit_display(void)
+{
+	/* UNREACHED */
+	return PIGLIT_FAIL;
+}
+
+GLint vs;
+GLint fs;
+
+static const char *vs_source =
+	"#version 150\n"
+	"\n"
+	"void main()\n"
+	"{\n"
+	"gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n"
+	"}\n";
+
+static const char *gs_template =
+	"#version 150\n"
+	"#extension GL_ARB_gpu_shader5: enable\n"
+	"\n"
+	"layout(points) in;\n"
+	"layout(points, stream = %d, max_vertices=1) out;\n"
+	"\n"
+	"void main()\n"
+	"{\n"
+	"gl_Position = vec4(1.0, 1.0, 1.0, 1.0);\n"
+	"EmitStreamVertex(0);\n"
+	"EndStreamPrimitive(0);\n"
+	"}\n";
+
+static const char *fs_source =
+	"#version 150\n"
+	"out vec3 color;\n"
+	"\n"
+	"void main()\n"
+	"{\n"
+	"color = vec3(0.0, 0.0, 0.0);\n"
+	"}\n";
+
+static GLint
+compile_shaders(GLint size, bool expect_ok, GLint *ok)
+{
+
+	char *shader_text;
+	GLint shader;
+
+	printf("Stream count of %d should %s: ", size,
+	       expect_ok ? "compile successfully" :
+	       "produce a compile error");
+
+	asprintf(&shader_text, gs_template, size);
+	shader = glCreateShader(GL_GEOMETRY_SHADER);
+	glShaderSource(shader, 1, (const GLchar **) &shader_text, NULL);
+	glCompileShader(shader);
+	glGetShaderiv(shader, GL_COMPILE_STATUS, ok);
+	if (!piglit_check_gl_error(GL_NO_ERROR)) {
+		/* Details of the error have already been printed. */
+		printf("GL Error occurred.\n");
+	}
+
+	if (*ok)
+		printf("Successful compile.\n");
+	else
+		printf("Compile error.\n");
+	return shader;
+}
+
+static bool
+test_streams_size(GLint size, bool expect_compile_ok, bool expect_link_ok)
+{
+	GLint program;
+	GLint ok;
+	GLint gs;
+
+	gs = compile_shaders(size, expect_compile_ok, &ok);
+	if (!ok)
+		return ok == expect_compile_ok;
+
+	/* Check if test was compiled but a compilation error was expected */
+	if (ok != expect_compile_ok)
+		return false;
+
+	printf("Stream count of %d should %s: ", size,
+	       expect_link_ok ? "link successfully" : "produce a link error");
+
+	program = glCreateProgram();
+	glAttachShader(program, vs);
+	glAttachShader(program, gs);
+	glAttachShader(program, fs);
+	glLinkProgram(program);
+	glGetProgramiv(program, GL_LINK_STATUS, &ok);
+
+	if (!piglit_link_check_status(program)) {
+		/* Details of the error have already been printed. */
+		printf("Link error occurred.\n");
+	}
+
+	if (ok)
+		printf("Successful link.\n");
+	else
+		printf("Link error.\n");
+
+	glDetachShader(program, fs);
+	glDetachShader(program, gs);
+	glDetachShader(program, vs);
+	glDeleteProgram(program);
+	glDeleteShader(gs);
+	return ok == expect_link_ok;
+}
+
+
+void
+piglit_init(int argc, char **argv)
+{
+	GLint max_streams;
+	int i;
+	bool pass = true;
+
+	piglit_require_extension("GL_ARB_gpu_shader5");
+
+	glGetIntegerv(GL_MAX_VERTEX_STREAMS, &max_streams);
+
+	if (!piglit_check_gl_error(GL_NO_ERROR))
+		piglit_report_result(PIGLIT_FAIL);
+
+	vs = glCreateShader(GL_VERTEX_SHADER);
+	glShaderSource(vs, 1, (const GLchar **) &vs_source, NULL);
+	glCompileShader(vs);
+	fs = glCreateShader(GL_FRAGMENT_SHADER);
+	glShaderSource(fs, 1, (const GLchar **) &fs_source, NULL);
+	glCompileShader(fs);
+
+	for (i = 0; i < max_streams; i++) {
+		/* Test that this value is allowed. */
+		pass = test_streams_size(i, true, true) && pass;
+	}
+
+	/* Test max multiple vertex stream value */
+	pass = test_streams_size(i, false, false) && pass;
+
+	glDeleteShader(vs);
+	glDeleteShader(fs);
+	piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
+}
-- 
2.1.0.rc1



More information about the Piglit mailing list