On 15 November 2011 09:03, Paul Berry <span dir="ltr"><<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>></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>
"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."<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 "tessellation polygon flat_last",<br>
"tessellation quad_strip flat_last", and "tessellation quads<br>
flat_last". 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'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 ['arrays', 'elements']:<br>
test_name = 'order {0} {1}'.format(drawcall, mode)<br>
ext_transform_feedback[test_name] = PlainExecTest(<br>
'ext_transform_feedback-{0} -auto'.format(test_name))<br>
+for draw_mode in ['line_loop', 'line_strip', 'triangle_strip', 'triangle_fan',<br>
+ 'quads', 'quad_strip', 'polygon']:<br>
+ for shade_mode in ['monochrome', 'smooth', 'flat_first', 'flat_last']:<br>
+ test_name = 'tessellation {0} {1}'.format(<br>
+ draw_mode, shade_mode)<br>
+ ext_transform_feedback[test_name] = PlainExecTest(<br>
+ 'ext_transform_feedback-{0} -auto'.format(test_name))<br>
<br>
ext_transform_feedback['output-type float'] = PlainExecTest(['ext_transform_feedback-output-type', '-auto', 'float'])<br>
ext_transform_feedback['output-type float[2]'] = PlainExecTest(['ext_transform_feedback-output-type', '-auto', 'float[2]'])<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 "Software"),<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 "AS IS", 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>
+ * "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."<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'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>
+ * - "monochrome", 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>
+ * - "smooth", 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>
+ * - "flat_last" or "flat_first", meaning that all vertices are<br>
+ * assigned different colors, and the primitives are flatshaded. In<br>
+ * the "flat_last" case, they are flatshaded using the GL standard<br>
+ * "last vertex" convention to select the provoking vertex. In the<br>
+ * "flat_first" case, they are flatshaded using the alternative<br>
+ * "first vertex" 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 "piglit-util.h"<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>