mirror of https://gitlab.freedesktop.org/mesa/mesa
glx: Clean up some funny business from context bind/unbind
We always fully unbind the old context before binding the new one, so there's no point in passing both contexts to both the unbind and then the bind. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20549>
This commit is contained in:
parent
f0eed00010
commit
cf9debb639
|
@ -50,13 +50,13 @@ applegl_destroy_context(struct glx_context *gc)
|
|||
|
||||
static int
|
||||
applegl_bind_context(
|
||||
struct glx_context *gc, struct glx_context *old,
|
||||
struct glx_context *gc,
|
||||
GLXDrawable draw, GLXDrawable read)
|
||||
{
|
||||
Display *dpy = gc->psc->dpy;
|
||||
bool error = apple_glx_make_current_context(
|
||||
dpy,
|
||||
(old && old != &dummyContext) ? old->driContext : NULL,
|
||||
NULL,
|
||||
gc ? gc->driContext : NULL, draw);
|
||||
|
||||
apple_glx_diagnostic("%s: error %s\n", __func__, error ? "YES" : "NO");
|
||||
|
@ -69,7 +69,7 @@ applegl_bind_context(
|
|||
}
|
||||
|
||||
static void
|
||||
applegl_unbind_context(struct glx_context *gc, struct glx_context *new)
|
||||
applegl_unbind_context(struct glx_context *gc)
|
||||
{
|
||||
Display *dpy;
|
||||
bool error;
|
||||
|
@ -78,10 +78,6 @@ applegl_unbind_context(struct glx_context *gc, struct glx_context *new)
|
|||
if (!gc)
|
||||
return;
|
||||
|
||||
/* If we have a new context, keep this one around and remove it during bind. */
|
||||
if (new)
|
||||
return;
|
||||
|
||||
dpy = gc->psc->dpy;
|
||||
|
||||
error = apple_glx_make_current_context(
|
||||
|
|
|
@ -111,8 +111,7 @@ dri2_destroy_context(struct glx_context *context)
|
|||
}
|
||||
|
||||
static Bool
|
||||
dri2_bind_context(struct glx_context *context, struct glx_context *old,
|
||||
GLXDrawable draw, GLXDrawable read)
|
||||
dri2_bind_context(struct glx_context *context, GLXDrawable draw, GLXDrawable read)
|
||||
{
|
||||
struct dri2_screen *psc = (struct dri2_screen *) context->psc;
|
||||
struct dri2_drawable *pdraw, *pread;
|
||||
|
@ -140,7 +139,7 @@ dri2_bind_context(struct glx_context *context, struct glx_context *old,
|
|||
}
|
||||
|
||||
static void
|
||||
dri2_unbind_context(struct glx_context *context, struct glx_context *new)
|
||||
dri2_unbind_context(struct glx_context *context)
|
||||
{
|
||||
struct dri2_screen *psc = (struct dri2_screen *) context->psc;
|
||||
|
||||
|
|
|
@ -157,8 +157,7 @@ dri3_destroy_context(struct glx_context *context)
|
|||
}
|
||||
|
||||
static Bool
|
||||
dri3_bind_context(struct glx_context *context, struct glx_context *old,
|
||||
GLXDrawable draw, GLXDrawable read)
|
||||
dri3_bind_context(struct glx_context *context, GLXDrawable draw, GLXDrawable read)
|
||||
{
|
||||
struct dri3_screen *psc = (struct dri3_screen *) context->psc;
|
||||
struct dri3_drawable *pdraw, *pread;
|
||||
|
@ -191,7 +190,7 @@ dri3_bind_context(struct glx_context *context, struct glx_context *old,
|
|||
}
|
||||
|
||||
static void
|
||||
dri3_unbind_context(struct glx_context *context, struct glx_context *new)
|
||||
dri3_unbind_context(struct glx_context *context)
|
||||
{
|
||||
struct dri3_screen *psc = (struct dri3_screen *) context->psc;
|
||||
|
||||
|
|
|
@ -431,8 +431,7 @@ drisw_destroy_context(struct glx_context *context)
|
|||
}
|
||||
|
||||
static int
|
||||
drisw_bind_context(struct glx_context *context, struct glx_context *old,
|
||||
GLXDrawable draw, GLXDrawable read)
|
||||
drisw_bind_context(struct glx_context *context, GLXDrawable draw, GLXDrawable read)
|
||||
{
|
||||
struct drisw_screen *psc = (struct drisw_screen *) context->psc;
|
||||
struct drisw_drawable *pdraw, *pread;
|
||||
|
@ -457,7 +456,7 @@ drisw_bind_context(struct glx_context *context, struct glx_context *old,
|
|||
}
|
||||
|
||||
static void
|
||||
drisw_unbind_context(struct glx_context *context, struct glx_context *new)
|
||||
drisw_unbind_context(struct glx_context *context)
|
||||
{
|
||||
struct drisw_screen *psc = (struct drisw_screen *) context->psc;
|
||||
|
||||
|
|
|
@ -79,8 +79,7 @@ driwindows_destroy_context(struct glx_context *context)
|
|||
}
|
||||
|
||||
static int
|
||||
driwindows_bind_context(struct glx_context *context, struct glx_context *old,
|
||||
GLXDrawable draw, GLXDrawable read)
|
||||
driwindows_bind_context(struct glx_context *context, GLXDrawable draw, GLXDrawable read)
|
||||
{
|
||||
struct driwindows_context *pcp = (struct driwindows_context *) context;
|
||||
struct driwindows_drawable *pdraw, *pread;
|
||||
|
@ -101,7 +100,7 @@ driwindows_bind_context(struct glx_context *context, struct glx_context *old,
|
|||
}
|
||||
|
||||
static void
|
||||
driwindows_unbind_context(struct glx_context *context, struct glx_context *new)
|
||||
driwindows_unbind_context(struct glx_context *context)
|
||||
{
|
||||
struct driwindows_context *pcp = (struct driwindows_context *) context;
|
||||
|
||||
|
|
|
@ -210,9 +210,8 @@ struct mesa_glinterop_export_out;
|
|||
|
||||
struct glx_context_vtable {
|
||||
void (*destroy)(struct glx_context *ctx);
|
||||
int (*bind)(struct glx_context *context, struct glx_context *old,
|
||||
GLXDrawable draw, GLXDrawable read);
|
||||
void (*unbind)(struct glx_context *context, struct glx_context *new_ctx);
|
||||
int (*bind)(struct glx_context *context, GLXDrawable draw, GLXDrawable read);
|
||||
void (*unbind)(struct glx_context *context);
|
||||
void (*wait_gl)(struct glx_context *ctx);
|
||||
void (*wait_x)(struct glx_context *ctx);
|
||||
int (*interop_query_device_info)(struct glx_context *ctx,
|
||||
|
|
|
@ -125,7 +125,7 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw,
|
|||
}
|
||||
|
||||
if (oldGC != &dummyContext) {
|
||||
oldGC->vtable->unbind(oldGC, gc);
|
||||
oldGC->vtable->unbind(oldGC);
|
||||
oldGC->currentDpy = NULL;
|
||||
}
|
||||
|
||||
|
@ -138,7 +138,7 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw,
|
|||
* blown away our old context. The caller is responsible for
|
||||
* figuring out how to handle setting a valid context.
|
||||
*/
|
||||
if (gc->vtable->bind(gc, oldGC, draw, read) != Success) {
|
||||
if (gc->vtable->bind(gc, draw, read) != Success) {
|
||||
__glXSetCurrentContextNull();
|
||||
__glXUnlock();
|
||||
__glXSendError(dpy, GLXBadContext, None, opcode, False);
|
||||
|
|
|
@ -123,21 +123,13 @@ SendMakeCurrentRequest(Display * dpy, GLXContextID gc_id,
|
|||
}
|
||||
|
||||
static int
|
||||
indirect_bind_context(struct glx_context *gc, struct glx_context *old,
|
||||
indirect_bind_context(struct glx_context *gc,
|
||||
GLXDrawable draw, GLXDrawable read)
|
||||
{
|
||||
GLXContextTag tag;
|
||||
Display *dpy = gc->psc->dpy;
|
||||
Bool sent;
|
||||
|
||||
if (old != &dummyContext && !old->isDirect && old->psc->dpy == dpy) {
|
||||
tag = old->currentContextTag;
|
||||
old->currentContextTag = 0;
|
||||
} else {
|
||||
tag = 0;
|
||||
}
|
||||
|
||||
sent = SendMakeCurrentRequest(dpy, gc->xid, tag, draw, read,
|
||||
sent = SendMakeCurrentRequest(dpy, gc->xid, 0, draw, read,
|
||||
&gc->currentContextTag);
|
||||
|
||||
if (sent) {
|
||||
|
@ -166,22 +158,12 @@ indirect_bind_context(struct glx_context *gc, struct glx_context *old,
|
|||
}
|
||||
|
||||
static void
|
||||
indirect_unbind_context(struct glx_context *gc, struct glx_context *new)
|
||||
indirect_unbind_context(struct glx_context *gc)
|
||||
{
|
||||
Display *dpy = gc->psc->dpy;
|
||||
|
||||
if (gc == new)
|
||||
return;
|
||||
|
||||
/* We are either switching to no context, away from an indirect
|
||||
* context to a direct context or from one dpy to another and have
|
||||
* to send a request to the dpy to unbind the previous context.
|
||||
*/
|
||||
if (!new || new->isDirect || new->psc->dpy != dpy) {
|
||||
SendMakeCurrentRequest(dpy, None, gc->currentContextTag, None, None,
|
||||
NULL);
|
||||
gc->currentContextTag = 0;
|
||||
}
|
||||
SendMakeCurrentRequest(dpy, None, gc->currentContextTag, None, None, NULL);
|
||||
gc->currentContextTag = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Reference in New Issue