[PATCH 1/4] glx: Remove current context cache

Adam Jackson ajax at redhat.com
Wed Oct 2 14:51:23 PDT 2013


This is something of a pessimization, since now we'll call the
provider's MakeCurrent hook more often.  But that's correct, since the
provider might have a current GL context itself (think glamor), so while
this cache might be useful it should be done down in the provider
itself.

Reviewed-by: Eric Anholt <eric at anholt.net>
Signed-off-by: Adam Jackson <ajax at redhat.com>
---
 glx/glxcmds.c               | 13 -------------
 glx/glxcontext.h            |  2 --
 glx/glxdri.c                |  1 -
 glx/glxdri2.c               |  1 -
 glx/glxdriswrast.c          |  1 -
 glx/glxext.c                | 25 +------------------------
 glx/glxext.h                |  1 -
 glx/glxserver.h             |  4 ----
 hw/dmx/glxProxy/global.c    |  6 ------
 hw/dmx/glxProxy/glxcmds.c   |  4 ----
 hw/dmx/glxProxy/glxext.c    | 13 -------------
 hw/dmx/glxProxy/glxext.h    |  1 -
 hw/dmx/glxProxy/glxserver.h |  6 ------
 13 files changed, 1 insertion(+), 77 deletions(-)

diff --git a/glx/glxcmds.c b/glx/glxcmds.c
index 5b7a628..663448a 100644
--- a/glx/glxcmds.c
+++ b/glx/glxcmds.c
@@ -187,16 +187,9 @@ validGlxDrawable(ClientPtr client, XID id, int type, int access_mode,
     return TRUE;
 }
 
-void
-__glXContextDestroy(__GLXcontext * context)
-{
-    __glXFlushContextCache();
-}
-
 static void
 __glXdirectContextDestroy(__GLXcontext * context)
 {
-    __glXContextDestroy(context);
     free(context);
 }
 
