On 10/17/2013 12:14 PM, Carl Worth wrote:
It is legal to gen and delete a new object while another object is active.

s/object/query/ ??



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 <[email protected]>
+ *    Carl Worth <[email protected]>
+ */
+
+/**
+ * \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;

You could drop the DOUBLE, DEPTH flags.


+
+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);

Could drop those lines since we're not drawing anything.


+
+       /* 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);

pilgit_check_gl_error() here?


+
+       /* Delete the inactive query. */
+       glDeleteQueries(1, &inactive);

pilgit_check_gl_error() here?


+       
+       /* Finish and get result from active query. */
+       glEndQuery(GL_TIME_ELAPSED);
+
+       do {
+               glGetQueryObjectiv(active, GL_QUERY_RESULT_AVAILABLE, &done);
+       } while (! done);

You don't need the loop since querying GL_QUERY_RESULT waits until the result is ready.


+
+       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;

This is where I added a call to glEndQuery() and valgrind found an invalid pointer.

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.

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.


+}
+
+void
+piglit_init(int argc, char **argv)
+{
+       piglit_require_extension("GL_ARB_timer_query");
+}


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).

-Brian

_______________________________________________
Piglit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/piglit

Reply via email to