Mesa (master): egl_glx: Try first a default lookup for glXGetProcAddress before loading dynamic lib .

Chia-I Wu olv at kemper.freedesktop.org
Sun Nov 27 03:23:03 UTC 2011


Module: Mesa
Branch: master
Commit: 6baa5f10c04641960e0bedce664d0a5cf39e8954
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=6baa5f10c04641960e0bedce664d0a5cf39e8954

Author: Beren Minor <beren.minor at gmail.com>
Date:   Fri Nov 25 11:58:38 2011 +0100

egl_glx: Try first a default lookup for glXGetProcAddress before loading dynamic lib.

GLX functions are sometimes directly available in the current binary. In such
cases, we do not need any alternate library loaded using dlopen. Otherwise,
dlopen may find the wrong libGL library and get functions that conflicts with
the current loaded ones.

For example, on Debian Sid with nvidia binary drivers, using mesa's libEGL with
GLX driver leads to wrong glXGetFBConfigs symbol loaded (or loaded twice?),
which leads to "GLX: failed to create any config" error message as the
glXGetFBConfigs symbol seems to return garbage. If the binary is linked with
nvidia's libGL, the GLX symbols are already available.
Without this patch, convert_fbconfig (src/egl/drivers/glx/egl_glx.c:233) fails
for every config found, after glXGetFBConfigAttrib(... GLX_RENDER_TYPE, ...)
call, as the value returned has GLX_COLOR_INDEX_BIT and not GLX_RGBA_BIT.

[olv: initialize handle, prepend egl_glx to the commit log]

---

 src/egl/drivers/glx/egl_glx.c |   23 ++++++++++++++---------
 1 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/src/egl/drivers/glx/egl_glx.c b/src/egl/drivers/glx/egl_glx.c
index 9082fb3..bdc8a28 100644
--- a/src/egl/drivers/glx/egl_glx.c
+++ b/src/egl/drivers/glx/egl_glx.c
@@ -1069,17 +1069,22 @@ static EGLBoolean
 GLX_Load(_EGLDriver *drv)
 {
    struct GLX_egl_driver *GLX_drv = GLX_egl_driver(drv);
-   void *handle;
-
-   handle = dlopen("libGL.so", RTLD_LAZY | RTLD_LOCAL);
-   if (!handle)
-      goto fail;
+   void *handle = NULL;
 
-   GLX_drv->glXGetProcAddress = dlsym(handle, "glXGetProcAddress");
+   GLX_drv->glXGetProcAddress = dlsym(RTLD_DEFAULT, "glXGetProcAddress");
    if (!GLX_drv->glXGetProcAddress)
-      GLX_drv->glXGetProcAddress = dlsym(handle, "glXGetProcAddressARB");
-   if (!GLX_drv->glXGetProcAddress)
-      goto fail;
+      GLX_drv->glXGetProcAddress = dlsym(RTLD_DEFAULT, "glXGetProcAddressARB");
+   if (!GLX_drv->glXGetProcAddress) {
+      handle = dlopen("libGL.so", RTLD_LAZY | RTLD_LOCAL);
+      if (!handle)
+         goto fail;
+
+      GLX_drv->glXGetProcAddress = dlsym(handle, "glXGetProcAddress");
+      if (!GLX_drv->glXGetProcAddress)
+         GLX_drv->glXGetProcAddress = dlsym(handle, "glXGetProcAddressARB");
+      if (!GLX_drv->glXGetProcAddress)
+         goto fail;
+   }
 
 #define GET_PROC(proc_type, proc_name, check)                        \
    do {                                                              \




More information about the mesa-commit mailing list