[PATCH 1/2] Patch to the Xserver to support AsyncSwap
Axel Davy
axel.davy at ens.fr
Thu Oct 17 00:16:58 CEST 2013
The patch is a modified version of a Chris Wilson patch of 2011.
It makes the X server call AsyncSwap, defined by the DDX, when
it does a dri2 swap and swap_interval is 0. It allows the DDX
to avoid the copy if possible, and reduce tearings.
Signed-off-by: Axel Davy <axel.davy at ens.fr>
---
hw/xfree86/dri2/dri2.c | 36 ++++++++++++++++++++++++------------
hw/xfree86/dri2/dri2.h | 8 +++++++-
2 files changed, 31 insertions(+), 13 deletions(-)
diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index 483d630..7b06da9 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -118,6 +118,7 @@ typedef struct _DRI2Screen {
DRI2CreateBufferProcPtr CreateBuffer;
DRI2DestroyBufferProcPtr DestroyBuffer;
DRI2CopyRegionProcPtr CopyRegion;
+ DRI2AsyncSwapProcPtr AsyncSwap;
DRI2ScheduleSwapProcPtr ScheduleSwap;
DRI2GetMSCProcPtr GetMSC;
DRI2ScheduleWaitMSCProcPtr ScheduleWaitMSC;
@@ -1107,20 +1108,30 @@ DRI2SwapBuffers(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc,
/* Old DDX or no swap interval, just blit */
if (!ds->ScheduleSwap || !pPriv->swap_interval || pPriv->prime_id) {
- BoxRec box;
- RegionRec region;
-
- box.x1 = 0;
- box.y1 = 0;
- box.x2 = pDraw->width;
- box.y2 = pDraw->height;
- RegionInit(®ion, &box, 0);
-
pPriv->swapsPending++;
- dri2_copy_region(pDraw, ®ion, pDestBuffer, pSrcBuffer);
- DRI2SwapComplete(client, pDraw, target_msc, 0, 0, DRI2_BLIT_COMPLETE,
- func, data);
+ if (ds->AsyncSwap)
+ {
+ (*ds->AsyncSwap)(client, pDraw,
+ pDestBuffer, pSrcBuffer,
+ func, data);
+ DRI2InvalidateDrawableAll(pDraw);
+ }
+ else
+ {
+ BoxRec box;
+ RegionRec region;
+
+ box.x1 = 0;
+ box.y1 = 0;
+ box.x2 = pDraw->width;
+ box.y2 = pDraw->height;
+ RegionInit(®ion, &box, 0);
+
+ dri2_copy_region(pDraw, ®ion, pDestBuffer, pSrcBuffer);
+ DRI2SwapComplete(client, pDraw, target_msc, 0, 0,
+ DRI2_BLIT_COMPLETE, func, data);
+ }
return Success;
}
@@ -1463,6 +1474,7 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
if (info->version >= 10) {
ds->AuthMagic = info->AuthMagic3;
+ ds->AsyncSwap = info->AsyncSwap;
}
if (info->version >= 8) {
ds->LegacyAuthMagic2 = info->AuthMagic2;
diff --git a/hw/xfree86/dri2/dri2.h b/hw/xfree86/dri2/dri2.h
index ed67d01..f376e42 100644
--- a/hw/xfree86/dri2/dri2.h
+++ b/hw/xfree86/dri2/dri2.h
@@ -52,7 +52,12 @@ extern CARD8 dri2_minor;
typedef DRI2BufferRec DRI2Buffer2Rec, *DRI2Buffer2Ptr;
typedef void (*DRI2SwapEventPtr) (ClientPtr client, void *data, int type,
CARD64 ust, CARD64 msc, CARD32 sbc);
-
+typedef void (*DRI2AsyncSwapProcPtr)(ClientPtr client,
+ DrawablePtr pDraw,
+ DRI2BufferPtr pDestBuffer,
+ DRI2BufferPtr pSrcBuffer,
+ DRI2SwapEventPtr func,
+ void *data);
typedef DRI2BufferPtr(*DRI2CreateBuffersProcPtr) (DrawablePtr pDraw,
unsigned int *attachments,
int count);
@@ -257,6 +262,7 @@ typedef struct {
/* added in version 10 */
DRI2AuthMagic3ProcPtr AuthMagic3;
+ DRI2AsyncSwapProcPtr AsyncSwap;
} DRI2InfoRec, *DRI2InfoPtr;
extern _X_EXPORT Bool DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info);
--
1.8.1.2
More information about the wayland-devel
mailing list