[Mesa-dev] [PATCH 2/2] egl-nok-swap-region: probe front not back buffer

Brian Paul brianp at vmware.com
Thu Sep 20 07:38:27 PDT 2012


On 09/20/2012 07:21 AM, Robert Bragg wrote:
> The egl-nok-swap-buffer was mistakenly reading the back buffer to test
> the correctness of eglSwapRegionNOK but once the second glClear() to red
> has been issued the whole back buffer is red and so the test would
> always passed since it only probed points it expected to be red anyway.
>
> This patch now uses egl_probe_front_pixel_rgb to read the front buffer
> instead and in addition to checking that certain pixels should be red,
> it also checks that other pixels are still green.
> ---
>   tests/egl/egl-nok-swap-region.c |   39 +++++++++++++++++++++++++++++++++------
>   1 files changed, 33 insertions(+), 6 deletions(-)
>
> diff --git a/tests/egl/egl-nok-swap-region.c b/tests/egl/egl-nok-swap-region.c
> index 9124161..dad2750 100644
> --- a/tests/egl/egl-nok-swap-region.c
> +++ b/tests/egl/egl-nok-swap-region.c
> @@ -40,12 +40,35 @@ draw(struct egl_state *state)
>   {
>   	EGLint rects[] = {
>   		10, 10, 10, 10,
> -		20, 20, 20, 10,
> -		40, 30, 10, 20,
> +		20, 20, 20, 10, /* wide rect */
> +		40, 30, 10, 20, /* tall rect */
>   		50, 50, 10, 10
>   	};
> -	PFNEGLSWAPBUFFERSREGIONNOK swap_buffers_region;
> +	float green[] = { 0.0, 1.0, 0.0, 1.0};
>   	float red[] = { 1.0, 0.0, 0.0, 1.0};
> +	struct {
> +		int x, y;
> +		const float *expected;
> +	} probes[] = {
> +		{ 15, 15, red },
> +		{ 15, state->height - 15, green },
> +
> +		{ 25, 25, red },
> +		{ 35, 25, red },
> +		{ 25, 35, green },
> +		{ 25, state->height - 25, green },
> +
> +		{ 45, 35, red },
> +		{ 45, 45, red },
> +		{ 55, 35, green },
> +		{ 45, state->height - 35, green },
> +
> +		{ 55, 55, red },
> +		{ 55, state->height - 55, green },
> +
> +		{ 0, 0, NULL }
> +	};
> +	PFNEGLSWAPBUFFERSREGIONNOK swap_buffers_region;
>   	int i;
>
>   	swap_buffers_region = (PFNEGLSWAPBUFFERSREGIONNOK)
> @@ -64,9 +87,13 @@ draw(struct egl_state *state)
>   	glClear(GL_COLOR_BUFFER_BIT);
>   	swap_buffers_region(state->egl_dpy, state->surf, 4, rects);
>
> -	for (i = 0; i<  16; i += 4)
> -		if (!piglit_probe_pixel_rgba(rects[i] + 5,
> -					     rects[i + 1] + 5, red))
> +	glFinish();
> +
> +	for (i = 0; probes[i].expected; i ++)
> +		if (!egl_probe_front_pixel_rgb(state,
> +					       probes[i].x,
> +					       probes[i].y,
> +					       probes[i].expected))
>   			return PIGLIT_FAIL;
>
>   	return PIGLIT_PASS;

An alternative to using a sentinel value to terminate the array is to 
use the ARRAY_SIZE macro:

for (i = 0; ARRAY_SIZE(probes); i ++)


-Brian


More information about the mesa-dev mailing list