[PATCH] DRI2: Expose API to set drawable swap limit.

Francisco Jerez currojerez at riseup.net
Tue Oct 12 06:33:09 PDT 2010


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

> This allows ddx to set swap_limit if there is more than one back
> buffer for drawable. Setting swap_limit has to also check if change
> affects a client that is blocked.
>
> This can be used to implement N-buffering in driver with minimal
> logic in allocation and selecting next back.
>
> Signed-off-by: Pauli Nieminen <ext-pauli.nieminen at nokia.com>

I can confirm that this works with some experimental patches for the
nouveau driver that make it do pageflip with triple buffering, my
'Reviewed-by' is pretty useless here, so:

Tested-by: Francisco Jerez <currojerez at riseup.net>

> ---
>  hw/xfree86/dri2/dri2.c |   23 +++++++++++++++++++++++
>  hw/xfree86/dri2/dri2.h |    1 +
>  2 files changed, 24 insertions(+), 0 deletions(-)
>
> diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
> index 34f735f..c96eb35 100644
> --- a/hw/xfree86/dri2/dri2.c
> +++ b/hw/xfree86/dri2/dri2.c
> @@ -190,6 +190,29 @@ DRI2AllocateDrawable(DrawablePtr pDraw)
>      return pPriv;
>  }
>  
> +Bool
> +DRI2SwapLimit(DrawablePtr pDraw, int swap_limit)
> +{
> +    DRI2DrawablePtr pPriv = DRI2GetDrawable(pDraw);
> +    if (!pPriv)
> +	return FALSE;
> +
> +    pPriv->swap_limit = swap_limit;
> +
> +    /* Check throttling */
> +    if (pPriv->swapsPending >= pPriv->swap_limit)
> +	return TRUE;
> +
> +    if (pPriv->target_sbc == -1 && !pPriv->blockedOnMsc) {
> +	if (pPriv->blockedClient) {
> +	    AttendClient(pPriv->blockedClient);
> +	    pPriv->blockedClient = NULL;
> +	}
> +    }
> +
> +    return TRUE;
> +}
> +
>  typedef struct DRI2DrawableRefRec {
>      XID		  id;
>      XID		  dri2_id;
> diff --git a/hw/xfree86/dri2/dri2.h b/hw/xfree86/dri2/dri2.h
> index fe0bf6c..0e0bea4 100644
> --- a/hw/xfree86/dri2/dri2.h
> +++ b/hw/xfree86/dri2/dri2.hn
> @@ -251,6 +251,7 @@ extern _X_EXPORT DRI2BufferPtr *DRI2GetBuffersWithFormat(DrawablePtr pDraw,
>  	int *out_count);
>  
>  extern _X_EXPORT void DRI2SwapInterval(DrawablePtr pDrawable, int interval);
> +extern _X_EXPORT Bool DRI2SwapLimit(DrawablePtr pDraw, int swap_limit);
>  extern _X_EXPORT int DRI2SwapBuffers(ClientPtr client, DrawablePtr pDrawable,
>  				     CARD64 target_msc, CARD64 divisor,
>  				     CARD64 remainder, CARD64 *swap_target,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 229 bytes
Desc: not available
URL: <http://lists.x.org/archives/xorg-devel/attachments/20101012/2011388f/attachment.pgp>


More information about the xorg-devel mailing list