Mesa (openchrome-branch): Fix libwsbm init and release when running as aiglx

Thomas Hellstrom thomash at kemper.freedesktop.org
Sun Feb 1 10:42:05 UTC 2009


Module: Mesa
Branch: openchrome-branch
Commit: 3761ed1248ef6645a49d4f43bc944d69e2322a8a
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=3761ed1248ef6645a49d4f43bc944d69e2322a8a

Author: Thomas Hellstrom <thomas-at-shipmail-dot-org>
Date:   Sun Feb  1 11:40:48 2009 +0100

Fix libwsbm init and release when running as aiglx

---

 src/mesa/drivers/dri/openchrome/via_screen.c |   32 +++++++++++++++++--------
 src/mesa/drivers/dri/openchrome/via_screen.h |    2 +
 2 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/src/mesa/drivers/dri/openchrome/via_screen.c b/src/mesa/drivers/dri/openchrome/via_screen.c
index c99bb95..dcf069a 100644
--- a/src/mesa/drivers/dri/openchrome/via_screen.c
+++ b/src/mesa/drivers/dri/openchrome/via_screen.c
@@ -120,16 +120,25 @@ viaInitDriver(__DRIscreenPrivate * sPriv)
 	return GL_FALSE;
     }
 
-    ret = wsbmInit(wsbmPThreadFuncs(), viaVNodeFuncs());
-    if (ret != 0)
-	return GL_FALSE;
-
     /* Allocate the private area */
     viaScreen = (viaScreenPrivate *) CALLOC(sizeof(viaScreenPrivate));
     if (!viaScreen) {
 	__driUtilMessage
 	    ("viaInitDriver: alloc viaScreenPrivate struct failed");
-	goto out_err0;
+	return GL_FALSE;
+    }
+
+    /*
+     * Are we running as AIGLX driver?
+     */
+
+    if (wsbmIsInitialized()) {
+	viaScreen->as_aiglx = GL_TRUE;
+    } else {
+	ret = wsbmInit(wsbmPThreadFuncs(), viaVNodeFuncs());
+	if (ret != 0)
+	    goto out_err0;
+	viaScreen->as_aiglx = GL_FALSE;
     }
 
     /* parse information in __driConfigOptions */
@@ -139,7 +148,7 @@ viaInitDriver(__DRIscreenPrivate * sPriv)
      */
 
     driParseConfigFiles(&viaScreen->parsedCache, &viaScreen->optionCache,
-			sPriv->myNum, "unichrome");
+			sPriv->myNum, "openchrome");
 
     viaScreen->driScrnPriv = sPriv;
     sPriv->private = (void *)viaScreen;
@@ -239,10 +248,11 @@ viaInitDriver(__DRIscreenPrivate * sPriv)
     viaScreen->mallocPool->takeDown(viaScreen->mallocPool);
   out_err1:
     driDestroyOptionCache(&viaScreen->parsedCache);
-    FREE(viaScreen);
-    sPriv->private = NULL;
+    if (!viaScreen->as_aiglx)
+	wsbmTakedown();
   out_err0:
-    wsbmTakedown();
+    sPriv->private = NULL;
+    FREE(viaScreen);
     return GL_FALSE;
 }
 
@@ -251,15 +261,17 @@ viaDestroyScreen(__DRIscreenPrivate * sPriv)
 {
     viaScreenPrivate *viaScreen = (viaScreenPrivate *) sPriv->private;
 
+
     wsbmFenceMgrTTMTakedown(viaScreen->fence_mgr);
     //    viaDestroyDummyHWContext(sPriv, viaScreen->dummyContextID);
     viaScreen->bufferPool->takeDown(viaScreen->bufferPool);
     viaScreen->mallocPool->takeDown(viaScreen->mallocPool);
     driDestroyOptionCache(&viaScreen->parsedCache);
     driDestroyOptionInfo(&viaScreen->optionCache);
+    if (!viaScreen->as_aiglx)
+	wsbmTakedown();
     FREE(viaScreen);
     sPriv->private = NULL;
-    wsbmTakedown();
 }
 
 static GLboolean
diff --git a/src/mesa/drivers/dri/openchrome/via_screen.h b/src/mesa/drivers/dri/openchrome/via_screen.h
index 64c775c..a1284de 100644
--- a/src/mesa/drivers/dri/openchrome/via_screen.h
+++ b/src/mesa/drivers/dri/openchrome/via_screen.h
@@ -77,6 +77,8 @@ typedef struct _viaScreenPrivate
     GLboolean irqEnabled;
     int execIoctlOffset;
 
+    GLboolean as_aiglx;
+
     const __DRIextension *extensions[5];
 } viaScreenPrivate;
 




More information about the mesa-commit mailing list