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 glx_gles2.c |
26 | * |
27 | * Catches a bug where a GLES2 context using |
28 | * GLX_EXT_create_context_es2_profile would try to find the symbols in |
29 | * libGLESv2.so.2 instead of libGL.so.1. |
30 | */ |
31 | |
32 | #include <stdio.h> |
33 | #include <assert.h> |
34 | #include <err.h> |
35 | #include "epoxy/gl.h" |
36 | #include "epoxy/glx.h" |
37 | #include <X11/Xlib.h> |
38 | |
39 | #include "glx_common.h" |
40 | |
41 | static Display *dpy; |
42 | |
43 | GLuint |
44 | override_GLES2_glCreateShader(GLenum target); |
45 | |
46 | GLuint |
47 | override_GLES2_glCreateShader(GLenum target) |
48 | { |
49 | return 0; |
50 | } |
51 | |
52 | void |
53 | override_GLES2_glGenQueries(GLsizei n, GLuint *ids); |
54 | |
55 | void |
56 | override_GLES2_glGenQueries(GLsizei n, GLuint *ids) |
57 | { |
58 | int i; |
59 | for (i = 0; i < n; i++) |
60 | ids[i] = 0; |
61 | } |
62 | |
63 | int |
64 | main(int argc, char **argv) |
65 | { |
66 | bool pass = true; |
67 | XVisualInfo *vis; |
68 | Window win; |
69 | GLXContext ctx; |
70 | GLXFBConfig config; |
71 | int context_attribs[] = { |
72 | GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_ES2_PROFILE_BIT_EXT, |
73 | GLX_CONTEXT_MAJOR_VERSION_ARB, 2, |
74 | GLX_CONTEXT_MINOR_VERSION_ARB, 0, |
75 | 0 |
76 | }; |
77 | GLuint shader; |
78 | |
79 | dpy = get_display_or_skip(); |
80 | |
81 | if (!epoxy_has_glx_extension(dpy, screen: 0, extension: "GLX_EXT_create_context_es2_profile" )) |
82 | errx(status: 77, format: "Test requires GLX_EXT_create_context_es2_profile" ); |
83 | |
84 | vis = get_glx_visual(dpy); |
85 | config = get_fbconfig_for_visinfo(dpy, visinfo: vis); |
86 | win = get_glx_window(dpy, visinfo: vis, false); |
87 | |
88 | ctx = glXCreateContextAttribsARB(dpy, config, NULL, true, |
89 | context_attribs); |
90 | |
91 | glXMakeCurrent(dpy, win, ctx); |
92 | |
93 | if (epoxy_is_desktop_gl()) { |
94 | errx(status: 1, format: "GLES2 context creation made a desktop context\n" ); |
95 | } |
96 | |
97 | if (epoxy_gl_version() < 20) { |
98 | errx(status: 1, format: "GLES2 context creation made a version %f context\n" , |
99 | epoxy_gl_version() / 10.0f); |
100 | } |
101 | |
102 | /* Test using an entrypoint that's in GLES2, but not the desktop GL ABI. */ |
103 | shader = glCreateShader(GL_FRAGMENT_SHADER); |
104 | if (shader == 0) |
105 | errx(status: 1, format: "glCreateShader() failed\n" ); |
106 | glDeleteShader(shader); |
107 | |
108 | if (epoxy_gl_version() >= 30) { |
109 | GLuint q = 0; |
110 | |
111 | glGenQueries(1, &q); |
112 | if (!q) |
113 | errx(status: 1, format: "glGenQueries() failed\n" ); |
114 | glDeleteQueries(1, &q); |
115 | } |
116 | |
117 | return pass != true; |
118 | } |
119 | |