1 /**
2 * Copyright © 2013 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 */
23
24 /**
25 * \file
26 * Test ClientWaitSync() returns correct error messages for invalid input
27 *
28 *
29 * Section 5.2.1(Waiting for Sync Objects) of OpenGL 3.2 Core says:
30 *
31 * "If <sync> is not the name of a sync object, an INVALID_VALUE error
32 * is generated. If <flags> contains any bits other than
33 * SYNC_FLUSH_COMMANDS_BIT, an INVALID_VALUE error is generated."
34 *
35 */
36
37 #include "piglit-util-gl.h"
38
39 PIGLIT_GL_TEST_CONFIG_BEGIN
40
41 config.supports_gl_compat_version = 10;
42 config.supports_gl_core_version = 31;
43 config.khr_no_error_support = PIGLIT_HAS_ERRORS;
44
45 PIGLIT_GL_TEST_CONFIG_END
46
47 enum piglit_result
piglit_display(void)48 piglit_display(void)
49 {
50 /* UNREACHED */
51 return PIGLIT_FAIL;
52 }
53
54 void
piglit_init(int argc,char ** argv)55 piglit_init(int argc, char **argv)
56 {
57 bool pass = true;
58 GLsync a = (GLsync)0xDEADBEEF;
59 GLenum status;
60 int i;
61
62 if (piglit_get_gl_version() < 32) {
63 piglit_require_extension("GL_ARB_sync");
64 }
65
66 /* sync not set up yet so this should fail with both GL error and
67 * respond GL_WAIT_FAILED
68 */
69 status = glClientWaitSync(a, GL_SYNC_FLUSH_COMMANDS_BIT, 0);
70 pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass;
71 if (status != GL_WAIT_FAILED) {
72 printf("Expected GL_WAIT_FAILED but returned: %s\n",
73 piglit_get_gl_enum_name(status));
74 pass = false;
75 }
76
77 a = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
78
79 /* test that valid sync results in NO_ERROR */
80 status = glClientWaitSync(a, GL_SYNC_FLUSH_COMMANDS_BIT, 0);
81 pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
82
83 /* test that invalid flag value results in INVALID_VALUE */
84 for (i = 0; i < sizeof(GLbitfield) * 8; i++) {
85 GLbitfield mask = 1 << i;
86 /* Skip over the valid bit */
87 if (mask == GL_SYNC_FLUSH_COMMANDS_BIT) {
88 continue;
89 }
90 status = glClientWaitSync(a, mask, 0);
91 pass = (status == GL_WAIT_FAILED) && pass;
92 pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass;
93 }
94
95 glDeleteSync(a);
96
97 piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
98 }
99