[Piglit] [PATCH 2/7] Cleanup occlusion-query test to not require function pointers.

Carl Worth cworth at cworth.org
Fri Dec 21 17:18:48 PST 2012


With the current piglit dispatch code, the distinction between things
like glBeginQuery and glBeginQueryARB is taken care of already so the
test can be simplified a bit.
---
 tests/spec/arb_occlusion_query/occlusion_query.c |   38 +++++++---------------
 1 file changed, 11 insertions(+), 27 deletions(-)

diff --git a/tests/spec/arb_occlusion_query/occlusion_query.c b/tests/spec/arb_occlusion_query/occlusion_query.c
index ba35ed0..f37dd46 100644
--- a/tests/spec/arb_occlusion_query/occlusion_query.c
+++ b/tests/spec/arb_occlusion_query/occlusion_query.c
@@ -43,12 +43,6 @@ PIGLIT_GL_TEST_CONFIG_END
 
 #define MAX_QUERIES 5
 static GLuint occ_queries[MAX_QUERIES];
-static PFNGLGENQUERIESPROC gen_queries = NULL;
-static PFNGLBEGINQUERYPROC begin_query = NULL;
-static PFNGLENDQUERYPROC end_query = NULL;
-static PFNGLGETQUERYIVPROC get_queryiv = NULL;
-static PFNGLGETQUERYOBJECTIVPROC get_query_objectiv = NULL;
-
 
 static void draw_box(float x, float y, float z, float w, float h)
 {
@@ -113,15 +107,15 @@ static int do_test(float x, int all_at_once)
 	draw_box(x + 20.0f, 20.0f, 0.0f, 55.0f, 55.0f);
 
 	for (i = 0; i < MAX_QUERIES; i++) {
-		(*begin_query)(GL_SAMPLES_PASSED, occ_queries[i]);
+		glBeginQuery(GL_SAMPLES_PASSED, occ_queries[i]);
 		glColor3ubv(tests[i].color);
 		draw_box(x + tests[i].x, tests[i].y, tests[i].z,
 			 tests[i].w, tests[i].h);
-		(*end_query)(GL_SAMPLES_PASSED);
+		glEndQuery(GL_SAMPLES_PASSED);
 
 		if (! all_at_once) {
-			(*get_query_objectiv)(occ_queries[i],
-					      GL_QUERY_RESULT, &passed);
+			glGetQueryObjectiv(occ_queries[i],
+					   GL_QUERY_RESULT, &passed);
 			test_pass &= check_result(passed, tests[i].expected);
 		}
 	}
@@ -129,8 +123,8 @@ static int do_test(float x, int all_at_once)
 
 	if (all_at_once) {
 		for (i = 0; i < MAX_QUERIES; i++) {
-			(*get_query_objectiv)(occ_queries[i], GL_QUERY_RESULT,
-					      &passed);
+			glGetQueryObjectiv(occ_queries[i], GL_QUERY_RESULT,
+					   &passed);
 			test_pass &= check_result(passed, tests[i].expected);
 		}
 	}
@@ -167,19 +161,9 @@ piglit_init(int argc, char **argv)
 	glDepthFunc(GL_LESS);
 
 
-	if (piglit_get_gl_version() >= 15) {
-		gen_queries = glGenQueries;
-		begin_query = glBeginQuery;
-		end_query = glEndQuery;
-		get_queryiv = glGetQueryiv;
-		get_query_objectiv = glGetQueryObjectiv;
-	} else if (piglit_is_extension_supported("GL_ARB_occlusion_query")) {
-		gen_queries = glGenQueriesARB;
-		begin_query = glBeginQueryARB;
-		end_query = glEndQueryARB;
-		get_queryiv = glGetQueryivARB;
-		get_query_objectiv = glGetQueryObjectivARB;
-	} else {
+	if (piglit_get_gl_version() < 15 &&
+	    ! piglit_is_extension_supported("GL_ARB_occlusion_query"))
+	{
 		piglit_report_result(PIGLIT_SKIP);
 	}
 
@@ -188,12 +172,12 @@ piglit_init(int argc, char **argv)
 	 * any query bits.  I wonder how many applications actually check for
 	 * this case...
 	 */
-	(*get_queryiv)(GL_SAMPLES_PASSED, GL_QUERY_COUNTER_BITS,
+	glGetQueryiv(GL_SAMPLES_PASSED, GL_QUERY_COUNTER_BITS,
 		       & query_bits);
 	if (query_bits == 0) {
 		piglit_report_result(PIGLIT_SKIP);
 	}
 
 
-	(*gen_queries)(MAX_QUERIES, occ_queries);
+	glGenQueries(MAX_QUERIES, occ_queries);
 }
-- 
1.7.10.4



More information about the Piglit mailing list