From a337949f99bc473ea0ae0af64736eae3d5b39399 Mon Sep 17 00:00:00 2001 From: Roman Gilg Date: Tue, 13 Mar 2018 16:00:50 +0100 Subject: [PATCH] present: Add cleanups for window flip mode Make sure that vblanks and windows get cleaned up correctly in window flip mode. Signed-off-by: Roman Gilg Reviewed-by: Adam Jackson --- 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 b0cae0fd1..8ad14ad17 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 7662c4dd9..f93a1afa9 100644 --- a/present/present_vblank.c +++ b/present/present_vblank.c @@ -172,6 +172,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,