This extension is a subset of GL_NV_conservative_raster, applying only
to polygons.

v2: Drop wrongly added files from Plamena's work (Lionel)

Signed-off-by: Lionel Landwerlin <lionel.g.landwer...@intel.com>
---
 tests/all.py                                       |   8 ++
 tests/spec/CMakeLists.txt                          |   1 +
 .../CMakeLists.gl.txt                              |  16 +++
 .../CMakeLists.txt                                 |   1 +
 .../depthcoverage.c                                |  67 ++++++++++
 .../innercoverage.c                                | 147 +++++++++++++++++++++
 .../intel_conservative_rasterization/invalid.c     | 106 +++++++++++++++
 tests/spec/intel_conservative_rasterization/tri.c  | 120 +++++++++++++++++
 8 files changed, 466 insertions(+)
 create mode 100644 
tests/spec/intel_conservative_rasterization/CMakeLists.gl.txt
 create mode 100644 tests/spec/intel_conservative_rasterization/CMakeLists.txt
 create mode 100644 tests/spec/intel_conservative_rasterization/depthcoverage.c
 create mode 100644 tests/spec/intel_conservative_rasterization/innercoverage.c
 create mode 100644 tests/spec/intel_conservative_rasterization/invalid.c
 create mode 100644 tests/spec/intel_conservative_rasterization/tri.c

