Blame SOURCES/0002-renderer-native-Try-the-gbm-renderer-before-the-EGLD.patch

5c9faf
From 425710866438a62843b96272a6cbc6c22174f10c Mon Sep 17 00:00:00 2001
5c9faf
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
5c9faf
Date: Mon, 11 Oct 2021 10:39:43 +0200
5c9faf
Subject: [PATCH 2/5] renderer/native: Try the gbm renderer before the
5c9faf
 EGLDevice renderer
5c9faf
5c9faf
This switches the order of what renderer mode is tried first, so that
5c9faf
the gbm renderer mode is preferred on an NVIDIA driver where it is
5c9faf
supported.
5c9faf
5c9faf
We fall back to still try the EGLDevice renderer mode if the created gbm
5c9faf
renderer is not hardware accelerated.
5c9faf
5c9faf
The last fallback is still to use the gbm renderer, even if it is not
5c9faf
hardware accelerated, as this is needed when hardware acceleration isn't
5c9faf
available at all. The original reason for the old order was due to the
5c9faf
fact that a gbm renderer without hardware acceleration would succeed
5c9faf
even on NVIDIA driver that didn't support gbm.
5c9faf
5c9faf
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2051>
5c9faf
(cherry picked from commit 8fc1325e8e713dfa05a12c47e6e981e50d3cda61)
5c9faf
---
5c9faf
 src/backends/native/meta-renderer-native.c | 44 +++++++++++-----------
5c9faf
 1 file changed, 23 insertions(+), 21 deletions(-)
5c9faf
5c9faf
diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c
5c9faf
index f92f648e5..c851619a1 100644
5c9faf
--- a/src/backends/native/meta-renderer-native.c
5c9faf
+++ b/src/backends/native/meta-renderer-native.c
5c9faf
@@ -1754,38 +1754,40 @@ meta_renderer_native_create_renderer_gpu_data (MetaRendererNative  *renderer_nat
5c9faf
                                                MetaGpuKms          *gpu_kms,
5c9faf
                                                GError             **error)
5c9faf
 {
5c9faf
-  MetaRendererNativeGpuData *renderer_gpu_data;
5c9faf
+  MetaRendererNativeGpuData *gbm_renderer_gpu_data;
5c9faf
   GError *gbm_error = NULL;
5c9faf
 #ifdef HAVE_EGL_DEVICE
5c9faf
+  MetaRendererNativeGpuData *egl_stream_renderer_gpu_data;
5c9faf
   GError *egl_device_error = NULL;
5c9faf
 #endif
5c9faf
 
5c9faf
   if (!gpu_kms)
5c9faf
     return create_renderer_gpu_data_surfaceless (renderer_native, error);
5c9faf
 
5c9faf
-#ifdef HAVE_EGL_DEVICE
5c9faf
-  /* Try to initialize the EGLDevice backend first. Whenever we use a
5c9faf
-   * non-NVIDIA GPU, the EGLDevice enumeration function won't find a match, and
5c9faf
-   * we'll fall back to GBM (which will always succeed as it has a software
5c9faf
-   * rendering fallback)
5c9faf
-   */
5c9faf
-  renderer_gpu_data = create_renderer_gpu_data_egl_device (renderer_native,
5c9faf
-                                                           gpu_kms,
5c9faf
-                                                           &egl_device_error);
5c9faf
-  if (renderer_gpu_data)
5c9faf
-    return renderer_gpu_data;
5c9faf
-#endif
5c9faf
-
5c9faf
-  renderer_gpu_data = create_renderer_gpu_data_gbm (renderer_native,
5c9faf
-                                                    gpu_kms,
5c9faf
-                                                    &gbm_error);
5c9faf
-  if (renderer_gpu_data)
5c9faf
+  gbm_renderer_gpu_data = create_renderer_gpu_data_gbm (renderer_native,
5c9faf
+                                                        gpu_kms,
5c9faf
+                                                        &gbm_error);
5c9faf
+  if (gbm_renderer_gpu_data)
5c9faf
     {
5c9faf
+      if (gbm_renderer_gpu_data->secondary.is_hardware_rendering)
5c9faf
+        return gbm_renderer_gpu_data;
5c9faf
+    }
5c9faf
+
5c9faf
 #ifdef HAVE_EGL_DEVICE
5c9faf
-      g_error_free (egl_device_error);
5c9faf
-#endif
5c9faf
-      return renderer_gpu_data;
5c9faf
+  egl_stream_renderer_gpu_data =
5c9faf
+    create_renderer_gpu_data_egl_device (renderer_native,
5c9faf
+                                         gpu_kms,
5c9faf
+                                         &egl_device_error);
5c9faf
+  if (egl_stream_renderer_gpu_data)
5c9faf
+    {
5c9faf
+      g_clear_pointer (&gbm_renderer_gpu_data,
5c9faf
+                       meta_renderer_native_gpu_data_free);
5c9faf
+      return egl_stream_renderer_gpu_data;
5c9faf
     }
5c9faf
+#endif
5c9faf
+
5c9faf
+  if (gbm_renderer_gpu_data)
5c9faf
+    return gbm_renderer_gpu_data;
5c9faf
 
5c9faf
   g_set_error (error, G_IO_ERROR,
5c9faf
                G_IO_ERROR_FAILED,
5c9faf
-- 
5c9faf
2.35.1
5c9faf