On 01/23/2014 01:06 PM, Jon Ashburn wrote:
> Verify that calling glScissorArrayv, glScissorIndexed, or glScissorIndexedv
> with an invalid width (or height) in elements after the first generates
> a GL error and does not modify any of the scissor rectangles.
> ---
>   tests/spec/arb_viewport_array/CMakeLists.gl.txt |   1 +
>   tests/spec/arb_viewport_array/scissor_ignore.c  | 136 
> ++++++++++++++++++++++++
>   2 files changed, 137 insertions(+)
>   create mode 100644 tests/spec/arb_viewport_array/scissor_ignore.c
> 
> diff --git a/tests/spec/arb_viewport_array/CMakeLists.gl.txt 
> b/tests/spec/arb_viewport_array/CMakeLists.gl.txt
> index 7cf98ff..de20d42 100644
> --- a/tests/spec/arb_viewport_array/CMakeLists.gl.txt
> +++ b/tests/spec/arb_viewport_array/CMakeLists.gl.txt
> @@ -13,6 +13,7 @@ piglit_add_executable(arb_viewport_array-viewport-indices 
> viewport_indices.c)
>   piglit_add_executable(arb_viewport_array-depthrange-indices 
> depth_range_indices.c)
>   piglit_add_executable(arb_viewport_array-scissor-check scissor_check.c)
>   piglit_add_executable(arb_viewport_array-scissor-indices scissor_indices.c)
> +piglit_add_executable(arb_viewport_array-scissor-ignore scissor_ignore.c)
>   piglit_add_executable(arb_viewport_array-bounds bounds.c)
>   piglit_add_executable(arb_viewport_array-queries queries.c)
>   piglit_add_executable(arb_viewport_array-minmax minmax.c)
> diff --git a/tests/spec/arb_viewport_array/scissor_ignore.c 
> b/tests/spec/arb_viewport_array/scissor_ignore.c
> new file mode 100644
> index 0000000..0fd05ff
> --- /dev/null
> +++ b/tests/spec/arb_viewport_array/scissor_ignore.c
> @@ -0,0 +1,136 @@
> +/*
> + * Copyright © 2014 LunarG, 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.
> + *
> + * Author: Jon Ashburn <[email protected]>
> + */
> +
> +/**
> + * Verify that calling glScissorArrayv, glScissorIndexed, or 
> glScissorIndexedv
> + * with an invalid width (or height) in elements after the first generates
> + * a GL error and does not modify any of the scissor rectangles.
> + */
> +#include "piglit-util-gl-common.h"
> +
> +PIGLIT_GL_TEST_CONFIG_BEGIN
> +
> +     config.supports_gl_compat_version = 32;
> +     config.supports_gl_core_version = 32;
> +
> +     config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
> +
> +PIGLIT_GL_TEST_CONFIG_END
> +
> +
> +/* MAX_VIEWPORTS must be at least 16 per SPEC,  so use 16 for static array */
> +#define MAX_INDICES 16
> +
> +enum piglit_result
> +piglit_display(void)
> +{
> +     /* should never get here */
> +     return PIGLIT_FAIL;
> +}
> +
> +void
> +piglit_init(int argc, char **argv)
> +{
> +     bool pass = true;
> +     GLint maxVP;
> +     int i, idx;
> +     GLint sc[4], scGet[4];
> +     GLint scInvalid[MAX_INDICES][4] = {

        static const GLint

> +             {10,  0, -10,  90},
> +             {11,  1,  90, -10},
> +             {12,  2, -90, -10},
> +             {13,  3, -70, -80},
> +             {14,  4,  80, -70},
> +             {15,  5, -70,  80},
> +             {16,  6,  15, -15},
> +             {17,  7, -15, -15},
> +             {18,  9, -15,  15},
> +             {10, 11,   0, -30},
> +             {12, 13, -30,   0},
> +             {14, 15,  60,  -1},
> +             {16, 17,  -1,  60},
> +             {0,  0, -60,  -1},
> +             {-1, -1,  -1,  -1},
> +             {-2, -2,   0,  -2}};

The final "};" should be on a line by itself.

> +
> +     piglit_require_extension("GL_ARB_viewport_array");
> +
> +     glGetIntegerv(GL_MAX_VIEWPORTS, &maxVP);
> +
> +     /* intialize Scissor left, bottom, width, height for all indices */
> +     for (i = 0; i < maxVP; i++) {
> +             sc[0] = 0 + i;
> +             sc[1] = maxVP + i;
> +             sc[2] = 100 + i;
> +             sc[3] = 100 + maxVP + i;
> +             glScissorIndexedv(i, sc);
> +             glEnablei(GL_SCISSOR_TEST, i);
> +     }
> +     pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
> +
> +     /* set scissor values  with illegal width or height */
> +     glScissorArrayv(0, maxVP, &(scInvalid[0][0]));
> +     pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass;

Blank line here.

> +     for (i = 0; i < maxVP; i++) {
> +             idx = i % MAX_INDICES;
> +             glScissorIndexedv(i, &(scInvalid[idx][0]));
> +             pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass;

Blank line here.

> +             glScissorIndexed(i, scInvalid[idx][0], scInvalid[idx][1],
> +                              scInvalid[idx][2], scInvalid[idx][3]);
> +             pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass;
> +     }
> +
> +     /* check that scissor rectangle with invalid width/height got ignored */
> +     for (i = 0; i < maxVP; i++) {
> +             sc[0] = 0 + i;
> +             sc[1] = maxVP + i;
> +             sc[2] = 100 + i;
> +             sc[3] = 100 + maxVP + i;
> +             glGetIntegeri_v(GL_SCISSOR_BOX, i, scGet);
> +             if (sc[0] != scGet[0]) {
> +                     pass = false;
> +                     printf("scissor left value wrong for idx %d, got %d\n",
> +                            i, scGet[0]);
> +             }
> +             if (sc[1] != scGet[1]) {
> +                     pass = false;
> +                     printf("scissor bottom value wrong for idx %d, got 
> %d\n",
> +                            i, scGet[1]);
> +             }
> +             if (sc[2] != scGet[2]) {
> +                     pass = false;
> +                     printf("scissor width value wrong for idx %d, got %d\n",
> +                            i, scGet[2]);
> +             }
> +             if (sc[3] != scGet[3]) {
> +                     pass = false;
> +                     printf("scissor height value wrong for idx %d, got 
> %d\n",
> +                            i, scGet[3]);
> +             }

I think I'd do all of these blocks as

        if (memcmp(sc, scGet, sizeof(sc)) != 0) {
            pass = false;
            printf("scissor %d expected { %d %d %d %d } but got { %d %d %d %d 
}",
                   ...);
        }

With those few things changed, this patch is

Reviewed-by: Ian Romanick <[email protected]>

> +     }
> +
> +     pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
> +     piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
> +}
> 

_______________________________________________
Piglit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/piglit

Reply via email to