[PATCH xserver v2 16/22] present: Add cleanups for window flip mode

Roman Gilg subdiff at gmail.com
Wed Feb 28 16:36:58 UTC 2018


Make sure that vblanks and windows get cleaned up correctly
in window flip mode.

Signed-off-by: Roman Gilg <subdiff at gmail.com>
---
 present/present_screen.c | 33 ++++++++++++++++++++++++++++++++-
 present/present_vblank.c |  2 ++
 2 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/present/present_screen.c b/present/present_screen.c
index b0cae0f..8ad14ad 100644
--- a/present/present_screen.c
+++ b/present/present_screen.c
@@ -109,6 +109,32 @@ present_clear_window_flip(WindowPtr window)
     }
 }
 
+static void
+present_wnmd_clear_window_flip(WindowPtr window)
+{
+    present_window_priv_ptr     window_priv = present_window_priv(window);
+    present_vblank_ptr          vblank, tmp;
+
+    if (window_priv->flip_pending) {
+        present_wnmd_set_abort_flip(window);
+        window_priv->flip_pending->window = NULL;
+    }
+
+    xorg_list_for_each_entry_safe(vblank, tmp, &window_priv->idle_queue, event_queue) {
+        present_pixmap_idle(vblank->pixmap, vblank->window, vblank->serial, vblank->idle_fence);
+        /* The pixmap will be destroyed by freeing the window resources. */
+        vblank->pixmap = NULL;
+        present_vblank_destroy(vblank);
+    }
+
+    vblank = window_priv->flip_active;
+    if (vblank) {
+        present_pixmap_idle(vblank->pixmap, vblank->window, vblank->serial, vblank->idle_fence);
+        present_vblank_destroy(vblank);
+    }
+    window_priv->flip_active = NULL;
+}
+
 /*
  * Hook the close window function to clean up our window private
  */
@@ -124,7 +150,12 @@ present_destroy_window(WindowPtr window)
         present_clear_window_notifies(window);
         present_free_events(window);
         present_free_window_vblank(window);
-        present_clear_window_flip(window);
+
+        if (screen_priv->wnmd_info)
+            present_wnmd_clear_window_flip(window);
+        else
+            present_clear_window_flip(window);
+
         free(window_priv);
     }
     unwrap(screen_priv, screen, DestroyWindow);
diff --git a/present/present_vblank.c b/present/present_vblank.c
index dbfedb4..af6ebe5 100644
--- a/present/present_vblank.c
+++ b/present/present_vblank.c
@@ -169,6 +169,8 @@ present_vblank_destroy(present_vblank_ptr vblank)
 {
     /* Remove vblank from window and screen lists */
     xorg_list_del(&vblank->window_list);
+    /* Also make sure vblank is removed from event queue (wnmd) */
+    xorg_list_del(&vblank->event_queue);
 
     DebugPresent(("\td %lld %p %8lld: %08lx -> %08lx\n",
                   vblank->event_id, vblank, vblank->target_msc,
-- 
2.7.4



More information about the xorg-devel mailing list