summaryrefslogtreecommitdiff
path: root/src/glx
diff options
context:
space:
mode:
authorFrancisco Jerez <currojerez@riseup.net>2010-02-08 19:27:56 +0100
committerKristian Høgsberg <krh@bitplanet.net>2010-02-16 10:38:50 -0500
commit61d26bc82e7c4100acfb551cbb0ba9d84bbc4ba5 (patch)
treecf096e387a6683a976e152586c355339de3c133e /src/glx
parent925b901ba313a3ddd7567eca088951be39414430 (diff)
dri2: Event driven buffer validation.
When a buffer invalidation event is received from the X server, the "invalidate" hook of the DRI2 flush extension is executed: A generic implementation (dri2InvalidateDrawable) is provided that just bumps the "pStamp" sequence number in __DRIdrawableRec. For old servers not supporting buffer invalidation events, the invalidate hook will be called before flushing the fake front/back buffer (that's typically once per frame -- not a lot worse than the situation we were in before). No effort has been made on preserving backwards compatibility with version 2 of the flush extension, but I think it's acceptable because AFAIK no released stack is making use of it. Signed-off-by: Kristian Høgsberg <krh@bitplanet.net>
Diffstat (limited to 'src/glx')
-rw-r--r--src/glx/dri2.c10
-rw-r--r--src/glx/dri2_glx.c42
-rw-r--r--src/glx/glxclient.h2
3 files changed, 39 insertions, 15 deletions
diff --git a/src/glx/dri2.c b/src/glx/dri2.c
index 91053d3fb6..a7a8cb50aa 100644
--- a/src/glx/dri2.c
+++ b/src/glx/dri2.c
@@ -81,7 +81,7 @@ static XEXT_GENERATE_FIND_DISPLAY (DRI2FindDisplay,
dri2Info,
dri2ExtensionName,
&dri2ExtensionHooks,
- 1, NULL)
+ DRI2NumberEvents, NULL)
static Bool
DRI2WireToEvent(Display *dpy, XEvent *event, xEvent *wire)
@@ -126,7 +126,15 @@ DRI2WireToEvent(Display *dpy, XEvent *event, xEvent *wire)
return True;
}
#endif
+#ifdef DRI2_InvalidateBuffers
+ case DRI2_InvalidateBuffers:
+ {
+ xDRI2InvalidateBuffers *awire = (xDRI2InvalidateBuffers *)wire;
+ dri2InvalidateBuffers(dpy, awire->drawable);
+ return False;
+ }
+#endif
default:
/* client doesn't support server event */
break;
diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c
index 15a3ea5907..29d589cdb9 100644
--- a/src/glx/dri2_glx.c
+++ b/src/glx/dri2_glx.c
@@ -67,6 +67,7 @@ struct __GLXDRIdisplayPrivateRec
int driMinor;
int driPatch;
int swapAvailable;
+ int invalidateAvailable;
};
struct __GLXDRIcontextPrivateRec
@@ -310,12 +311,18 @@ dri2WaitGL(__GLXDRIdrawable * pdraw)
XFixesDestroyRegion(pdraw->psc->dpy, region);
}
-
static void
-dri2FlushFrontBuffer(__DRIdrawable * driDrawable, void *loaderPrivate)
+dri2FlushFrontBuffer(__DRIdrawable *driDrawable, void *loaderPrivate)
{
- (void) driDrawable;
- dri2WaitGL((__GLXDRIdrawable *) loaderPrivate);
+ __GLXDRIdrawablePrivate *pdraw = loaderPrivate;
+ __GLXdisplayPrivate *priv = __glXInitialize(pdraw->base.psc->dpy);
+ __GLXDRIdisplayPrivate *pdp = (__GLXDRIdisplayPrivate *)priv->dri2Display;
+
+ /* Old servers don't send invalidate events */
+ if (!pdp->invalidateAvailable)
+ dri2InvalidateBuffers(priv->dpy, pdraw->base.xDrawable);
+
+ dri2WaitGL(loaderPrivate);
}
@@ -375,6 +382,10 @@ dri2SwapBuffers(__GLXDRIdrawable *pdraw, int64_t target_msc, int64_t divisor,
(*pdraw->psc->f->flush)(pdraw->driDrawable);
#endif
+ /* Old servers don't send invalidate events */
+ if (!pdp->invalidateAvailable)
+ dri2InvalidateBuffers(dpyPriv->dpy, pdraw->xDrawable);
+
/* Old servers can't handle swapbuffers */
if (!pdp->swapAvailable) {
dri2CopySubBuffer(pdraw, 0, 0, priv->width, priv->height);
@@ -386,11 +397,6 @@ dri2SwapBuffers(__GLXDRIdrawable *pdraw, int64_t target_msc, int64_t divisor,
remainder, &ret);
#endif
-#if __DRI2_FLUSH_VERSION >= 2
- if (pdraw->psc->f)
- (*pdraw->psc->f->flushInvalidate)(pdraw->driDrawable);
-#endif
-
return ret;
}
@@ -485,6 +491,17 @@ static const __DRIextension *loader_extensions_old[] = {
NULL
};
+_X_HIDDEN void
+dri2InvalidateBuffers(Display *dpy, XID drawable)
+{
+ __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, NULL);
+
+#if __DRI2_FLUSH_VERSION >= 3
+ if (pdraw && pdraw->psc->f)
+ pdraw->psc->f->invalidate(pdraw->driDrawable);
+#endif
+}
+
static __GLXDRIscreen *
dri2CreateScreen(__GLXscreenConfigs * psc, int screen,
__GLXdisplayPrivate * priv)
@@ -651,11 +668,8 @@ dri2CreateDisplay(Display * dpy)
}
pdp->driPatch = 0;
- pdp->swapAvailable = 0;
-#ifdef X_DRI2SwapBuffers
- if (pdp->driMinor >= 2)
- pdp->swapAvailable = 1;
-#endif
+ pdp->swapAvailable = (pdp->driMinor >= 2);
+ pdp->invalidateAvailable = (pdp->driMinor >= 3);
pdp->base.destroyDisplay = dri2DestroyDisplay;
pdp->base.createScreen = dri2CreateScreen;
diff --git a/src/glx/glxclient.h b/src/glx/glxclient.h
index f88e9fbcde..04ce781c43 100644
--- a/src/glx/glxclient.h
+++ b/src/glx/glxclient.h
@@ -182,6 +182,8 @@ struct __GLXDRIdrawableRec
extern __GLXDRIdisplay *driswCreateDisplay(Display * dpy);
extern __GLXDRIdisplay *driCreateDisplay(Display * dpy);
extern __GLXDRIdisplay *dri2CreateDisplay(Display * dpy);
+extern void dri2InvalidateBuffers(Display *dpy, XID drawable);
+
extern void DRI_glXUseXFont(Font font, int first, int count, int listbase);