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

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