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

Carl Worth cworth at cworth.org
Mon Oct 28 18:59:43 CET 2013


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

It is also legal to delete the currently active object.

Ensure that both of these operations can be performed without any error,
(as well as ensuring that glEndQuery on a deleted query does generate
an error).
---

Brian Paul <brianp at vmware.com> writes:
> On 10/17/2013 12:14 PM, Carl Worth wrote:
> This is where I added  a call to glEndQuery() and valgrind found an 
> invalid pointer.

Thanks for the catch. I verified that problem myself, and also verified
that your suggested improvement for the Mesa change fixes the problem.

I've also incorporated all of your other suggested improvements to this
test.

> BTW, I'd expect that a glEndQuery() call here would generate an error 
> since we're calling glEndQuery() for a query object that was just
> deleted.

Yes. I expect the same. I've written the test to ensure that.

> The GL 4 man page says " GL_INVALID_OPERATION is generated if glEndQuery 
> is executed when a query object of the same target is not active."
>
> But I get no error with NVIDIA's driver.  I haven't check the GL 4.x 
> specs.  Maybe you can dig into that a bit.

The 4.4 specification is quite clear. In section 4.2 and in the list of
errors for glEndQuery:

	An INVALID_OPERATION error is generated if the active query
	object name for target and index is zero.

> Can you change the test to use GL_ARB_occlusion_query instead?  Timer 
> queries aren't supported in as many drivers (such as the svga driver).

Also done.

-Carl

 tests/all.tests                                    |   1 +
 tests/spec/arb_occlusion_query/CMakeLists.gl.txt   |   1 +
 .../arb_occlusion_query/gen_delete_while_active.c  | 107 +++++++++++++++++++++
 3 files changed, 109 insertions(+)
 create mode 100644 tests/spec/arb_occlusion_query/gen_delete_while_active.c

diff --git a/tests/all.tests b/tests/all.tests
index 4bfdcea..22c3a84 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -1373,6 +1373,7 @@ add_concurrent_test(arb_occlusion_query, 'occlusion_query_lifetime')
 add_concurrent_test(arb_occlusion_query, 'occlusion_query_meta_fragments')
 add_concurrent_test(arb_occlusion_query, 'occlusion_query_meta_no_fragments')
 add_concurrent_test(arb_occlusion_query, 'occlusion_query_order')
+add_concurrent_test(arb_occlusion_query, 'gen_delete_while_active')
 
 # Group ARB_separate_shader_objects
 arb_separate_shader_objects = Group()
diff --git a/tests/spec/arb_occlusion_query/CMakeLists.gl.txt b/tests/spec/arb_occlusion_query/CMakeLists.gl.txt
index 30fb519..188f07d 100644
--- a/tests/spec/arb_occlusion_query/CMakeLists.gl.txt
+++ b/tests/spec/arb_occlusion_query/CMakeLists.gl.txt
@@ -14,3 +14,4 @@ piglit_add_executable (occlusion_query_lifetime occlusion_query_lifetime.c)
 piglit_add_executable (occlusion_query_meta_no_fragments occlusion_query_meta_no_fragments.c)
 piglit_add_executable (occlusion_query_meta_fragments occlusion_query_meta_fragments.c)
 piglit_add_executable (occlusion_query_order occlusion_query_order.c)
+piglit_add_executable (gen_delete_while_active gen_delete_while_active.c)
diff --git a/tests/spec/arb_occlusion_query/gen_delete_while_active.c b/tests/spec/arb_occlusion_query/gen_delete_while_active.c
new file mode 100644
index 0000000..715580d
--- /dev/null
+++ b/tests/spec/arb_occlusion_query/gen_delete_while_active.c
@@ -0,0 +1,107 @@
+/*
+ * 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_TEST_CONFIG_END
+
+enum piglit_result
+piglit_display(void)
+{
+	GLuint active, inactive;
+	GLint elapsed, done;
+ 
+	/* Generate and start a query. */
+	glGenQueries(1, &active);
+
+	glBeginQuery(GL_SAMPLES_PASSED, active);
+
+	printf ("Testing Gen/Delete of query while another query is active.\n");
+	{
+		/* While first query is active, gen a new one. */
+		glGenQueries(1, &inactive);
+
+		if (!piglit_check_gl_error(GL_NO_ERROR))
+			return PIGLIT_FAIL;
+
+		/* Delete the inactive query. */
+		glDeleteQueries(1, &inactive);
+
+		if (!piglit_check_gl_error(GL_NO_ERROR))
+			return PIGLIT_FAIL;
+
+		/* Finish and get result from active query. */
+		glEndQuery(GL_SAMPLES_PASSED);
+
+		glGetQueryObjectiv(active, GL_QUERY_RESULT, &elapsed);
+	}
+
+	printf ("Testing Delete of currently-active query.\n");
+	{
+		/* Finally, ensure that an active query can be deleted. */
+		glGenQueries(1, &active);
+
+		glBeginQuery(GL_SAMPLES_PASSED, active);
+
+		glDeleteQueries(1, &active);
+
+		if (!piglit_check_gl_error(GL_NO_ERROR))
+			return PIGLIT_FAIL;
+	}
+
+	printf ("Testing that glEndQuery on deleted query (expecting error).\n");
+	{
+		/* And ensure that we get an error if we try to end a deleted
+		 * query. */
+		glEndQuery(GL_SAMPLES_PASSED);
+
+		if (!piglit_check_gl_error(GL_INVALID_OPERATION))
+			return PIGLIT_FAIL;
+	}
+
+	return PIGLIT_PASS;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+	piglit_require_extension("GL_ARB_occlusion_query");
+}
-- 
1.8.4.rc3

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20131028/938a5158/attachment.pgp>


More information about the Piglit mailing list