[Piglit] [PATCH v2] Add a test of tessellation of transform feedback primitives.
Paul Berry
stereotype441 at gmail.com
Tue Nov 15 09:08:47 PST 2011
On 15 November 2011 09:03, Paul Berry <stereotype441 at gmail.com> wrote:
> According to the OpenGL 3.0 spec (section 2.15: Transform Feedback):
>
> "When quads and polygons are provided to transform feedback with a
> primitive mode of TRIANGLES, they will be tessellated and recorded
> as triangles (the order of tessellation within a primitive is
> undefined). Individual lines or triangles of a strip or fan
> primitive will be extracted and recorded separately."
>
> This test verifies the correctness of the tessellation and extraction
> from strips and fans. It does so by feeding the output of transform
> feedback back into the GL pipeline and verifying that the rendered
> image is the same.
>
> Verified using the nVidia proprietary driver for Linux. The nVidia
> driver passes all tests except "tessellation polygon flat_last",
> "tessellation quad_strip flat_last", and "tessellation quads
> flat_last". These tests fail because the order in which the driver
> tessellates polygons and quads fails to preserve the correct provoking
> vertex, leading to different results from flatshading.
> ---
> Changes from v1:
> - Use ARRAY_SIZE() (from piglit-util.h) instead of making a new
> Elements() macro
> - In match_strips(), use glReadPixels() and piglit_probe_image_rgba()
> so that the comparison is fast
> - Don't call exit() after piglit_report_result(), since
> piglit_report_result() calls exit().
>
> tests/all.tests | 7 +
> .../spec/ext_transform_feedback/CMakeLists.gl.txt | 1 +
> tests/spec/ext_transform_feedback/tessellation.c | 515
> ++++++++++++++++++++
> 3 files changed, 523 insertions(+), 0 deletions(-)
> create mode 100644 tests/spec/ext_transform_feedback/tessellation.c
>
> diff --git a/tests/all.tests b/tests/all.tests
> index 2a85b7a..ed30997 100644
> --- a/tests/all.tests
> +++ b/tests/all.tests
> @@ -1343,6 +1343,13 @@ for drawcall in ['arrays', 'elements']:
> test_name = 'order {0} {1}'.format(drawcall, mode)
> ext_transform_feedback[test_name] = PlainExecTest(
> 'ext_transform_feedback-{0}
> -auto'.format(test_name))
> +for draw_mode in ['line_loop', 'line_strip', 'triangle_strip',
> 'triangle_fan',
> + 'quads', 'quad_strip', 'polygon']:
> + for shade_mode in ['monochrome', 'smooth', 'flat_first',
> 'flat_last']:
> + test_name = 'tessellation {0} {1}'.format(
> + draw_mode, shade_mode)
> + ext_transform_feedback[test_name] = PlainExecTest(
> + 'ext_transform_feedback-{0}
> -auto'.format(test_name))
>
> ext_transform_feedback['output-type float'] =
> PlainExecTest(['ext_transform_feedback-output-type', '-auto', 'float'])
> ext_transform_feedback['output-type float[2]'] =
> PlainExecTest(['ext_transform_feedback-output-type', '-auto', 'float[2]'])
> diff --git a/tests/spec/ext_transform_feedback/CMakeLists.gl.txt
> b/tests/spec/ext_transform_feedback/CMakeLists.gl.txt
> index 35c5dce..06dd099 100644
> --- a/tests/spec/ext_transform_feedback/CMakeLists.gl.txt
> +++ b/tests/spec/ext_transform_feedback/CMakeLists.gl.txt
> @@ -23,5 +23,6 @@ add_executable (ext_transform_feedback-interleaved
> interleaved.c)
> add_executable (ext_transform_feedback-separate separate.c)
> add_executable (ext_transform_feedback-output-type output-type.c)
> add_executable (ext_transform_feedback-order order.c)
> +add_executable (ext_transform_feedback-tessellation tessellation.c)
>
> # vim: ft=cmake:
> diff --git a/tests/spec/ext_transform_feedback/tessellation.c
> b/tests/spec/ext_transform_feedback/tessellation.c
> new file mode 100644
> index 0000000..c976e9e
> --- /dev/null
> +++ b/tests/spec/ext_transform_feedback/tessellation.c
> @@ -0,0 +1,515 @@
> +/*
> + * Copyright © 2011 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 tessellation.c
> + *
> + * Verify that transform feedback properly converts primitives of
> + * types GL_LINE_LOOP, GL_LINE_STRIP, GL_TRIANGLE_STRIP,
> + * GL_TRIANGLE_FAN, GL_QUADS, GL_QUAD_STRIP, and GL_POLYGON into
> + * primitives of type GL_LINES or GL_TRIANGLES, as appropriate.
> + *
> + * According to the OpenGL 3.0 spec (section 2.15: Transform Feedback):
> + *
> + * "When quads and polygons are provided to transform feedback
> + * with a primitive mode of TRIANGLES, they will be tessellated
> + * and recorded as triangles (the order of tessellation within a
> + * primitive is undefined). Individual lines or triangles of a
> + * strip or fan primitive will be extracted and recorded
> + * separately."
> + *
> + * Although it is not stated explicitly, it is clear from context that
> + * individual lines of a LINE_LOOP primitive are also expected to be
> + * extracted and recorded separately. Also, the spec does not place
> + * any requirement on the order in which vertices are output when
> + * extracting individual lines or triangles of a strip, fan, or
> + * LINE_LOOP primitive.
> + *
> + * Because the spec allows variability in how these primitives are
> + * tessellated and extracted, we can't verify correct operation by
> + * examining the vertices themselves. However, we can check that if
> + * the transform feedback output is fed back into the GL pipeline
> + * (using GL_TRIANGLES or GL_LINES, as appropriate), the same image
> + * will be rendered.
> + *
> + * This test operates by first rendering an image without transform
> + * feedback, then rendering the same image with transform feedback,
> + * then rendering the transform feedback output. Then it checks that
> + * the 3 generated images match exactly.
> + *
> + * In addition, the test verifies that the expected number of vertices
> + * was output by transform feedback.
> + *
> + * The images are rendered using a fragment shader that attenuates the
> + * color of back-facing primitives, so that the test will verify that
> + * tesellation preserves winding order properly.
> + *
> + * The test can be run in four different coloring modes:
> + *
> + * - "monochrome", meaning that all vertices are assigned the same
> + * color. A failure in this mode means that the tessellated image
> + * did not have the correct shape.
> + *
> + * - "smooth", meaning that all vertices are assigned different
> + * colors, and the primitives are drawn with smooth interpolation.
> + * A failure in this mode means that the tessellation performed by
> + * transform feedback failed to match the tessellation performed by
> + * the GL pipeline under normal operation.
> + *
> + * - "flat_last" or "flat_first", meaning that all vertices are
> + * assigned different colors, and the primitives are flatshaded. In
> + * the "flat_last" case, they are flatshaded using the GL standard
> + * "last vertex" convention to select the provoking vertex. In the
> + * "flat_first" case, they are flatshaded using the alternative
> + * "first vertex" convention provided by GL_EXT_provoking_vertex or
> + * GL_ARB_provoking_vertex. A failure in one of these modes means
> + * that within at least one of the tessellated primitives, transform
> + * feedback failed to output the vertices in the correct order for
> + * proper flatshading.
> + */
> +
> +#include "piglit-util.h"
> +
> +#ifndef M_PI
> +#define M_PI 3.141592653589793
> +#endif
>
Argh, I said I was going to remove this bogus #define also. I will do that
before I push the patch, I promise.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20111115/778c422b/attachment.htm>
More information about the Piglit
mailing list