[mutter/wip/texture-purge-on-nvidia: 63/66] renderer/native: Retry EGLStream page flip again after 17ms if busy



commit 3b80b02e804acc637d596c0fee54974a5fb66042
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Fri Jan 4 11:40:44 2019 +0100

    renderer/native: Retry EGLStream page flip again after 17ms if busy
    
    After changing mode, the first page flip will fail with EGL_RESOURCE_BUSY_EXT
    but testing shows that waiting for 8ms then retrying makes it succeed. To be a
    bit more on the safe side, try this once but wait for 17ms instead.
    
    This should avoids a dead lock when calling eglSwapBuffers() after the failed
    page flip we now retry.

 src/backends/native/meta-renderer-native.c | 44 +++++++++++++++++++++---------
 1 file changed, 31 insertions(+), 13 deletions(-)
---
diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c
index b15a6da96..a3711b707 100644
--- a/src/backends/native/meta-renderer-native.c
+++ b/src/backends/native/meta-renderer-native.c
@@ -1289,6 +1289,7 @@ flip_egl_stream (MetaOnscreenNative *onscreen_native,
   MetaGpuKmsFlipClosureContainer *closure_container;
   EGLAttrib *acquire_attribs;
   GError *error = NULL;
+  gboolean was_busy_once = FALSE;
 
   renderer_gpu_data =
     meta_renderer_native_get_gpu_data (onscreen_native->renderer_native,
@@ -1306,22 +1307,39 @@ flip_egl_stream (MetaOnscreenNative *onscreen_native,
   };
 
   egl_display = renderer_gpu_data->egl_display;
-  if (!meta_egl_stream_consumer_acquire_attrib (egl,
-                                                egl_display,
-                                                onscreen_native->egl.stream,
-                                                acquire_attribs,
-                                                &error))
+
+  while (TRUE)
     {
-      if (error->domain != META_EGL_ERROR ||
-          error->code != EGL_RESOURCE_BUSY_EXT)
+      if (!meta_egl_stream_consumer_acquire_attrib (egl,
+                                                    egl_display,
+                                                    onscreen_native->egl.stream,
+                                                    acquire_attribs,
+                                                    &error))
         {
-          g_warning ("Failed to flip EGL stream (%s), relying on clock from "
-                     "now on", error->message);
-          renderer_gpu_data->egl.no_egl_output_drm_flip_event = TRUE;
+          if (error->domain != META_EGL_ERROR ||
+              error->code != EGL_RESOURCE_BUSY_EXT ||
+              was_busy_once)
+            {
+              g_warning ("Failed to flip EGL stream (%s), inhibiting eglSwapBuffers()",
+                         error->message);
+              renderer_gpu_data->egl.no_egl_output_drm_flip_event = TRUE;
+
+              g_error_free (error);
+              meta_gpu_kms_flip_closure_container_free (closure_container);
+              return FALSE;
+            }
+          else
+            {
+              g_warning ("Failed to flip EGL stream (%s), retrying after 17ms",
+                         error->message);
+              was_busy_once = TRUE;
+              usleep(17000);
+              g_clear_error (&error);
+              continue;
+            }
+
         }
-      g_error_free (error);
-      meta_gpu_kms_flip_closure_container_free (closure_container);
-      return FALSE;
+      break;
     }
 
   g_closure_ref (flip_closure);


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