[Mesa-dev] [PATCH 4/7] EGL/Wayland drirc: Use drirc to complement DRI_PRIME

Axel Davy axel.davy at ens.fr
Fri Mar 7 08:26:04 PST 2014


Add to drirc a new parameter: "wanted_device_id_path_tag"
to indicate the gpu we would like to use.

The EGL Wayland platform checks this parameter under
the driver name "init". It should be possible to get GLX
to check this parameter too, and use it for DRI3
GPU offloading.

Signed-off-by: Axel Davy <axel.davy at ens.fr>
---
 src/egl/drivers/dri2/Makefile.am                | 13 ++++++++++---
 src/egl/drivers/dri2/platform_wayland.c         | 24 ++++++++++++++++++++++++
 src/mesa/drivers/dri/common/xmlpool/t_options.h |  5 +++++
 3 files changed, 39 insertions(+), 3 deletions(-)

diff --git a/src/egl/drivers/dri2/Makefile.am b/src/egl/drivers/dri2/Makefile.am
index 12ee2cc..91af9d0 100644
--- a/src/egl/drivers/dri2/Makefile.am
+++ b/src/egl/drivers/dri2/Makefile.am
@@ -53,10 +53,17 @@ AM_CFLAGS += $(XCB_DRI2_CFLAGS)
 endif
 
 if HAVE_EGL_PLATFORM_WAYLAND
-libegl_dri2_la_SOURCES += platform_wayland.c
+libegl_dri2_la_SOURCES += platform_wayland.c \
+			  $(top_srcdir)/src/mesa/drivers/dri/common/xmlconfig.c
 AM_CFLAGS += -DHAVE_WAYLAND_PLATFORM
-AM_CFLAGS += $(WAYLAND_CFLAGS) $(LIBUDEV_CFLAGS)
-libegl_dri2_la_LIBADD += $(LIBUDEV_LIBS)
+AM_CFLAGS += $(WAYLAND_CFLAGS) $(LIBUDEV_CFLAGS) \
+	     -I$(top_srcdir)/src/mesa/drivers/dri/common \
+             -I$(top_builddir)/src/mesa/drivers/dri/common \
+             -I$(top_builddir)/src/egl/wayland/wayland-drm \
+             -I$(top_builddir)/src/mesa \
+             -I$(top_builddir)/src/mapi
+
+libegl_dri2_la_LIBADD += $(LIBUDEV_LIBS) -lexpat
 endif
 
 if HAVE_EGL_PLATFORM_DRM
diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c
index 245463d..0bee4d2 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -45,6 +45,17 @@
 #include <libudev.h>
 #endif
 
+#include "xmlconfig.h"
+#include "xmlpool.h"
+
+
+PUBLIC const char __driConfigOptionsWayland[] =
+DRI_CONF_BEGIN
+    DRI_CONF_SECTION_MISCELLANEOUS
+        DRI_CONF_WANTED_DEVICE_ID_PATH_TAG()
+    DRI_CONF_SECTION_END
+DRI_CONF_END;
+
 enum wl_drm_format_flags {
    HAS_ARGB8888 = 1,
    HAS_XRGB8888 = 2,
@@ -1074,12 +1085,25 @@ dri2_initialize_wayland(_EGLDriver *drv, _EGLDisplay *disp)
    static const unsigned int rgb_masks[4] = { 0xff0000, 0xff00, 0xff, 0 };
    static const unsigned int rgb565_masks[4] = { 0xf800, 0x07e0, 0x001f, 0 };
 
+   driOptionCache defaultInitOptions;
+   driOptionCache userInitOptions;
    char *prime_device_name = NULL;
    char *prime = NULL;
    const char *dri_prime = getenv("DRI_PRIME");
 
    if (dri_prime)
       prime = strdup(dri_prime);
+   else {
+      driParseOptionInfo(&defaultInitOptions, __driConfigOptionsWayland);
+      driParseConfigFiles(&userInitOptions, &defaultInitOptions, 0, "init");
+      if (driCheckOption(&userInitOptions, "wanted_device_id_path_tag",
+                         DRI_STRING))
+         prime = strdup(driQueryOptionstr(&userInitOptions,
+                                          "wanted_device_id_path_tag"));
+      driDestroyOptionCache(&userInitOptions);
+      driDestroyOptionInfo(&defaultInitOptions);
+   }
+
    loader_set_logger(_eglLog);
 
    drv->API.CreateWindowSurface = dri2_create_window_surface;
diff --git a/src/mesa/drivers/dri/common/xmlpool/t_options.h b/src/mesa/drivers/dri/common/xmlpool/t_options.h
index 3bf804a..ac72e3b 100644
--- a/src/mesa/drivers/dri/common/xmlpool/t_options.h
+++ b/src/mesa/drivers/dri/common/xmlpool/t_options.h
@@ -321,3 +321,8 @@ DRI_CONF_SECTION_BEGIN \
 DRI_CONF_OPT_BEGIN_B(always_have_depth_buffer, def) \
         DRI_CONF_DESC(en,gettext("Create all visuals with a depth buffer")) \
 DRI_CONF_OPT_END
+
+#define DRI_CONF_WANTED_DEVICE_ID_PATH_TAG(def) \
+DRI_CONF_OPT_BEGIN(wanted_device_id_path_tag, string, def) \
+        DRI_CONF_DESC(en,gettext("Define the graphic device to use if possible")) \
+DRI_CONF_OPT_END
-- 
1.8.3.2



More information about the mesa-dev mailing list