From 3628f11cb6a396de4e95f4fb8cd87995061fb004 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Wed, 6 Apr 2016 00:30:27 +0100 Subject: [PATCH] sna/present: Restore root window pixmap on flip failure When Present flips, it does not update the ScreenPixmap. When we fail to flip and are forced to restore the previous framebuffer (because we updated the scanout on some but not all of the outputs), we try to restore the ScreenPixmap. Change this to try to restore the root Window's Pixmap instead. Reported-by: Christoph Haag Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94829 Signed-off-by: Chris Wilson --- src/sna/sna_display.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c index 8de65dc..8193d34 100644 --- a/src/sna/sna_display.c +++ b/src/sna/sna_display.c @@ -6366,11 +6366,23 @@ sna_crtc_flip(struct sna *sna, struct sna_crtc *crtc, struct kgem_bo *bo, int x, static void sna_mode_restore(struct sna *sna) { xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(sna->scrn); + ScreenPtr screen = to_screen_from_sna(sna); + PixmapPtr saved_front = sna->front; + PixmapPtr current_front = sna->front; int error = 0; int i; assert(!sna->mode.hidden); + if (screen->root) + current_front = get_drawable_pixmap(&screen->root->drawable); + if (current_front != saved_front) { + DBG(("%s: Front buffer has been hijacked! expected our pixmap=%ld, found pixmap=%ld\n", + __FUNCTION__, saved_front->drawable.serialNumber, current_front->drawable.serialNumber)); + sna->front = current_front; + current_front->refcnt++; /* paranoia */ + } + for (i = 0; i < sna->mode.num_real_crtc; i++) { xf86CrtcPtr crtc = config->crtc[i]; @@ -6384,6 +6396,11 @@ static void sna_mode_restore(struct sna *sna) error++; } } + if (current_front != saved_front) { + screen->DestroyPixmap(current_front); + sna->front = saved_front; + } + sna_mode_wakeup(sna); while (sna->mode.flip_active && sna_mode_wakeup(sna)) ; -- 1.9.1