These tests does a lot of common operations, so let's factor those out into dedicated helpers. This will help us port these tests to gles.
Signed-off-by: Erik Faye-Lund <erik.faye-l...@collabora.com> --- .../nv_conditional_render/CMakeLists.gl.txt | 14 ++++---- .../begin-while-active.c | 5 +-- tests/spec/nv_conditional_render/bitmap.c | 9 ++--- .../nv_conditional_render/blitframebuffer.c | 5 +-- tests/spec/nv_conditional_render/clear.c | 9 ++--- tests/spec/nv_conditional_render/common.c | 35 +++++++++++++++++++ tests/spec/nv_conditional_render/common.h | 17 +++++++++ tests/spec/nv_conditional_render/copypixels.c | 9 ++--- .../spec/nv_conditional_render/copyteximage.c | 5 +-- .../nv_conditional_render/copytexsubimage.c | 5 +-- tests/spec/nv_conditional_render/dlist.c | 9 ++--- tests/spec/nv_conditional_render/drawpixels.c | 9 ++--- .../nv_conditional_render/generatemipmap.c | 5 +-- .../spec/nv_conditional_render/vertex_array.c | 9 ++--- 14 files changed, 84 insertions(+), 61 deletions(-) diff --git a/tests/spec/nv_conditional_render/CMakeLists.gl.txt b/tests/spec/nv_conditional_render/CMakeLists.gl.txt index 0f24564d4..6a32a3248 100644 --- a/tests/spec/nv_conditional_render/CMakeLists.gl.txt +++ b/tests/spec/nv_conditional_render/CMakeLists.gl.txt @@ -8,15 +8,15 @@ link_libraries ( ${OPENGL_gl_LIBRARY} ) -piglit_add_executable (nv_conditional_render-begin-while-active begin-while-active.c) +piglit_add_executable (nv_conditional_render-begin-while-active begin-while-active.c common.c) piglit_add_executable (nv_conditional_render-begin-zero begin-zero.c) -piglit_add_executable (nv_conditional_render-bitmap bitmap.c) +piglit_add_executable (nv_conditional_render-bitmap bitmap.c common.c) piglit_add_executable (nv_conditional_render-blitframebuffer blitframebuffer.c common.c) -piglit_add_executable (nv_conditional_render-clear clear.c) -piglit_add_executable (nv_conditional_render-copypixels copypixels.c) +piglit_add_executable (nv_conditional_render-clear clear.c common.c) +piglit_add_executable (nv_conditional_render-copypixels copypixels.c common.c) piglit_add_executable (nv_conditional_render-copyteximage copyteximage.c common.c) piglit_add_executable (nv_conditional_render-copytexsubimage copytexsubimage.c common.c) -piglit_add_executable (nv_conditional_render-dlist dlist.c) -piglit_add_executable (nv_conditional_render-drawpixels drawpixels.c) +piglit_add_executable (nv_conditional_render-dlist dlist.c common.c) +piglit_add_executable (nv_conditional_render-drawpixels drawpixels.c common.c) piglit_add_executable (nv_conditional_render-generatemipmap generatemipmap.c common.c) -piglit_add_executable (nv_conditional_render-vertex_array vertex_array.c) +piglit_add_executable (nv_conditional_render-vertex_array vertex_array.c common.c) diff --git a/tests/spec/nv_conditional_render/begin-while-active.c b/tests/spec/nv_conditional_render/begin-while-active.c index 821544113..8a21243eb 100644 --- a/tests/spec/nv_conditional_render/begin-while-active.c +++ b/tests/spec/nv_conditional_render/begin-while-active.c @@ -22,6 +22,7 @@ */ #include "piglit-util-gl.h" +#include "common.h" /** * @file begin-while-active.c @@ -62,11 +63,11 @@ piglit_init(int argc, char **argv) piglit_require_extension("GL_NV_conditional_render"); glGenQueries(1, &q); - glBeginQuery(GL_SAMPLES_PASSED, q); + begin_query(q); glBeginConditionalRenderNV(q, GL_QUERY_WAIT_NV); if (!piglit_check_gl_error(GL_INVALID_OPERATION)) piglit_report_result(PIGLIT_FAIL); - glEndQuery(GL_SAMPLES_PASSED); + end_query(); glDeleteQueries(1, &q); piglit_report_result(PIGLIT_PASS); diff --git a/tests/spec/nv_conditional_render/bitmap.c b/tests/spec/nv_conditional_render/bitmap.c index e3954c919..2c0bd8e48 100644 --- a/tests/spec/nv_conditional_render/bitmap.c +++ b/tests/spec/nv_conditional_render/bitmap.c @@ -22,6 +22,7 @@ */ #include "piglit-util-gl.h" +#include "common.h" /** * @file bitmap.c @@ -67,9 +68,7 @@ piglit_display(void) /* Generate query pass: draw top half of screen. */ glColor4f(0.0, 1.0, 0.0, 0.0); - glBeginQuery(GL_SAMPLES_PASSED, q); - piglit_draw_rect(-1, 0, 2, 1); - glEndQuery(GL_SAMPLES_PASSED); + query_rect_top(q); /* Conditional render that should draw the whole screen. */ glBeginConditionalRenderNV(q, GL_QUERY_WAIT_NV); @@ -77,9 +76,7 @@ piglit_display(void) glBitmap(piglit_width, piglit_height, 0, 0, 0, 0, buf); glEndConditionalRenderNV(); - /* Generate query fail */ - glBeginQuery(GL_SAMPLES_PASSED, q); - glEndQuery(GL_SAMPLES_PASSED); + fail_query(q); /* Conditional render that should not draw full screen. */ glBeginConditionalRenderNV(q, GL_QUERY_WAIT_NV); diff --git a/tests/spec/nv_conditional_render/blitframebuffer.c b/tests/spec/nv_conditional_render/blitframebuffer.c index 062af4d48..9a981d45e 100644 --- a/tests/spec/nv_conditional_render/blitframebuffer.c +++ b/tests/spec/nv_conditional_render/blitframebuffer.c @@ -87,10 +87,7 @@ piglit_display(void) fill_tex(0, piglit_width, piglit_height / 2, green_ub); glGenQueries(1, &q); - - /* Generate query fail. */ - glBeginQuery(GL_SAMPLES_PASSED, q); - glEndQuery(GL_SAMPLES_PASSED); + fail_query(q); /* BlitFramebuffer() should be affected by conditional rendering. */ glBeginConditionalRenderNV(q, GL_QUERY_WAIT_NV); diff --git a/tests/spec/nv_conditional_render/clear.c b/tests/spec/nv_conditional_render/clear.c index 288239d06..ad8169d3f 100644 --- a/tests/spec/nv_conditional_render/clear.c +++ b/tests/spec/nv_conditional_render/clear.c @@ -22,6 +22,7 @@ */ #include "piglit-util-gl.h" +#include "common.h" /** * @file clear.c @@ -62,9 +63,7 @@ piglit_display(void) /* Generate query pass: draw top half of screen. */ glColor4f(0.0, 1.0, 0.0, 0.0); - glBeginQuery(GL_SAMPLES_PASSED, q); - piglit_draw_rect(-1, 0, 2, 1); - glEndQuery(GL_SAMPLES_PASSED); + query_rect_top(q); /* Conditional render that should draw bottom half of screen. */ glBeginConditionalRenderNV(q, GL_QUERY_WAIT_NV); @@ -72,9 +71,7 @@ piglit_display(void) glClear(GL_COLOR_BUFFER_BIT); glEndConditionalRenderNV(); - /* Generate query fail */ - glBeginQuery(GL_SAMPLES_PASSED, q); - glEndQuery(GL_SAMPLES_PASSED); + fail_query(q); /* Conditional render that should not draw full screen. */ glBeginConditionalRenderNV(q, GL_QUERY_WAIT_NV); diff --git a/tests/spec/nv_conditional_render/common.c b/tests/spec/nv_conditional_render/common.c index b183bfb36..b29a6bf6d 100644 --- a/tests/spec/nv_conditional_render/common.c +++ b/tests/spec/nv_conditional_render/common.c @@ -42,3 +42,38 @@ fill_tex(int level, int w, int h, const unsigned char *color) GL_RGBA, GL_UNSIGNED_BYTE, data); free(data); } + +void +begin_query(GLuint id) +{ + glBeginQuery(GL_SAMPLES_PASSED, id); +} + +void +end_query() +{ + glEndQuery(GL_SAMPLES_PASSED); +} + +void +fail_query(GLuint id) +{ + begin_query(id); + end_query(); +} + +void +query_rect_top(GLuint id) +{ + begin_query(id); + piglit_draw_rect(-1, 0, 2, 1); + end_query(); +} + +void +query_rect_bottom(GLuint id) +{ + begin_query(id); + piglit_draw_rect(-1, -1, 2, 1); + end_query(); +} diff --git a/tests/spec/nv_conditional_render/common.h b/tests/spec/nv_conditional_render/common.h index 30a9f680f..752d3eb34 100644 --- a/tests/spec/nv_conditional_render/common.h +++ b/tests/spec/nv_conditional_render/common.h @@ -25,7 +25,24 @@ #ifndef COMMON_H #define COMMON_H +#include "piglit-util-gl.h" + void fill_tex(int level, int w, int h, const unsigned char *color); +void +begin_query(GLuint id); + +void +end_query(); + +void +fail_query(GLuint id); + +void +query_rect_top(GLuint id); + +void +query_rect_bottom(GLuint id); + #endif /* COMMON_H */ diff --git a/tests/spec/nv_conditional_render/copypixels.c b/tests/spec/nv_conditional_render/copypixels.c index 6bb3ff8a8..92c65a207 100644 --- a/tests/spec/nv_conditional_render/copypixels.c +++ b/tests/spec/nv_conditional_render/copypixels.c @@ -22,6 +22,7 @@ */ #include "piglit-util-gl.h" +#include "common.h" /** * @file copypixels.c @@ -63,13 +64,9 @@ piglit_display(void) /* Generate query pass: draw top half of screen. */ glColor4f(0.0, 1.0, 0.0, 0.0); - glBeginQuery(GL_SAMPLES_PASSED, qpass); - piglit_draw_rect(-1, 0, 2, 1); - glEndQuery(GL_SAMPLES_PASSED); + query_rect_top(qpass); - /* Generate query fail */ - glBeginQuery(GL_SAMPLES_PASSED, qfail); - glEndQuery(GL_SAMPLES_PASSED); + fail_query(qfail); /* Conditional render that should not copy red over the green. */ glBeginConditionalRenderNV(qfail, GL_QUERY_WAIT_NV); diff --git a/tests/spec/nv_conditional_render/copyteximage.c b/tests/spec/nv_conditional_render/copyteximage.c index 99e7ba449..8d167e47e 100644 --- a/tests/spec/nv_conditional_render/copyteximage.c +++ b/tests/spec/nv_conditional_render/copyteximage.c @@ -71,10 +71,7 @@ piglit_display(void) fill_tex(0, piglit_width, piglit_height / 2, red); glGenQueries(1, &q); - - /* Generate query fail. */ - glBeginQuery(GL_SAMPLES_PASSED, q); - glEndQuery(GL_SAMPLES_PASSED); + fail_query(q); /* This should not be affected by conditional rendering. */ glBeginConditionalRenderNV(q, GL_QUERY_WAIT_NV); diff --git a/tests/spec/nv_conditional_render/copytexsubimage.c b/tests/spec/nv_conditional_render/copytexsubimage.c index 71bf66b56..043b3b5ba 100644 --- a/tests/spec/nv_conditional_render/copytexsubimage.c +++ b/tests/spec/nv_conditional_render/copytexsubimage.c @@ -71,10 +71,7 @@ piglit_display(void) fill_tex(0, piglit_width*2, piglit_height / 2, red); glGenQueries(1, &q); - - /* Generate query fail. */ - glBeginQuery(GL_SAMPLES_PASSED, q); - glEndQuery(GL_SAMPLES_PASSED); + fail_query(q); /* This should not be affected by conditional rendering. */ glBeginConditionalRenderNV(q, GL_QUERY_WAIT_NV); diff --git a/tests/spec/nv_conditional_render/dlist.c b/tests/spec/nv_conditional_render/dlist.c index d322c1c5d..85dc3f73f 100644 --- a/tests/spec/nv_conditional_render/dlist.c +++ b/tests/spec/nv_conditional_render/dlist.c @@ -22,6 +22,7 @@ */ #include "piglit-util-gl.h" +#include "common.h" /** * @file dlist.c @@ -55,18 +56,14 @@ piglit_display(void) /* Generate query pass: draw bottom half of screen. */ glColor4f(0.0, 1.0, 0.0, 0.0); - glBeginQuery(GL_SAMPLES_PASSED, q); - piglit_draw_rect(-1, -1, 2, 1); - glEndQuery(GL_SAMPLES_PASSED); + query_rect_bottom(q); /* Conditional render that should draw top half of screen. */ glBeginConditionalRenderNV(q, GL_QUERY_WAIT_NV); piglit_draw_rect(-1, 0, 2, 1); glEndConditionalRenderNV(); - /* Generate query fail */ - glBeginQuery(GL_SAMPLES_PASSED, q); - glEndQuery(GL_SAMPLES_PASSED); + fail_query(q); /* Conditional render that should not draw full screen. */ glBeginConditionalRenderNV(q, GL_QUERY_WAIT_NV); diff --git a/tests/spec/nv_conditional_render/drawpixels.c b/tests/spec/nv_conditional_render/drawpixels.c index ce32b8e1b..f99ad3058 100644 --- a/tests/spec/nv_conditional_render/drawpixels.c +++ b/tests/spec/nv_conditional_render/drawpixels.c @@ -22,6 +22,7 @@ */ #include "piglit-util-gl.h" +#include "common.h" /** * @file drawpixels.c @@ -66,9 +67,7 @@ piglit_display(void) /* Generate query pass: draw top half of screen. */ glColor4f(0.0, 1.0, 0.0, 0.0); - glBeginQuery(GL_SAMPLES_PASSED, q); - piglit_draw_rect(-1, 0, 2, 1); - glEndQuery(GL_SAMPLES_PASSED); + query_rect_top(q); /* Conditional render that should draw bottom half of screen. */ for (i = 0; i < piglit_width * piglit_height / 2; i++) { @@ -82,9 +81,7 @@ piglit_display(void) glDrawPixels(piglit_width, piglit_height / 2, GL_RGBA, GL_FLOAT, buf); glEndConditionalRenderNV(); - /* Generate query fail */ - glBeginQuery(GL_SAMPLES_PASSED, q); - glEndQuery(GL_SAMPLES_PASSED); + fail_query(q); /* Conditional render that should not draw full screen. */ for (i = 0; i < piglit_width * piglit_height; i++) { diff --git a/tests/spec/nv_conditional_render/generatemipmap.c b/tests/spec/nv_conditional_render/generatemipmap.c index 1e148e5f8..f6516a450 100644 --- a/tests/spec/nv_conditional_render/generatemipmap.c +++ b/tests/spec/nv_conditional_render/generatemipmap.c @@ -78,10 +78,7 @@ piglit_display(void) } glGenQueries(1, &q); - - /* Generate query fail. */ - glBeginQuery(GL_SAMPLES_PASSED, q); - glEndQuery(GL_SAMPLES_PASSED); + fail_query(q); /* Mipmap generation should not be affected by conditional rendering. */ glBeginConditionalRenderNV(q, GL_QUERY_WAIT_NV); diff --git a/tests/spec/nv_conditional_render/vertex_array.c b/tests/spec/nv_conditional_render/vertex_array.c index 4c5ed25f9..51a2aae27 100644 --- a/tests/spec/nv_conditional_render/vertex_array.c +++ b/tests/spec/nv_conditional_render/vertex_array.c @@ -22,6 +22,7 @@ */ #include "piglit-util-gl.h" +#include "common.h" /** * @file vertex_array.c @@ -63,18 +64,14 @@ piglit_display(void) /* Generate query pass: draw bottom half of screen. */ glColor4f(0.0, 1.0, 0.0, 0.0); - glBeginQuery(GL_SAMPLES_PASSED, q); - piglit_draw_rect(-1, -1, 2, 1); - glEndQuery(GL_SAMPLES_PASSED); + query_rect_bottom(q); /* Conditional render that should draw top half of screen. */ glBeginConditionalRenderNV(q, GL_QUERY_WAIT_NV); piglit_draw_rect(-1, 0, 2, 1); glEndConditionalRenderNV(); - /* Generate query fail */ - glBeginQuery(GL_SAMPLES_PASSED, q); - glEndQuery(GL_SAMPLES_PASSED); + fail_query(q); /* Conditional render that should not draw full screen. */ glBeginConditionalRenderNV(q, GL_QUERY_WAIT_NV); -- 2.19.1 _______________________________________________ Piglit mailing list Piglit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/piglit