dri2: support glXWaitGL & glXWaitX by copying fake front to front and

vice-versa.
This commit is contained in:
Alan Hourihane 2009-02-16 11:39:34 +00:00
parent ddb8d8945d
commit 2a8b8077d8
4 changed files with 67 additions and 11 deletions

View File

@ -760,29 +760,46 @@ int __glXDisp_QueryVersion(__GLXclientState *cl, GLbyte *pc)
int __glXDisp_WaitGL(__GLXclientState *cl, GLbyte *pc) int __glXDisp_WaitGL(__GLXclientState *cl, GLbyte *pc)
{ {
xGLXWaitGLReq *req = (xGLXWaitGLReq *)pc; xGLXWaitGLReq *req = (xGLXWaitGLReq *)pc;
GLXContextTag tag = req->contextTag;
__GLXcontext *glxc = NULL;
int error; int error;
if (tag) {
glxc = __glXLookupContextByTag(cl, tag);
if (!glxc)
return __glXError(GLXBadContextTag);
if (!__glXForceCurrent(cl, req->contextTag, &error)) { if (!__glXForceCurrent(cl, req->contextTag, &error))
return error; return error;
CALL_Finish( GET_DISPATCH(), () );
} }
CALL_Finish( GET_DISPATCH(), () );
if (glxc && glxc->drawPriv->waitGL)
(*glxc->drawPriv->waitGL)(glxc->drawPriv);
return Success; return Success;
} }
int __glXDisp_WaitX(__GLXclientState *cl, GLbyte *pc) int __glXDisp_WaitX(__GLXclientState *cl, GLbyte *pc)
{ {
xGLXWaitXReq *req = (xGLXWaitXReq *)pc; xGLXWaitXReq *req = (xGLXWaitXReq *)pc;
GLXContextTag tag = req->contextTag;
__GLXcontext *glxc = NULL;
int error; int error;
if (tag) {
glxc = __glXLookupContextByTag(cl, tag);
if (!glxc)
return __glXError(GLXBadContextTag);
if (!__glXForceCurrent(cl, req->contextTag, &error)) { if (!__glXForceCurrent(cl, req->contextTag, &error))
return error; return error;
} }
/*
** In a multithreaded server that had separate X and GL threads, we would if (glxc && glxc->drawPriv->waitGL)
** have to wait for the X thread to finish before returning. As it stands, (*glxc->drawPriv->waitGL)(glxc->drawPriv);
** this sample implementation only supports singlethreaded servers, and
** nothing needs to be done here.
*/
return Success; return Success;
} }

View File

@ -49,6 +49,8 @@ struct __GLXdrawable {
GLboolean (*swapBuffers)(__GLXdrawable *); GLboolean (*swapBuffers)(__GLXdrawable *);
void (*copySubBuffer)(__GLXdrawable *drawable, void (*copySubBuffer)(__GLXdrawable *drawable,
int x, int y, int w, int h); int x, int y, int w, int h);
void (*waitX)(__GLXdrawable *);
void (*waitGL)(__GLXdrawable *);
DrawablePtr pDraw; DrawablePtr pDraw;
XID drawId; XID drawId;

View File

@ -704,6 +704,8 @@ __glXDRIscreenCreateDrawable(__GLXscreen *screen,
private->base.destroy = __glXDRIdrawableDestroy; private->base.destroy = __glXDRIdrawableDestroy;
private->base.swapBuffers = __glXDRIdrawableSwapBuffers; private->base.swapBuffers = __glXDRIdrawableSwapBuffers;
private->base.copySubBuffer = __glXDRIdrawableCopySubBuffer; private->base.copySubBuffer = __glXDRIdrawableCopySubBuffer;
private->base.waitX = NULL;
private->base.waitGL = NULL;
__glXenterServer(GL_FALSE); __glXenterServer(GL_FALSE);
retval = DRICreateDrawable(screen->pScreen, serverClient, retval = DRICreateDrawable(screen->pScreen, serverClient,

View File

@ -139,6 +139,39 @@ __glXDRIdrawableSwapBuffers(__GLXdrawable *drawable)
return TRUE; return TRUE;
} }
static void
__glXDRIdrawableWaitX(__GLXdrawable *drawable)
{
__GLXDRIdrawable *private = (__GLXDRIdrawable *) drawable;
BoxRec box;
RegionRec region;
box.x1 = 0;
box.y1 = 0;
box.x2 = private->width;
box.y2 = private->height;
REGION_INIT(drawable->pDraw->pScreen, &region, &box, 0);
DRI2CopyRegion(drawable->pDraw, &region,
DRI2BufferFakeFrontLeft, DRI2BufferFrontLeft);
}
static void
__glXDRIdrawableWaitGL(__GLXdrawable *drawable)
{
__GLXDRIdrawable *private = (__GLXDRIdrawable *) drawable;
BoxRec box;
RegionRec region;
box.x1 = 0;
box.y1 = 0;
box.x2 = private->width;
box.y2 = private->height;
REGION_INIT(drawable->pDraw->pScreen, &region, &box, 0);
DRI2CopyRegion(drawable->pDraw, &region,
DRI2BufferFrontLeft, DRI2BufferFakeFrontLeft);
}
static int static int
__glXDRIdrawableSwapInterval(__GLXdrawable *drawable, int interval) __glXDRIdrawableSwapInterval(__GLXdrawable *drawable, int interval)
@ -337,6 +370,8 @@ __glXDRIscreenCreateDrawable(__GLXscreen *screen,
private->base.destroy = __glXDRIdrawableDestroy; private->base.destroy = __glXDRIdrawableDestroy;
private->base.swapBuffers = __glXDRIdrawableSwapBuffers; private->base.swapBuffers = __glXDRIdrawableSwapBuffers;
private->base.copySubBuffer = __glXDRIdrawableCopySubBuffer; private->base.copySubBuffer = __glXDRIdrawableCopySubBuffer;
private->base.waitGL = __glXDRIdrawableWaitGL;
private->base.waitX = __glXDRIdrawableWaitX;
if (DRI2CreateDrawable(pDraw)) { if (DRI2CreateDrawable(pDraw)) {
xfree(private); xfree(private);