[Piglit] [PATCH] Add a test for viewport triangle clipping.
Brian Paul
brianp at vmware.com
Thu Nov 15 07:15:03 PST 2012
On 11/14/2012 03:30 PM, Stuart Abercrombie wrote:
> Triangles should be clipped to the clip volume and therefore shouldn't end up being rasterized outside the viewport.
>
> This was failing on Sandy Bridge with guard band clipping enabled.
>
> v2 with a new name, more comments and addition to all.tests.
>
> v3 with Eric's comments incorporated, and the explicit window size removed.
> ---
> tests/all.tests | 1 +
> tests/general/CMakeLists.gl.txt | 1 +
> tests/general/triangle-guardband-viewport.c | 77 +++++++++++++++++++++++++++
> 3 files changed, 79 insertions(+), 0 deletions(-)
> create mode 100644 tests/general/triangle-guardband-viewport.c
>
> diff --git a/tests/all.tests b/tests/all.tests
> index 306473b..6b4c2e5 100644
> --- a/tests/all.tests
> +++ b/tests/all.tests
> @@ -556,6 +556,7 @@ add_plain_test(gl11, 'streaming-texture-leak')
> add_plain_test(gl11, 'texredefine')
> add_plain_test(gl11, 'texsubimage')
> add_plain_test(gl11, 'texture-al')
> +add_concurrent_test(gl11, 'triangle-guardband-viewport')
>
> gl10 = Group()
> spec['!OpenGL 1.0'] = gl10
> diff --git a/tests/general/CMakeLists.gl.txt b/tests/general/CMakeLists.gl.txt
> index 0a5cd11..efaa56e 100644
> --- a/tests/general/CMakeLists.gl.txt
> +++ b/tests/general/CMakeLists.gl.txt
> @@ -137,5 +137,6 @@ piglit_add_executable (occlusion-query-discard occlusion-query-discard.c)
> piglit_add_executable (quad-invariance quad-invariance.c)
> piglit_add_executable (clear-accum clear-accum.c)
> piglit_add_executable (vs-point_size-zero vs-point_size-zero.c)
> +piglit_add_executable (triangle-guardband-viewport triangle-guardband-viewport.c)
>
> # vim: ft=cmake:
> diff --git a/tests/general/triangle-guardband-viewport.c b/tests/general/triangle-guardband-viewport.c
> new file mode 100644
> index 0000000..6a99f30
> --- /dev/null
> +++ b/tests/general/triangle-guardband-viewport.c
> @@ -0,0 +1,77 @@
> +/* Copyright 2012 Google Inc.
> + *
> + * This library is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * This library is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this library; if not, write to the Free Software
> + * Foundation Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
> + *
> + * Authors:
> + * Stuart Abercrombie<sabercrombie at google.com>
> +*/
> +
> +/** @file triangle-guardband-vewport.c
> + *
> + * Tests whether clipping of triangles to the clip volume
> + * is reflected in what is rasterized. Specifically,
> + * triangles (unlike some other primitives) should not be
> + * rasterized outside the viewport extents because they should
> + * have been clipped to the clip volume mapping to the viewport.
> + *
> + * Faulty guard-band clipping optimizations have been known to
> + * not honor this requirement.
> + */
> +
> +#include "piglit-util-gl-common.h"
> +
> +PIGLIT_GL_TEST_CONFIG_BEGIN
> +
> + config.supports_gl_compat_version = 10;
> +
> + config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGB;
> +
> +PIGLIT_GL_TEST_CONFIG_END
> +
> +enum piglit_result
> +piglit_display(void)
> +{
> + bool pass = true;
> + static float green[] = {0.0, 1.0, 0.0, 0.0};
> + static float blue[] = {0.0, 0.0, 1.0, 0.0};
> +
> + /* make the whole window green. */
> + glClearColor(0.0, 1.0, 0.0, 0.0);
> + glClear(GL_COLOR_BUFFER_BIT);
> +
> + /* set viewport to the left half of the window */
> + glViewport(0, 0, piglit_width / 2, piglit_height);
> +
> + /* draw blue rect extending beyond the right edge of the
> + frustrum, notionally across the whole window
> + */
> + glColor4fv(blue);
> + piglit_draw_rect(-1.0, -1.0, 4.0, 2.0);
> +
> + /* check that the right half of the window, outside
> + the viewport, still has the clear color
> + */
> + pass&= (bool)piglit_probe_rect_rgb(piglit_width/2, 0,
I don't think you need to use &= here and we haven't bothered with the
cast in other tests.
Unrelated: we should probably change piglit_probe_XXX() to return bool
instead of int.
> + piglit_width/2, piglit_height, green);
> +
> + piglit_present_results();
> +
> + return pass ? PIGLIT_PASS : PIGLIT_FAIL;
> +}
> +
> +void
> +piglit_init(int argc, char **argv)
> +{
> +}
Looks good otherwise.
Reviewed-by: Brian Paul <brianp at vmware.com>
More information about the Piglit
mailing list