[Piglit] [PATCH 7/7] Add occlusion-query tests for various meta operations.
Carl Worth
cworth at cworth.org
Fri Dec 21 17:18:53 PST 2012
These tests invoke occlusion queries around the several
meta-operations implemented within mesa. They are designed to
demonstrate various bugs in the current implementation of mesa, (where
meta operations either do or do not generate fragments as specified by
the OpenGL specification).
---
tests/all.tests | 2 +
tests/spec/arb_occlusion_query/CMakeLists.gl.txt | 2 +
.../occlusion_query_meta_fragments.c | 145 +++++++++++++++
.../occlusion_query_meta_no_fragments.c | 190 ++++++++++++++++++++
4 files changed, 339 insertions(+)
create mode 100644 tests/spec/arb_occlusion_query/occlusion_query_meta_fragments.c
create mode 100644 tests/spec/arb_occlusion_query/occlusion_query_meta_no_fragments.c
diff --git a/tests/all.tests b/tests/all.tests
index 6ad2a1d..5505072 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -1014,6 +1014,8 @@ arb_occlusion_query = Group()
spec['ARB_occlusion_query'] = arb_occlusion_query
add_plain_test(arb_occlusion_query, 'occlusion_query')
add_plain_test(arb_occlusion_query, 'occlusion_query_lifetime')
+add_plain_test(arb_occlusion_query, 'occlusion_query_meta_fragments')
+add_plain_test(arb_occlusion_query, 'occlusion_query_meta_no_fragments')
add_plain_test(arb_occlusion_query, 'occlusion_query_order')
# Group ARB_sampler_objects
diff --git a/tests/spec/arb_occlusion_query/CMakeLists.gl.txt b/tests/spec/arb_occlusion_query/CMakeLists.gl.txt
index 0878f78..30fb519 100644
--- a/tests/spec/arb_occlusion_query/CMakeLists.gl.txt
+++ b/tests/spec/arb_occlusion_query/CMakeLists.gl.txt
@@ -11,4 +11,6 @@ link_libraries (
piglit_add_executable (occlusion_query occlusion_query.c)
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)
diff --git a/tests/spec/arb_occlusion_query/occlusion_query_meta_fragments.c b/tests/spec/arb_occlusion_query/occlusion_query_meta_fragments.c
new file mode 100644
index 0000000..d2c923d
--- /dev/null
+++ b/tests/spec/arb_occlusion_query/occlusion_query_meta_fragments.c
@@ -0,0 +1,145 @@
+/*
+ * Copyright © 2009,2012 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 occlusion_query_meta.c
+ *
+ * Verify that various operations, (potentially implemented as
+ * meta-operations within the OpenGL implementation), generate
+ * fragments as specified.
+ */
+
+#include "piglit-util-gl-common.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+ config.supports_gl_compat_version = 10;
+
+ config.window_width = 16;
+ config.window_height = 16;
+ config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_DEPTH;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+static int
+verify_fragments(GLuint query, const char *operation)
+{
+ GLint result;
+
+ glGetQueryObjectiv(query, GL_QUERY_RESULT, &result);
+
+ if (result == 0) {
+ printf("Occlusion query for %s resulted in 0 samples, (expected non-zero)\n", operation);
+ return 0;
+ }
+
+ return 1;
+}
+
+/* Draw several things that should generate fragments, each within an
+ * occlusion query. Then verify that each query returns a non-zero
+ * value.
+ */
+enum piglit_result
+piglit_display(void)
+{
+ /* 2x2 data: Red, Green, Blue, and White. */
+ float data[16] = { 1.0, 0.0, 0.0,
+ 0.0, 1.0, 0.0,
+ 0.0, 0.0, 1.0,
+ 1.0, 1.0, 1.0 };
+ GLubyte bitmap[16] = { 0x5f, 0xff, 0xff, 0xff,
+ 0xAf, 0xff, 0xff, 0xff,
+ 0x5f, 0xff, 0xff, 0xff,
+ 0xAf, 0xff, 0xff, 0xff };
+ GLuint query;
+ int test_pass = 1;
+
+ piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
+
+ glClearColor(0.0, 1.0, 0.0, 0.0);
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ glGenQueries(1, &query);
+
+ /* Fragments for glDrawPixels */
+ glBeginQuery(GL_SAMPLES_PASSED, query);
+ {
+ glRasterPos2i(2, 2);
+ glDrawPixels(2, 2, GL_RGB, GL_FLOAT, data);
+ }
+ glEndQuery(GL_SAMPLES_PASSED);
+ test_pass &= verify_fragments(query, "glDrawPixels");
+
+ /* Fragments for glCopyPixels */
+ glBeginQuery(GL_SAMPLES_PASSED, query);
+ {
+ glRasterPos2i(6, 2);
+ glCopyPixels(2, 2, 2, 2, GL_COLOR);
+ }
+ glEndQuery(GL_SAMPLES_PASSED);
+ test_pass &= verify_fragments(query, "glCopyPixels");
+
+ /* Fragments for glBitmap */
+ glBeginQuery(GL_SAMPLES_PASSED, query);
+ {
+ glRasterPos2i(10, 2);
+ glColor4f(0.0, 0.0, 1.0, 0.0);
+ glBitmap(4, 4, 0, 0, 0, 0, bitmap);
+ }
+ glEndQuery(GL_SAMPLES_PASSED);
+ test_pass &= verify_fragments(query, "glBitmap");
+
+ glDeleteQueries(1, &query);
+
+ piglit_present_results();
+
+ return test_pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+ GLint query_bits;
+
+ if (piglit_get_gl_version() < 15 &&
+ ! piglit_is_extension_supported("GL_ARB_occlusion_query"))
+ {
+ piglit_report_result(PIGLIT_SKIP);
+ }
+
+
+ /* It is legal for a driver to support the query API but not have
+ * any query bits. I wonder how many applications actually check for
+ * this case...
+ */
+ glGetQueryiv(GL_SAMPLES_PASSED, GL_QUERY_COUNTER_BITS,
+ & query_bits);
+ if (query_bits == 0) {
+ piglit_report_result(PIGLIT_SKIP);
+ }
+}
diff --git a/tests/spec/arb_occlusion_query/occlusion_query_meta_no_fragments.c b/tests/spec/arb_occlusion_query/occlusion_query_meta_no_fragments.c
new file mode 100644
index 0000000..ea976d4
--- /dev/null
+++ b/tests/spec/arb_occlusion_query/occlusion_query_meta_no_fragments.c
@@ -0,0 +1,190 @@
+/*
+ * Copyright © 2009,2012 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 occlusion_query_meta.c
+ *
+ * Verify that various operations, (potentially implemented as
+ * meta-operations within the OpenGL implementation), do not generate
+ * fragments as specified.
+ */
+
+#include "piglit-util-gl-common.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+ config.supports_gl_compat_version = 10;
+
+ config.window_width = 64;
+ config.window_height = 64;
+ config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_DEPTH;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+static int
+verify_no_fragments(GLuint query, const char *operation)
+{
+ GLint result;
+
+ glGetQueryObjectiv(query, GL_QUERY_RESULT, &result);
+
+ if (result != 0) {
+ printf("Occlusion query for %s resulted in %d samples, (expected 0)\n", operation, result);
+ return 0;
+ }
+
+ return 1;
+}
+
+/* Draw several things that should not generate fragments, each within
+ * an occlusion query. Then verify that each query returns 0.
+ */
+
+enum piglit_result
+piglit_display(void)
+{
+ /* 2x2 texture data: Red, Green, Blue, and White. */
+ float data[16] = { 1.0, 0.0, 0.0,
+ 0.0, 1.0, 0.0,
+ 0.0, 0.0, 1.0,
+ 1.0, 1.0, 1.0 };
+ GLuint texture, texture_copy, fb;
+ GLuint query;
+ int test_pass = 1;
+
+ piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
+
+ glGenQueries(1, &query);
+ glGenTextures(1, &texture);
+ glGenTextures(1, &texture_copy);
+ glBindTexture(GL_TEXTURE_2D, texture);
+ glGenFramebuffers(1, &fb);
+
+ /* No fragments for glClear */
+ glBeginQuery(GL_SAMPLES_PASSED, query);
+ {
+ glClearColor(0.0, 1.0, 0.0, 0.0);
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ }
+ glEndQuery(GL_SAMPLES_PASSED);
+ test_pass &= verify_no_fragments(query, "glClear");
+
+ /* No fragments for glGenerateMipmap */
+ glBeginQuery(GL_SAMPLES_PASSED, query);
+ {
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, 2, 2, 0,
+ GL_RGB, GL_FLOAT, data);
+
+ glGenerateMipmap(GL_TEXTURE_2D);
+ }
+ glEndQuery(GL_SAMPLES_PASSED);
+ test_pass &= verify_no_fragments(query, "glGenerateMipmap");
+
+ /* No fragments for glBlitFramebuffer */
+ glBeginQuery(GL_SAMPLES_PASSED, query);
+ {
+ glBindFramebuffer(GL_FRAMEBUFFER, fb);
+
+ glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
+ GL_COLOR_ATTACHMENT0_EXT,
+ GL_TEXTURE_2D,
+ texture,
+ 0);
+
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, fb);
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
+ glBlitFramebuffer(0, 0, 2, 2,
+ 2, 2, 20, 20,
+ GL_COLOR_BUFFER_BIT, GL_NEAREST);
+ glBindFramebuffer(GL_FRAMEBUFFER, 0);
+ }
+ glEndQuery(GL_SAMPLES_PASSED);
+ test_pass &= verify_no_fragments(query, "glBlitFramebuffer");
+
+ /* No fragments for glCopyTexImage */
+ glBeginQuery(GL_SAMPLES_PASSED, query);
+ {
+ glBindTexture(GL_TEXTURE_2D, texture_copy);
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, fb);
+ glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8,
+ 0, 0, 2, 2, 0);
+ }
+ glEndQuery(GL_SAMPLES_PASSED);
+ test_pass &= verify_no_fragments(query, "glCopyTexImage2D");
+
+ /* Paint the copied texture just ensure it worked. */
+ glEnable(GL_TEXTURE_2D);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ piglit_draw_rect_tex(22, 2, 18, 18, 0, 0, 1, 1);
+
+ /* No fragments for glCopyTexSubImage */
+ glBeginQuery(GL_SAMPLES_PASSED, query);
+ {
+ glBindTexture(GL_TEXTURE_2D, texture_copy);
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, fb);
+ glCopyTexSubImage2D(GL_TEXTURE_2D, 0,
+ 1, 1, 0, 0, 1, 1);
+ glBindFramebuffer(GL_FRAMEBUFFER, 0);
+ }
+ glEndQuery(GL_SAMPLES_PASSED);
+ test_pass &= verify_no_fragments(query, "glCopyTexImage2D");
+
+ /* Paint the copied texture just ensure it worked. */
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ piglit_draw_rect_tex(42, 2, 18, 18, 0, 0, 1, 1);
+
+ glDeleteQueries(1, &query);
+
+ piglit_present_results();
+
+ return test_pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+ GLint query_bits;
+
+ if (piglit_get_gl_version() < 15 &&
+ ! piglit_is_extension_supported("GL_ARB_occlusion_query"))
+ {
+ piglit_report_result(PIGLIT_SKIP);
+ }
+
+
+ /* It is legal for a driver to support the query API but not have
+ * any query bits. I wonder how many applications actually check for
+ * this case...
+ */
+ glGetQueryiv(GL_SAMPLES_PASSED, GL_QUERY_COUNTER_BITS,
+ & query_bits);
+ if (query_bits == 0) {
+ piglit_report_result(PIGLIT_SKIP);
+ }
+}
--
1.7.10.4
More information about the Piglit
mailing list