ext_gpu_shader4: add compiler tests for everything
[piglit.git] / tests / spec / glx_ext_import_context / query-context-info.c
blob6e187a1fb229f04b3c0d6f6f06ae49313a76d4f9
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
12 * Software.
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
20 * IN THE SOFTWARE.
23 #include "piglit-util-gl.h"
24 #include "piglit-glx-util.h"
25 #include "common.h"
27 static bool
28 try_query(GLXContext ctx, int attribute, const char *attribute_string,
29 int expected_error, int expected_value)
31 bool pass = true;
32 int value = 0xDEADBEEF;
33 int err;
35 err = glXQueryContextInfoEXT(dpy, ctx, attribute, &value);
36 XSync(dpy, 0);
38 if (err != expected_error) {
39 fprintf(stderr,
40 "Query of %s had error %d, but %d was expected.\n",
41 attribute_string,
42 err,
43 expected_error);
44 pass = false;
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) {
57 fprintf(stderr,
58 "Query of %s had value %d, but %d was "
59 "expected.\n",
60 attribute_string,
61 value,
62 expected_value);
63 pass = false;
65 } else {
66 if (value == 0xDEADBEEF) {
67 fprintf(stderr,
68 "Query of %s did not set a value.\n",
69 attribute_string);
70 pass = false;
74 /* No GLX protocol error should be generated.
76 pass = validate_glx_error_code(Success, -1) && pass;
78 return pass;
81 int main(int argc, char **argv)
83 bool pass = true;
84 GLXContext ctx;
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",
92 Success, 0)
93 && pass;
94 pass = try_query(indirectCtx,
95 GLX_SCREEN_EXT, "GLX_SCREEN_EXT",
96 Success, DefaultScreen(dpy))
97 && pass;
98 pass = try_query(indirectCtx,
99 GLX_VISUAL_ID_EXT, "GLX_VISUAL_ID_EXT",
100 Success, visinfo->visualid)
101 && pass;
102 pass = try_query(indirectCtx,
103 0xffff0000, "0xffff0000 (invalid)",
104 GLX_BAD_ATTRIBUTE, 0)
105 && pass;
107 /* Create a second indirect-rendering context, and have it share the
108 * first indirect-rendering context. The XID of the share conext for
109 * the original context should be unchanged.
111 ctx = glXCreateContext(dpy, visinfo, indirectCtx, False);
112 assert(ctx != NULL);
114 pass = try_query(indirectCtx,
115 GLX_SHARE_CONTEXT_EXT, "GLX_SHARE_CONTEXT_EXT",
116 Success, 0)
117 && pass;
118 pass = try_query(ctx,
119 GLX_SHARE_CONTEXT_EXT, "GLX_SHARE_CONTEXT_EXT",
120 Success, glXGetContextIDEXT(indirectCtx))
121 && pass;
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",
126 Success, 0)
127 && pass;
130 GLX_EXT_import_context_teardown();
132 piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
133 return 0;