pipe-loader: Try loading freedreno for virtgpu device
authorRob Clark <robdclark@chromium.org>
Wed, 2 Feb 2022 19:53:36 +0000 (11:53 -0800)
committerMarge Bot <emma+marge@anholt.net>
Fri, 25 Mar 2022 02:03:30 +0000 (02:03 +0000)
Freedreno will check if the virtgpu supports the pass-thru context, and
if not will bail, falling back to virgl.

TODO this requires that virgl is also enabled in the mesa build, even if
it is not needed.. maybe there is a better way to handle this?

Signed-off-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14900>

src/gallium/auxiliary/target-helpers/drm_helper.h
src/gallium/targets/dri/meson.build
src/gallium/targets/dri/target.c

index 6167a94..601396a 100644 (file)
@@ -274,21 +274,31 @@ DRM_DRIVER_DESCRIPTOR_STUB(msm)
 #endif
 DRM_DRIVER_DESCRIPTOR_ALIAS(msm, kgsl, NULL, 0)
 
-#ifdef GALLIUM_VIRGL
+#if defined(GALLIUM_VIRGL) || (defined(GALLIUM_FREEDRENO) && !defined(PIPE_LOADER_DYNAMIC))
 #include "virgl/drm/virgl_drm_public.h"
 #include "virgl/virgl_public.h"
 
 static struct pipe_screen *
 pipe_virtio_gpu_create_screen(int fd, const struct pipe_screen_config *config)
 {
-   struct pipe_screen *screen;
+   struct pipe_screen *screen = NULL;
 
-   screen = virgl_drm_screen_create(fd, config);
+   /* Try native guest driver(s) first, and then fallback to virgl: */
+#ifdef GALLIUM_FREEDRENO
+   if (!screen)
+      screen = fd_drm_screen_create(fd, NULL, config);
+#endif
+#ifdef GALLIUM_VIRGL
+   if (!screen)
+      screen = virgl_drm_screen_create(fd, config);
+#endif
    return screen ? debug_screen_wrap(screen) : NULL;
 }
 
 const driOptionDescription virgl_driconf[] = {
+#ifdef GALLIUM_VIRGL
       #include "virgl/virgl_driinfo.h.in"
+#endif
 };
 DRM_DRIVER_DESCRIPTOR(virtio_gpu, virgl_driconf, ARRAY_SIZE(virgl_driconf))
 
index 4733f43..2fc6363 100644 (file)
@@ -108,7 +108,9 @@ foreach d : [[with_gallium_kmsro, [
              [with_gallium_r300, 'r300_dri.so'],
              [with_gallium_r600, 'r600_dri.so'],
              [with_gallium_svga, 'vmwgfx_dri.so'],
-             [with_gallium_virgl, 'virtio_gpu_dri.so'],
+             [with_gallium_virgl or
+               (with_gallium_freedreno and with_freedreno_virtio),
+               'virtio_gpu_dri.so'],
              [with_gallium_lima, 'lima_dri.so'],
              [with_gallium_zink, 'zink_dri.so'],
              [with_gallium_d3d12, 'd3d12_dri.so'],
index 2ac9ef4..54fe382 100644 (file)
@@ -71,7 +71,7 @@ DEFINE_LOADER_DRM_ENTRYPOINT(msm)
 DEFINE_LOADER_DRM_ENTRYPOINT(kgsl)
 #endif
 
-#if defined(GALLIUM_VIRGL)
+#if defined(GALLIUM_VIRGL) || (defined(GALLIUM_FREEDRENO) && !defined(PIPE_LOADER_DYNAMIC))
 DEFINE_LOADER_DRM_ENTRYPOINT(virtio_gpu)
 #endif