[PATCH xserver] dri2: Invalidate DRI2 buffers for all windows with the same pixmap on swap.

Michel Dänzer michel at daenzer.net
Fri Mar 25 04:35:37 PDT 2011


From: Michel Dänzer <daenzer at vmware.com>

Without this, when a compositing manager unredirects a fullscreen window which
uses DRI2 and page flipping, the DRI2 buffer information for the compositing
manager's output window (typically the Composite Overlay Window or root window)
may become stale, resulting in all kinds of hilarity.

Also re-generate the real front buffer information every time the client asks
for it, or we might keep around stale cached information.

Fixes https://bugs.freedesktop.org/show_bug.cgi?id=35452 .

Signed-off-by: Michel Dänzer <daenzer at vmware.com>
---
 hw/xfree86/dri2/dri2.c |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index d8851f2..c229959 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -339,6 +339,7 @@ allocate_or_reuse_buffer(DrawablePtr pDraw, DRI2ScreenPtr ds,
     int old_buf = find_attachment(pPriv, attachment);
 
     if ((old_buf < 0)
+	|| attachment == DRI2BufferFrontLeft
 	|| !dimensions_match
 	|| (pPriv->buffers[old_buf]->format != format)) {
 	*buffer = (*ds->CreateBuffer)(pDraw, attachment, format);
@@ -814,6 +815,15 @@ DRI2WaitSwap(ClientPtr client, DrawablePtr pDrawable)
     return FALSE;
 }
 
+static int
+DRI2SwapWalk(WindowPtr pWin, pointer data)
+{
+    if (pWin->drawable.pScreen->GetWindowPixmap(pWin) == data)
+	DRI2InvalidateDrawable(&pWin->drawable);
+
+    return WT_WALKCHILDREN;
+}
+
 int
 DRI2SwapBuffers(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc,
 		CARD64 divisor, CARD64 remainder, CARD64 *swap_target,
@@ -914,7 +924,14 @@ DRI2SwapBuffers(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc,
      */
     *swap_target = pPriv->swap_count + pPriv->swapsPending;
 
-    DRI2InvalidateDrawable(pDraw);
+    if (pDraw->type == DRAWABLE_WINDOW) {
+	/* Invalidate DRI2 buffers for all windows with the same window pixmap
+	 * as this one.
+	 */
+	WalkTree(pScreen, DRI2SwapWalk,
+		 pScreen->GetWindowPixmap((WindowPtr)pDraw));
+    } else
+	DRI2InvalidateDrawable(pDraw);
 
     return Success;
 }
-- 
1.7.4.1



More information about the xorg-devel mailing list