Blame SOURCES/0003-wayland-Only-init-EGLStream-controller-if-we-didn-t-.patch

1e895f
From 07f63ad466b66cc02b49a326789686bce9325201 Mon Sep 17 00:00:00 2001
1e895f
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
1e895f
Date: Thu, 14 Oct 2021 18:36:43 +0200
1e895f
Subject: [PATCH 3/5] wayland: Only init EGLStream controller if we didn't end
1e895f
 up with gbm
1e895f
1e895f
When we use gbm together with the NVIDIA driver, we want the EGL/Vulkan
1e895f
clients to do the same, instead of using the EGLStream paths. To achieve
1e895f
that, make sure to only initialize the EGLStream controller when we
1e895f
didn't end up using gbm as the renderer backend.
1e895f
1e895f
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2052>
1e895f
(cherry picked from commit ac907119ae0f415c099976635c3b1dff4d2d7201)
1e895f
(cherry picked from commit e3931f7b8cbd44072137c5dc9de9041486daeade)
1e895f
---
1e895f
 src/backends/native/meta-renderer-native.c | 11 +++++++++
1e895f
 src/backends/native/meta-renderer-native.h |  2 ++
1e895f
 src/wayland/meta-wayland.c                 | 26 ++++++++++++++++++++--
1e895f
 3 files changed, 37 insertions(+), 2 deletions(-)
1e895f
1e895f
diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c
1e895f
index c851619a1..e7460fbf1 100644
1e895f
--- a/src/backends/native/meta-renderer-native.c
1e895f
+++ b/src/backends/native/meta-renderer-native.c
1e895f
@@ -201,6 +201,17 @@ meta_renderer_native_has_pending_mode_set (MetaRendererNative *renderer_native)
1e895f
   return renderer_native->pending_mode_set;
1e895f
 }
1e895f
 
1e895f
+MetaRendererNativeMode
1e895f
+meta_renderer_native_get_mode (MetaRendererNative *renderer_native)
1e895f
+{
1e895f
+  MetaGpuKms *primary_gpu = renderer_native->primary_gpu_kms;
1e895f
+  MetaRendererNativeGpuData *primary_gpu_data;
1e895f
+
1e895f
+  primary_gpu_data = meta_renderer_native_get_gpu_data (renderer_native,
1e895f
+                                                        primary_gpu);
1e895f
+  return primary_gpu_data->mode;
1e895f
+}
1e895f
+
1e895f
 static void
1e895f
 meta_renderer_native_disconnect (CoglRenderer *cogl_renderer)
1e895f
 {
1e895f
diff --git a/src/backends/native/meta-renderer-native.h b/src/backends/native/meta-renderer-native.h
1e895f
index 9475e1857..8c06c2473 100644
1e895f
--- a/src/backends/native/meta-renderer-native.h
1e895f
+++ b/src/backends/native/meta-renderer-native.h
1e895f
@@ -66,4 +66,6 @@ void meta_renderer_native_reset_modes (MetaRendererNative *renderer_native);
1e895f
 
1e895f
 gboolean meta_renderer_native_use_modifiers (MetaRendererNative *renderer_native);
1e895f
 
1e895f
+MetaRendererNativeMode meta_renderer_native_get_mode (MetaRendererNative *renderer_native);
1e895f
+
1e895f
 #endif /* META_RENDERER_NATIVE_H */
1e895f
diff --git a/src/wayland/meta-wayland.c b/src/wayland/meta-wayland.c
1e895f
index 8f16aa429..a3f098410 100644
1e895f
--- a/src/wayland/meta-wayland.c
1e895f
+++ b/src/wayland/meta-wayland.c
1e895f
@@ -50,6 +50,10 @@
1e895f
 #include "wayland/meta-xwayland-private.h"
1e895f
 #include "wayland/meta-xwayland.h"
1e895f
 
1e895f
+#ifdef HAVE_NATIVE_BACKEND
1e895f
+#include "backends/native/meta-renderer-native.h"
1e895f
+#endif
1e895f
+
1e895f
 static char *_display_name_override;
1e895f
 
1e895f
 G_DEFINE_TYPE (MetaWaylandCompositor, meta_wayland_compositor, G_TYPE_OBJECT)
1e895f
@@ -521,8 +525,26 @@ meta_wayland_compositor_setup (MetaWaylandCompositor *compositor)
1e895f
                                   compositor);
1e895f
 
1e895f
 #ifdef HAVE_WAYLAND_EGLSTREAM
1e895f
-  meta_wayland_eglstream_controller_init (compositor);
1e895f
-#endif
1e895f
+    {
1e895f
+      gboolean should_enable_eglstream_controller = TRUE;
1e895f
+#if defined(HAVE_EGL_DEVICE) && defined(HAVE_NATIVE_BACKEND)
1e895f
+      MetaBackend *backend = meta_get_backend ();
1e895f
+      MetaRenderer *renderer = meta_backend_get_renderer (backend);
1e895f
+
1e895f
+      if (META_IS_RENDERER_NATIVE (renderer))
1e895f
+        {
1e895f
+          MetaRendererNative *renderer_native = META_RENDERER_NATIVE (renderer);
1e895f
+
1e895f
+          if (meta_renderer_native_get_mode (renderer_native) ==
1e895f
+              META_RENDERER_NATIVE_MODE_GBM)
1e895f
+            should_enable_eglstream_controller = FALSE;
1e895f
+        }
1e895f
+#endif /* defined(HAVE_EGL_DEVICE) && defined(HAVE_NATIVE_BACKEND) */
1e895f
+
1e895f
+      if (should_enable_eglstream_controller)
1e895f
+        meta_wayland_eglstream_controller_init (compositor);
1e895f
+    }
1e895f
+#endif /* HAVE_WAYLAND_EGLSTREAM */
1e895f
 
1e895f
   if (meta_get_x11_display_policy () != META_DISPLAY_POLICY_DISABLED)
1e895f
     {
1e895f
-- 
1e895f
2.35.1
1e895f