[PATCH 8/9] dri2: copy front to fake front in SwapBuffers

Christopher James Halse Rogers christopher.halse.rogers at canonical.com
Thu Feb 3 18:34:21 PST 2011


On Thu, 2011-02-03 at 19:48 +0200, Pauli wrote:
> 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.
> 
> Signed-off-by: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
> ---
>  hw/xfree86/dri2/dri2.c |   34 ++++++++++++++++++++--------------
>  1 files changed, 20 insertions(+), 14 deletions(-)
> 
> diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
> index 12c1f72..604930c 100644
> --- a/hw/xfree86/dri2/dri2.c
> +++ b/hw/xfree86/dri2/dri2.c
> @@ -811,7 +811,6 @@ DRI2SwapComplete(ClientPtr client, DRI2DrawablePtr pPriv, int frame,
>  {
>      DRI2SwapCompleteDataPtr pSwapData = swap_data;
>      DRI2DrawableRefPtr ref = DRI2LookupClientDrawableRef(pPriv, client, 0);
> -    DrawablePtr     pDraw = pPriv->drawable;
>      CARD64          ust = 0;
>  
>      pPriv->swapsPending--;
> @@ -821,19 +820,6 @@ DRI2SwapComplete(ClientPtr client, 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);
> -    }
> -
>      ust = ((CARD64)tv_sec * 1000000) + tv_usec;
>      if (swap_complete)
>  	swap_complete(client, pSwapData->data, type, ust, frame,
> @@ -868,6 +854,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,
> @@ -933,6 +936,8 @@ DRI2SwapBuffers(ClientPtr client, DRI2DrawablePtr pPriv, CARD64 target_msc,
>  	(*ds->CopyRegion)(pDraw, &region, pDestBuffer, pSrcBuffer);
>  	DRI2SwapComplete(client, pPriv, target_msc, 0, 0, DRI2_BLIT_COMPLETE,
>  			 func, pSwapData);
> +
> +	DRI2CopyFrontToFakeFront(pDraw, pPriv);

It doesn't make any functional difference, but wouldn't it make more
sense to copy to the fake front before calling SwapComplete?

>  	return Success;
>      }
>  
> @@ -991,6 +996,7 @@ DRI2SwapBuffers(ClientPtr client, DRI2DrawablePtr pPriv, CARD64 target_msc,
>  
>      DRI2InvalidateDrawable(pPriv);
>  
> +    DRI2CopyFrontToFakeFront(pDraw, pPriv);
>      return Success;
>  }
>  

Reviewed-By: Christopher James Halse Rogers
<christopher.halse.rogers at canonical.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: This is a digitally signed message part
URL: <http://lists.x.org/archives/xorg-devel/attachments/20110204/77da0c19/attachment.pgp>


More information about the xorg-devel mailing list