[Piglit] [PATCH] arb_gpu_shader_fp64: Add tests to check float to double conversion under non-uniform control flow

Samuel Iglesias Gonsálvez siglesias at igalia.com
Thu Oct 13 09:45:17 UTC 2016


We found issues with this case while developing i965's Ivybridge patches
to support arb_gpu_shader_fp64.

Signed-off-by: Samuel Iglesias Gonsálvez <siglesias at igalia.com>
---
 tests/all.py                                       |   2 +
 tests/spec/arb_gpu_shader_fp64/CMakeLists.gl.txt   |   2 +
 .../fs-non-uniform-control-flow-f2d.c              | 135 +++++++++++++++++
 .../vs-non-uniform-control-flow-f2d.c              | 166 +++++++++++++++++++++
 4 files changed, 305 insertions(+)
 create mode 100644 tests/spec/arb_gpu_shader_fp64/fs-non-uniform-control-flow-f2d.c
 create mode 100644 tests/spec/arb_gpu_shader_fp64/vs-non-uniform-control-flow-f2d.c

diff --git a/tests/all.py b/tests/all.py
index 6d5826c..fec7137 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -2211,6 +2211,8 @@ with profile.group_manager(
     g(['arb_gpu_shader_fp64-fs-non-uniform-control-flow-alu'])
     g(['arb_gpu_shader_fp64-vs-non-uniform-control-flow-packing'])
     g(['arb_gpu_shader_fp64-fs-non-uniform-control-flow-packing'])
+    g(['arb_gpu_shader_fp64-vs-non-uniform-control-flow-f2d'])
+    g(['arb_gpu_shader_fp64-fs-non-uniform-control-flow-f2d'])
 
 with profile.group_manager(
         PiglitGLTest,
diff --git a/tests/spec/arb_gpu_shader_fp64/CMakeLists.gl.txt b/tests/spec/arb_gpu_shader_fp64/CMakeLists.gl.txt
index 209442f..d9f5dd5 100644
--- a/tests/spec/arb_gpu_shader_fp64/CMakeLists.gl.txt
+++ b/tests/spec/arb_gpu_shader_fp64/CMakeLists.gl.txt
@@ -19,3 +19,5 @@ piglit_add_executable (arb_gpu_shader_fp64-fs-non-uniform-control-flow-alu fs-no
 piglit_add_executable (arb_gpu_shader_fp64-vs-non-uniform-control-flow-alu vs-non-uniform-control-flow-alu.c)
 piglit_add_executable (arb_gpu_shader_fp64-fs-non-uniform-control-flow-packing fs-non-uniform-control-flow-packing.c)
 piglit_add_executable (arb_gpu_shader_fp64-vs-non-uniform-control-flow-packing vs-non-uniform-control-flow-packing.c)
+piglit_add_executable (arb_gpu_shader_fp64-fs-non-uniform-control-flow-f2d fs-non-uniform-control-flow-f2d.c)
+piglit_add_executable (arb_gpu_shader_fp64-vs-non-uniform-control-flow-f2d vs-non-uniform-control-flow-f2d.c)
diff --git a/tests/spec/arb_gpu_shader_fp64/fs-non-uniform-control-flow-f2d.c b/tests/spec/arb_gpu_shader_fp64/fs-non-uniform-control-flow-f2d.c
new file mode 100644
index 0000000..b701dd0
--- /dev/null
+++ b/tests/spec/arb_gpu_shader_fp64/fs-non-uniform-control-flow-f2d.c
@@ -0,0 +1,135 @@
+/*
+ * Copyright © 2016 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 fs-non-uniform-control-flow-f2d.c
+ *
+ * It checks that a float to double conversion works correctly when it is
+ * under non-uniform control flow.
+ */
+
+#include "piglit-util-gl.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+	config.window_width = 62;
+	config.window_height = 62;
+	config.supports_gl_compat_version = 32;
+	config.supports_gl_core_version = 32;
+	config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
+PIGLIT_GL_TEST_CONFIG_END
+
+static const char vs_pass_thru_text[] =
+	"#version 130\n"
+	"\n"
+	"in vec4 piglit_vertex;\n"
+	"void main() {\n"
+	"        gl_Position = piglit_vertex;\n"
+	"}\n";
+
+static const char fs_source[] =
+	"#version 330\n"
+	"#extension GL_ARB_gpu_shader_fp64 : require\n"
+	"\n"
+	"out vec4 color;\n"
+	"\n"
+	"void main() {\n"
+	"        int cx = int(gl_FragCoord.x) / 31;\n"
+	"        int cy = int(gl_FragCoord.y) / 31;\n"
+	"        dvec2 rg; \n"
+	"        vec2 value;\n"
+	"        if ((cx + cy) % 2 == 0)\n"
+	"                value = vec2(1.0f, 0.0f);\n"
+	"        else\n"
+	"                value = vec2(0.0f, 1.0f);\n"
+	"        rg = dvec2(value); \n"
+	"        if (rg == dvec2(0, 1))\n"
+	"            color = vec4(0, 0, 1, 1);\n"
+	"        else\n"
+	"            color = vec4(rg, 0, 1);\n"
+	"}\n";
+
+GLuint prog, fbo;
+
+void
+piglit_init(int argc, char **argv)
+{
+	GLuint buffer;
+
+	piglit_require_GLSL_version(330);
+	piglit_require_extension("GL_ARB_gpu_shader_fp64");
+
+	prog = piglit_build_simple_program(vs_pass_thru_text, fs_source);
+
+	glUseProgram(prog);
+
+	glClearColor(0, 0, 0, 1);
+
+	if (!piglit_check_gl_error(GL_NO_ERROR))
+		piglit_report_result(PIGLIT_FAIL);
+}
+
+enum piglit_result piglit_display(void)
+{
+	bool pass = true;
+	const int num_pixels = piglit_width * piglit_height;
+	float *srcPixels = malloc(num_pixels * 4 * sizeof(float));
+	float expected[4];
+	int i, j;
+
+	glViewport(0, 0, piglit_width, piglit_height);
+	glUseProgram(prog);
+	glClear(GL_COLOR_BUFFER_BIT);
+
+	piglit_draw_rect(-1, -1, 2, 2);
+
+	glReadPixels(0, 0, piglit_width, piglit_height,
+		     GL_RGBA, GL_FLOAT, srcPixels);
+
+	/* Verify */
+	for (i = 0; i < piglit_height; i++) {
+		for (j = 0; j < piglit_width; j++) {
+			int cx = j / 31;
+			int cy = i / 31;
+			int pos = (i * piglit_width + j) * 4;
+			if ((cx + cy) % 2 != 0) {
+				expected[0] = 0.0;
+				expected[1] = 0.0;
+				expected[2] = 1.0;
+				expected[3] = 1.0;
+			} else {
+				expected[0] = 1.0;
+				expected[1] = 0.0;
+				expected[2] = 0.0;
+				expected[3] = 1.0;
+			}
+
+			pass = piglit_compare_pixels(j, i, expected,
+						     srcPixels + pos,
+						     piglit_tolerance,
+						     4) && pass;
+		}
+	}
+	piglit_present_results();
+	free(srcPixels);
+
+	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
diff --git a/tests/spec/arb_gpu_shader_fp64/vs-non-uniform-control-flow-f2d.c b/tests/spec/arb_gpu_shader_fp64/vs-non-uniform-control-flow-f2d.c
new file mode 100644
index 0000000..94af02c
--- /dev/null
+++ b/tests/spec/arb_gpu_shader_fp64/vs-non-uniform-control-flow-f2d.c
@@ -0,0 +1,166 @@
+/*
+ * Copyright © 2016 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 vs-non-uniform-control-flow-f2d.c
+ *
+ * It checks that a float to double conversion works correctly when it is
+ * under non-uniform control flow.
+ */
+
+#include "piglit-util-gl.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+	config.window_width = 62;
+	config.window_height = 62;
+	config.supports_gl_compat_version = 32;
+	config.supports_gl_core_version = 32;
+	config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
+PIGLIT_GL_TEST_CONFIG_END
+
+static const char vs_source[] =
+	"#version 330\n"
+	"#extension GL_ARB_gpu_shader_fp64 : require\n"
+	"\n"
+	"out vec4 color;\n"
+	"\n"
+	"layout(location = 0) in vec3 inVertexPosition;\n"
+	"\n"
+	"void main() {\n"
+	"        gl_Position = vec4(inVertexPosition, 1);\n"
+	"        dvec2 rg; \n"
+	"        vec2 value;\n"
+	"        if (inVertexPosition.x < 0 && inVertexPosition.y < 0)\n"
+	"                value = vec2(1.0f, 0.0f);\n"
+	"        else\n"
+	"                value = vec2(0.0f, 1.0f);\n"
+	"        rg = dvec2(value); \n"
+	"        if (rg == dvec2(0, 1))\n"
+	"            color = vec4(0, 0, 1, 1);\n"
+	"        else\n"
+	"            color = vec4(rg, 0, 1);\n"
+	"}\n";
+
+static const char fs_source[] =
+	"#version 130\n"
+	"\n"
+	"in vec4 color;\n"
+	"out vec4 frag_color;\n"
+	"\n"
+	"void main() {\n"
+	"        frag_color = color;\n"
+	"}\n";
+
+static GLuint prog, vertexArrayID;
+static GLuint fb, rb;
+
+void
+piglit_init(int argc, char **argv)
+{
+	GLuint vertexBuffer;
+	// Vertex data
+	static const GLfloat vertexData[4 * 3] = {
+		-1.0f,  -1.0f,  -1.0f,
+		 1.0f,  -1.0f,  -1.0f,
+		-1.0f,   1.0f,  -1.0f,
+		 1.0f,   1.0f,  -1.0f,
+	};
+
+	piglit_require_extension("GL_ARB_gpu_shader_fp64");
+
+	piglit_require_GLSL_version(330);
+
+	prog = piglit_build_simple_program(vs_source, fs_source);
+	glUseProgram(prog);
+
+	glClearColor(0, 0, 0, 1);
+	glPointSize(10.0);
+
+	glGenRenderbuffers(1, &rb);
+	glBindRenderbuffer(GL_RENDERBUFFER, rb);
+	glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA,
+			      piglit_width, piglit_height);
+
+	glGenFramebuffers(1, &fb);
+	glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fb);
+	glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+				  GL_RENDERBUFFER, rb);
+
+	// Record vertex data and attributes in a VAO
+	glGenVertexArrays(1, &vertexArrayID);
+	glBindVertexArray(vertexArrayID);
+	// Upload vertex position data to a VBO
+	glGenBuffers(1, &vertexBuffer);
+	glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
+	glBufferData(GL_ARRAY_BUFFER, sizeof(vertexData),
+		     vertexData, GL_STATIC_DRAW);
+
+	// Bind vertex position VBO to vertex shader attribute index 0
+	glEnableVertexAttribArray(0);
+	glVertexAttribPointer(
+		0,                  // attribute index
+		3,                  // size
+		GL_FLOAT,           // type
+		GL_FALSE,           // normalized?
+		0,                  // stride
+		(void*)0            // buffer offset
+		);
+
+	glBindBuffer(GL_ARRAY_BUFFER, 0);
+	// Unbind VAO
+	glBindVertexArray(0);
+	// Disable attribute arrays
+	glDisableVertexAttribArray(0);
+
+	if (!piglit_check_gl_error(GL_NO_ERROR))
+		piglit_report_result(PIGLIT_FAIL);
+}
+
+enum piglit_result piglit_display(void)
+{
+	bool pass = true;
+	float red[4] = {1.0, 0.0, 0.0, 1.0};
+	float blue[4] = {0.0, 0.0, 1.0, 1.0};
+
+	glUseProgram(prog);
+	glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fb);
+	glViewport(0, 0, piglit_width, piglit_height);
+
+	glClear(GL_COLOR_BUFFER_BIT);
+	glBindVertexArray(vertexArrayID);
+	glDrawArrays(GL_POINTS, 0, 4);
+	glBindVertexArray(0);
+
+	glBindFramebuffer(GL_READ_FRAMEBUFFER, fb);
+
+	/* Verify */
+	pass = piglit_probe_pixel_rgba(0, 0, red) && pass;
+	pass = piglit_probe_pixel_rgba(0, piglit_height - 1, blue) && pass;
+	pass = piglit_probe_pixel_rgba(piglit_width - 1,
+				       piglit_height - 1, blue) && pass;
+	pass = piglit_probe_pixel_rgba(piglit_width - 1, 0, blue) && pass;
+
+	pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
+	piglit_present_results();
+
+	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
-- 
2.7.4



More information about the Piglit mailing list