mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-09 06:48:06 +02:00
glx: Bind to our context before __glXSetCurrentContext
We want to bind to our context before calling __glXSetCurrentContext or messing with the gc rect in order to properly handle error conditions. Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
This commit is contained in:
parent
517614141b
commit
4fbdde889c
1 changed files with 16 additions and 9 deletions
|
|
@ -212,7 +212,6 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw,
|
||||||
{
|
{
|
||||||
struct glx_context *gc = (struct glx_context *) gc_user;
|
struct glx_context *gc = (struct glx_context *) gc_user;
|
||||||
struct glx_context *oldGC = __glXGetCurrentContext();
|
struct glx_context *oldGC = __glXGetCurrentContext();
|
||||||
int ret = Success;
|
|
||||||
|
|
||||||
/* XXX: If this is left out, then libGL ends up not having this
|
/* XXX: If this is left out, then libGL ends up not having this
|
||||||
* symbol, and drivers using it fail to load. Compare the
|
* symbol, and drivers using it fail to load. Compare the
|
||||||
|
|
@ -259,15 +258,28 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gc) {
|
if (gc) {
|
||||||
|
/* Attempt to bind the context. We do this before mucking with
|
||||||
|
* gc and __glXSetCurrentContext to properly handle our state in
|
||||||
|
* case of an error.
|
||||||
|
*
|
||||||
|
* If an error occurs, set the Null context since we've already
|
||||||
|
* 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) {
|
||||||
|
__glXSetCurrentContextNull();
|
||||||
|
__glXUnlock();
|
||||||
|
__glXGenerateError(dpy, None, GLXBadContext, X_GLXMakeContextCurrent);
|
||||||
|
return GL_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
if (gc->thread_refcount == 0)
|
if (gc->thread_refcount == 0)
|
||||||
gc->currentDpy = dpy;
|
gc->currentDpy = dpy;
|
||||||
__glXSetCurrentContext(gc);
|
|
||||||
ret = gc->vtable->bind(gc, oldGC, draw, read);
|
|
||||||
if (gc->thread_refcount == 0) {
|
|
||||||
gc->currentDrawable = draw;
|
gc->currentDrawable = draw;
|
||||||
gc->currentReadable = read;
|
gc->currentReadable = read;
|
||||||
}
|
}
|
||||||
gc->thread_refcount++;
|
gc->thread_refcount++;
|
||||||
|
__glXSetCurrentContext(gc);
|
||||||
} else {
|
} else {
|
||||||
__glXSetCurrentContextNull();
|
__glXSetCurrentContextNull();
|
||||||
}
|
}
|
||||||
|
|
@ -281,11 +293,6 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw,
|
||||||
|
|
||||||
__glXUnlock();
|
__glXUnlock();
|
||||||
|
|
||||||
if (ret) {
|
|
||||||
__glXGenerateError(dpy, None, ret, X_GLXMakeContextCurrent);
|
|
||||||
return GL_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return GL_TRUE;
|
return GL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue