1 /* Copyright © 2011 Intel Corporation
2 *
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:
9 *
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.
13 *
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.
21 */
22 #include "piglit-util-gl.h"
23 #include "piglit-glx-util.h"
24 #include "common.h"
25
try_render_type(int type)26 static bool try_render_type(int type)
27 {
28 const int attribs[] = {
29 GLX_RENDER_TYPE, type,
30 None
31 };
32 GLXContext ctx;
33 bool pass = true;
34
35 ctx = glXCreateContextAttribsARB(dpy, fbconfig, NULL, True, attribs);
36 XSync(dpy, 0);
37
38 if (ctx != NULL) {
39 fprintf(stderr,
40 "Created OpenGL context with invalid render-type "
41 "0x%08x, but this should have failed.\n",
42 type);
43 glXDestroyContext(dpy, ctx);
44 pass = false;
45 }
46
47 /* The GLX_ARB_create_context spec says:
48 *
49 * "* If attribute GLX_RENDER_TYPE does not describe a valid
50 * rendering type, BadValue is generated."
51 */
52 if (!validate_glx_error_code(BadValue, -1)) {
53 if (ctx == NULL)
54 fprintf(stderr, "Render type = 0x%08x\n", type);
55
56 pass = false;
57 }
58
59 return pass;
60 }
61
main(int argc,char ** argv)62 int main(int argc, char **argv)
63 {
64 static const int invalid_render_types[] = {
65 GLX_COLOR_INDEX_BIT,
66 GLX_RGBA_BIT,
67 GLX_RGBA_FLOAT_BIT_ARB,
68 GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT,
69 0,
70 -1,
71 ~GLX_RGBA_TYPE,
72 ~GLX_COLOR_INDEX_TYPE
73 };
74 bool pass = true;
75 unsigned i;
76
77 GLX_ARB_create_context_setup();
78
79 for (i = 0; i < ARRAY_SIZE(invalid_render_types); i++) {
80 pass = try_render_type(invalid_render_types[i])
81 && pass;
82 }
83
84 if (!piglit_is_glx_extension_supported(dpy, "GLX_ARB_fbconfig_float")) {
85 pass = try_render_type(GLX_RGBA_FLOAT_TYPE_ARB)
86 && pass;
87 }
88
89 if (!piglit_is_glx_extension_supported(dpy, "GLX_EXT_fbconfig_packed_float")) {
90 pass = try_render_type(GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT)
91 && pass;
92 }
93
94 GLX_ARB_create_context_teardown();
95
96 piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
97 return 0;
98 }
99