1 /* Copyright © 2012 Intel Corporation
3 * Permission is hereby granted, free of charge, to any person obtaining a
4 * copy of this software and associated documentation files (the "Software"),
5 * to deal in the Software without restriction, including without limitation
6 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
7 * and/or sell copies of the Software, and to permit persons to whom the
8 * Software is furnished to do so, subject to the following conditions:
10 * The above copyright notice and this permission notice (including the next
11 * paragraph) shall be included in all copies or substantial portions of the
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
23 /** @file repeat-wait.c
25 * From the GL_ARB_sync spec:
27 * "If <sync> is signaled at the time ClientWaitSync is called
28 * then ClientWaitSync returns immediately. If <sync> is
29 * unsignaled at the time ClientWaitSync is called then
30 * ClientWaitSync will block and will wait up to <timeout>
31 * nanoseconds for <sync> to become signaled.
35 * ALREADY_SIGNALED will always be returned if <sync> was
36 * signaled, even if the value of <timeout> is zero."
38 * There was concern that the implementation of the kernel API on i965
39 * might violate this for the specific case of back-to-back
40 * ClientWaitSyncs, but Mesa core doesn't end up calling into the
41 * driver on a later ClientWaitSync.
44 #include "piglit-util-gl.h"
46 PIGLIT_GL_TEST_CONFIG_BEGIN
48 config
.supports_gl_compat_version
= 10;
50 config
.window_width
= 10;
51 config
.window_height
= 10;
52 config
.window_visual
= PIGLIT_GL_VISUAL_RGBA
| PIGLIT_GL_VISUAL_DOUBLE
;
53 config
.khr_no_error_support
= PIGLIT_NO_ERRORS
;
55 PIGLIT_GL_TEST_CONFIG_END
57 #define ONE_SECOND 1000000000
67 piglit_init(int argc
, char **argv
)
72 piglit_require_extension("GL_ARB_sync");
74 glClear(GL_COLOR_BUFFER_BIT
);
76 sync
= glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE
, 0);
78 ret1
= glClientWaitSync(sync
, GL_SYNC_FLUSH_COMMANDS_BIT
, ONE_SECOND
);
79 ret2
= glClientWaitSync(sync
, 0, ONE_SECOND
);
81 if (ret1
== GL_TIMEOUT_EXPIRED
) {
82 printf("timeout expired on the first wait\n");
83 piglit_report_result(PIGLIT_SKIP
);
86 if (ret2
!= GL_ALREADY_SIGNALED
) {
88 "Expected GL_ALREADY_SIGNALED on second wait, got %s",
89 piglit_get_gl_enum_name(ret2
));
90 piglit_report_result(PIGLIT_FAIL
);
93 piglit_report_result(PIGLIT_PASS
);