[mutter] renderer/native: Restore EGL state after creating secondary GPU state



commit ad838ec540f41190917fe16a1118cf46980c8e64
Author: Ɓukasz Spintzyk <lukasz spintzyk synaptics com>
Date:   Wed Apr 6 12:39:09 2022 +0200

    renderer/native: Restore EGL state after creating secondary GPU state
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2347>

 src/backends/native/meta-renderer-native.c | 40 ++++++++++++++----------------
 1 file changed, 18 insertions(+), 22 deletions(-)
---
diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c
index 41bf04d665..d538cc25a4 100644
--- a/src/backends/native/meta-renderer-native.c
+++ b/src/backends/native/meta-renderer-native.c
@@ -1566,9 +1566,12 @@ init_secondary_gpu_data_gpu (MetaRendererNativeGpuData *renderer_gpu_data,
   MetaRendererNative *renderer_native = renderer_gpu_data->renderer_native;
   MetaRenderDevice *render_device = renderer_gpu_data->render_device;
   MetaEgl *egl = meta_renderer_native_get_egl (renderer_native);
+  gboolean ret = FALSE;
   EGLDisplay egl_display;
   EGLConfig egl_config;
   EGLContext egl_context;
+  CoglContext *cogl_context;
+  CoglDisplay *cogl_display;
   const char **missing_gl_extensions;
 
   egl_display = meta_render_device_get_egl_display (render_device);
@@ -1576,26 +1579,26 @@ init_secondary_gpu_data_gpu (MetaRendererNativeGpuData *renderer_gpu_data,
     {
       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
                    "No EGL display");
-      return FALSE;
+      goto out;
     }
 
   if (!meta_render_device_is_hardware_accelerated (render_device))
     {
       g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
                    "Not hardware accelerated");
-      return FALSE;
+      goto out;
     }
 
   meta_egl_bind_api (egl, EGL_OPENGL_ES_API, NULL);
 
   if (!create_secondary_egl_config (egl, renderer_gpu_data->mode, egl_display,
                                     &egl_config, error))
-    goto err;
+    goto out;
 
   egl_context = create_secondary_egl_context (egl, egl_display, egl_config,
                                               error);
   if (egl_context == EGL_NO_CONTEXT)
-    goto err;
+    goto out;
 
   meta_renderer_native_ensure_gles3 (renderer_native);
 
@@ -1607,7 +1610,7 @@ init_secondary_gpu_data_gpu (MetaRendererNativeGpuData *renderer_gpu_data,
                               error))
     {
       meta_egl_destroy_context (egl, egl_display, egl_context, NULL);
-      goto err;
+      goto out;
     }
 
   if (!meta_gles3_has_extensions (renderer_native->gles3,
@@ -1625,7 +1628,7 @@ init_secondary_gpu_data_gpu (MetaRendererNativeGpuData *renderer_gpu_data,
       g_free (missing_gl_extensions_str);
       g_free (missing_gl_extensions);
 
-      goto err_fail_make_current;
+      goto out;
     }
 
   renderer_gpu_data->secondary.egl_context = egl_context;
@@ -1636,23 +1639,16 @@ init_secondary_gpu_data_gpu (MetaRendererNativeGpuData *renderer_gpu_data,
     meta_egl_has_extensions (egl, egl_display, NULL,
                              "EGL_EXT_image_dma_buf_import_modifiers",
                              NULL);
-
-  maybe_restore_cogl_egl_api (renderer_native);
-
-  return TRUE;
-
-err_fail_make_current:
-  meta_egl_make_current (egl,
-                         egl_display,
-                         EGL_NO_SURFACE,
-                         EGL_NO_SURFACE,
-                         EGL_NO_CONTEXT,
-                         NULL);
-
-err:
+  ret = TRUE;
+out:
   maybe_restore_cogl_egl_api (renderer_native);
-
-  return FALSE;
+  cogl_context = cogl_context_from_renderer_native (renderer_native);
+  if (cogl_context)
+    {
+      cogl_display = cogl_context_get_display (cogl_context);
+      _cogl_winsys_egl_ensure_current (cogl_display);
+    }
+  return ret;
 }
 
 static void


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