[Piglit] [PATCH v3] polygon-line-aa test case added.

Iago Toral Quiroga itoral at igalia.com
Thu Jun 12 00:00:18 PDT 2014


This tests correct rendering of polygons using antialised GL_LINE mode for one
face and GL_FILL for the other one. On some Intel hardware at least this used
to require special handling that has caused regressions in the past.

The test checks that the GL_FILL face of the polygon renders properly.
---

I don't see a reason why we could not run this concurrently with other tests,
so added the test as concurrent. At least I did not spot anything wrong when
running a piglit test run.

Still, I am not sure about the exact requirements for this, I browsed a few
tests that are added with add_plain_test that do not seem to do anything
special either...

 tests/all.py                 |  1 +
 tests/bugs/CMakeLists.gl.txt |  1 +
 tests/bugs/polygon-line-aa.c | 95 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 97 insertions(+)
 create mode 100644 tests/bugs/polygon-line-aa.c

diff --git a/tests/all.py b/tests/all.py
index 3830013..d59df6a 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -714,6 +714,7 @@ add_plain_test(gl11, 'fdo10370')
 add_plain_test(gl11, 'fdo23489')
 add_plain_test(gl11, 'fdo23670-depth_test')
 add_plain_test(gl11, 'fdo23670-drawpix_stencil')
+add_concurrent_test(gl11, 'polygon-line-aa')
 add_plain_test(gl11, 'r300-readcache')
 add_plain_test(gl11, 'tri-tex-crash')
 add_plain_test(gl11, 'vbo-buffer-unmap')
diff --git a/tests/bugs/CMakeLists.gl.txt b/tests/bugs/CMakeLists.gl.txt
index e24ec6b..8e112ae 100644
--- a/tests/bugs/CMakeLists.gl.txt
+++ b/tests/bugs/CMakeLists.gl.txt
@@ -30,5 +30,6 @@ piglit_add_executable (fdo28551 fdo28551.c)
 piglit_add_executable (fdo31934 fdo31934.c)
 piglit_add_executable (tri-tex-crash tri-tex-crash.c)
 piglit_add_executable (vbo-buffer-unmap vbo-buffer-unmap.c)
+piglit_add_executable (polygon-line-aa polygon-line-aa.c)
 
 # vim: ft=cmake:
diff --git a/tests/bugs/polygon-line-aa.c b/tests/bugs/polygon-line-aa.c
new file mode 100644
index 0000000..ed45963
--- /dev/null
+++ b/tests/bugs/polygon-line-aa.c
@@ -0,0 +1,95 @@
+/* Copyright © 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 polygon-line-aa.c
+ * Test case for a special case of line antialiasing
+ * https://bugs.freedesktop.org/show_bug.cgi?id=78679
+ *
+ * This test renders a polygon using GL_LINE mode (with antialised lines)
+ * for one face of the polygon, and GL_FILL for the other face. For gen < 6
+ * intel hardware this setup requires special handling that if not done
+ * correctly produces incorrect rendering of the GL_FILL face. This caused
+ * regressions in the past.
+ *
+ * Author: Iago Toral <itoral at igalia.com>
+ */
+
+#include "piglit-util-gl-common.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+   config.supports_gl_compat_version = 10;
+   config.window_width = 100;
+   config.window_height = 100;
+   config.window_visual = PIGLIT_GL_VISUAL_RGBA;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+void
+piglit_init(int argc, char **argv)
+{
+   /* This enables the case we want to test for */
+   glEnable(GL_LINE_SMOOTH);
+   glShadeModel(GL_SMOOTH);
+   glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
+   glLineWidth(1.5);
+   glEnable(GL_BLEND);
+   glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+   glPolygonMode(GL_BACK, GL_LINE);
+
+   glMatrixMode(GL_PROJECTION);
+   glLoadIdentity();
+   glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
+
+   glClearColor(1, 1, 1, 1);
+}
+
+enum piglit_result
+piglit_display(void)
+{
+   glClear(GL_COLOR_BUFFER_BIT);
+
+   glViewport(0, 0, piglit_width, piglit_height);
+
+   glMatrixMode(GL_MODELVIEW);
+   glLoadIdentity();
+
+   glColor4f(0.0f, 0.0f, 1.0f, 1.0);
+   glBegin(GL_QUADS);
+      glVertex2f(-1.0f, -1.0f);
+      glVertex2f( 1.0f, -1.0f);
+      glVertex2f( 1.0f,  1.0f);
+      glVertex2f(-1.0f,  1.0f);
+   glEnd();
+
+   glFlush();
+
+   /* The test checks that the fill face of the quad is all blue without
+    * noise artifacts
+    */
+   GLfloat expected[4] = { 0.0, 0.0, 1.0, 1.0 };
+   if (piglit_probe_rect_rgba(0, 0, 100, 100, expected))
+      return PIGLIT_PASS;
+   else
+      return PIGLIT_FAIL;
+}
-- 
1.9.1



More information about the Piglit mailing list