[Mesa-dev] [PATCH] egl-nok-swap-region: probe front not back buffer
Robert Bragg
robert at sixbynine.org
Thu Sep 20 09:16:30 PDT 2012
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.
---
I've tweaked the style of this patch, compared to my last, to use the
ARRAY_SIZE macro instead of a sentinel array, as suggested by Brian.
tests/egl/egl-nok-swap-region.c | 37 +++++++++++++++++++++++++++++++------
1 files changed, 31 insertions(+), 6 deletions(-)
diff --git a/tests/egl/egl-nok-swap-region.c b/tests/egl/egl-nok-swap-region.c
index 9124161..b32bec9 100644
--- a/tests/egl/egl-nok-swap-region.c
+++ b/tests/egl/egl-nok-swap-region.c
@@ -40,12 +40,33 @@ 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 },
+ };
+ PFNEGLSWAPBUFFERSREGIONNOK swap_buffers_region;
int i;
swap_buffers_region = (PFNEGLSWAPBUFFERSREGIONNOK)
@@ -64,9 +85,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; i < ARRAY_SIZE(probes); i++)
+ if (!egl_probe_front_pixel_rgb(state,
+ probes[i].x,
+ probes[i].y,
+ probes[i].expected))
return PIGLIT_FAIL;
return PIGLIT_PASS;
--
1.7.7.6
More information about the mesa-dev
mailing list