Track the currently bound read drawable and make sure its info is up
authorIan Romanick <idr@us.ibm.com>
Mon, 16 Oct 2006 20:59:53 +0000 (20:59 +0000)
committerIan Romanick <idr@us.ibm.com>
Mon, 16 Oct 2006 20:59:53 +0000 (20:59 +0000)
to date.

src/mesa/drivers/dri/common/dri_util.c
src/mesa/drivers/dri/common/dri_util.h

index b5c20a066a51fa212eac6e2aa002d9469024f2b7..1ca2756e012315f0d87e63948ee7dfca7fa1a95d 100644 (file)
@@ -323,6 +323,7 @@ static GLboolean DoBindContext(__DRInativeDisplay *dpy,
 
     /* Bind the drawable to the context */
     pcp->driDrawablePriv = pdp;
+    pcp->driReadablePriv = prp;
     pdp->driContextPriv = pcp;
     pdp->refcount++;
     if ( pdp != prp ) {
@@ -339,6 +340,12 @@ static GLboolean DoBindContext(__DRInativeDisplay *dpy,
        DRM_SPINUNLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID);
     }
 
+    if ((pdp != prp) && (!pdp->pStamp || *pdp->pStamp != pdp->lastStamp)) {
+       DRM_SPINLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID);
+       __driUtilUpdateDrawableInfo(prp);
+       DRM_SPINUNLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID);
+    }
+
     /* Call device-specific MakeCurrent */
     (*psp->DriverAPI.MakeCurrent)(pcp, pdp, prp);
 
@@ -402,7 +409,8 @@ __driUtilUpdateDrawableInfo(__DRIdrawablePrivate *pdp)
     __DRIscreenPrivate *psp;
     __DRIcontextPrivate *pcp = pdp->driContextPriv;
     
-    if (!pcp || (pdp != pcp->driDrawablePriv)) {
+    if (!pcp 
+       || ((pdp != pcp->driDrawablePriv) && (pdp != pcp->driReadablePriv))) {
        /* ERROR!!! */
        return;
     }
index 14c24a0efaab6eb4648f170febf13a83741aba92..885d5899e0f46bb7123c8ad5870c68ef6e53e931 100644 (file)
@@ -355,10 +355,15 @@ struct __DRIcontextPrivateRec {
     __DRInativeDisplay *display;
 
     /**
-     * Pointer to drawable currently bound to this context.
+     * Pointer to drawable currently bound to this context for drawing.
      */
     __DRIdrawablePrivate *driDrawablePriv;
 
+    /**
+     * Pointer to drawable currently bound to this context for reading.
+     */
+    __DRIdrawablePrivate *driReadablePriv;
+
     /**
      * Pointer to screen on which this context was created.
      */