From f36a13ce5f43575fe144ff78f05663e92e0808cb Mon Sep 17 00:00:00 2001 From: Adrian Negreanu Date: Wed, 1 Oct 2014 23:12:34 +0300 Subject: [PATCH] SendMakeCurrentRequest --- src/glx/dri2_glx.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c index 462d560..69b0ee1 100644 --- a/src/glx/dri2_glx.c +++ b/src/glx/dri2_glx.c @@ -130,6 +130,74 @@ dri2_destroy_context(struct glx_context *context) free(pcp); } +static Bool +SendMakeCurrentRequest(Display * dpy, CARD8 opcode, + GLXContextID gc_id, GLXContextTag gc_tag, + GLXDrawable draw, GLXDrawable read, + GLXContextTag *out_tag) +{ + xGLXMakeCurrentReply reply; + Bool ret; + + LockDisplay(dpy); + + if (draw == read) { + xGLXMakeCurrentReq *req; + + GetReq(GLXMakeCurrent, req); + req->reqType = opcode; + req->glxCode = X_GLXMakeCurrent; + req->drawable = draw; + req->context = gc_id; + req->oldContextTag = gc_tag; + } + else { + struct glx_display *priv = __glXInitialize(dpy); + + /* If the server can support the GLX 1.3 version, we should + * perfer that. Not only that, some servers support GLX 1.3 but + * not the SGI extension. + */ + + if ((priv->majorVersion > 1) || (priv->minorVersion >= 3)) { + xGLXMakeContextCurrentReq *req; + + GetReq(GLXMakeContextCurrent, req); + req->reqType = opcode; + req->glxCode = X_GLXMakeContextCurrent; + req->drawable = draw; + req->readdrawable = read; + req->context = gc_id; + req->oldContextTag = gc_tag; + } + else { + xGLXVendorPrivateWithReplyReq *vpreq; + xGLXMakeCurrentReadSGIReq *req; + + GetReqExtra(GLXVendorPrivateWithReply, + sz_xGLXMakeCurrentReadSGIReq - + sz_xGLXVendorPrivateWithReplyReq, vpreq); + req = (xGLXMakeCurrentReadSGIReq *) vpreq; + req->reqType = opcode; + req->glxCode = X_GLXVendorPrivateWithReply; + req->vendorCode = X_GLXvop_MakeCurrentReadSGI; + req->drawable = draw; + req->readable = read; + req->context = gc_id; + req->oldContextTag = gc_tag; + } + } + + ret = _XReply(dpy, (xReply *) &reply, 0, False); + + if (out_tag) + *out_tag = reply.contextTag; + + UnlockDisplay(dpy); + SyncHandle(); + + return ret; +} static Bool dri2_bind_context(struct glx_context *context, struct glx_context *old, @@ -169,6 +237,9 @@ dri2_bind_context(struct glx_context *context, struct glx_context *old, if (pread != pdraw && pread) dri2InvalidateBuffers(psc->base.dpy, pread->base.xDrawable); } + const int opcode = __glXSetupForCommand(dpyPriv->dpy); + SendMakeCurrentRequest(dpyPriv->dpy, opcode , + context->xid, None , draw, read, NULL); return Success; } @@ -179,6 +250,9 @@ dri2_unbind_context(struct glx_context *context, struct glx_context *new) struct dri2_context *pcp = (struct dri2_context *) context; struct dri2_screen *psc = (struct dri2_screen *) pcp->base.psc; + const int opcode = __glXSetupForCommand(context->psc->dpy); + SendMakeCurrentRequest(context->psc->dpy, opcode , + None, context->currentContextTag , None, None, NULL); (*psc->core->unbindContext) (pcp->driContext); } -- 2.1.1