[mutter/gnome-41] wayland: Only init EGLStream controller if we didn't end up with gbm



commit e3931f7b8cbd44072137c5dc9de9041486daeade
Author: Jonas Ådahl <jadahl gmail com>
Date:   Thu Oct 14 18:36:43 2021 +0200

    wayland: Only init EGLStream controller if we didn't end up with gbm
    
    When we use gbm together with the NVIDIA driver, we want the EGL/Vulkan
    clients to do the same, instead of using the EGLStream paths. To achieve
    that, make sure to only initialize the EGLStream controller when we
    didn't end up using gbm as the renderer backend.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2052>
    (cherry picked from commit ac907119ae0f415c099976635c3b1dff4d2d7201)

 src/backends/native/meta-renderer-native.c | 11 +++++++++++
 src/backends/native/meta-renderer-native.h |  2 ++
 src/wayland/meta-wayland.c                 | 25 +++++++++++++++++++++++--
 3 files changed, 36 insertions(+), 2 deletions(-)
---
diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c
index 452503777d..75751fb672 100644
--- a/src/backends/native/meta-renderer-native.c
+++ b/src/backends/native/meta-renderer-native.c
@@ -220,6 +220,17 @@ meta_renderer_native_has_pending_mode_set (MetaRendererNative *renderer_native)
   return renderer_native->pending_mode_set;
 }
 
+MetaRendererNativeMode
+meta_renderer_native_get_mode (MetaRendererNative *renderer_native)
+{
+  MetaGpuKms *primary_gpu = renderer_native->primary_gpu_kms;
+  MetaRendererNativeGpuData *primary_gpu_data;
+
+  primary_gpu_data = meta_renderer_native_get_gpu_data (renderer_native,
+                                                        primary_gpu);
+  return primary_gpu_data->mode;
+}
+
 static void
 meta_renderer_native_disconnect (CoglRenderer *cogl_renderer)
 {
diff --git a/src/backends/native/meta-renderer-native.h b/src/backends/native/meta-renderer-native.h
index 2c23c651ad..a01ceede26 100644
--- a/src/backends/native/meta-renderer-native.h
+++ b/src/backends/native/meta-renderer-native.h
@@ -68,4 +68,6 @@ void meta_renderer_native_reset_modes (MetaRendererNative *renderer_native);
 
 gboolean meta_renderer_native_use_modifiers (MetaRendererNative *renderer_native);
 
+MetaRendererNativeMode meta_renderer_native_get_mode (MetaRendererNative *renderer_native);
+
 #endif /* META_RENDERER_NATIVE_H */
diff --git a/src/wayland/meta-wayland.c b/src/wayland/meta-wayland.c
index 089b2d5026..ceb2afed35 100644
--- a/src/wayland/meta-wayland.c
+++ b/src/wayland/meta-wayland.c
@@ -51,6 +51,10 @@
 #include "wayland/meta-xwayland-private.h"
 #include "wayland/meta-xwayland.h"
 
+#ifdef HAVE_NATIVE_BACKEND
+#include "backends/native/meta-renderer-native.h"
+#endif
+
 static char *_display_name_override;
 
 G_DEFINE_TYPE (MetaWaylandCompositor, meta_wayland_compositor, G_TYPE_OBJECT)
@@ -573,8 +577,25 @@ meta_wayland_compositor_new (MetaContext *context)
                                   compositor);
 
 #ifdef HAVE_WAYLAND_EGLSTREAM
-  meta_wayland_eglstream_controller_init (compositor);
-#endif
+    {
+      gboolean should_enable_eglstream_controller = TRUE;
+#if defined(HAVE_EGL_DEVICE) && defined(HAVE_NATIVE_BACKEND)
+      MetaRenderer *renderer = meta_backend_get_renderer (backend);
+
+      if (META_IS_RENDERER_NATIVE (renderer))
+        {
+          MetaRendererNative *renderer_native = META_RENDERER_NATIVE (renderer);
+
+          if (meta_renderer_native_get_mode (renderer_native) ==
+              META_RENDERER_NATIVE_MODE_GBM)
+            should_enable_eglstream_controller = FALSE;
+        }
+#endif /* defined(HAVE_EGL_DEVICE) && defined(HAVE_NATIVE_BACKEND) */
+
+      if (should_enable_eglstream_controller)
+        meta_wayland_eglstream_controller_init (compositor);
+    }
+#endif /* HAVE_WAYLAND_EGLSTREAM */
 
   x11_display_policy =
     meta_context_get_x11_display_policy (compositor->context);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]