[Piglit] [PATCH v2 4/4] arb_gpu_shader5: Add new test emitstreamvertex_nodraw

Samuel Iglesias Gonsalvez siglesias at igalia.com
Thu Jun 26 23:20:39 PDT 2014


It checks that a vertex emitted in stream !=0 is not
processed by the fragment shader.

Signed-off-by: Samuel Iglesias Gonsalvez <siglesias at igalia.com>
---
 tests/all.py                                       |   1 +
 .../arb_gpu_shader5/execution/CMakeLists.gl.txt    |   1 +
 .../execution/emitstreamvertex_nodraw.c            | 170 +++++++++++++++++++++
 3 files changed, 172 insertions(+)
 create mode 100644 tests/spec/arb_gpu_shader5/execution/emitstreamvertex_nodraw.c

diff --git a/tests/all.py b/tests/all.py
index 8667fa4..4b0caf0 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -1702,6 +1702,7 @@ add_concurrent_test(arb_gpu_shader5, 'arb_gpu_shader5-stream_value_too_large')
 add_concurrent_test(arb_gpu_shader5, 'arb_gpu_shader5-emitstreamvertex_stream_too_large')
 add_concurrent_test(arb_gpu_shader5, 'arb_gpu_shader5-tf-wrong-stream-value')
 add_concurrent_test(arb_gpu_shader5, 'arb_gpu_shader5-xfb-streams-without-invocations')
+add_concurrent_test(arb_gpu_shader5, 'arb_gpu_shader5-emitstreamvertex_nodraw')
 
 arb_texture_query_levels = {}
 spec['ARB_texture_query_levels'] = arb_texture_query_levels
diff --git a/tests/spec/arb_gpu_shader5/execution/CMakeLists.gl.txt b/tests/spec/arb_gpu_shader5/execution/CMakeLists.gl.txt
index fcd271f..0b743d9 100644
--- a/tests/spec/arb_gpu_shader5/execution/CMakeLists.gl.txt
+++ b/tests/spec/arb_gpu_shader5/execution/CMakeLists.gl.txt
@@ -12,3 +12,4 @@ link_libraries (
 piglit_add_executable (arb_gpu_shader5-invocation-id invocation-id.c)
 piglit_add_executable (arb_gpu_shader5-xfb-streams xfb-streams.c)
 piglit_add_executable (arb_gpu_shader5-xfb-streams-without-invocations xfb-streams-without-invocations.c)
+piglit_add_executable (arb_gpu_shader5-emitstreamvertex_nodraw emitstreamvertex_nodraw.c)
diff --git a/tests/spec/arb_gpu_shader5/execution/emitstreamvertex_nodraw.c b/tests/spec/arb_gpu_shader5/execution/emitstreamvertex_nodraw.c
new file mode 100644
index 0000000..777cdc3
--- /dev/null
+++ b/tests/spec/arb_gpu_shader5/execution/emitstreamvertex_nodraw.c
@@ -0,0 +1,170 @@
+/*
+ * Copyright (c) 2014 Igalia S.L.
+ *
+ * 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 emitstreamvertex_no_draw.c
+ *
+ * Test that a vertex emitted in stream 1 is not processed by fragment
+ * shader.
+ */
+
+#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_DOUBLE | PIGLIT_GL_VISUAL_RGB;
+	config.window_width = 100;
+	config.window_height = 100;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+GLuint vertexbuffer;
+GLint program;
+
+static const GLfloat g_vertex_buffer_data[] = {
+		-0.5f, -0.5f, 0.0f,
+		0.5f, -0.5f, 0.0f,
+		0.0f,  0.50f, 0.0f,
+};
+
+enum piglit_result
+piglit_display(void)
+{
+	int pass;
+	float c[3] = {1.0, 0.0 , 0.0};
+	float c_clear[3] = {0.0, 0.0 , 0.0};
+
+	glUseProgram(program);
+
+	/*
+	 * Workaround: if define glPointSize == 1, piglit_probe_pixel_rgb()
+	 * will fail unless the window is resized.
+	 */
+	glPointSize(2);
+
+	glViewport(0, 0, piglit_width, piglit_height);
+	/* Clear the back buffer to black */
+	glClearColor(0, 0, 0, 0);
+	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+	glEnableVertexAttribArray(0);
+	glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
+	glVertexAttribPointer(
+			0,
+			3,
+			GL_FLOAT,
+			GL_FALSE,
+			0,
+			(void*)0);
+
+	glDrawArrays(GL_POINTS, 0, 3);
+	glDisableVertexAttribArray(0);
+
+	/* Probe that the point in stream=1 is not drawn. */
+	pass = piglit_probe_pixel_rgb(piglit_width/2, piglit_height/2, c_clear);
+	/* Probe that the rest of points are actually drawn. */
+	pass &= piglit_probe_pixel_rgb(piglit_width*1/4, piglit_height/4, c);
+	pass &= piglit_probe_pixel_rgb(piglit_width*3/4, piglit_height*1/4, c);
+	pass &= piglit_probe_pixel_rgb(piglit_width/2, piglit_height*3/4, c);
+	piglit_present_results();
+
+	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+static const char *vs_source =
+	"#version 330\n"
+	"\n"
+	"layout(location=0) in vec3 inVertexPosition;\n"
+	"\n"
+	"void main()\n"
+	"{\n"
+	"   gl_Position = vec4(inVertexPosition, 1);\n"
+	"}\n";
+
+static const char *gs_source =
+	"#version 330\n"
+	"#extension GL_ARB_gpu_shader5: enable\n"
+	"\n"
+	"layout(points) in;\n"
+	"layout(points, stream=0, max_vertices=2) out;\n"
+	"void main()\n"
+	"{\n"
+	"    gl_Position = gl_in[0].gl_Position;\n"
+	"    EmitVertex();\n"
+	"    EndPrimitive();\n"
+	"\n"
+        "    gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n"
+	"    EmitStreamVertex(1);\n"
+	"    EndStreamPrimitive(1);\n"
+	"}\n";
+
+static const char *fs_source =
+	"#version 330\n"
+	"out vec3 color;\n"
+	"void main()\n"
+	"{\n"
+	"	    color = vec3(1.0, 0.0, 0.0);\n"
+	"}\n";
+
+void
+piglit_init(int argc, char **argv)
+{
+	GLint max_streams;
+	GLint vs, fs, gs;
+	GLuint VertexArrayID;
+
+	piglit_require_GLSL_version(150);
+	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);
+	vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_source);
+	gs = piglit_compile_shader_text(GL_GEOMETRY_SHADER, gs_source);
+	fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fs_source);
+
+	program = glCreateProgram();
+	glAttachShader(program, vs);
+	glAttachShader(program, gs);
+	glAttachShader(program, fs);
+	glLinkProgram(program);
+
+	if (!piglit_link_check_status(program)) {
+		piglit_report_result(PIGLIT_FAIL);
+		return;
+	}
+
+	glGenVertexArrays(1, &VertexArrayID);
+	glBindVertexArray(VertexArrayID);
+
+	glGenBuffers(1, &vertexbuffer);
+	glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
+	glBufferData(GL_ARRAY_BUFFER, sizeof(g_vertex_buffer_data), g_vertex_buffer_data, GL_STATIC_DRAW);
+}
-- 
2.0.0



More information about the Piglit mailing list