xserver: Branch 'dri2-swapbuffers' - 2 commits
Jesse Barnes
jbarnes at kemper.freedesktop.org
Wed Jun 3 08:53:23 PDT 2009
glx/glxdri2.c | 22 +++++-------------
hw/xfree86/dri2/dri2.c | 55 +++++++++++++++++-----------------------------
hw/xfree86/dri2/dri2.h | 8 +++---
hw/xfree86/dri2/dri2ext.c | 23 -------------------
4 files changed, 33 insertions(+), 75 deletions(-)
New commits:
commit 688bdf061b8ba5e5b7745dcd20695627a4cb9529
Author: Jesse Barnes <jbarnes at jbarnes-x200.(none)>
Date: Wed Jun 3 16:52:41 2009 +0100
dri2: update to new swapbuffers interface
Now that swapbuffers is a one way request, we don't have to return new
buffers to the client.
diff --git a/glx/glxdri2.c b/glx/glxdri2.c
index 64d7895..c54a507 100644
--- a/glx/glxdri2.c
+++ b/glx/glxdri2.c
@@ -172,9 +172,10 @@ __glXDRIdrawableSwapBuffers(__GLXdrawable *drawable)
{
__GLXDRIdrawable *priv = (__GLXDRIdrawable *) drawable;
__GLXDRIscreen *screen = priv->screen;
- int count;
- DRI2SwapBuffers(drawable->pDraw, &count);
+ if (!DRI2SwapBuffers(drawable->pDraw))
+ return FALSE;
+
(*screen->flush->flushInvalidate)(priv->driDrawable);
return TRUE;
diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index 5682f16..c78aa28 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -329,57 +329,44 @@ DRI2CopyRegion(DrawablePtr pDraw, RegionPtr pRegion,
return Success;
}
-DRI2BufferPtr *
-DRI2SwapBuffers(DrawablePtr pDraw, int *reply_count)
+Bool
+DRI2SwapBuffers(DrawablePtr pDraw)
{
DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
DRI2DrawablePtr pPriv;
- DRI2BufferPtr *buffers;
- int i;
+ DRI2BufferPtr pDestBuffer, pSrcBuffer;
+ int i;
pPriv = DRI2GetDrawable(pDraw);
if (pPriv == NULL)
- return NULL;
-
- if (!ds->SwapBuffers)
- goto copy;
-
- buffers = (*ds->SwapBuffers)(pDraw, pPriv->buffers, pPriv->bufferCount);
- if (!buffers)
- goto copy;
+ return FALSE;
- for (i = 0; i < pPriv->bufferCount; i++) {
- (*ds->DestroyBuffer)(pDraw, pPriv->buffers[i]);
- pPriv->buffers[i] = buffers[i];
+ pDestBuffer = NULL;
+ pSrcBuffer = NULL;
+ for (i = 0; i < pPriv->bufferCount; i++)
+ {
+ if (pPriv->buffers[i]->attachment == DRI2BufferFrontLeft)
+ pDestBuffer = pPriv->buffers[i];
+ if (pPriv->buffers[i]->attachment == DRI2BufferBackLeft)
+ pSrcBuffer = pPriv->buffers[i];
}
+ if (pSrcBuffer == NULL || pDestBuffer == NULL)
+ return FALSE;
- xfree(buffers);
-
- *reply_count = pPriv->bufferCount;
-
- return pPriv->buffers;
-
-copy:
- /* Fall back to a copy */
- {
+ if (!(*ds->SwapBuffers)(pDraw, pDestBuffer, pSrcBuffer)) {
BoxRec box;
RegionRec region;
- int ret;
box.x1 = 0;
box.y1 = 0;
box.x2 = pDraw->width;
box.y2 = pDraw->height;
- REGION_INIT(pDraw->pScreen, ®ion, &box, 0);
- ret = DRI2CopyRegion(pDraw, ®ion, DRI2BufferFrontLeft,
- DRI2BufferBackLeft);
- if (ret != Success) {
- *reply_count = 0;
- return NULL;
- }
- *reply_count = pPriv->bufferCount;
- return pPriv->buffers;
+ REGION_INIT(drawable->pDraw->pScreen, ®ion, &box, 0);
+ if (DRI2CopyRegion(pDraw, ®ion, DRI2BufferFrontLeft, DRI2BufferBackLeft) != Success)
+ return FALSE;
}
+
+ return TRUE;
}
void
diff --git a/hw/xfree86/dri2/dri2.h b/hw/xfree86/dri2/dri2.h
index d5b38d7..faaecae 100644
--- a/hw/xfree86/dri2/dri2.h
+++ b/hw/xfree86/dri2/dri2.h
@@ -55,9 +55,9 @@ typedef void (*DRI2CopyRegionProcPtr)(DrawablePtr pDraw,
RegionPtr pRegion,
DRI2BufferPtr pDestBuffer,
DRI2BufferPtr pSrcBuffer);
-typedef DRI2BufferPtr *(*DRI2SwapBuffersProcPtr)(DrawablePtr pDraw,
- DRI2BufferPtr *buffers,
- int count);
+typedef Bool (*DRI2SwapBuffersProcPtr)(DrawablePtr pDraw,
+ DRI2BufferPtr pFrontBuffer,
+ DRI2BufferPtr pBackBuffer);
typedef void (*DRI2WaitProcPtr)(WindowPtr pWin,
unsigned int sequence);
@@ -146,6 +146,6 @@ extern _X_EXPORT DRI2BufferPtr *DRI2GetBuffersWithFormat(DrawablePtr pDraw,
int *width, int *height, unsigned int *attachments, int count,
int *out_count);
-extern _X_EXPORT DRI2BufferPtr *DRI2SwapBuffers(DrawablePtr pDraw, int *count);
+extern _X_EXPORT Bool DRI2SwapBuffers(DrawablePtr pDraw);
#endif
diff --git a/hw/xfree86/dri2/dri2ext.c b/hw/xfree86/dri2/dri2ext.c
index 6d690a8..9f5a196 100644
--- a/hw/xfree86/dri2/dri2ext.c
+++ b/hw/xfree86/dri2/dri2ext.c
@@ -327,14 +327,14 @@ ProcDRI2SwapBuffers(ClientPtr client)
REQUEST(xDRI2SwapBuffersReq);
DrawablePtr pDrawable;
int status;
- int count;
REQUEST_SIZE_MATCH(xDRI2SwapBuffersReq);
if (!validDrawable(client, stuff->drawable, &pDrawable, &status))
return status;
- DRI2SwapBuffers(pDrawable, &count);
+ if (!DRI2SwapBuffers(pDrawable))
+ return BadAlloc;
return client->noClientException;
}
commit 718de3235fdb503dad373eba5d30d1c37ad14354
Author: Jesse Barnes <jbarnes at jbarnes-x200.(none)>
Date: Wed Jun 3 12:57:47 2009 +0100
dri2: use flushinvalidate for swapbuffers
Swapbuffers no long returns a reply; invalidate the buffers and require
a new getbuffers call instead.
diff --git a/glx/glxdri2.c b/glx/glxdri2.c
index 23bbaa0..64d7895 100644
--- a/glx/glxdri2.c
+++ b/glx/glxdri2.c
@@ -70,6 +70,7 @@ struct __GLXDRIscreen {
const __DRIcoreExtension *core;
const __DRIdri2Extension *dri2;
+ const __DRI2flushExtension *flush;
const __DRIcopySubBufferExtension *copySubBuffer;
const __DRIswapControlExtension *swapControl;
const __DRItexBufferExtension *texBuffer;
@@ -171,24 +172,10 @@ __glXDRIdrawableSwapBuffers(__GLXdrawable *drawable)
{
__GLXDRIdrawable *priv = (__GLXDRIdrawable *) drawable;
__GLXDRIscreen *screen = priv->screen;
- DRI2BufferPtr *buffers;
- int i, count;
-
- buffers = DRI2SwapBuffers(drawable->pDraw, &count);
- if (!buffers)
- return FALSE;
-
- for (i = 0; i < count; i++) {
- priv->buffers[i].attachment = buffers[i]->attachment;
- priv->buffers[i].name = buffers[i]->name;
- priv->buffers[i].pitch = buffers[i]->pitch;
- priv->buffers[i].cpp = buffers[i]->cpp;
- priv->buffers[i].flags = buffers[i]->flags;
- }
-
- priv->count = count;
+ int count;
- (*screen->dri2->setBuffers)(priv->driDrawable, priv->buffers, count);
+ DRI2SwapBuffers(drawable->pDraw, &count);
+ (*screen->flush->flushInvalidate)(priv->driDrawable);
return TRUE;
}
@@ -650,6 +637,10 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
extensions[i]->version >= __DRI_DRI2_VERSION) {
screen->dri2 = (const __DRIdri2Extension *) extensions[i];
}
+ if (strcmp(extensions[i]->name, __DRI2_FLUSH) == 0 &&
+ extensions[i]->version >= __DRI2_FLUSH_VERSION) {
+ screen->flush = (__DRI2flushExtension *) extensions[i];
+ }
}
if (screen->core == NULL || screen->dri2 == NULL) {
diff --git a/hw/xfree86/dri2/dri2ext.c b/hw/xfree86/dri2/dri2ext.c
index 0b9443e..6d690a8 100644
--- a/hw/xfree86/dri2/dri2ext.c
+++ b/hw/xfree86/dri2/dri2ext.c
@@ -325,37 +325,16 @@ static int
ProcDRI2SwapBuffers(ClientPtr client)
{
REQUEST(xDRI2SwapBuffersReq);
- xDRI2SwapBuffersReply rep;
DrawablePtr pDrawable;
- DRI2BufferPtr *buffers;
- xDRI2Buffer buffer;
int status;
- int i, count;
+ int count;
REQUEST_SIZE_MATCH(xDRI2SwapBuffersReq);
if (!validDrawable(client, stuff->drawable, &pDrawable, &status))
return status;
- buffers = DRI2SwapBuffers(pDrawable, &count);
- if (!buffers) {
- return BadAlloc;
- }
-
- rep.type = X_Reply;
- rep.length = count * sizeof(xDRI2Buffer) / 4;
- rep.count = count;
- rep.sequenceNumber = client->sequence;
- WriteToClient(client, sizeof(xDRI2GetBuffersReply), &rep);
-
- for (i = 0; i < count; i++) {
- buffer.attachment = buffers[i]->attachment;
- buffer.name = buffers[i]->name;
- buffer.pitch = buffers[i]->pitch;
- buffer.cpp = buffers[i]->cpp;
- buffer.flags = buffers[i]->flags;
- WriteToClient(client, sizeof(xDRI2Buffer), &buffer);
- }
+ DRI2SwapBuffers(pDrawable, &count);
return client->noClientException;
}
More information about the xorg-commit
mailing list