diff options
-rw-r--r-- | include/epoxy/glx_common.h | 5 | ||||
-rw-r--r-- | src/dispatch_common.c | 26 | ||||
-rw-r--r-- | src/dispatch_common.h | 1 | ||||
-rwxr-xr-x | src/gen_dispatch.py | 2 | ||||
-rw-r--r-- | test/Makefile.am | 2 | ||||
-rw-r--r-- | test/glx_glxgetprocaddress_nocontext.c | 2 | ||||
-rw-r--r-- | test/glx_public_api.c | 2 |
7 files changed, 28 insertions, 12 deletions
diff --git a/include/epoxy/glx_common.h b/include/epoxy/glx_common.h index cee9f51..c23ec72 100644 --- a/include/epoxy/glx_common.h +++ b/include/epoxy/glx_common.h @@ -31,8 +31,11 @@ #include <stdbool.h> +#include <X11/Xlib.h> +#include <X11/Xutil.h> + bool epoxy_has_glx_extension(const char *extension); -int epoxy_glx_version(void); +int epoxy_glx_version(Display *dpy, int screen); #endif /* EPOXY_GLX_COMMON_H */ diff --git a/src/dispatch_common.c b/src/dispatch_common.c index 4bd432e..a32b30b 100644 --- a/src/dispatch_common.c +++ b/src/dispatch_common.c @@ -138,21 +138,35 @@ epoxy_is_glx(void) return true; /* XXX */ } -PUBLIC int -epoxy_glx_version(void) +/** + * If we can determine the GLX version from the current context, then + * return that, otherwise return a version that will just send us on + * to dlsym() or get_proc_address(). + */ +int +epoxy_conservative_glx_version(void) { Display *dpy = glXGetCurrentDisplay(); GLXContext ctx = glXGetCurrentContext(); + int screen; + + if (!dpy || !ctx) + return 14; + + glXQueryContext(dpy, ctx, GLX_SCREEN, &screen); + + return epoxy_glx_version(dpy, screen); +} + +PUBLIC int +epoxy_glx_version(Display *dpy, int screen) +{ int server_major, server_minor; int client_major, client_minor; int server, client; const char *version_string; - int screen = 0; int ret; - /* XXX: What if there's no current context? */ - glXQueryContext(dpy, ctx, GLX_SCREEN, &screen); - version_string = glXQueryServerString(dpy, screen, GLX_VERSION); ret = sscanf(version_string, "%d.%d", &server_major, &server_minor); assert(ret == 2); diff --git a/src/dispatch_common.h b/src/dispatch_common.h index cf90248..ed3fa5b 100644 --- a/src/dispatch_common.h +++ b/src/dispatch_common.h @@ -49,6 +49,7 @@ struct api { bool epoxy_is_glx(void); void *epoxy_get_proc_address(const char *name); +int epoxy_conservative_glx_version(void); void *epoxy_dlsym(const char *name); void epoxy_glx_autoinit(void); void epoxy_platform_autoinit(void); diff --git a/src/gen_dispatch.py b/src/gen_dispatch.py index b402745..8b9cc54 100755 --- a/src/gen_dispatch.py +++ b/src/gen_dispatch.py @@ -292,7 +292,7 @@ class Generator(object): # We could just always use GPA, but dlsym() is a more # efficient lookup. if version > 13: - condition = condition + ' && epoxy_glx_version() >= {0}'.format(version) + condition = condition + ' && epoxy_conservative_glx_version() >= {0}'.format(version) loader = self.gpa_loader else: loader = self.dlsym_loader diff --git a/test/Makefile.am b/test/Makefile.am index 6fdfdae..4023b31 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -37,8 +37,6 @@ TESTS = \ headerguards \ $() -XFAIL_TESTS = glx_glxgetprocaddress_nocontext - check_PROGRAMS = $(TESTS) glx_public_api_LDFLAGS = $(X11_LIBS) $(EPOXY) libglx_common.la diff --git a/test/glx_glxgetprocaddress_nocontext.c b/test/glx_glxgetprocaddress_nocontext.c index 3ab2c09..3d12bf4 100644 --- a/test/glx_glxgetprocaddress_nocontext.c +++ b/test/glx_glxgetprocaddress_nocontext.c @@ -45,7 +45,7 @@ main(int argc, char **argv) bool pass = true; dpy = get_display_or_skip(); - if (epoxy_glx_version() < 14) + if (epoxy_glx_version(dpy, 0) < 14) errx(77, "GLX version 1.4 required for glXGetProcAddress().\n"); void *func = glXGetProcAddress("glGetString"); diff --git a/test/glx_public_api.c b/test/glx_public_api.c index 1eab7bf..e89a4a4 100644 --- a/test/glx_public_api.c +++ b/test/glx_public_api.c @@ -48,7 +48,7 @@ test_gl_version(void) static bool test_glx_version(void) { - int version = epoxy_glx_version(); + int version = epoxy_glx_version(dpy, 0); const char *version_string; int ret; int server_major, server_minor; |