1 /* Copyright © 2011 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 #include "piglit-util-gl.h"
24 #include "piglit-glx-util.h"
28 try_query(GLXContext ctx
, int attribute
, const char *attribute_string
,
29 int expected_error
, int expected_value
)
32 int value
= 0xDEADBEEF;
35 err
= glXQueryContextInfoEXT(dpy
, ctx
, attribute
, &value
);
38 if (err
!= expected_error
) {
40 "Query of %s had error %d, but %d was expected.\n",
47 /* There is no way in GLX_SGIX_fbconfig to get an XID from a
48 * GLXFBConfig. As a result, there's no way to verify
49 * glXQueryContextInfoEXT has returned the correct value. The
50 * required functionality was not added until GLX 1.3.
52 if (attribute
!= GLX_FBCONFIG_ID_SGIX
) {
53 if (expected_error
!= Success
)
54 expected_value
= 0xDEADBEEF;
56 if (value
!= expected_value
) {
58 "Query of %s had value %d, but %d was "
66 if (value
== 0xDEADBEEF) {
68 "Query of %s did not set a value.\n",
74 /* No GLX protocol error should be generated.
76 pass
= validate_glx_error_code(Success
, -1) && pass
;
81 int main(int argc
, char **argv
)
86 GLX_EXT_import_context_setup();
88 /* Try the simple stuff.
90 pass
= try_query(indirectCtx
,
91 GLX_SHARE_CONTEXT_EXT
, "GLX_SHARE_CONTEXT_EXT",
94 pass
= try_query(indirectCtx
,
95 GLX_SCREEN_EXT
, "GLX_SCREEN_EXT",
96 Success
, DefaultScreen(dpy
))
98 pass
= try_query(indirectCtx
,
99 GLX_VISUAL_ID_EXT
, "GLX_VISUAL_ID_EXT",
100 Success
, visinfo
->visualid
)
102 pass
= try_query(indirectCtx
,
103 0xffff0000, "0xffff0000 (invalid)",
104 GLX_BAD_ATTRIBUTE
, 0)
107 /* Create a second indirect-rendering context, and have it share the
108 * first indirect-rendering context. The XID of the share context for
109 * the original context should be unchanged.
111 ctx
= glXCreateContext(dpy
, visinfo
, indirectCtx
, False
);
114 pass
= try_query(indirectCtx
,
115 GLX_SHARE_CONTEXT_EXT
, "GLX_SHARE_CONTEXT_EXT",
118 pass
= try_query(ctx
,
119 GLX_SHARE_CONTEXT_EXT
, "GLX_SHARE_CONTEXT_EXT",
120 Success
, glXGetContextIDEXT(indirectCtx
))
123 if (piglit_is_glx_extension_supported(dpy
, "GLX_SGIX_fbconfig")) {
124 pass
= try_query(indirectCtx
,
125 GLX_FBCONFIG_ID_SGIX
, "GLX_FBCONFIG_ID_SGIX",
130 GLX_EXT_import_context_teardown();
132 piglit_report_result(pass
? PIGLIT_PASS
: PIGLIT_FAIL
);