[mutter/gnome-41] renderer/native: Allow forcing EGLStream backend



commit 0f68e57444b3eb932de1acfe89ba7022f47882ce
Author: Jonas Ådahl <jadahl gmail com>
Date:   Fri Dec 3 11:07:00 2021 +0100

    renderer/native: Allow forcing EGLStream backend
    
    The GBM support in the NVIDIA driver is fairly new, and to make it
    easier to identify whether a problem encountered is related to using GBM
    instead of EGLStreams, add a debug environment variable to force using
    EGLStream instead of GBM.
    
    To force using EGLStream instead of GBM, use
    
        MUTTER_DEBUG_FORCE_EGL_STREAM=1
    
    Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/2045
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2132>
    (cherry picked from commit d43cc776ef733251fc02e8e62669ea4ba7e68e2c)

 src/backends/native/meta-renderer-native.c | 28 ++++++++++++++++++++--------
 1 file changed, 20 insertions(+), 8 deletions(-)
---
diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c
index 4c6fa5b709..4e8786a4dd 100644
--- a/src/backends/native/meta-renderer-native.c
+++ b/src/backends/native/meta-renderer-native.c
@@ -1975,7 +1975,7 @@ meta_renderer_native_create_renderer_gpu_data (MetaRendererNative  *renderer_nat
   MetaBackend *backend = meta_renderer_get_backend (renderer);
   MetaDevicePool *device_pool =
     meta_backend_native_get_device_pool (META_BACKEND_NATIVE (backend));
-  MetaRendererNativeGpuData *gbm_renderer_gpu_data;
+  MetaRendererNativeGpuData *gbm_renderer_gpu_data = NULL;
   MetaDeviceFileFlags device_file_flags = META_DEVICE_FILE_FLAG_NONE;
   g_autoptr (MetaDeviceFile) device_file = NULL;
   GError *gbm_error = NULL;
@@ -1998,15 +1998,27 @@ meta_renderer_native_create_renderer_gpu_data (MetaRendererNative  *renderer_nat
   if (!device_file)
     return NULL;
 
-  gbm_renderer_gpu_data = create_renderer_gpu_data_gbm (renderer_native,
-                                                        gpu_kms,
-                                                        device_file,
-                                                        &gbm_error);
-  if (gbm_renderer_gpu_data)
+#ifdef HAVE_EGL_DEVICE
+  if (g_strcmp0 (getenv ("MUTTER_DEBUG_FORCE_EGL_STREAM"), "1") != 0)
+#endif
+    {
+      gbm_renderer_gpu_data = create_renderer_gpu_data_gbm (renderer_native,
+                                                            gpu_kms,
+                                                            device_file,
+                                                            &gbm_error);
+      if (gbm_renderer_gpu_data)
+        {
+          if (gbm_renderer_gpu_data->secondary.is_hardware_rendering)
+            return gbm_renderer_gpu_data;
+        }
+    }
+#ifdef HAVE_EGL_DEVICE
+  else
     {
-      if (gbm_renderer_gpu_data->secondary.is_hardware_rendering)
-        return gbm_renderer_gpu_data;
+      g_set_error (&gbm_error, G_IO_ERROR, G_IO_ERROR_FAILED,
+                   "GBM backend was disabled using env var");
     }
+#endif
 
 #ifdef HAVE_EGL_DEVICE
   egl_stream_renderer_gpu_data =


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