[Mesa-dev] [xorg 2/3] dri2: Pass swap-interval=0 ScheduleSwap requests to the ddx

Chris Wilson chris at chris-wilson.co.uk
Mon Jan 19 03:00:39 PST 2015


Allow the DDXes to opt-in and handle swap-interval=0 requests for
themselves, for example by using asynchronous pageflips, rather than
forcing a blit. This has the important side-effect of also
disambiguating CopyRegion calls to always be client requests.

References: http://lists.x.org/archives/xorg-devel/2011-June/023102.html
References: http://lists.x.org/archives/xorg-devel/2012-February/029336.html
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 hw/xfree86/dri2/dri2.c | 14 ++++++++++----
 hw/xfree86/dri2/dri2.h |  5 ++++-
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index f9f594d..2c0367e 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -114,6 +114,7 @@ typedef struct _DRI2Screen {
     int fd;
     unsigned int lastSequence;
     int prime_id;
+    int scheduleSwap0;
 
     DRI2CreateBufferProcPtr CreateBuffer;
     DRI2DestroyBufferProcPtr DestroyBuffer;
@@ -1116,8 +1117,8 @@ DRI2SwapBuffers(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc,
         return BadDrawable;
     }
 
-    /* Old DDX or no swap interval, just blit */
-    if (!ds->ScheduleSwap || !pPriv->swap_interval || pPriv->prime_id) {
+    /* Old DDX or PRIME, just blit */
+    if (!ds->scheduleSwap0 || pPriv->prime_id) {
         BoxRec box;
         RegionRec region;
 
@@ -1139,7 +1140,9 @@ DRI2SwapBuffers(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc,
      * In the simple glXSwapBuffers case, all params will be 0, and we just
      * need to schedule a swap for the last swap target + the swap interval.
      */
-    if (target_msc == 0 && divisor == 0 && remainder == 0) {
+    if (pPriv->swap_interval == 0) {
+	target_msc = 0;
+    } else if (target_msc == 0 && divisor == 0 && remainder == 0) {
         /* If the current vblank count of the drawable's crtc is lower
          * than the count stored in last_swap_target from a previous swap
          * then reinitialize last_swap_target to the current crtc's msc,
@@ -1162,7 +1165,6 @@ DRI2SwapBuffers(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc,
          * number of pending swaps.
          */
         target_msc = pPriv->last_swap_target + pPriv->swap_interval;
-
     }
 
     pPriv->swapsPending++;
@@ -1558,6 +1560,10 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
         ds->CopyRegion2 = info->CopyRegion2;
     }
 
+    if (info->version >= 10) {
+        ds->scheduleSwap0 = info->scheduleSwap0;
+    }
+
     /*
      * if the driver doesn't provide an AuthMagic function or the info struct
      * version is too low, call through LegacyAuthMagic
diff --git a/hw/xfree86/dri2/dri2.h b/hw/xfree86/dri2/dri2.h
index 1e7afdd..1cf4288 100644
--- a/hw/xfree86/dri2/dri2.h
+++ b/hw/xfree86/dri2/dri2.h
@@ -205,7 +205,7 @@ typedef int (*DRI2GetParamProcPtr) (ClientPtr client,
 /**
  * Version of the DRI2InfoRec structure defined in this header
  */
-#define DRI2INFOREC_VERSION 9
+#define DRI2INFOREC_VERSION 10
 
 typedef struct {
     unsigned int version;       /**< Version of this struct */
@@ -252,6 +252,9 @@ typedef struct {
     DRI2CreateBuffer2ProcPtr CreateBuffer2;
     DRI2DestroyBuffer2ProcPtr DestroyBuffer2;
     DRI2CopyRegion2ProcPtr CopyRegion2;
+
+    /* added in version 10 */
+    int scheduleSwap0;
 } DRI2InfoRec, *DRI2InfoPtr;
 
 extern _X_EXPORT Bool DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info);
-- 
2.1.4



More information about the mesa-dev mailing list