diff --git a/tests/all.py b/tests/all.py
index 30df61c..c8e1cda 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -4897,5 +4897,13 @@ with profile.test_list.group_manager(
     g(['arb_compute_variable_group_size-local-size'], 'local-size')
     g(['arb_compute_variable_group_size-minmax'], 'minmax')

+with profile.test_list.group_manager(
+        PiglitGLTest,
+        grouptools.join('spec', 'intel_conservative_rasterization')) as g:
+    g(['intel_conservative_rasterization-depthcoverage'])
+    g(['intel_conservative_rasterization-innercoverage'])
+    g(['intel_conservative_rasterization-invalid'])
+    g(['intel_conservative_rasterization-tri'])
+
 if platform.system() is 'Windows':
     profile.filters.append(lambda p, _: not p.startswith('glx'))
diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
index 4ac1a53..548515d 100644
--- a/tests/spec/CMakeLists.txt
+++ b/tests/spec/CMakeLists.txt
@@ -153,3 +153,4 @@ add_subdirectory (arb_query_buffer_object)
 add_subdirectory (ext_window_rectangles)
 add_subdirectory (arb_shader_texture_image_samples)
 add_subdirectory (arb_texture_barrier)
+add_subdirectory (intel_conservative_rasterization)
diff --git a/tests/spec/intel_conservative_rasterization/CMakeLists.gl.txt 
b/tests/spec/intel_conservative_rasterization/CMakeLists.gl.txt
new file mode 100644
index 0000000..6e0ab44
--- /dev/null
+++ b/tests/spec/intel_conservative_rasterization/CMakeLists.gl.txt
@@ -0,0 +1,16 @@
+include_directories(
+       ${GLEXT_INCLUDE_DIR}
+       ${OPENGL_INCLUDE_PATH}
+)
+
+link_libraries (
+       piglitutil_${piglit_target_api}
+       ${OPENGL_gl_LIBRARY}
+)
+
+piglit_add_executable (intel_conservative_rasterization-depthcoverage 
depthcoverage.c)
+piglit_add_executable (intel_conservative_rasterization-innercoverage 
innercoverage.c)
+piglit_add_executable (intel_conservative_rasterization-invalid invalid.c)
+piglit_add_executable (intel_conservative_rasterization-tri tri.c)
+
+# vim: ft=cmake:
diff --git a/tests/spec/intel_conservative_rasterization/CMakeLists.txt 
b/tests/spec/intel_conservative_rasterization/CMakeLists.txt
new file mode 100644
index 0000000..144a306
--- /dev/null
+++ b/tests/spec/intel_conservative_rasterization/CMakeLists.txt
@@ -0,0 +1 @@
+piglit_include_target_api()
diff --git a/tests/spec/intel_conservative_rasterization/depthcoverage.c 
b/tests/spec/intel_conservative_rasterization/depthcoverage.c
new file mode 100644
index 0000000..e92083d
--- /dev/null
+++ b/tests/spec/intel_conservative_rasterization/depthcoverage.c
@@ -0,0 +1,67 @@
+/*
+ * 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 depthcoverage.c
+ *
+ * Verifies that post_depth_coverage & inner_coverage layout
+ * qualifiers are mutually exclusives.
+ */
+
+#include "piglit-util-gl.h"
+#include "piglit-shader.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+       config.supports_gl_core_version = 42;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+enum piglit_result
+piglit_display(void)
+{
+       return PIGLIT_FAIL;
+}
+
+void piglit_init(int argc, char **argv)
+{
+       piglit_require_extension("GL_INTEL_conservative_rasterization");
+       piglit_require_extension("GL_ARB_post_depth_coverage");
+
+       GLuint invalid_prog = piglit_compile_shader_text_nothrow(
+               GL_FRAGMENT_SHADER,
+               "#version 430\n"
+               "#extension GL_ARB_post_depth_coverage: enable\n"
+               "#extension GL_INTEL_conservative_rasterization: enable\n"
+               "layout(inner_coverage) in;\n"
+               "layout(post_depth_coverage) in;\n"
+               "out vec4 color;\n"
+               "void main()\n"
+               "{\n"
+               "  color = vec4(1.0, 0.0, 0.0, 1.0);\n"
+               "}\n");
+       if (invalid_prog)
+               piglit_report_result(PIGLIT_FAIL);
+
+       piglit_report_result(PIGLIT_PASS);
+}
diff --git a/tests/spec/intel_conservative_rasterization/innercoverage.c 
b/tests/spec/intel_conservative_rasterization/innercoverage.c
new file mode 100644
index 0000000..5ca909f
--- /dev/null
+++ b/tests/spec/intel_conservative_rasterization/innercoverage.c
@@ -0,0 +1,147 @@
+/*
+ * 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 innercoverage.c
+ *
+ * Verifies that the inner_coverage layout qualifier works when
+ * GL_INTEL_conservative_rasterization is enabled.
+ */
+
+#include "piglit-util-gl.h"
+#include "piglit-matrix.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+       config.supports_gl_core_version = 42;
+
+       config.window_width = 400;
+       config.window_height = 400;
+       config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+enum piglit_result
+piglit_display(void)
+{
+       enum piglit_result result = PIGLIT_PASS;
+
+       /* The following fragment programs render the opaque red color
+        * only when dispatched with a gl_SampleMaskIn empty. It
+        * should therefore expose the effect of the inner_coverage
+        * (i.e. no color with this qualifier and a triangle outline
+        * without it). */
+       GLuint inner_prog = piglit_build_simple_program(
+               "#version 430\n"
+               "in vec4 piglit_vertex;\n"
+               "void main()\n"
+               "{\n"
+               "  gl_Position = piglit_vertex;\n"
+               "}\n",
+               "#version 430\n"
+               "#extension GL_INTEL_conservative_rasterization: enable\n"
+               "layout(inner_coverage) in;\n"
+               "out vec4 color;\n"
+               "void main()\n"
+               "{\n"
+               "  float one = 1.0 - float(gl_SampleMaskIn[0]);\n"
+               "  color = vec4(one, 0.0, 0.0, one);\n"
+               "}\n");
+       if (!inner_prog)
+               piglit_report_result(PIGLIT_FAIL);
+
+       GLuint conservative_prog = piglit_build_simple_program(
+               "#version 430\n"
+               "in vec4 piglit_vertex;\n"
+               "void main()\n"
+               "{\n"
+               "  gl_Position = piglit_vertex;\n"
+               "}\n",
+               "#version 430\n"
+               "#extension GL_INTEL_conservative_rasterization: enable\n"
+               "out vec4 color;\n"
+               "void main()\n"
+               "{\n"
+               "  float one = 1.0 - float(gl_SampleMaskIn[0]);\n"
+               "  color = vec4(one, 0.0, 0.0, one);\n"
+               "}\n");
+       if (!conservative_prog)
+               piglit_report_result(PIGLIT_FAIL);
+
+       glBindFramebuffer(GL_DRAW_FRAMEBUFFER, piglit_winsys_fbo);
+       glViewport(0, 0, piglit_width, piglit_height);
+
+       glClearColor(0.0, 0.0, 0.0, 0.0);
+
+       GLuint vao;
+       glGenVertexArrays(1, &vao);
+       glBindVertexArray(vao);
+
+       GLuint vbo;
+       float delta = 1.01 / piglit_width;
+       float vertices[3][2] = {
+               { -0.5, -1 + delta, },
+               { 0, 0.8, },
+               { 0.5, -1 + delta, },
+       };
+       glGenBuffers(1, &vbo);
+       glBindBuffer(GL_ARRAY_BUFFER, vbo);
+       glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, 
GL_STATIC_DRAW);
+       glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(GLfloat), 
NULL);
+       glEnableVertexAttribArray(0);
+
+       glEnable(GL_CONSERVATIVE_RASTERIZATION_INTEL);
+
+       glUseProgram(conservative_prog);
+       glClear(GL_COLOR_BUFFER_BIT);
+       glDrawArrays(GL_TRIANGLES, 0, 3);
+
+       if(!piglit_check_gl_error(GL_NO_ERROR))
+               return PIGLIT_FAIL;
+
+       piglit_present_results();
+
+       const float conservative_expected[] = { 0.0, 0.0, 0.0, 0.0 };
+       if (!piglit_probe_pixel_rgba(piglit_width / 2, 0, 
conservative_expected))
+               result = PIGLIT_FAIL;
+
+       glUseProgram(inner_prog);
+       glClear(GL_COLOR_BUFFER_BIT);
+       glDrawArrays(GL_TRIANGLES, 0, 3);
+
+       if(!piglit_check_gl_error(GL_NO_ERROR))
+               result = PIGLIT_FAIL;
+
+       piglit_present_results();
+
+       const float inner_expected[] = { 1.0, 0.0, 0.0, 1.0 };
+       if (!piglit_probe_pixel_rgba(piglit_width / 2, 0, inner_expected))
+               result = PIGLIT_FAIL;
+
+       return result;
+}
+
+void piglit_init(int argc, char **argv)
+{
+       piglit_require_extension("GL_INTEL_conservative_rasterization");
+}
diff --git a/tests/spec/intel_conservative_rasterization/invalid.c 
b/tests/spec/intel_conservative_rasterization/invalid.c
new file mode 100644
index 0000000..217d69a
--- /dev/null
+++ b/tests/spec/intel_conservative_rasterization/invalid.c
@@ -0,0 +1,106 @@
+/*
+ * 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 invalid.c
+ *
+ * Verifies that with GL_INTEL_conservative_rasterization enabled, we
+ * get specified errors when using invalid modes for that extension.
+ */
+
+#include "piglit-util-gl.h"
+#include "piglit-matrix.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+       config.supports_gl_core_version = 42;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+enum piglit_result
+piglit_display(void)
+{
+       return PIGLIT_FAIL;
+}
+
+void piglit_init(int argc, char **argv)
+{
+       piglit_require_extension("GL_INTEL_conservative_rasterization");
+
+       GLuint prog = piglit_build_simple_program(
+               "#version 130 \n"
+               "in vec4 piglit_vertex;\n"
+               "void main()\n"
+               "{\n"
+               "  gl_Position = piglit_vertex;\n"
+               "}\n",
+               "void main()\n"
+               "{\n"
+               "  gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n"
+               "}\n");
+       if (!prog)
+               piglit_report_result(PIGLIT_FAIL);
+
+       glBindFramebuffer(GL_DRAW_FRAMEBUFFER, piglit_winsys_fbo);
+       glUseProgram(prog);
+
+       GLuint vao;
+       glGenVertexArrays(1, &vao);
+       glBindVertexArray(vao);
+
+       GLuint vbo;
+       float vertices[3][2] = {
+               { -0.5, -1, },
+               { 0, 0.8, },
+               { 0.5, -1, },
+       };
+       glGenBuffers(1, &vbo);
+       glBindBuffer(GL_ARRAY_BUFFER, vbo);
+       glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, 
GL_STATIC_DRAW);
+       glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(GLfloat), 
NULL);
+       glEnableVertexAttribArray(0);
+
+       glEnable(GL_CONSERVATIVE_RASTERIZATION_INTEL);
+       glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+       glClear(GL_COLOR_BUFFER_BIT);
+
+       glDrawArrays(GL_POINTS, 0, 3);
+       if (!piglit_check_gl_error(GL_INVALID_OPERATION))
+               piglit_report_result(PIGLIT_FAIL);
+
+       glDrawArrays(GL_LINES, 0, 3);
+       if (!piglit_check_gl_error(GL_INVALID_OPERATION))
+               piglit_report_result(PIGLIT_FAIL);
+
+       glPolygonMode(GL_FRONT_AND_BACK, GL_POINT);
+       glDrawArrays(GL_LINES, 0, 3);
+       if (!piglit_check_gl_error(GL_INVALID_OPERATION))
+               piglit_report_result(PIGLIT_FAIL);
+
+       glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+       glDrawArrays(GL_LINES, 0, 3);
+       if (!piglit_check_gl_error(GL_INVALID_OPERATION))
+               piglit_report_result(PIGLIT_FAIL);
+
+       piglit_report_result(PIGLIT_PASS);
+}
diff --git a/tests/spec/intel_conservative_rasterization/tri.c 
b/tests/spec/intel_conservative_rasterization/tri.c
new file mode 100644
index 0000000..7996e4e
--- /dev/null
+++ b/tests/spec/intel_conservative_rasterization/tri.c
@@ -0,0 +1,120 @@
+/*
+ * 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 tri.c
+ *
+ * Verifies that with GL_INTEL_conservative_rasterization enabled,
+ * partially covered pixels are rasterized.
+ */
+
+#include "piglit-util-gl.h"
+#include "piglit-matrix.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+       config.supports_gl_core_version = 42;
+
+       config.window_width = 400;
+       config.window_height = 400;
+       config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+enum piglit_result
+piglit_display(void)
+{
+       float delta = 1.01 / piglit_width;
+       GLuint prog;
+       enum piglit_result result = PIGLIT_PASS;
+
+       prog = piglit_build_simple_program(
+               "#version 130 \n"
+               "in vec4 piglit_vertex;\n"
+               "void main()\n"
+               "{\n"
+               "  gl_Position = piglit_vertex;\n"
+               "}\n",
+               "void main()\n"
+               "{\n"
+               "  gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n"
+               "}\n");
+       if (!prog)
+               piglit_report_result(PIGLIT_FAIL);
+
+       glBindFramebuffer(GL_DRAW_FRAMEBUFFER, piglit_winsys_fbo);
+       glViewport(0, 0, piglit_width, piglit_height);
+
+       glClearColor(0.0, 0.0, 0.0, 0.0);
+
+       glUseProgram(prog);
+
+       GLuint vao;
+       glGenVertexArrays(1, &vao);
+       glBindVertexArray(vao);
+
+       GLuint vbo;
+       float vertices[3][2] = {
+               { -0.5, -1 + delta, },
+               { 0, 0.8, },
+               { 0.5, -1 + delta, },
+       };
+       glGenBuffers(1, &vbo);
+       glBindBuffer(GL_ARRAY_BUFFER, vbo);
+       glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, 
GL_STATIC_DRAW);
+       glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(GLfloat), 
NULL);
+       glEnableVertexAttribArray(0);
+
+       glEnable(GL_CONSERVATIVE_RASTERIZATION_INTEL);
+       glClear(GL_COLOR_BUFFER_BIT);
+       glDrawArrays(GL_TRIANGLES, 0, 3);
+
+       if(!piglit_check_gl_error(GL_NO_ERROR))
+               return PIGLIT_FAIL;
+
+       piglit_present_results();
+
+       const float conservative_expected[] = { 1.0, 0.0, 0.0, 1.0 };
+       if (!piglit_probe_pixel_rgba(piglit_width / 2, 0, 
conservative_expected))
+               result = PIGLIT_FAIL;
+
+       glDisable(GL_CONSERVATIVE_RASTERIZATION_INTEL);
+       glClear(GL_COLOR_BUFFER_BIT);
+       glDrawArrays(GL_TRIANGLES, 0, 3);
+
+       if(!piglit_check_gl_error(GL_NO_ERROR))
+               return PIGLIT_FAIL;
+
+       piglit_present_results();
+
+       const float expected[] = { 0.0, 0.0, 0.0, 0.0 };
+       if (!piglit_probe_pixel_rgba(piglit_width / 2, 0, expected))
+               result = PIGLIT_FAIL;
+
+       return result;
+}
+
+void piglit_init(int argc, char **argv)
+{
+       piglit_require_extension("GL_INTEL_conservative_rasterization");
+}
--
2.10.2
_______________________________________________
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit

Reply via email to