-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
[email protected] wrote:
> From: Thomas Hellstrom <thellstrom-at-vmware-dot-com>
>
> 1) If MakeContextCurrent is called with (NULL, None, None), Don't
> send the request to the X server if the current context is direct.
> 2) Return BadMatch in some error cases according to the glx spec.
> 3) If MakeContextCurrent is called for a context which is current in
> another thread, return BadAccess according to the glx spec.
>
> Signed-off-by: Thomas Hellstrom <thellstrom-at-vmware-dot-com>
> ---
> src/glx/x11/glxclient.h | 5 +++++
> src/glx/x11/glxcurrent.c | 33 +++++++++++++++++++++++++++++++++
> 2 files changed, 38 insertions(+), 0 deletions(-)
>
> diff --git a/src/glx/x11/glxclient.h b/src/glx/x11/glxclient.h
> index fa3ec26..bf68d0f 100644
> --- a/src/glx/x11/glxclient.h
> +++ b/src/glx/x11/glxclient.h
> @@ -426,6 +426,11 @@ struct __GLXcontextRec {
> int server_minor; /**< Minor version number. */
> /*...@}*/
>
> + /**
> + * Thread ID we're currently current in. Zero if none.
> + */
> + unsigned long thread_id;
> +
Is this the right type? Would uintptr_t be better? void *?
> char gl_extension_bits[ __GL_EXT_BYTES ];
> };
>
> diff --git a/src/glx/x11/glxcurrent.c b/src/glx/x11/glxcurrent.c
> index 4d0a7c6..c36c611 100644
> --- a/src/glx/x11/glxcurrent.c
> +++ b/src/glx/x11/glxcurrent.c
> @@ -369,8 +369,36 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw,
> return GL_FALSE;
> }
>
> + if ((gc == NULL && (draw != None || read != None)) ||
> + (gc != NULL && (draw == None || read == None))) {
> + xError error;
> +
> + error.errorCode = BadMatch;
> + error.resourceID = draw;
> + error.sequenceNumber = dpy->request;
> + error.type = X_Error;
> + error.majorCode = gc->majorOpcode;
> + error.minorCode = X_GLXMakeContextCurrent;
> + _XError(dpy, &error);
> + return False;
> + }
> +
> _glapi_check_multithread();
>
> + if (gc != NULL && gc->thread_id != 0 &&
> + gc->thread_id != _glthread_GetID()) {
> + xError error;
> +
> + error.errorCode = BadAccess;
> + error.resourceID = gc->xid;
> + error.sequenceNumber = dpy->request;
> + error.type = X_Error;
> + error.majorCode = gc->majorOpcode;
> + error.minorCode = X_GLXMakeContextCurrent;
> + _XError(dpy, &error);
> + return False;
There are a lot of places where we don't generate correct X errors in
the direct rendering path. Perhaps we could make a small function that
encapsulates this? I expect those code will see a lot of copy-and-paste
otherwise. Something like:
void __glXGenerateError(Display *dpy, __GLXcontext *gc, BYTE errorCode,
CARD16 minorCode);
> + }
> +
> #ifdef GLX_DIRECT_RENDERING
> /* Bind the direct rendering context to the drawable */
> if (gc && gc->driContext) {
> @@ -393,6 +421,9 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw,
> bindReturnValue =
> (gc->driContext->bindContext) (gc->driContext, pdraw, pread);
> }
> + else if (!gc && oldGC && oldGC->driContext) {
> + bindReturnValue = True;
> + }
> else
> #endif
> {
> @@ -453,6 +484,7 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw,
> oldGC->currentDrawable = None;
> oldGC->currentReadable = None;
> oldGC->currentContextTag = 0;
> + oldGC->thread_id = 0;
Whitespace.
>
> if (oldGC->xid == None) {
> /* We are switching away from a context that was
> @@ -477,6 +509,7 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw,
> gc->currentDpy = dpy;
> gc->currentDrawable = draw;
> gc->currentReadable = read;
> + gc->thread_id = _glthread_GetID();
Whitespace.
>
> #ifdef GLX_DIRECT_RENDERING
> if (!gc->driContext) {
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAknSkHQACgkQX1gOwKyEAw/+sACcC21AF4nZQcoewDFb12IyxRfC
y3sAn2+qdRayqMobhfb8YPBuuk7SVI6w
=pJhO
-----END PGP SIGNATURE-----
------------------------------------------------------------------------------
_______________________________________________
Mesa3d-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev