diff options
author | Eric Anholt <eric@anholt.net> | 2013-12-04 18:45:52 -0800 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2013-12-04 19:18:31 -0800 |
commit | 0f67bf3f1192fb0bbd0b868eeb73a18f76951b01 (patch) | |
tree | 8ae10824b0fcd93f0fb6fc4d38372b932cda5425 /src | |
parent | 14f822ee91adc1531b7689d2f6083cdb1476154d (diff) |
Fix bug in public entrypoint for epoxy_glx_version()
Unfortunately, for GLX 1.4+ entrypoints (just glxGetProcAddress
currently) or extensions, if there isn't a context bound then we don't
have a dpy and screen available to provide useful debug messages. Oh
well.
Diffstat (limited to 'src')
-rw-r--r-- | src/dispatch_common.c | 26 | ||||
-rw-r--r-- | src/dispatch_common.h | 1 | ||||
-rwxr-xr-x | src/gen_dispatch.py | 2 |
3 files changed, 22 insertions, 7 deletions
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 |