summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdam Jackson <ajax@redhat.com>2017-07-12 13:26:05 -0400
committerAdam Jackson <ajax@redhat.com>2017-07-12 14:05:54 -0400
commit7c4817f2eed2faf0353c1ceb5f38b500f6aff7cf (patch)
tree51e3c1779514b1d2e076c04e81502c809a6ac125 /src
parentf81274b12470a0ce8678465112998708f63c3559 (diff)
downloadlibepoxy-7c4817f2eed2faf0353c1ceb5f38b500f6aff7cf.tar.gz
dispatch: Be more paranoid about detecting GLX or not
This code attempts not to dlopen anything if it can find the appropriate winsys symbols in the global namespace. That's nice. However we normally do dlopen(RTLD_LOCAL) when we open lib{GLX,EGL} so those symbols will _not_ in fact be in the global namespace. The code also prefers checking GLX to EGL, which means even if we initialize EGL through epoxy, and even if we're using glvnd, we'll still dlopen libGL the first time we hit epoxy_is_desktop_gl(). There's a couple of ways to skin this cat, let's take the easy one. If either-but-not-both of the glx or egl handles in the global API state are initialized, then we know we're already in one or the other. If neither or both are initialized, then the current heuristic should work fine. Note that epoxy_is_desktop_gl() is only bothering to check for GLX to work around PowerVR's broken GLES. One suspects a better way to do that would be to check GL_VENDOR or GL_RENDERER and avoid probing the window system at all. Signed-off-by: Adam Jackson <ajax@redhat.com>
Diffstat (limited to 'src')
-rw-r--r--src/dispatch_common.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/dispatch_common.c b/src/dispatch_common.c
index 48bd3f5..87bd98a 100644
--- a/src/dispatch_common.c
+++ b/src/dispatch_common.c
@@ -522,6 +522,16 @@ epoxy_current_context_is_glx(void)
#if !PLATFORM_HAS_GLX
return false;
#else
+ void *sym;
+
+ /* If we've been called already, don't load more */
+ if (!api.egl_handle != !api.glx_handle) {
+ if (api.glx_handle)
+ return true;
+ else if (api.egl_handle)
+ return false;
+ }
+
/* If the application hasn't explicitly called some of our GLX
* or EGL code but has presumably set up a context on its own,
* then we need to figure out how to getprocaddress anyway.
@@ -529,7 +539,6 @@ epoxy_current_context_is_glx(void)
* If there's a public GetProcAddress loaded in the
* application's namespace, then use that.
*/
- void *sym;
sym = dlsym(NULL, "glXGetCurrentContext");
if (sym) {