[Mesa-stable] [PATCH v2] glx: fix error code when there is no context bound
Tapani Pälli
tapani.palli at intel.com
Fri May 27 07:09:04 UTC 2016
From: Bernard Kilarski <bernard.r.kilarski at intel.com>
v2: change all related NULL checks to check against dummyContext
Signed-off-by: Bernard Kilarski <bernard.r.kilarski at intel.com>
Signed-off-by: Matt Roper <matthew.d.roper at intel.com>
Cc: "11.2" <mesa-stable at lists.freedesktop.org
---
src/glx/glx_pbuffer.c | 2 +-
src/glx/glxcmds.c | 16 ++++++++--------
src/glx/query_renderer.c | 4 ++--
src/glx/tests/fake_glx_screen.cpp | 6 +++++-
4 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/src/glx/glx_pbuffer.c b/src/glx/glx_pbuffer.c
index 231ab20..ab29899 100644
--- a/src/glx/glx_pbuffer.c
+++ b/src/glx/glx_pbuffer.c
@@ -328,7 +328,7 @@ GetDrawableAttribute(Display * dpy, GLXDrawable drawable,
* the calling thread's current context a GLXBadDrawable error is
* generated."
*/
- if (pdraw == NULL || gc == NULL || gc->currentDpy != dpy ||
+ if (pdraw == NULL || gc == &dummyContext || gc->currentDpy != dpy ||
(gc->currentDrawable != drawable &&
gc->currentReadable != drawable)) {
__glXSendError(dpy, GLXBadDrawable, drawable,
diff --git a/src/glx/glxcmds.c b/src/glx/glxcmds.c
index 589a87a..699a81f 100644
--- a/src/glx/glxcmds.c
+++ b/src/glx/glxcmds.c
@@ -456,7 +456,7 @@ glXDestroyContext(Display * dpy, GLXContext ctx)
{
struct glx_context *gc = (struct glx_context *) ctx;
- if (gc == NULL || gc->xid == None)
+ if (gc == &dummyContext || gc->xid == None)
return;
__glXLock();
@@ -1581,7 +1581,7 @@ glXFreeContextEXT(Display *dpy, GLXContext ctx)
{
struct glx_context *gc = (struct glx_context *) ctx;
- if (gc == NULL || gc->xid == None)
+ if (gc == &dummyContext || gc->xid == None)
return;
/* The GLX_EXT_import_context spec says:
@@ -1728,7 +1728,7 @@ __glXSwapIntervalSGI(int interval)
CARD32 *interval_ptr;
CARD8 opcode;
- if (gc == NULL) {
+ if (gc == &dummyContext) {
return GLX_BAD_CONTEXT;
}
@@ -1834,7 +1834,7 @@ __glXGetVideoSyncSGI(unsigned int *count)
__GLXDRIdrawable *pdraw;
#endif
- if (!gc)
+ if (gc == &dummyContext)
return GLX_BAD_CONTEXT;
#ifdef GLX_DIRECT_RENDERING
@@ -1876,7 +1876,7 @@ __glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count)
if (divisor <= 0 || remainder < 0)
return GLX_BAD_VALUE;
- if (!gc)
+ if (gc == &dummyContext)
return GLX_BAD_CONTEXT;
#ifdef GLX_DIRECT_RENDERING
@@ -2189,7 +2189,7 @@ __glXSwapBuffersMscOML(Display * dpy, GLXDrawable drawable,
struct glx_screen *psc = pdraw ? pdraw->psc : NULL;
#endif
- if (!gc) /* no GLX for this */
+ if (gc == &dummyContext) /* no GLX for this */
return -1;
#ifdef GLX_DIRECT_RENDERING
@@ -2408,7 +2408,7 @@ __glXBindTexImageEXT(Display * dpy,
{
struct glx_context *gc = __glXGetCurrentContext();
- if (gc == NULL || gc->vtable->bind_tex_image == NULL)
+ if (gc == &dummyContext || gc->vtable->bind_tex_image == NULL)
return;
gc->vtable->bind_tex_image(dpy, drawable, buffer, attrib_list);
@@ -2419,7 +2419,7 @@ __glXReleaseTexImageEXT(Display * dpy, GLXDrawable drawable, int buffer)
{
struct glx_context *gc = __glXGetCurrentContext();
- if (gc == NULL || gc->vtable->release_tex_image == NULL)
+ if (gc == &dummyContext || gc->vtable->release_tex_image == NULL)
return;
gc->vtable->release_tex_image(dpy, drawable, buffer);
diff --git a/src/glx/query_renderer.c b/src/glx/query_renderer.c
index 9108ec2..4debf06 100644
--- a/src/glx/query_renderer.c
+++ b/src/glx/query_renderer.c
@@ -106,7 +106,7 @@ glXQueryCurrentRendererIntegerMESA(int attribute, unsigned int *value)
{
struct glx_context *gc = __glXGetCurrentContext();
- if (gc == NULL)
+ if (gc == &dummyContext)
return False;
return __glXQueryRendererInteger(gc->psc, attribute, value);
@@ -166,7 +166,7 @@ glXQueryCurrentRendererStringMESA(int attribute)
{
struct glx_context *gc = __glXGetCurrentContext();
- if (gc == NULL)
+ if (gc == &dummyContext)
return False;
return __glXQueryRendererString(gc->psc, attribute);
diff --git a/src/glx/tests/fake_glx_screen.cpp b/src/glx/tests/fake_glx_screen.cpp
index db20749..c288aa6 100644
--- a/src/glx/tests/fake_glx_screen.cpp
+++ b/src/glx/tests/fake_glx_screen.cpp
@@ -75,7 +75,11 @@ indirect_create_context_attribs(struct glx_screen *base,
return indirect_create_context(base, config_base, shareList, 0);
}
-__thread void *__glX_tls_Context = NULL;
+/* This is necessary so that we don't have to link with glxcurrent.c
+ * which would require us to link with X libraries and what not.
+ */
+struct glx_context dummyContext;
+__thread void *__glX_tls_Context = &dummyContext;
#if !defined(GLX_USE_TLS)
extern "C" struct glx_context *
--
2.5.5
More information about the mesa-stable
mailing list