xserver: Branch 'server-1.20-branch' - 2 commits

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Dec 18 20:22:02 UTC 2019


 glamor/glamor.h                       |    2 ++
 glamor/glamor_egl.c                   |   16 ++++++++++++++++
 hw/xfree86/common/xf86Module.h        |    2 +-
 hw/xfree86/drivers/modesetting/dri2.c |   28 +++++++++++++++++++++++++---
 include/meson.build                   |    2 ++
 5 files changed, 46 insertions(+), 4 deletions(-)

New commits:
commit 255d8c3c36a9d52b3acc5e016efa0ef0f2371f79
Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Thu Nov 21 23:03:50 2019 -0800

    modesetting: Use EGL_MESA_query_driver to select DRI driver if possible
    
    We now ask Glamor to use EGL_MESA_query_driver to obtain the DRI driver
    name; if successful, we use that as the DRI driver name.  Following the
    existing dri2.c logic, we also use the same name for the VDPAU driver,
    except for i965 (and now iris), where we switch to the "va_gl" fallback.
    
    This allows us to bypass the PCI ID lists in xserver and centralize the
    driver selection mechanism inside Mesa.  The hope is that we no longer
    have to update these lists for any future hardware.
    
    (backported from commit 8d4be7f6c4f7c673d7ec1a6bfdef944907a3916e)
    
    Acked-by: Michel Dänzer <mdaenzer at redhat.com>

diff --git a/hw/xfree86/common/xf86Module.h b/hw/xfree86/common/xf86Module.h
index dd4d5f958..00aa84ae2 100644
--- a/hw/xfree86/common/xf86Module.h
+++ b/hw/xfree86/common/xf86Module.h
@@ -74,7 +74,7 @@
  * mask is 0xFFFF0000.
  */
 #define ABI_ANSIC_VERSION	SET_ABI_VERSION(0, 4)
-#define ABI_VIDEODRV_VERSION	SET_ABI_VERSION(24, 0)
+#define ABI_VIDEODRV_VERSION	SET_ABI_VERSION(24, 1)
 #define ABI_XINPUT_VERSION	SET_ABI_VERSION(24, 1)
 #define ABI_EXTENSION_VERSION	SET_ABI_VERSION(10, 0)
 
diff --git a/hw/xfree86/drivers/modesetting/dri2.c b/hw/xfree86/drivers/modesetting/dri2.c
index 96eaaaaf7..167814015 100644
--- a/hw/xfree86/drivers/modesetting/dri2.c
+++ b/hw/xfree86/drivers/modesetting/dri2.c
@@ -1033,6 +1033,7 @@ ms_dri2_screen_init(ScreenPtr screen)
     ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
     modesettingPtr ms = modesettingPTR(scrn);
     DRI2InfoRec info;
+    const char *driver_names[2] = { NULL, NULL };
 
     if (!glamor_supports_pixmap_import_export(screen)) {
         xf86DrvMsg(scrn->scrnIndex, X_WARNING,
@@ -1071,9 +1072,30 @@ ms_dri2_screen_init(ScreenPtr screen)
     info.DestroyBuffer2 = ms_dri2_destroy_buffer2;
     info.CopyRegion2 = ms_dri2_copy_region2;
 
-    /* These two will be filled in by dri2.c */
-    info.numDrivers = 0;
-    info.driverNames = NULL;
+    /* Ask Glamor to obtain the DRI driver name via EGL_MESA_query_driver. */
+    driver_names[0] = glamor_egl_get_driver_name(screen);
+
+    if (driver_names[0]) {
+        /* There is no VDPAU driver for Intel, fallback to the generic
+         * OpenGL/VAAPI va_gl backend to emulate VDPAU.  Otherwise,
+         * guess that the DRI and VDPAU drivers have the same name.
+         */
+        if (strcmp(driver_names[0], "i965") == 0 ||
+            strcmp(driver_names[0], "iris") == 0) {
+            driver_names[1] = "va_gl";
+        } else {
+            driver_names[1] = driver_names[0];
+        }
+
+        info.numDrivers = 2;
+        info.driverNames = driver_names;
+    } else {
+        /* EGL_MESA_query_driver was unavailable; let dri2.c select the
+         * driver and fill in these fields for us.
+         */
+        info.numDrivers = 0;
+        info.driverNames = NULL;
+    }
 
     return DRI2ScreenInit(screen, &info);
 }
commit 2a1a96d956f4023796737d26a32354e940c8e6cf
Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Thu Nov 21 23:01:28 2019 -0800

    glamor: Add a function to get the driver name via EGL_MESA_query_driver
    
    This maps to eglGetDisplayDriverName if EGL_MESA_query_render is
    supported, otherwise it returns NULL.
    
    (cherry picked from commit 195c2ef8f9f07b9bdabc0f554a9033b7857b99c7)

diff --git a/glamor/glamor.h b/glamor/glamor.h
index 09e9c895c..3f9d265db 100644
--- a/glamor/glamor.h
+++ b/glamor/glamor.h
@@ -395,6 +395,8 @@ extern _X_EXPORT Bool
                                                struct gbm_bo *bo,
                                                Bool used_modifiers);
 
+extern _X_EXPORT const char *glamor_egl_get_driver_name(ScreenPtr screen);
+
 #endif
 
 extern _X_EXPORT void glamor_egl_screen_init(ScreenPtr screen,
diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index 9a619a133..ce8cbfaf4 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -688,6 +688,22 @@ glamor_get_modifiers(ScreenPtr screen, uint32_t format,
 #endif
 }
 
+_X_EXPORT const char *
+glamor_egl_get_driver_name(ScreenPtr screen)
+{
+#ifdef GLAMOR_HAS_EGL_QUERY_DRIVER
+    struct glamor_egl_screen_private *glamor_egl;
+
+    glamor_egl = glamor_egl_get_screen_private(xf86ScreenToScrn(screen));
+
+    if (epoxy_has_egl_extension(glamor_egl->display, "EGL_MESA_query_driver"))
+        return eglGetDisplayDriverName(glamor_egl->display);
+#endif
+
+    return NULL;
+}
+
+
 static Bool
 glamor_egl_destroy_pixmap(PixmapPtr pixmap)
 {
diff --git a/include/meson.build b/include/meson.build
index 64c6c81ce..ac2415327 100644
--- a/include/meson.build
+++ b/include/meson.build
@@ -74,6 +74,8 @@ conf_data.set('HAVE_XSHMFENCE', xshmfence_dep.found())
 conf_data.set('WITH_LIBDRM', libdrm_dep.found())
 conf_data.set('GLAMOR_HAS_EGL_QUERY_DMABUF',
               epoxy_dep.found() and epoxy_dep.version().version_compare('>= 1.4.4'))
+conf_data.set('GLAMOR_HAS_EGL_QUERY_DRIVER',
+              epoxy_dep.found() and epoxy_dep.version().version_compare('>= 1.5.4'))
 conf_data.set('GLXEXT', build_glx)
 conf_data.set('GLAMOR', build_glamor)
 conf_data.set('GLAMOR_HAS_GBM', gbm_dep.found())


More information about the xorg-commit mailing list