On 15 November 2011 09:03, Paul Berry <span dir="ltr">&lt;<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
According to the OpenGL 3.0 spec (section 2.15: Transform Feedback):<br>
<br>
    &quot;When quads and polygons are provided to transform feedback with a<br>
    primitive mode of TRIANGLES, they will be tessellated and recorded<br>
    as triangles (the order of tessellation within a primitive is<br>
    undefined). Individual lines or triangles of a strip or fan<br>
    primitive will be extracted and recorded separately.&quot;<br>
<br>
This test verifies the correctness of the tessellation and extraction<br>
from strips and fans.  It does so by feeding the output of transform<br>
feedback back into the GL pipeline and verifying that the rendered<br>
image is the same.<br>
<br>
Verified using the nVidia proprietary driver for Linux.  The nVidia<br>
driver passes all tests except &quot;tessellation polygon flat_last&quot;,<br>
&quot;tessellation quad_strip flat_last&quot;, and &quot;tessellation quads<br>
flat_last&quot;.  These tests fail because the order in which the driver<br>
tessellates polygons and quads fails to preserve the correct provoking<br>
vertex, leading to different results from flatshading.<br>
---<br>
Changes from v1:<br>
- Use ARRAY_SIZE() (from piglit-util.h) instead of making a new<br>
  Elements() macro<br>
- In match_strips(), use glReadPixels() and piglit_probe_image_rgba()<br>
  so that the comparison is fast<br>
- Don&#39;t call exit() after piglit_report_result(), since<br>
  piglit_report_result() calls exit().<br>
<br>
 tests/all.tests                                    |    7 +<br>
 .../spec/ext_transform_feedback/CMakeLists.gl.txt  |    1 +<br>
 tests/spec/ext_transform_feedback/tessellation.c   |  515 ++++++++++++++++++++<br>
 3 files changed, 523 insertions(+), 0 deletions(-)<br>
 create mode 100644 tests/spec/ext_transform_feedback/tessellation.c<br>
<br>
diff --git a/tests/all.tests b/tests/all.tests<br>
index 2a85b7a..ed30997 100644<br>
--- a/tests/all.tests<br>
+++ b/tests/all.tests<br>
@@ -1343,6 +1343,13 @@ for drawcall in [&#39;arrays&#39;, &#39;elements&#39;]:<br>
                 test_name = &#39;order {0} {1}&#39;.format(drawcall, mode)<br>
                 ext_transform_feedback[test_name] = PlainExecTest(<br>
                         &#39;ext_transform_feedback-{0} -auto&#39;.format(test_name))<br>
+for draw_mode in [&#39;line_loop&#39;, &#39;line_strip&#39;, &#39;triangle_strip&#39;, &#39;triangle_fan&#39;,<br>
+                  &#39;quads&#39;, &#39;quad_strip&#39;, &#39;polygon&#39;]:<br>
+        for shade_mode in [&#39;monochrome&#39;, &#39;smooth&#39;, &#39;flat_first&#39;, &#39;flat_last&#39;]:<br>
+                test_name = &#39;tessellation {0} {1}&#39;.format(<br>
+                        draw_mode, shade_mode)<br>
+                ext_transform_feedback[test_name] = PlainExecTest(<br>
+                        &#39;ext_transform_feedback-{0} -auto&#39;.format(test_name))<br>
<br>
 ext_transform_feedback[&#39;output-type float&#39;] = PlainExecTest([&#39;ext_transform_feedback-output-type&#39;, &#39;-auto&#39;, &#39;float&#39;])<br>
 ext_transform_feedback[&#39;output-type float[2]&#39;] = PlainExecTest([&#39;ext_transform_feedback-output-type&#39;, &#39;-auto&#39;, &#39;float[2]&#39;])<br>
diff --git a/tests/spec/ext_transform_feedback/CMakeLists.gl.txt b/tests/spec/ext_transform_feedback/CMakeLists.gl.txt<br>
index 35c5dce..06dd099 100644<br>
--- a/tests/spec/ext_transform_feedback/CMakeLists.gl.txt<br>
+++ b/tests/spec/ext_transform_feedback/CMakeLists.gl.txt<br>
@@ -23,5 +23,6 @@ add_executable (ext_transform_feedback-interleaved interleaved.c)<br>
 add_executable (ext_transform_feedback-separate separate.c)<br>
 add_executable (ext_transform_feedback-output-type output-type.c)<br>
 add_executable (ext_transform_feedback-order order.c)<br>
+add_executable (ext_transform_feedback-tessellation tessellation.c)<br>
<br>
 # vim: ft=cmake:<br>
diff --git a/tests/spec/ext_transform_feedback/tessellation.c b/tests/spec/ext_transform_feedback/tessellation.c<br>
new file mode 100644<br>
index 0000000..c976e9e<br>
--- /dev/null<br>
+++ b/tests/spec/ext_transform_feedback/tessellation.c<br>
@@ -0,0 +1,515 @@<br>
+/*<br>
+ * Copyright © 2011 Intel Corporation<br>
+ *<br>
+ * Permission is hereby granted, free of charge, to any person obtaining a<br>
+ * copy of this software and associated documentation files (the &quot;Software&quot;),<br>
+ * to deal in the Software without restriction, including without limitation<br>
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
+ * and/or sell copies of the Software, and to permit persons to whom the<br>
+ * Software is furnished to do so, subject to the following conditions:<br>
+ *<br>
+ * The above copyright notice and this permission notice (including the next<br>
+ * paragraph) shall be included in all copies or substantial portions of the<br>
+ * Software.<br>
+ *<br>
+ * THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL<br>
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br>
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING<br>
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER<br>
+ * DEALINGS IN THE SOFTWARE.<br>
+ */<br>
+<br>
+/**<br>
+ * \file tessellation.c<br>
+ *<br>
+ * Verify that transform feedback properly converts primitives of<br>
+ * types GL_LINE_LOOP, GL_LINE_STRIP, GL_TRIANGLE_STRIP,<br>
+ * GL_TRIANGLE_FAN, GL_QUADS, GL_QUAD_STRIP, and GL_POLYGON into<br>
+ * primitives of type GL_LINES or GL_TRIANGLES, as appropriate.<br>
+ *<br>
+ * According to the OpenGL 3.0 spec (section 2.15: Transform Feedback):<br>
+ *<br>
+ *     &quot;When quads and polygons are provided to transform feedback<br>
+ *     with a primitive mode of TRIANGLES, they will be tessellated<br>
+ *     and recorded as triangles (the order of tessellation within a<br>
+ *     primitive is undefined). Individual lines or triangles of a<br>
+ *     strip or fan primitive will be extracted and recorded<br>
+ *     separately.&quot;<br>
+ *<br>
+ * Although it is not stated explicitly, it is clear from context that<br>
+ * individual lines of a LINE_LOOP primitive are also expected to be<br>
+ * extracted and recorded separately.  Also, the spec does not place<br>
+ * any requirement on the order in which vertices are output when<br>
+ * extracting individual lines or triangles of a strip, fan, or<br>
+ * LINE_LOOP primitive.<br>
+ *<br>
+ * Because the spec allows variability in how these primitives are<br>
+ * tessellated and extracted, we can&#39;t verify correct operation by<br>
+ * examining the vertices themselves.  However, we can check that if<br>
+ * the transform feedback output is fed back into the GL pipeline<br>
+ * (using GL_TRIANGLES or GL_LINES, as appropriate), the same image<br>
+ * will be rendered.<br>
+ *<br>
+ * This test operates by first rendering an image without transform<br>
+ * feedback, then rendering the same image with transform feedback,<br>
+ * then rendering the transform feedback output.  Then it checks that<br>
+ * the 3 generated images match exactly.<br>
+ *<br>
+ * In addition, the test verifies that the expected number of vertices<br>
+ * was output by transform feedback.<br>
+ *<br>
+ * The images are rendered using a fragment shader that attenuates the<br>
+ * color of back-facing primitives, so that the test will verify that<br>
+ * tesellation preserves winding order properly.<br>
+ *<br>
+ * The test can be run in four different coloring modes:<br>
+ *<br>
+ * - &quot;monochrome&quot;, meaning that all vertices are assigned the same<br>
+ *   color.  A failure in this mode means that the tessellated image<br>
+ *   did not have the correct shape.<br>
+ *<br>
+ * - &quot;smooth&quot;, meaning that all vertices are assigned different<br>
+ *   colors, and the primitives are drawn with smooth interpolation.<br>
+ *   A failure in this mode means that the tessellation performed by<br>
+ *   transform feedback failed to match the tessellation performed by<br>
+ *   the GL pipeline under normal operation.<br>
+ *<br>
+ * - &quot;flat_last&quot; or &quot;flat_first&quot;, meaning that all vertices are<br>
+ *   assigned different colors, and the primitives are flatshaded.  In<br>
+ *   the &quot;flat_last&quot; case, they are flatshaded using the GL standard<br>
+ *   &quot;last vertex&quot; convention to select the provoking vertex.  In the<br>
+ *   &quot;flat_first&quot; case, they are flatshaded using the alternative<br>
+ *   &quot;first vertex&quot; convention provided by GL_EXT_provoking_vertex or<br>
+ *   GL_ARB_provoking_vertex.  A failure in one of these modes means<br>
+ *   that within at least one of the tessellated primitives, transform<br>
+ *   feedback failed to output the vertices in the correct order for<br>
+ *   proper flatshading.<br>
+ */<br>
+<br>
+#include &quot;piglit-util.h&quot;<br>
+<br>
+#ifndef M_PI<br>
+#define M_PI 3.141592653589793<br>
+#endif<br></blockquote><div><br>Argh, I said I was going to remove this bogus #define also.  I will do that before I push the patch, I promise.<br></div></div>