Blame SOURCES/0004-renderer-native-Allow-forcing-EGLStream-backend.patch

1e895f
From 4c23158f81c3c4b91353150fd4c28246ce1e692f Mon Sep 17 00:00:00 2001
1e895f
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
1e895f
Date: Fri, 3 Dec 2021 11:07:00 +0100
1e895f
Subject: [PATCH 4/5] renderer/native: Allow forcing EGLStream backend
1e895f
1e895f
The GBM support in the NVIDIA driver is fairly new, and to make it
1e895f
easier to identify whether a problem encountered is related to using GBM
1e895f
instead of EGLStreams, add a debug environment variable to force using
1e895f
EGLStream instead of GBM.
1e895f
1e895f
To force using EGLStream instead of GBM, use
1e895f
1e895f
    MUTTER_DEBUG_FORCE_EGL_STREAM=1
1e895f
1e895f
Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/2045
1e895f
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2132>
1e895f
(cherry picked from commit d43cc776ef733251fc02e8e62669ea4ba7e68e2c)
1e895f
---
1e895f
 src/backends/native/meta-renderer-native.c | 26 ++++++++++++++++------
1e895f
 1 file changed, 19 insertions(+), 7 deletions(-)
1e895f
1e895f
diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c
1e895f
index e7460fbf1..0cd7a27d6 100644
1e895f
--- a/src/backends/native/meta-renderer-native.c
1e895f
+++ b/src/backends/native/meta-renderer-native.c
1e895f
@@ -1765,7 +1765,7 @@ meta_renderer_native_create_renderer_gpu_data (MetaRendererNative  *renderer_nat
1e895f
                                                MetaGpuKms          *gpu_kms,
1e895f
                                                GError             **error)
1e895f
 {
1e895f
-  MetaRendererNativeGpuData *gbm_renderer_gpu_data;
1e895f
+  MetaRendererNativeGpuData *gbm_renderer_gpu_data = NULL;
1e895f
   GError *gbm_error = NULL;
1e895f
 #ifdef HAVE_EGL_DEVICE
1e895f
   MetaRendererNativeGpuData *egl_stream_renderer_gpu_data;
1e895f
@@ -1775,14 +1775,26 @@ meta_renderer_native_create_renderer_gpu_data (MetaRendererNative  *renderer_nat
1e895f
   if (!gpu_kms)
1e895f
     return create_renderer_gpu_data_surfaceless (renderer_native, error);
1e895f
 
1e895f
-  gbm_renderer_gpu_data = create_renderer_gpu_data_gbm (renderer_native,
1e895f
-                                                        gpu_kms,
1e895f
-                                                        &gbm_error);
1e895f
-  if (gbm_renderer_gpu_data)
1e895f
+#ifdef HAVE_EGL_DEVICE
1e895f
+  if (g_strcmp0 (getenv ("MUTTER_DEBUG_FORCE_EGL_STREAM"), "1") != 0)
1e895f
+#endif
1e895f
+    {
1e895f
+      gbm_renderer_gpu_data = create_renderer_gpu_data_gbm (renderer_native,
1e895f
+                                                            gpu_kms,
1e895f
+                                                            &gbm_error);
1e895f
+      if (gbm_renderer_gpu_data)
1e895f
+        {
1e895f
+          if (gbm_renderer_gpu_data->secondary.is_hardware_rendering)
1e895f
+            return gbm_renderer_gpu_data;
1e895f
+        }
1e895f
+    }
1e895f
+#ifdef HAVE_EGL_DEVICE
1e895f
+  else
1e895f
     {
1e895f
-      if (gbm_renderer_gpu_data->secondary.is_hardware_rendering)
1e895f
-        return gbm_renderer_gpu_data;
1e895f
+      g_set_error (&gbm_error, G_IO_ERROR, G_IO_ERROR_FAILED,
1e895f
+                   "GBM backend was disabled using env var");
1e895f
     }
1e895f
+#endif
1e895f
 
1e895f
 #ifdef HAVE_EGL_DEVICE
1e895f
   egl_stream_renderer_gpu_data =
1e895f
-- 
1e895f
2.35.1
1e895f