glx: add support for a reallyFlush() function before swap occurs.
authorAlan Hourihane <alanh@vmware.com>
Thu, 19 Feb 2009 18:39:08 +0000 (18:39 +0000)
committerAlan Hourihane <alanh@vmware.com>
Mon, 23 Feb 2009 20:28:11 +0000 (20:28 +0000)
include/GL/internal/dri_interface.h
src/glx/x11/dri2_glx.c
src/glx/x11/dri_common.c
src/glx/x11/glxclient.h

index 27cc1be7ff3c3cf9ec1a67eb29bad0457d60f972..a726b932340090f328d8c1e5f0623282937682a0 100644 (file)
@@ -78,6 +78,7 @@ typedef struct __DRIswrastExtensionRec                __DRIswrastExtension;
 typedef struct __DRIbufferRec                  __DRIbuffer;
 typedef struct __DRIdri2ExtensionRec           __DRIdri2Extension;
 typedef struct __DRIdri2LoaderExtensionRec     __DRIdri2LoaderExtension;
+typedef struct __DRI2flushExtensionRec __DRI2flushExtension;
 
 /*@}*/
 
@@ -245,6 +246,16 @@ struct __DRItexBufferExtensionRec {
                         __DRIdrawable *pDraw);
 };
 
+/**
+ * Used by drivers that implement DRI2
+ */
+#define __DRI2_FLUSH "DRI2_Flush"
+#define __DRI2_FLUSH_VERSION 1
+struct __DRI2flushExtensionRec {
+    __DRIextension base;
+    void (*flush)(__DRIdrawable *drawable);
+};
+
 
 /**
  * XML document describing the configuration options supported by the
index 776a14f614aa950e5f315d5841a046ea5ad1bd24..0ef5d3ab56f19f46f32e19733be8dc8a99e5d189 100644 (file)
@@ -208,7 +208,13 @@ static void dri2CopySubBuffer(__GLXDRIdrawable *pdraw,
     xrect.width = width;
     xrect.height = height;
 
+#ifdef __DRI2_FLUSH
+    if (pdraw->psc->f)
+       (*pdraw->psc->f->flush)(pdraw->driDrawable);
+#endif
+
     region = XFixesCreateRegion(pdraw->psc->dpy, &xrect, 1);
+    /* should get a fence ID back from here at some point */
     DRI2CopyRegion(pdraw->psc->dpy, pdraw->drawable, region,
                   DRI2BufferFrontLeft, DRI2BufferBackLeft);
     XFixesDestroyRegion(pdraw->psc->dpy, region);
@@ -236,6 +242,11 @@ static void dri2WaitX(__GLXDRIdrawable *pdraw)
     xrect.width = priv->width;
     xrect.height = priv->height;
 
+#ifdef __DRI2_FLUSH
+    if (pdraw->psc->f)
+       (*pdraw->psc->f->flush)(pdraw->driDrawable);
+#endif
+
     region = XFixesCreateRegion(pdraw->psc->dpy, &xrect, 1);
     DRI2CopyRegion(pdraw->psc->dpy, pdraw->drawable, region,
                   DRI2BufferFakeFrontLeft, DRI2BufferFrontLeft);
@@ -256,6 +267,11 @@ static void dri2WaitGL(__GLXDRIdrawable *pdraw)
     xrect.width = priv->width;
     xrect.height = priv->height;
 
+#ifdef __DRI2_FLUSH
+    if (pdraw->psc->f)
+       (*pdraw->psc->f->flush)(pdraw->driDrawable);
+#endif
+
     region = XFixesCreateRegion(pdraw->psc->dpy, &xrect, 1);
     DRI2CopyRegion(pdraw->psc->dpy, pdraw->drawable, region,
                   DRI2BufferFrontLeft, DRI2BufferFakeFrontLeft);
index 4fda649e59ab7160b3d737401097bd68cf55975b..90c3d8c7d9d3fa2310c53da28577a2985613137a 100644 (file)
@@ -392,6 +392,13 @@ driBindExtensions(__GLXscreenConfigs *psc, int dri2)
        }
 #endif
 
+#ifdef __DRI2_FLUSH
+       if ((strcmp(extensions[i]->name, __DRI2_FLUSH) == 0) && dri2) {
+           psc->f = (__DRI2flushExtension *) extensions[i];
+           /* internal driver extension, no GL extension exposed */
+       }
+#endif
+
        /* Ignore unknown extensions */
     }
 }
index 3e70759a6c4e6091e3ac03e9a14e5cf8cbe507d7..caf58bbd44a005b2858ec9198bf789e829f30ff9 100644 (file)
@@ -519,6 +519,10 @@ struct __GLXscreenConfigsRec {
     const __DRItexBufferExtension *texBuffer;
 #endif
 
+#ifdef __DRI2_FLUSH
+    const __DRI2flushExtension *f;
+#endif
+
 #endif
 
     /**