add to drirc a parameter "wanted_device_id_path_tag", and check its value to choose which gpu to use, if DRI_PRIME isn't set.
Signed-off-by: Axel Davy <axel.d...@ens.fr> --- configure.ac | 1 + src/egl/drivers/dri2/Makefile.am | 12 +++++++++++ src/egl/drivers/dri2/platform_wayland.c | 27 +++++++++++++++++++++++++ src/mesa/drivers/dri/common/xmlpool/t_options.h | 5 +++++ 4 files changed, 45 insertions(+) diff --git a/configure.ac b/configure.ac index f75325d..bdec31f 100644 --- a/configure.ac +++ b/configure.ac @@ -714,6 +714,7 @@ AM_CONDITIONAL(HAVE_DRI_GLX, test "x$enable_glx" = xyes -a \ "x$enable_dri" = xyes) AM_CONDITIONAL(HAVE_DRI, test "x$enable_dri" = xyes) AM_CONDITIONAL(HAVE_DRI3, test "x$enable_dri3" = xyes) +AM_CONDITIONAL(HAVE_DRIRC_CHOOSE_GPU, test "x$enable_drirc_choose_gpu" = xyes) AC_ARG_ENABLE([shared-glapi], [AS_HELP_STRING([--enable-shared-glapi], diff --git a/src/egl/drivers/dri2/Makefile.am b/src/egl/drivers/dri2/Makefile.am index 823ef5e..da1094c 100644 --- a/src/egl/drivers/dri2/Makefile.am +++ b/src/egl/drivers/dri2/Makefile.am @@ -57,6 +57,18 @@ if HAVE_EGL_PLATFORM_WAYLAND libegl_dri2_la_SOURCES += platform_wayland.c AM_CFLAGS += -DHAVE_WAYLAND_PLATFORM AM_CFLAGS += $(WAYLAND_CFLAGS) + +if HAVE_DRIRC_CHOOSE_GPU +libegl_dri2_la_LIBADD += -lexpat +libegl_dri2_la_SOURCES += $(top_srcdir)/src/mesa/drivers/dri/common/xmlconfig.c +AM_CFLAGS += -DUSE_DRICONF_CHOOSE_GPU_INIT \ + -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 +endif + 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 0f022c1..7c8e076 100644 --- a/src/egl/drivers/dri2/platform_wayland.c +++ b/src/egl/drivers/dri2/platform_wayland.c @@ -44,6 +44,21 @@ #include <libudev.h> #endif +#ifdef USE_DRICONF_CHOOSE_GPU_INIT + +#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; + +#endif + enum wl_drm_format_flags { HAS_ARGB8888 = 1, HAS_XRGB8888 = 2, @@ -1069,6 +1084,18 @@ dri2_initialize_wayland(_EGLDriver *drv, _EGLDisplay *disp) if (dri_prime) prime = strdup(dri_prime); +#ifdef USE_DRICONF_CHOOSE_GPU_INIT + else { + driOptionCache defaultDevice; + driOptionCache askedDevice; + driParseOptionInfo(&defaultDevice, __driConfigOptionsWayland); + driParseConfigFiles(&askedDevice, &defaultDevice, 0, "init"); + if (driCheckOption(&askedDevice, "wanted_device_id_path_tag", DRI_STRING)) + prime = strdup(driQueryOptionst(&askedDevice, "wanted_device_id_path_tag")); + driDestroyOptionCache(&askedDevice); + driDestroyOptionInfo(&defaultDevice); + } +#endif drv->API.CreateWindowSurface = dri2_create_window_surface; drv->API.DestroySurface = dri2_destroy_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 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev