[Piglit] [PATCH] arb_viewport_array: add test for fractional viewport coordinates
Józef Kucia
joseph.kucia at gmail.com
Tue May 15 11:43:23 UTC 2018
In Direct3D 11, negative fractional viewport coordinates shift the
bottom right corner by a whole integer. Some OpenGL drivers seem to
implement Direct3D 11 behavior.
The test fails on i965 and Nvidia binary driver. It succeeds on
radeonsi.
---
The test exercises a bug in i965.
I don't have commit access.
---
tests/opengl.py | 1 +
tests/spec/arb_viewport_array/CMakeLists.gl.txt | 1 +
.../spec/arb_viewport_array/fractional_viewport.c | 94 ++++++++++++++++++++++
3 files changed, 96 insertions(+)
create mode 100644 tests/spec/arb_viewport_array/fractional_viewport.c
diff --git a/tests/opengl.py b/tests/opengl.py
index 347e8c5d4009..7605fe5d990d 100644
--- a/tests/opengl.py
+++ b/tests/opengl.py
@@ -2693,6 +2693,7 @@ with profile.test_list.group_manager(
g(['arb_viewport_array-render-depthrange'], 'render-depthrange')
g(['arb_viewport_array-render-scissor'], 'render-scissor')
g(['arb_viewport_array-clear'], 'clear')
+ g(['arb_viewport_array-fractional-viewport'], 'fractional-viewport')
with profile.test_list.group_manager(
PiglitGLTest,
diff --git a/tests/spec/arb_viewport_array/CMakeLists.gl.txt b/tests/spec/arb_viewport_array/CMakeLists.gl.txt
index 85715774c674..5abb23d3e6bf 100644
--- a/tests/spec/arb_viewport_array/CMakeLists.gl.txt
+++ b/tests/spec/arb_viewport_array/CMakeLists.gl.txt
@@ -20,5 +20,6 @@ piglit_add_executable(arb_viewport_array-render-viewport render_viewport.c)
piglit_add_executable(arb_viewport_array-render-viewport-2 render_viewport_2.c)
piglit_add_executable(arb_viewport_array-render-depthrange render_depthrange.c)
piglit_add_executable(arb_viewport_array-render-scissor render_scissor.c)
+piglit_add_executable(arb_viewport_array-fractional-viewport fractional_viewport.c)
# vim: ft=cmake:
diff --git a/tests/spec/arb_viewport_array/fractional_viewport.c b/tests/spec/arb_viewport_array/fractional_viewport.c
new file mode 100644
index 000000000000..1c4a9da941f2
--- /dev/null
+++ b/tests/spec/arb_viewport_array/fractional_viewport.c
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2018 Józef Kucia <joseph.kucia at gmail.com>
+ *
+ * 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.
+ *
+ */
+
+/**
+ * Tests rendering with negative fractional viewport coordinates.
+ */
+#include "piglit-util-gl.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+ config.supports_gl_compat_version = 33;
+ config.supports_gl_core_version = 33;
+
+ config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
+ config.khr_no_error_support = PIGLIT_NO_ERRORS;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+static const char *vs =
+ "#version 150\n"
+ "in vec4 piglit_vertex;\n"
+ "void main() { \n"
+ " gl_Position = piglit_vertex;\n"
+ "}\n";
+
+static const char *fs =
+ "#version 150\n"
+ "out vec4 color;\n"
+ "void main() {\n"
+ " color = uvec4(0.0f, 1.0f, 0.0f, 1.0f);\n"
+ "}\n";
+
+static bool
+draw_fractional_viewport(void)
+{
+ static const float green[] = {0.0f, 1.0f, 0.0f, 1.0f};
+
+ glViewport(0, 0, piglit_width, piglit_height); /* for glClear() */
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glViewportIndexedf(0, -0.4f, -0.4f, piglit_width, piglit_height);
+ piglit_draw_rect(-1, -1, 2, 2);
+ return piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height, green);
+}
+
+enum piglit_result
+piglit_display(void)
+{
+ bool pass = true;
+
+ pass = draw_fractional_viewport();
+ pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
+ piglit_present_results();
+ return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+ GLuint program;
+ GLuint vao;
+
+ piglit_require_extension("GL_ARB_viewport_array");
+
+ program = piglit_build_simple_program_multiple_shaders(
+ GL_VERTEX_SHADER, vs,
+ GL_FRAGMENT_SHADER, fs,
+ 0);
+ glUseProgram(program);
+
+ glGenVertexArrays(1, &vao);
+ glBindVertexArray(vao);
+}
--
2.16.1
More information about the Piglit
mailing list