DRI2: Expose API to set drawable swap limit.

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@nokia.com>
Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
Reviewed-by: Mario Kleiner <mario.kleiner@tuebingen.mpg.de>
Signed-off-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
Pauli Nieminen 2010-11-01 16:22:00 +02:00 committed by Keith Packard
parent 86f8da0aa7
commit b435e2aac1
2 changed files with 24 additions and 0 deletions

View File

@ -192,6 +192,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;

View File

@ -265,6 +265,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,