[Piglit] [PATCH 2/2] ARB_sync: Add two new tests of glClientWaitSync.
Eric Anholt
eric at anholt.net
Wed May 30 12:46:39 PDT 2012
The second one catches the failure of the intel driver to actually
implement the timeout.
---
tests/all.tests | 4 ++
tests/spec/CMakeLists.txt | 1 +
tests/spec/arb_sync/CMakeLists.gl.txt | 14 +++++
tests/spec/arb_sync/CMakeLists.txt | 1 +
tests/spec/arb_sync/repeat-wait.c | 87 +++++++++++++++++++++++++++
tests/spec/arb_sync/timeout-zero.c | 106 +++++++++++++++++++++++++++++++++
6 files changed, 213 insertions(+)
create mode 100644 tests/spec/arb_sync/CMakeLists.gl.txt
create mode 100644 tests/spec/arb_sync/CMakeLists.txt
create mode 100644 tests/spec/arb_sync/repeat-wait.c
create mode 100644 tests/spec/arb_sync/timeout-zero.c
diff --git a/tests/all.tests b/tests/all.tests
index 9c602d4..0fc3650 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -1049,6 +1049,10 @@ import_glsl_parser_tests(spec['ARB_shader_stencil_export'],
os.path.join(testsDir, 'spec', 'arb_shader_stencil_export'),
[''])
+# Group ARB_sync
+spec['ARB_sync/repeat-wait'] = concurrent_test('arb_sync-repeat-wait')
+spec['ARB_sync/timeout-zero'] = concurrent_test('arb_sync-timeout-zero')
+
# Group ARB_ES2_compatibility
arb_es2_compatibility = Group()
spec['ARB_ES2_compatibility'] = arb_es2_compatibility
diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
index a0186d3..317548a 100644
--- a/tests/spec/CMakeLists.txt
+++ b/tests/spec/CMakeLists.txt
@@ -12,6 +12,7 @@ add_subdirectory (arb_seamless_cube_map)
add_subdirectory (amd_seamless_cubemap_per_texture)
add_subdirectory (arb_shader_texture_lod/execution)
add_subdirectory (arb_shader_objects)
+add_subdirectory (arb_sync)
add_subdirectory (arb_uniform_buffer_object)
add_subdirectory (ati_draw_buffers)
add_subdirectory (arb_texture_buffer_object)
diff --git a/tests/spec/arb_sync/CMakeLists.gl.txt b/tests/spec/arb_sync/CMakeLists.gl.txt
new file mode 100644
index 0000000..f41ff52
--- /dev/null
+++ b/tests/spec/arb_sync/CMakeLists.gl.txt
@@ -0,0 +1,14 @@
+include_directories(
+ ${GLEXT_INCLUDE_DIR}
+ ${OPENGL_INCLUDE_PATH}
+ ${piglit_SOURCE_DIR}/tests/util
+)
+
+link_libraries (
+ piglitutil
+ ${OPENGL_gl_LIBRARY}
+ ${OPENGL_glu_LIBRARY}
+)
+
+piglit_add_executable (arb_sync-repeat-wait repeat-wait.c)
+piglit_add_executable (arb_sync-timeout-zero timeout-zero.c)
diff --git a/tests/spec/arb_sync/CMakeLists.txt b/tests/spec/arb_sync/CMakeLists.txt
new file mode 100644
index 0000000..144a306
--- /dev/null
+++ b/tests/spec/arb_sync/CMakeLists.txt
@@ -0,0 +1 @@
+piglit_include_target_api()
diff --git a/tests/spec/arb_sync/repeat-wait.c b/tests/spec/arb_sync/repeat-wait.c
new file mode 100644
index 0000000..8009c27
--- /dev/null
+++ b/tests/spec/arb_sync/repeat-wait.c
@@ -0,0 +1,87 @@
+/* Copyright © 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.
+ */
+
+/** @file repeat-wait.c
+ *
+ * From the GL_ARB_sync spec:
+ *
+ * "If <sync> is signaled at the time ClientWaitSync is called
+ * then ClientWaitSync returns immediately. If <sync> is
+ * unsignaled at the time ClientWaitSync is called then
+ * ClientWaitSync will block and will wait up to <timeout>
+ * nanoseconds for <sync> to become signaled.
+ *
+ * ...
+ *
+ * ALREADY_SIGNALED will always be returned if <sync> was
+ * signaled, even if the value of <timeout> is zero."
+ *
+ * There was concern that the implementation of the kernel API on i965
+ * might violate this for the specific case of back-to-back
+ * ClientWaitSyncs, but Mesa core doesn't end up calling into the
+ * driver on a later ClientWaitSync.
+ */
+
+#include "piglit-util.h"
+
+int piglit_width = 256;
+int piglit_height = 256;
+int piglit_window_mode = GLUT_DOUBLE | GLUT_RGB | GLUT_ALPHA;
+
+#define ONE_SECOND 1000000
+
+enum piglit_result
+piglit_display(void)
+{
+ /* UNREACHED */
+ return PIGLIT_FAIL;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+ GLsync sync;
+ GLenum ret1, ret2;
+
+ piglit_require_extension("GL_ARB_sync");
+
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
+
+ ret1 = glClientWaitSync(sync, GL_SYNC_FLUSH_COMMANDS_BIT, ONE_SECOND);
+ ret2 = glClientWaitSync(sync, 0, ONE_SECOND);
+
+ if (ret1 == GL_TIMEOUT_EXPIRED) {
+ printf("timeout expired on the first wait\n");
+ piglit_report_result(PIGLIT_SKIP);
+ }
+
+ if (ret2 != GL_ALREADY_SIGNALED) {
+ fprintf(stderr,
+ "Expected GL_ALREADY_SIGNALED on second wait, got %s",
+ piglit_get_gl_enum_name(ret2));
+ piglit_report_result(PIGLIT_FAIL);
+ }
+
+ piglit_report_result(PIGLIT_PASS);
+}
diff --git a/tests/spec/arb_sync/timeout-zero.c b/tests/spec/arb_sync/timeout-zero.c
new file mode 100644
index 0000000..491d14f
--- /dev/null
+++ b/tests/spec/arb_sync/timeout-zero.c
@@ -0,0 +1,106 @@
+/* Copyright © 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.
+ */
+
+/** @file repeat-wait.c
+ *
+ * From the GL_ARB_sync spec:
+ *
+ * "ALREADY_SIGNALED will always be returned if <sync> was
+ * signaled, even if the value of <timeout> is zero
+ *
+ * ...
+ *
+ * If the value of <timeout> is zero, then ClientWaitSync does
+ * not block, but simply tests the current state of
+ * <sync>. TIMEOUT_EXPIRED will be returned in this case if
+ * <sync> is not signaled, even though no actual wait was
+ * performed."
+ */
+
+#include "piglit-util.h"
+
+int piglit_width = 256;
+int piglit_height = 256;
+int piglit_window_mode = GLUT_DOUBLE | GLUT_RGB | GLUT_ALPHA;
+
+#define ONE_SECOND 1000000
+
+enum piglit_result
+piglit_display(void)
+{
+ /* UNREACHED */
+ return PIGLIT_FAIL;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+ GLsync sync;
+ GLenum ret1, ret2;
+ bool pass = true;
+
+
+ piglit_require_extension("GL_ARB_sync");
+
+ glClear(GL_COLOR_BUFFER_BIT);
+ sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
+ ret1 = glClientWaitSync(sync, GL_SYNC_FLUSH_COMMANDS_BIT, 0);
+ glFinish();
+ ret2 = glClientWaitSync(sync, 0, 0);
+
+ glDeleteSync(sync);
+
+ if (ret1 != GL_TIMEOUT_EXPIRED &&
+ ret1 != GL_ALREADY_SIGNALED) {
+ fprintf(stderr,
+ "On first wait:\n"
+ " Expected GL_ALREADY_SIGNALED or GL_TIMEOUT_EXPIRED\n"
+ " Got %s\n",
+ piglit_get_gl_enum_name(ret1));
+ pass = false;
+ }
+
+ if (ret2 != GL_ALREADY_SIGNALED) {
+ fprintf(stderr,
+ "On repeated wait:\n"
+ " Expected GL_ALREADY_SIGNALED\n"
+ " Got %s\n",
+ piglit_get_gl_enum_name(ret2));
+ pass = false;
+ }
+
+ glClear(GL_COLOR_BUFFER_BIT);
+ sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
+ glFinish();
+ ret1 = glClientWaitSync(sync, GL_SYNC_FLUSH_COMMANDS_BIT, 0);
+
+ if (ret1 != GL_ALREADY_SIGNALED) {
+ fprintf(stderr,
+ "On wait after a finish:\n"
+ " Expected GL_ALREADY_SIGNALED\n"
+ " Got %s\n",
+ piglit_get_gl_enum_name(ret1));
+ pass = false;
+ }
+
+ piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
+}
--
1.7.10
More information about the Piglit
mailing list