[mutter] onscreen/native: Make sure to reset the EGL context after dGPU blit



commit 14f6869381a95a7bafb0878cea771d38cf05456d
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Thu Mar 25 18:24:10 2021 +0100

    onscreen/native: Make sure to reset the EGL context after dGPU blit
    
    On hybrid graphics system, the primary path used to transfer the stage
    framebuffer onto the dedicated GPU's video memory preparing for scanout,
    is using the dedicated GPU to glBlitFramebuffer() the content from the
    iGPU texture onto the scanout buffer.
    
    After we have done this, we reset the current EGL context back to the
    one managed by cogl. What we failed to do, however, was to reset the
    current EGL context when we inhibited the actual page flip due to having
    entered power save mode.
    
    When we later started to paint again, Cogl thought the current EGL
    context was still the correct one, but in fact it was the one used for
    the iGPU -> dGPU blit, causing various EGL surface errors, and as a side
    effect, eventually hitting an assert.
    
    Fix this by making sure we reset to the Cogl managed EGL context also
    for this case.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1803>

 src/backends/native/meta-onscreen-native.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
---
diff --git a/src/backends/native/meta-onscreen-native.c b/src/backends/native/meta-onscreen-native.c
index e8c4355274..eb49bd45c6 100644
--- a/src/backends/native/meta-onscreen-native.c
+++ b/src/backends/native/meta-onscreen-native.c
@@ -1071,6 +1071,15 @@ meta_onscreen_native_swap_buffers_with_damage (CoglOnscreen  *onscreen,
 
   update_secondary_gpu_state_post_swap_buffers (onscreen, &egl_context_changed);
 
+  /*
+   * If we changed EGL context, cogl will have the wrong idea about what is
+   * current, making it fail to set it when it needs to. Avoid that by making
+   * EGL_NO_CONTEXT current now, making cogl eventually set the correct
+   * context.
+   */
+  if (egl_context_changed)
+    _cogl_winsys_egl_ensure_current (cogl_display);
+
   power_save_mode = meta_monitor_manager_get_power_save_mode (monitor_manager);
   if (power_save_mode == META_POWER_SAVE_ON)
     {
@@ -1089,15 +1098,6 @@ meta_onscreen_native_swap_buffers_with_damage (CoglOnscreen  *onscreen,
       return;
     }
 
-  /*
-   * If we changed EGL context, cogl will have the wrong idea about what is
-   * current, making it fail to set it when it needs to. Avoid that by making
-   * EGL_NO_CONTEXT current now, making cogl eventually set the correct
-   * context.
-   */
-  if (egl_context_changed)
-    _cogl_winsys_egl_ensure_current (cogl_display);
-
   COGL_TRACE_BEGIN_SCOPED (MetaRendererNativePostKmsUpdate,
                            "Onscreen (post pending update)");
   kms_crtc = meta_crtc_kms_get_kms_crtc (META_CRTC_KMS (onscreen_native->crtc));


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