dri2: Trust our own driver name lookup over the server's.
authorEric Anholt <eric@anholt.net>
Thu, 23 Jan 2014 18:21:09 +0000 (10:21 -0800)
committerEric Anholt <eric@anholt.net>
Mon, 27 Jan 2014 17:37:10 +0000 (09:37 -0800)
This allows Mesa to choose to rename driver .sos (or split drivers),
without needing a flag day with the corresponding 2D driver.

v2: Undo the loader-only-for-dri3 change.

Reviewed-by: Keith Packard <keithp@keithp.com> [v1]
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net> [v1]
src/glx/Makefile.am
src/glx/dri2_glx.c

index 69a6bf93da38065ec8cbba191df8f53b28426188..54a0cc027da0b07ae12b7c0aa0edc05f5fe708f4 100644 (file)
@@ -100,9 +100,9 @@ libglx_la_SOURCES = \
 if HAVE_DRI3
 libglx_la_SOURCES += \
           dri3_glx.c
+endif
 
 libglx_la_LIBADD = $(top_builddir)/src/loader/libloader.la
-endif
 
 GL_LIBS = \
        libglx.la \
index 4e2c16adf2297d572f85ec3770f3689a00389898..0a0dac9864617d1b210046660fd597c8b41261ea 100644 (file)
@@ -51,6 +51,7 @@
 #include "dri2.h"
 #include "dri_common.h"
 #include "dri2_priv.h"
+#include "loader.h"
 
 /* From xmlpool/options.h, user exposed so should be stable */
 #define DRI_CONF_VBLANK_NEVER 0
@@ -1156,7 +1157,7 @@ dri2CreateScreen(int screen, struct glx_display * priv)
    struct dri2_screen *psc;
    __GLXDRIscreen *psp;
    struct glx_config *configs = NULL, *visuals = NULL;
-   char *driverName, *deviceName, *tmp;
+   char *driverName = NULL, *loader_driverName, *deviceName, *tmp;
    drm_magic_t magic;
    int i;
 
@@ -1193,6 +1194,15 @@ dri2CreateScreen(int screen, struct glx_display * priv)
       goto handle_error;
    }
 
+   /* If Mesa knows about the appropriate driver for this fd, then trust it.
+    * Otherwise, default to the server's value.
+    */
+   loader_driverName = loader_get_driver_for_fd(psc->fd, 0);
+   if (loader_driverName) {
+      free(driverName);
+      driverName = loader_driverName;
+   }
+
    psc->driver = driOpenDriver(driverName);
    if (psc->driver == NULL) {
       ErrorMessageF("driver pointer missing\n");