Mesa (master): dri1: Add a macro to validate two dri drawables in one go.

Thomas Hellstrom thomash at kemper.freedesktop.org
Tue Jan 20 10:30:03 UTC 2009


Module: Mesa
Branch: master
Commit: 11351f0c8a88ae84ec397c7f9abb4a83c64b2cfc
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=11351f0c8a88ae84ec397c7f9abb4a83c64b2cfc

Author: Thomas Hellstrom <thomas-at-tungstengraphics-dot-com>
Date:   Tue Jan 20 11:07:10 2009 +0100

dri1: Add a macro to validate two dri drawables in one go.

Dri drivers often may validate first a write drawable and then a read
drawable ("readable"). However, the hardware lock may be unlocked when
validating the readable, causing the write drawable status to be stale.

Drivers should use this macro instead when validating two drawables.

---

 src/mesa/drivers/dri/common/dri_util.h |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/src/mesa/drivers/dri/common/dri_util.h b/src/mesa/drivers/dri/common/dri_util.h
index c0e1bea..c6781f1 100644
--- a/src/mesa/drivers/dri/common/dri_util.h
+++ b/src/mesa/drivers/dri/common/dri_util.h
@@ -108,6 +108,28 @@ do {                                                                    \
     }                                                                   \
 } while (0)
 
+/**
+ * Same as above, but for two drawables simultaneously.
+ *
+ */
+
+#define DRI_VALIDATE_TWO_DRAWABLES_INFO(psp, pdp, prp)			\
+do {								\
+    while (*((pdp)->pStamp) != (pdp)->lastStamp ||			\
+	   *((prp)->pStamp) != (prp)->lastStamp) {			\
+        register unsigned int hwContext = (psp)->pSAREA->lock.lock &	\
+	    ~(DRM_LOCK_HELD | DRM_LOCK_CONT);				\
+	DRM_UNLOCK((psp)->fd, &(psp)->pSAREA->lock, hwContext);		\
+									\
+	DRM_SPINLOCK(&(psp)->pSAREA->drawable_lock, (psp)->drawLockID);	\
+	DRI_VALIDATE_DRAWABLE_INFO_ONCE(pdp);                           \
+	DRI_VALIDATE_DRAWABLE_INFO_ONCE(prp);				\
+	DRM_SPINUNLOCK(&(psp)->pSAREA->drawable_lock, (psp)->drawLockID); \
+									\
+	DRM_LIGHT_LOCK((psp)->fd, &(psp)->pSAREA->lock, hwContext);	\
+    }                                                                   \
+} while (0)
+
 
 /**
  * Driver callback functions.




More information about the mesa-commit mailing list