Merge branch '7.8'
[mesa.git] / src / mesa / drivers / dri / common / dri_util.h
index 0feb57b3c6e6ac6d40e070f909e04a917ca2d200..f63583cebc01256039731e98f3ec077197d3818e 100644 (file)
 
 typedef struct __DRIswapInfoRec        __DRIswapInfo;
 
-/* Typedefs to avoid rewriting the world. */
-typedef struct __DRIscreenRec  __DRIscreenPrivate;
-typedef struct __DRIdrawableRec        __DRIdrawablePrivate;
-typedef struct __DRIcontextRec __DRIcontextPrivate;
-
 /**
  * Extensions.
  */
 extern const __DRIlegacyExtension driLegacyExtension;
 extern const __DRIcoreExtension driCoreExtension;
+extern const __DRIdri2Extension driDRI2Extension;
 extern const __DRIextension driReadDrawableExtension;
 extern const __DRIcopySubBufferExtension driCopySubBufferExtension;
 extern const __DRIswapControlExtension driSwapControlExtension;
@@ -106,6 +102,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.
@@ -277,7 +295,8 @@ struct __DRIdrawableRec {
     unsigned int index;
 
     /**
-     * Pointer to the "drawable has changed ID" stamp in the SAREA.
+     * Pointer to the "drawable has changed ID" stamp in the SAREA (or
+     * to dri2.stamp if DRI2 is being used).
      */
     unsigned int *pStamp;
 
@@ -358,6 +377,11 @@ struct __DRIdrawableRec {
      * GLX_MESA_swap_control.
      */
     unsigned int swap_interval;
+
+    struct {
+       unsigned int stamp;
+       drm_clip_rect_t clipRect;
+    } dri2;
 };
 
 /**
@@ -393,6 +417,16 @@ struct __DRIcontextRec {
      * Pointer to screen on which this context was created.
      */
     __DRIscreen *driScreenPriv;
+
+    /**
+     * The loaders's private context data.  This structure is opaque.
+     */
+    void *loaderPrivate;
+
+    struct {
+       int draw_stamp;
+       int read_stamp;
+    } dri2;
 };
 
 /**
@@ -510,16 +544,13 @@ struct __DRIscreenRec {
         * fields will not be valid or initializaed in that case. */
        int enabled;
        __DRIdri2LoaderExtension *loader;
+       __DRIimageLookupExtension *image;
     } dri2;
 
     /* The lock actually in use, old sarea or DRI2 */
     drmLock *lock;
 };
 
-extern void
-__driUtilMessage(const char *f, ...);
-
-
 extern void
 __driUtilUpdateDrawableInfo(__DRIdrawable *pdp);
 
@@ -530,4 +561,7 @@ driCalculateSwapUsage( __DRIdrawable *dPriv,
 extern GLint
 driIntersectArea( drm_clip_rect_t rect1, drm_clip_rect_t rect2 );
 
+extern void
+dri2InvalidateDrawable(__DRIdrawable *drawable);
+
 #endif /* _DRI_UTIL_H_ */