@@ -438,10 +431,6 @@ static void
 StopUsingContext(__GLXcontext * glxc)
 {
     if (glxc) {
-        if (glxc == __glXLastContext) {
-            /* Tell server GL library */
-            __glXLastContext = 0;
-        }
         glxc->isCurrent = GL_FALSE;
         if (!glxc->idExists) {
             FreeResourceByType(glxc->id, __glXContextRes, FALSE);
@@ -453,7 +442,6 @@ static void
 StartUsingContext(__GLXclientState * cl, __GLXcontext * glxc)
 {
     glxc->isCurrent = GL_TRUE;
-    __glXLastContext = glxc;
 }
 
 /**
@@ -627,7 +615,6 @@ DoMakeCurrent(__GLXclientState * cl,
         if (!(*prevglxc->loseCurrent) (prevglxc)) {
             return __glXError(GLXBadContext);
         }
-        __glXFlushContextCache();
         if (!prevglxc->isDirect) {
             prevglxc->drawPriv = NULL;
             prevglxc->readPriv = NULL;
diff --git a/glx/glxcontext.h b/glx/glxcontext.h
index 4764e56..96a4dd2 100644
--- a/glx/glxcontext.h
+++ b/glx/glxcontext.h
@@ -124,8 +124,6 @@ struct __GLXcontext {
     __GLXdrawable *readPriv;
 };
 
-void __glXContextDestroy(__GLXcontext * context);
-
 extern int validGlxScreen(ClientPtr client, int screen,
                           __GLXscreen ** pGlxScreen, int *err);
 
diff --git a/glx/glxdri.c b/glx/glxdri.c
index 1ac6839..f146c7c 100644
--- a/glx/glxdri.c
+++ b/glx/glxdri.c
@@ -295,7 +295,6 @@ __glXDRIcontextDestroy(__GLXcontext * baseContext)
                                context->hwContextID);
     __glXleaveServer(GL_FALSE);
 
-    __glXContextDestroy(&context->base);
     free(context);
 }
 
diff --git a/glx/glxdri2.c b/glx/glxdri2.c
index 8a1fa41..19caeed 100644
--- a/glx/glxdri2.c
+++ b/glx/glxdri2.c
@@ -261,7 +261,6 @@ __glXDRIcontextDestroy(__GLXcontext * baseContext)
     __GLXDRIscreen *screen = (__GLXDRIscreen *) context->base.pGlxScreen;
 
     (*screen->core->destroyContext) (context->driContext);
-    __glXContextDestroy(&context->base);
     free(context);
 }
 
diff --git a/glx/glxdriswrast.c b/glx/glxdriswrast.c
index b478398..861e97c 100644
--- a/glx/glxdriswrast.c
+++ b/glx/glxdriswrast.c
@@ -137,7 +137,6 @@ __glXDRIcontextDestroy(__GLXcontext * baseContext)
     __GLXDRIscreen *screen = (__GLXDRIscreen *) context->base.pGlxScreen;
 
     (*screen->core->destroyContext) (context->driContext);
-    __glXContextDestroy(&context->base);
     free(context);
 }
 
diff --git a/glx/glxext.c b/glx/glxext.c
index bc7fe82..1bb884f 100644
--- a/glx/glxext.c
+++ b/glx/glxext.c
@@ -48,12 +48,6 @@
 #include "indirect_util.h"
 
 /*
-** The last context used by the server.  It is the context that is current
-** from the server's perspective.
-*/
-__GLXcontext *__glXLastContext;
-
-/*
 ** X resources.
 */
 RESTYPE __glXContextRes;
@@ -79,7 +73,6 @@ static int __glXDispatch(ClientPtr);
 static void
 ResetExtension(ExtensionEntry * extEntry)
 {
-    __glXFlushContextCache();
 }
 
 /*
@@ -141,8 +134,6 @@ DrawableGone(__GLXdrawable * glxPriv, XID xid)
         if (c->isCurrent && (c->drawPriv == glxPriv || c->readPriv == glxPriv)) {
             (*c->loseCurrent) (c);
             c->isCurrent = GL_FALSE;
-            if (c == __glXLastContext)
-                __glXFlushContextCache();
         }
         if (c->drawPriv == glxPriv)
             c->drawPriv = NULL;
@@ -201,9 +192,6 @@ __glXFreeContext(__GLXcontext * cx)
 
     free(cx->feedbackBuf);
     free(cx->selectBuf);
-    if (cx == __glXLastContext) {
-        __glXFlushContextCache();
-    }
 
     __glXRemoveFromContextList(cx);
 
@@ -396,12 +384,6 @@ GlxExtensionInit(void)
 
 /************************************************************************/
 
-void
-__glXFlushContextCache(void)
-{
-    __glXLastContext = 0;
-}
-
 /*
 ** Make a context the current one for the GL (in this implementation, there
 ** is only one instance of the GL, and we use it to serve all GL clients by
@@ -439,11 +421,6 @@ __glXForceCurrent(__GLXclientState * cl, GLXContextTag tag, int *error)
     if (cx->wait && (*cx->wait) (cx, cl, error))
         return NULL;
 
-    if (cx == __glXLastContext) {
-        /* No need to re-bind */
-        return cx;
-    }
-
     /* Make this context the current one for the GL. */
     if (!cx->isDirect) {
         if (!(*cx->makeCurrent) (cx)) {
@@ -453,7 +430,7 @@ __glXForceCurrent(__GLXclientState * cl, GLXContextTag tag, int *error)
             return 0;
         }
     }
-    __glXLastContext = cx;
+
     return cx;
 }
 
diff --git a/glx/glxext.h b/glx/glxext.h
index 9b0978b..8b62c40 100644
--- a/glx/glxext.h
+++ b/glx/glxext.h
@@ -36,7 +36,6 @@
  */
 
 extern GLboolean __glXFreeContext(__GLXcontext * glxc);
-extern void __glXFlushContextCache(void);
 
 extern Bool __glXAddContext(__GLXcontext * cx);
 extern void __glXErrorCallBack(GLenum code);
diff --git a/glx/glxserver.h b/glx/glxserver.h
index 1021aec..9178537 100644
--- a/glx/glxserver.h
+++ b/glx/glxserver.h
@@ -80,10 +80,6 @@ void GlxSetVisualConfigs(int nconfigs, void *configs, void **privates);
 
 void __glXScreenInitVisuals(__GLXscreen * screen);
 
-/*
-** The last context used (from the server's persective) is cached.
-*/
-extern __GLXcontext *__glXLastContext;
 extern __GLXcontext *__glXForceCurrent(__GLXclientState *, GLXContextTag,
                                        int *);
 
diff --git a/hw/dmx/glxProxy/global.c b/hw/dmx/glxProxy/global.c
index 6d4612d..9f6e022 100644
--- a/hw/dmx/glxProxy/global.c
+++ b/hw/dmx/glxProxy/global.c
@@ -31,12 +31,6 @@
 #include "glxserver.h"
 
 /*
-** The last context used by the server.  It is the context that is current
-** from the server's perspective.
-*/
-__GLXcontext *__glXLastContext;
-
-/*
 ** X resources.
 */
 RESTYPE __glXContextRes;
diff --git a/hw/dmx/glxProxy/glxcmds.c b/hw/dmx/glxProxy/glxcmds.c
index 8cdb25e..2220399 100644
--- a/hw/dmx/glxProxy/glxcmds.c
+++ b/hw/dmx/glxProxy/glxcmds.c
@@ -763,10 +763,6 @@ static void
 StopUsingContext(__GLXcontext * glxc)
 {
     if (glxc) {
-        if (glxc == __glXLastContext) {
-            /* Tell server GL library */
-            __glXLastContext = 0;
-        }
         glxc->isCurrent = GL_FALSE;
         if (!glxc->idExists) {
             __glXFreeContext(glxc);
diff --git a/hw/dmx/glxProxy/glxext.c b/hw/dmx/glxProxy/glxext.c
index e72a040..e4abd02 100644
--- a/hw/dmx/glxProxy/glxext.c
+++ b/hw/dmx/glxProxy/glxext.c
@@ -59,7 +59,6 @@ static int __glXDispatch(ClientPtr);
 static void
 ResetExtension(ExtensionEntry * extEntry)
 {
-    __glXFlushContextCache();
     __glXScreenReset();
     SwapBarrierReset();
 }
@@ -274,10 +273,6 @@ __glXFreeContext(__GLXcontext * cx)
 
     free(cx);
 
-    if (cx == __glXLastContext) {
-        __glXFlushContextCache();
-    }
-
     return GL_TRUE;
 }
 
@@ -378,14 +373,6 @@ __glXCoreType(void)
 
 /************************************************************************/
 
-void
-__glXFlushContextCache(void)
-{
-    __glXLastContext = 0;
-}
-
-/************************************************************************/
-
 /*
 ** Top level dispatcher; all commands are executed from here down.
 */
diff --git a/hw/dmx/glxProxy/glxext.h b/hw/dmx/glxProxy/glxext.h
index 47cec15..fcdba75 100644
--- a/hw/dmx/glxProxy/glxext.h
+++ b/hw/dmx/glxProxy/glxext.h
@@ -49,7 +49,6 @@ typedef struct {
 } __GLXextensionInfo;
 
 extern GLboolean __glXFreeContext(__GLXcontext * glxc);
-extern void __glXFlushContextCache(void);
 
 extern void __glXFreeGLXWindow(__glXWindow * pGlxWindow);
 extern void __glXFreeGLXPixmap(__GLXpixmap * pGlxPixmap);
diff --git a/hw/dmx/glxProxy/glxserver.h b/hw/dmx/glxProxy/glxserver.h
index ad94966..9fa837c 100644
--- a/hw/dmx/glxProxy/glxserver.h
+++ b/hw/dmx/glxProxy/glxserver.h
@@ -76,12 +76,6 @@ typedef struct __GLXclientStateRec __GLXclientState;
 extern __GLXscreenInfo *__glXActiveScreens;
 extern GLint __glXNumActiveScreens;
 
-/************************************************************************/
-
-/*
-** The last context used (from the server's persective) is cached.
-*/
-extern __GLXcontext *__glXLastContext;
 extern __GLXcontext *__glXForceCurrent(__GLXclientState *, GLXContextTag,
                                        int *);
 
-- 
1.8.3.1



More information about the xorg-devel mailing list