[Piglit] [PATCH 2/2] arb_viewport_array: Test glViewport indexed ignores invalid width/height

Ian Romanick idr at freedesktop.org
Mon Feb 24 13:45:56 PST 2014


I have all the same comments for this patch as for the previous.

On 01/23/2014 01:06 PM, Jon Ashburn wrote:
> Verify that calling glViewportArrayv, glViewportIndexed, or glViewportIndexedv
> with an invalid width (or height) in elements after the first generates
> a GL error and does not modify any of the viewports.
> ---
>   tests/spec/arb_viewport_array/CMakeLists.gl.txt |   1 +
>   tests/spec/arb_viewport_array/viewport_ignore.c | 135 ++++++++++++++++++++++++
>   2 files changed, 136 insertions(+)
>   create mode 100644 tests/spec/arb_viewport_array/viewport_ignore.c
>
> diff --git a/tests/spec/arb_viewport_array/CMakeLists.gl.txt b/tests/spec/arb_viewport_array/CMakeLists.gl.txt
> index de20d42..94a49a7 100644
> --- a/tests/spec/arb_viewport_array/CMakeLists.gl.txt
> +++ b/tests/spec/arb_viewport_array/CMakeLists.gl.txt
> @@ -10,6 +10,7 @@ link_libraries(
>   	)
>
>   piglit_add_executable(arb_viewport_array-viewport-indices viewport_indices.c)
> +piglit_add_executable(arb_viewport_array-viewport-ignore viewport_ignore.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)
> diff --git a/tests/spec/arb_viewport_array/viewport_ignore.c b/tests/spec/arb_viewport_array/viewport_ignore.c
> new file mode 100644
> index 0000000..5246849
> --- /dev/null
> +++ b/tests/spec/arb_viewport_array/viewport_ignore.c
> @@ -0,0 +1,135 @@
> +/*
> + * 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 <jon at lunarg.com>
> + */
> +
> +/**
> + * Verify that calling glViewportArrayv, glViewportIndexed, or glViewportIndexedv
> + * with an invalid width (or height) in elements after the first generates
> + * a GL error and does not modify any of the viewports.
> + */
> +#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;
> +	GLfloat vp[4], vpGet[4];
> +	GLfloat vpInvalid[MAX_INDICES][4] = {
> +		{10.0,  0.0, -10.0,  90.0},
> +		{11.0,  1.0,  90.0, -10.0},
> +		{12.0,  2.0, -90.0, -10.0},
> +		{13.0,  3.0, -70.0, -80.0},
> +		{14.0,  4.0,  80.0, -70.0},
> +		{15.0,  5.0, -70.0,  80.0},
> +		{16.0,  6.0,  15.0, -15.0},
> +		{17.0,  7.0, -15.0, -15.0},
> +		{18.0,  9.0, -15.0,  15.0},
> +		{10.0, 11.0,   0.0, -30.0},
> +		{12.0, 13.0, -30.0,   0.0},
> +		{14.0, 15.0,  60.0,  -1.0},
> +		{16.0, 17.0,  -1.0,  60.0},
> +		{ 0.0,  0.0, -60.0,  -1.0},
> +		{-1.0, -1.0,  -1.0,  -1.0},
> +		{-2.0, -2.0,   0.0,  -2.0}};
> +
> +	piglit_require_extension("GL_ARB_viewport_array");
> +
> +	glGetIntegerv(GL_MAX_VIEWPORTS, &maxVP);
> +
> +	/* intialize Viewport x, y, width, height for all indices */
> +	for (i = 0; i < maxVP; i++) {
> +		vp[0] = 0.0 + i;
> +		vp[1] = (GLfloat) maxVP + i;
> +		vp[2] = 100.0 + i;
> +		vp[3] = 100.0 + maxVP + i;
> +		glViewportIndexedfv(i, vp);
> +	}
> +	pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
> +
> +	/* set Viewport values  with illegal width or height */
> +	glViewportArrayv(0, maxVP, &(vpInvalid[0][0]));
> +	pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass;
> +	for (i = 0; i < maxVP; i++) {
> +		idx = i % MAX_INDICES;
> +		glViewportIndexedfv(i, &(vpInvalid[idx][0]));
> +		pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass;
> +		glViewportIndexedf(i, vpInvalid[idx][0], vpInvalid[idx][1],
> +				 vpInvalid[idx][2], vpInvalid[idx][3]);
> +		pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass;
> +	}
> +
> +	/* check that Viewport with invalid width/height got ignored */
> +	for (i = 0; i < maxVP; i++) {
> +		vp[0] = 0.0 + i;
> +		vp[1] = (GLfloat) maxVP + i;
> +		vp[2] = 100.0 + i;
> +		vp[3] = 100.0 + maxVP + i;
> +		glGetFloati_v(GL_VIEWPORT, i, vpGet);
> +		if (vp[0] != vpGet[0]) {
> +			pass = false;
> +			printf("Viewprt x value wrong for idx %d, got %f\n",
> +			       i, vpGet[0]);
> +		}
> +		if (vp[1] != vpGet[1]) {
> +			pass = false;
> +			printf("Viewport y value wrong for idx %d, got %f\n",
> +			       i, vpGet[1]);
> +		}
> +		if (vp[2] != vpGet[2]) {
> +			pass = false;
> +			printf("Viewport width value wrong for idx %d, got %f\n",
> +			       i, vpGet[2]);
> +		}
> +		if (vp[3] != vpGet[3]) {
> +			pass = false;
> +			printf("Viewport height value wrong for idx %d, got %f\n",
> +			       i, vpGet[3]);
> +		}
> +	}
> +
> +	pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
> +	piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
> +}
>



More information about the Piglit mailing list