dri glx: Fix dri_util::driBindContext
authorThomas Hellstrom <thellstrom-at-vmware-dot-com>
Thu, 2 Apr 2009 08:36:40 +0000 (10:36 +0200)
committerThomas Hellstrom <thellstrom-at-vmware-dot-com>
Thu, 2 Apr 2009 09:33:19 +0000 (11:33 +0200)
1) Don't error-check here. It's done in glx makeCurrent.
2) Allow ctx and the dri drawables to be NULL for future use. This is
   currently blocked in glx makeCurrent.
3) Avoid updating dri drawables unless they are completely uninitialized.
   Since the updating was done outside of the lock, the driver need to
   verify and redo it anyway.

Signed-off-by: Thomas Hellstrom <thellstrom-at-vmware-dot-com>
src/mesa/drivers/dri/common/dri_util.c

index a9e37ca51eb77204a687269cbf7c77bbe3c74aee..38c2e7b00d19d29c157137dd7404c83e50ee7e1f 100644 (file)
@@ -163,21 +163,18 @@ static int driBindContext(__DRIcontext *pcp,
 {
     __DRIscreenPrivate *psp = pcp->driScreenPriv;
 
-    /*
-    ** Assume error checking is done properly in glXMakeCurrent before
-    ** calling driBindContext.
-    */
-
-    if (pcp == NULL || pdp == None || prp == None)
-       return GL_FALSE;
-
     /* Bind the drawable to the context */
-    pcp->driDrawablePriv = pdp;
-    pcp->driReadablePriv = prp;
-    pdp->driContextPriv = pcp;
-    pdp->refcount++;
-    if ( pdp != prp ) {
-       prp->refcount++;
+
+    if (pcp) {
+       pcp->driDrawablePriv = pdp;
+       pcp->driReadablePriv = prp;
+       if (pdp) {
+           pdp->driContextPriv = pcp;
+           pdp->refcount++;
+       }
+       if ( prp && pdp != prp ) {
+           prp->refcount++;
+       }
     }
 
     /*
@@ -186,17 +183,16 @@ static int driBindContext(__DRIcontext *pcp,
     */
 
     if (!psp->dri2.enabled) {
-       if (!pdp->pStamp || *pdp->pStamp != pdp->lastStamp) {
+       if (pdp && !pdp->pStamp) {
            DRM_SPINLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID);
            __driUtilUpdateDrawableInfo(pdp);
            DRM_SPINUNLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID);
        }
-       
-       if ((pdp != prp) && (!prp->pStamp || *prp->pStamp != prp->lastStamp)) {
+       if (prp && pdp != prp && !prp->pStamp) {
            DRM_SPINLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID);
            __driUtilUpdateDrawableInfo(prp);
            DRM_SPINUNLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID);
-       }
+        }
     }
 
     /* Call device-specific MakeCurrent */