[Piglit] [PATCH] Add new test for calling glGenQueries/glDeleteQueries with an active query

Carl Worth cworth at cworth.org
Thu Oct 17 20:14:35 CEST 2013


It is legal to gen and delete a new object while another object is active.

It is also legal to delete the currently active object.

Ensure that both of these operations can be performed without any error.
---
 tests/all.tests                                    |  1 +
 tests/spec/ext_timer_query/CMakeLists.gl.txt       |  1 +
 .../spec/ext_timer_query/gen-delete-while-active.c | 92 ++++++++++++++++++++++
 3 files changed, 94 insertions(+)
 create mode 100644 tests/spec/ext_timer_query/gen-delete-while-active.c

diff --git a/tests/all.tests b/tests/all.tests
index c919f19..c8b2b31 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -2176,6 +2176,7 @@ arb_timer_query = Group()
 spec['ARB_timer_query'] = arb_timer_query
 arb_timer_query['query GL_TIMESTAMP'] = concurrent_test('ext_timer_query-time-elapsed timestamp')
 arb_timer_query['query-lifetime'] = concurrent_test('ext_timer_query-lifetime')
+arb_timer_query['gen-delete-while-active'] = concurrent_test('ext_timer_query-gen-delete-while-active')
 arb_timer_query['timestamp-get'] = concurrent_test('arb_timer_query-timestamp-get')
 
 ext_transform_feedback = Group()
diff --git a/tests/spec/ext_timer_query/CMakeLists.gl.txt b/tests/spec/ext_timer_query/CMakeLists.gl.txt
index f7019ad..8d4a452 100644
--- a/tests/spec/ext_timer_query/CMakeLists.gl.txt
+++ b/tests/spec/ext_timer_query/CMakeLists.gl.txt
@@ -14,3 +14,4 @@ IF (UNIX)
 ENDIF (UNIX)
 
  piglit_add_executable (ext_timer_query-lifetime lifetime.c)
+ piglit_add_executable (ext_timer_query-gen-delete-while-active gen-delete-while-active.c)
diff --git a/tests/spec/ext_timer_query/gen-delete-while-active.c b/tests/spec/ext_timer_query/gen-delete-while-active.c
new file mode 100644
index 0000000..7a87f90
--- /dev/null
+++ b/tests/spec/ext_timer_query/gen-delete-while-active.c
@@ -0,0 +1,92 @@
+/*
+ * Copyright © 2009,2012,2013 Intel Corporation
+ *
+ * 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.
+ *
+ * Authors:
+ *    Ian Romanick <ian.d.romanick at intel.com>
+ *    Carl Worth <cworth at cworth.org>
+ */
+
+/**
+ * \file gen-delete-while-active.c
+ *
+ * Ensure that both glGenQueries and glDeleteQuery can be called on a
+ * new object while another query object is active. Also, that
+ * glDeleteQuery can be called on an active query object.
+ */
+
+#include "piglit-util-gl-common.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_compat_version = 10;
+
+	config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_DEPTH;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+enum piglit_result
+piglit_display(void)
+{
+	GLuint active, inactive;
+	GLint elapsed, done;
+
+	piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
+	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+	/* Generate and start a query. */
+	glGenQueries(1, &active);
+
+	glBeginQuery(GL_TIME_ELAPSED, active);
+
+	/* While first query is active, gen a new one. */
+	glGenQueries(1, &inactive);
+
+	/* Delete the inactive query. */
+	glDeleteQueries(1, &inactive);
+	
+	/* Finish and get result from active query. */
+	glEndQuery(GL_TIME_ELAPSED);
+
+	do {
+		glGetQueryObjectiv(active, GL_QUERY_RESULT_AVAILABLE, &done);
+	} while (! done);
+
+	glGetQueryObjectiv(active, GL_QUERY_RESULT, &elapsed);
+
+	/* Finally, ensure that an active query can be deleted. */
+	glGenQueries(1, &active);
+
+	glBeginQuery(GL_TIME_ELAPSED, active);
+
+	glDeleteQueries(1, &active);
+
+	if (piglit_check_gl_error(GL_NO_ERROR))
+		return PIGLIT_PASS;
+	else
+		return PIGLIT_FAIL;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+	piglit_require_extension("GL_ARB_timer_query");
+}
-- 
1.8.4.rc3



More information about the Piglit mailing list