Mesa (master): xlib: fix glXGetCurrentDisplay() failure

Brian Paul brianp at kemper.freedesktop.org
Fri Jun 2 14:22:44 UTC 2017


Module: Mesa
Branch: master
Commit: c6ba85a8c0f02b3b7058dae7afb6c49f56567319
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=c6ba85a8c0f02b3b7058dae7afb6c49f56567319

Author: Brian Paul <brianp at vmware.com>
Date:   Mon May 22 11:46:27 2017 -0600

xlib: fix glXGetCurrentDisplay() failure

glXGetCurrentDisplay() has been broken for years and nobody noticed until
recently.  This change adds a new XMesaGetCurrentDisplay() that the GLX
emulation API can call, just as we did for glXGetCurrentContext().

Tested by hacking glxgears to call glXGetCurrentContext() before and
after glXMakeCurrent() to verify the return value is NULL beforehand and
the same as the opened display afterward.

Also tested by Tom Hudson with his tests programs.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=100988
Cc: mesa-stable at lists.freedesktop.org
Tested-by: Tom Hudson <tom.hudson.phd at gmail.com>
Signed-off-by: Brian Paul <brianp at vmware.com>

---

 src/mesa/drivers/x11/glxapi.c | 8 ++++----
 src/mesa/drivers/x11/glxapi.h | 1 -
 src/mesa/drivers/x11/xm_api.c | 8 ++++++++
 src/mesa/drivers/x11/xmesa.h  | 6 ++++++
 4 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/src/mesa/drivers/x11/glxapi.c b/src/mesa/drivers/x11/glxapi.c
index a807074a86..52e6026569 100644
--- a/src/mesa/drivers/x11/glxapi.c
+++ b/src/mesa/drivers/x11/glxapi.c
@@ -379,13 +379,13 @@ glXQueryServerString(Display *dpy, int screen, int name)
 
 /*** GLX_VERSION_1_2 ***/
 
+/* declare here to avoid including xmesa.h */
+extern Display *XMesaGetCurrentDisplay(void);
+
 Display PUBLIC *
 glXGetCurrentDisplay(void)
 {
-   /* Same code as in libGL's glxext.c */
-   __GLXcontext *gc = (__GLXcontext *) glXGetCurrentContext();
-   if (NULL == gc) return NULL;
-   return gc->currentDpy;
+   return XMesaGetCurrentDisplay();
 }
 
 
diff --git a/src/mesa/drivers/x11/glxapi.h b/src/mesa/drivers/x11/glxapi.h
index aff38f7531..cc4f902925 100644
--- a/src/mesa/drivers/x11/glxapi.h
+++ b/src/mesa/drivers/x11/glxapi.h
@@ -37,7 +37,6 @@
  * work properly.
  */
 typedef struct __GLXcontextRec {
-   Display *currentDpy;
    GLboolean isDirect;
    GLXDrawable currentDrawable;
    GLXDrawable currentReadable;
diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c
index b54900b2ae..a0695c3d87 100644
--- a/src/mesa/drivers/x11/xm_api.c
+++ b/src/mesa/drivers/x11/xm_api.c
@@ -1304,6 +1304,14 @@ XMesaBuffer XMesaGetCurrentReadBuffer( void )
 }
 
 
+Display *XMesaGetCurrentDisplay(void)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   XMesaContext xmctx = XMESA_CONTEXT(ctx);
+   return xmctx ? xmctx->display : NULL;
+}
+
+
 
 GLboolean XMesaSetFXmode( GLint mode )
 {
diff --git a/src/mesa/drivers/x11/xmesa.h b/src/mesa/drivers/x11/xmesa.h
index cc878e7402..84b2b27006 100644
--- a/src/mesa/drivers/x11/xmesa.h
+++ b/src/mesa/drivers/x11/xmesa.h
@@ -241,6 +241,12 @@ extern XMesaBuffer XMesaGetCurrentReadBuffer( void );
 
 
 /*
+ * Return display of current context.
+ */
+extern Display *XMesaGetCurrentDisplay( void );
+
+
+/*
  * Swap the front and back buffers for the given buffer.  No action is
  * taken if the buffer is not double buffered.
  */




More information about the mesa-commit mailing list