| 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 |
#include <stdio.h> |
| 25 |
#include <assert.h> |
| 26 |
#include "epoxy/gl.h" |
| 27 |
#include "epoxy/glx.h" |
| 28 |
#include <X11/Xlib.h> |
| 29 |
|
| 30 |
#include "glx_common.h" |
| 31 |
|
| 32 |
static Display *dpy; |
| 33 |
|
| 34 |
static bool |
| 35 |
test_gl_version(void) |
| 36 |
{ |
| 37 |
int version = epoxy_gl_version(); |
| 38 |
if (version < 12) { |
| 39 |
fprintf(stderr, |
| 40 |
"Reported GL version %d, should be at least 12\n", |
| 41 |
version); |
| 42 |
return false; |
| 43 |
} |
| 44 |
|
| 45 |
return true; |
| 46 |
} |
| 47 |
|
| 48 |
static bool |
| 49 |
test_glx_version(void) |
| 50 |
{ |
| 51 |
int version = epoxy_glx_version(dpy, 0); |
| 52 |
const char *version_string; |
| 53 |
int ret; |
| 54 |
int server_major, server_minor; |
| 55 |
int client_major, client_minor; |
| 56 |
int server, client, expected; |
| 57 |
|
| 58 |
if (version < 13) { |
| 59 |
fprintf(stderr, |
| 60 |
"Reported GLX version %d, should be at least 13 " |
| 61 |
"according to Linux GL ABI\n", |
| 62 |
version); |
| 63 |
return false; |
| 64 |
} |
| 65 |
|
| 66 |
version_string = glXQueryServerString(dpy, 0, GLX_VERSION); |
| 67 |
ret = sscanf(version_string, "%d.%d", &server_major, &server_minor); |
| 68 |
assert(ret == 2); |
| 69 |
server = server_major * 10 + server_minor; |
| 70 |
|
| 71 |
version_string = glXGetClientString(dpy, GLX_VERSION); |
| 72 |
ret = sscanf(version_string, "%d.%d", &client_major, &client_minor); |
| 73 |
assert(ret == 2); |
| 74 |
client = client_major * 10 + client_minor; |
| 75 |
|
| 76 |
if (client < server) |
| 77 |
expected = client; |
| 78 |
else |
| 79 |
expected = server; |
| 80 |
|
| 81 |
if (version != expected) { |
| 82 |
fprintf(stderr, |
| 83 |
"Reported GLX version %d, should be %d (%s)\n", |
| 84 |
version, expected, version_string); |
| 85 |
return false; |
| 86 |
} |
| 87 |
|
| 88 |
return true; |
| 89 |
} |
| 90 |
|
| 91 |
static bool |
| 92 |
test_glx_extension_supported(void) |
| 93 |
{ |
| 94 |
if (!epoxy_has_glx_extension(dpy, 0, "GLX_ARB_get_proc_address")) { |
| 95 |
fputs("Incorrectly reported no support for GLX_ARB_get_proc_address " |
| 96 |
"(should always be present in Linux ABI)\n", |
| 97 |
stderr); |
| 98 |
return false; |
| 99 |
} |
| 100 |
|
| 101 |
if (epoxy_has_glx_extension(dpy, 0, "GLX_EXT_ham_sandwich")) { |
| 102 |
fputs("Incorrectly reported support for GLX_EXT_ham_sandwich\n", |
| 103 |
stderr); |
| 104 |
return false; |
| 105 |
} |
| 106 |
|
| 107 |
return true; |
| 108 |
} |
| 109 |
|
| 110 |
int |
| 111 |
main(int argc, char **argv) |
| 112 |
{ |
| 113 |
bool pass = true; |
| 114 |
|
| 115 |
dpy = get_display_or_skip(); |
| 116 |
make_glx_context_current_or_skip(dpy); |
| 117 |
|
| 118 |
pass = test_gl_version() && pass; |
| 119 |
pass = test_glx_version() && pass; |
| 120 |
pass = test_glx_extension_supported() && pass; |
| 121 |
|
| 122 |
return pass != true; |
| 123 |
} |