----- Original Message -----
> This exercises a bug found in Mesa with softpipe, llvmpipe and swrast
> ---
>  tests/all.py                         |    1 +
>  tests/general/CMakeLists.gl.txt      |    1 +
>  tests/general/line-flat-clip-color.c |  156
>  ++++++++++++++++++++++++++++++++++
>  3 files changed, 158 insertions(+)
>  create mode 100644 tests/general/line-flat-clip-color.c
> 
> diff --git a/tests/all.py b/tests/all.py
> index 5d6ef9a..d1bd617 100644
> --- a/tests/all.py
> +++ b/tests/all.py
> @@ -861,6 +861,7 @@ add_concurrent_test(gl11, 'glinfo')
>  add_plain_test(gl11, 'hiz')
>  add_plain_test(gl11, 'infinite-spot-light')
>  add_plain_test(gl11, 'line-aa-width')
> +add_concurrent_test(gl11, 'line-flat-clip-color')
>  add_plain_test(gl11, 'linestipple')
>  add_plain_test(gl11, 'longprim')
>  add_concurrent_test(gl11, 'masked-clear')
> diff --git a/tests/general/CMakeLists.gl.txt
> b/tests/general/CMakeLists.gl.txt
> index 1933b13..69ed167 100644
> --- a/tests/general/CMakeLists.gl.txt
> +++ b/tests/general/CMakeLists.gl.txt
> @@ -81,6 +81,7 @@ piglit_add_executable (line-aa-width line-aa-width.c)
>  IF (UNIX)
>       target_link_libraries (line-aa-width m)
>  ENDIF (UNIX)
> +piglit_add_executable (line-flat-clip-color line-flat-clip-color.c)
>  piglit_add_executable (longprim longprim.c)
>  piglit_add_executable (masked-clear masked-clear.c)
>  piglit_add_executable (pos-array pos-array.c)
> diff --git a/tests/general/line-flat-clip-color.c
> b/tests/general/line-flat-clip-color.c
> new file mode 100644
> index 0000000..4cf37b2
> --- /dev/null
> +++ b/tests/general/line-flat-clip-color.c
> @@ -0,0 +1,156 @@
> +/*
> + * Copyright © 2014 VMware, Inc.
> + *
> + * 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.
> + */
> +
> +/*
> + * Test flat-shaded clipped line color.
> + * Exercises provoking vertex, line smooth, line width, etc.
> + *
> + * Author: Brian Paul
> + */
> +
> +
> +#include "piglit-util-gl-common.h"
> +
> +PIGLIT_GL_TEST_CONFIG_BEGIN
> +     config.supports_gl_compat_version = 10;
> +     config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
> +PIGLIT_GL_TEST_CONFIG_END
> +
> +
> +/* far left, far right verts */
> +static const float verts[2][2] = {
> +     { -10.0, 0.0 }, { 10.0, 0.0 }
> +};
> +
> +static const float colors[2][3] = {
> +     { 1.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }
> +};
> +
> +static const GLuint forward_order[2] = { 0, 1 };
> +static const GLuint backward_order[2] = { 1, 0 };
> +
> +static bool have_pv = false;
> +
> +
> +static bool
> +test_one(int order, const float expected[3])
> +{
> +     bool pass;
> +     int dy, y = piglit_height / 2;
> +
> +     glClear(GL_COLOR_BUFFER_BIT);
> +
> +     /* draw horizontal line across middle of window */
> +     if (order == 0)
> +             glDrawElements(GL_LINES, 2, GL_UNSIGNED_INT, forward_order);
> +     else
> +             glDrawElements(GL_LINES, 2, GL_UNSIGNED_INT, backward_order);
> +
> +     /* To be resilient in the face of different line rasterization,
> +      * try several Y values to find where the line was drawn.
> +      */
> +     for (dy = -1; dy <= 1; dy++) {
> +             GLfloat color[3];
> +             glReadPixels(0, y + dy, 1, 1, GL_RGB, GL_FLOAT, color);
> +             if (color[0] || color[1] || color[2]) {
> +                     /* found non-black pixel */
> +                     /* test all pixels across middle of window */
> +                     pass = piglit_probe_rect_rgb(0, y + dy, /* x, y */
> +                                                  piglit_width, 1, /* w, h */
> +                                                  expected);
> +                     break;
> +             }
> +     }
> +
> +     piglit_present_results();
> +
> +     return pass;
> +}
> +
> +
> +void
> +piglit_init(int argc, char **argv)
> +{
> +     glMatrixMode(GL_PROJECTION);
> +     glLoadIdentity();
> +     glMatrixMode(GL_MODELVIEW);
> +     glLoadIdentity();
> +
> +     glEnable(GL_VERTEX_ARRAY);
> +     glEnable(GL_COLOR_ARRAY);
> +     glVertexPointer(2, GL_FLOAT, 0, verts);
> +     glColorPointer(3, GL_FLOAT, 0, colors);
> +
> +     glShadeModel(GL_FLAT);
> +
> +     if (piglit_is_extension_supported("GL_ARB_provoking_vertex")) {
> +             have_pv = true;
> +     }
> +     else if (piglit_is_extension_supported("GL_EXT_provoking_vertex")) {
> +             have_pv = true;
> +     }
> +
> +     if (have_pv)
> +             printf("Have provoking vertex.\n");
> +}
> +
> +
> +enum piglit_result
> +piglit_display(void)
> +{
> +     int direction, smooth, pv, width;
> +     bool p, pass = true;
> +
> +     for (pv = 0; pv <= (int) have_pv; pv++) {
> +             if (pv == 1)
> +                     glProvokingVertex(GL_FIRST_VERTEX_CONVENTION_EXT);
> +
> +             for (width = 1; width <= 5; width += 4) {
> +                     glLineWidth((float) width);
> +
> +                     for (smooth = 0; smooth <= 1; smooth++) {
> +                             if (smooth)
> +                                     glEnable(GL_LINE_SMOOTH);
> +                             else
> +                                     glDisable(GL_LINE_SMOOTH);
> +
> +                             for (direction = 0; direction <= 1; 
> direction++) {
> +                                     /* Determine which vertex color should
> +                                      * have been used for the line.
> +                                      */
> +                                     int c = !(direction ^ pv);
> +
> +                                     p = test_one(direction, colors[c]);
> +                                     if (!p) {
> +                                             printf("failure (pv = %d, dir = 
> %d,"
> +                                                    " smooth = %d, width = 
> %d)\n",
> +                                                    pv, direction, smooth, 
> width);
> +                                     }
> +                                     pass = pass && p;
> +                             }
> +                     }
> +             }
> +     }
> +
> +     return pass ? PIGLIT_PASS : PIGLIT_FAIL;
> +}
> --
> 1.7.10.4
> 
> _______________________________________________
> Piglit mailing list
> Piglit@lists.freedesktop.org
> https://urldefense.proofpoint.com/v1/url?u=http://lists.freedesktop.org/mailman/listinfo/piglit&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=NMr9uy2iTjWVixC0wOcYCWEIYhfo80qKwRgdodpoDzA%3D%0A&m=bnO86pIlC1DDzgJxVlVoXu2A0KJ0aKxKlV9ndbopacU%3D%0A&s=4afa91f721556f49c6558902863081c41be20cd12211307d2afc443c457b6ce3
 

Reviewed-by: Jose Fonseca <jfons...@vmware.com>
_______________________________________________
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit

Reply via email to