[PATCH v3 10/11] dri2: copy front to fake front in SwapBuffers

Pauli ext-pauli.nieminen at nokia.com
Wed Feb 16 02:21:44 PST 2011


From: Pauli Nieminen <ext-pauli.nieminen at nokia.com>

DRI2SwapComplete is too late for front to fake front copy if swap is
completed asynchronously. Client could be able to use fake front already
before swap completes.

Moving front to fake front solves the problem but requires that driver
is capable to copy from new front to fake front immediately after
ScheduleSwap hook returns.

v2:
* In blit path copy front to fake before completing the swap

Signed-off-by: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
---
 hw/xfree86/dri2/dri2.c |   33 +++++++++++++++++++--------------
 1 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index 145286d..4b31447 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -854,7 +854,6 @@ DRI2SwapComplete2(DRI2DrawablePtr pPriv, int frame,
 {
     DRI2SwapCompleteDataPtr pSwapData = swap_data;
     ClientPtr               client = pSwapData->event.client;
-    DrawablePtr             pDraw = pPriv->drawable;
     CARD64                  ust = 0;
     DRI2DrawableRefPtr      ref;
 
@@ -872,19 +871,6 @@ DRI2SwapComplete2(DRI2DrawablePtr pPriv, int frame,
     if (ref == NULL)
 	goto out;
 
-    if (pDraw) {
-	BoxRec          box;
-	RegionRec       region;
-
-	box.x1 = 0;
-	box.y1 = 0;
-	box.x2 = pDraw->width;
-	box.y2 = pDraw->height;
-	RegionInit(&region, &box, 0);
-	DRI2CopyRegion(pPriv, &region, DRI2BufferFakeFrontLeft,
-		       DRI2BufferFrontLeft);
-    }
-
     if (swap_complete)
 	swap_complete(client, pSwapData->data, type, ust, frame,
 		pPriv->swap_count);
@@ -918,6 +904,23 @@ DRI2WaitSwap(ClientPtr client, DRI2DrawablePtr pPriv)
     return FALSE;
 }
 
+static void
+DRI2CopyFrontToFakeFront(DrawablePtr pDraw, DRI2DrawablePtr pPriv)
+{
+    if (pDraw) {
+	BoxRec          box;
+	RegionRec       region;
+
+	box.x1 = 0;
+	box.y1 = 0;
+	box.x2 = pDraw->width;
+	box.y2 = pDraw->height;
+	RegionInit(&region, &box, 0);
+	DRI2CopyRegion(pPriv, &region, DRI2BufferFakeFrontLeft,
+		       DRI2BufferFrontLeft);
+    }
+}
+
 int
 DRI2SwapBuffers(ClientPtr client, DRI2DrawablePtr pPriv, CARD64 target_msc,
 		CARD64 divisor, CARD64 remainder, CARD64 *swap_target,
@@ -984,6 +987,7 @@ DRI2SwapBuffers(ClientPtr client, DRI2DrawablePtr pPriv, CARD64 target_msc,
 	pPriv->refcnt++;
 
 	(*ds->CopyRegion)(pDraw, &region, pDestBuffer, pSrcBuffer);
+	DRI2CopyFrontToFakeFront(pDraw, pPriv);
 	DRI2SwapComplete2(pPriv, target_msc, 0, 0, DRI2_BLIT_COMPLETE,
 			  func, pSwapData);
 	return Success;
@@ -1044,6 +1048,7 @@ DRI2SwapBuffers(ClientPtr client, DRI2DrawablePtr pPriv, CARD64 target_msc,
 
     DRI2InvalidateDrawable(pPriv);
 
+    DRI2CopyFrontToFakeFront(pDraw, pPriv);
     return Success;
 }
 
-- 
1.7.0.4



More information about the xorg-devel mailing list