[PATCH v2 1/2] dri2: Let client call swap before previous swap target has been passed

Pauli Nieminen suokkos at gmail.com
Tue Aug 30 03:11:05 PDT 2011


From: Pauli Nieminen <pauli.nieminen at linux.intel.com>

Client has to be allowed to call swap buffers before last_swap_target
has been passed if driver implements triple buffering with
swap_interval.

Time that swap may come before reaching last_swap_target is swap_limit *
swap_interval if application renders very fast until throttled.

Signed-off-by: Pauli Nieminen <pauli.nieminen at linux.intel.com>
CC: Walter Harms <wharms at bfs.de>
---

Thanks Walter to point that int64_t is allowed in the server. I hadn't
noticed that POSIX-1.2001 includes many C99 features.

 hw/xfree86/dri2/dri2.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index af3bcae..20f40ad 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -854,12 +854,21 @@ DRI2SwapBuffers(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc,
 	 * got enabled.
 	 */
 	if (ds->GetMSC) {
+	    int64_t msc_diff;
+	    int64_t future_frames_allowed = pPriv->swap_limit * pPriv->swap_interval;
 	    if (!(*ds->GetMSC)(pDraw, &ust, &current_msc))
 		pPriv->last_swap_target = 0;
 
-	    if (current_msc < pPriv->last_swap_target)
-		pPriv->last_swap_target = current_msc;
+	    msc_diff = (int64_t)pPriv->last_swap_target - (int64_t)current_msc;
 
+	    /*
+	     * If current_msc is more than swap_limit * swap_interval in future
+	     * assume there was CRTC switch. That requires fixing swap_target for
+	     * driver.
+	     */
+	    if (msc_diff < future_frames_allowed)
+		pPriv->last_swap_target = current_msc
+			+ pPriv->swapsPending * pPriv->swap_interval;
 	}
 
 	/*
-- 
1.7.4.1



More information about the xorg-devel mailing list