summaryrefslogtreecommitdiffstats
path: root/src/glx
diff options
context:
space:
mode:
authorJesse Barnes <[email protected]>2009-07-17 03:30:29 -0400
committerJesse Barnes <[email protected]>2010-01-08 12:29:50 -0500
commita35f6bb207efe3c959bbd16a37f2049e5aceeea9 (patch)
tree63229cca1d391ccfc284a3f72852e09240f97c66 /src/glx
parent1baaf111c8c42ed7f7218c46038f32eb51b9c6eb (diff)
DRI2: add SwapBuffers support
Support the new DRI2 protocol request, DRI2SwapBuffers, in both direct and indirect rendering context. This request allows the display server to optimize back->front swaps (e.g. through page flipping) and allows us to more easily support other GLX features like swap interval and the OML sync extension in DRI2. Signed-off-by: Jesse Barnes <[email protected]>
Diffstat (limited to 'src/glx')
-rw-r--r--src/glx/x11/dri2.c16
-rw-r--r--src/glx/x11/dri2.h3
-rw-r--r--src/glx/x11/dri2_glx.c32
3 files changed, 50 insertions, 1 deletions
diff --git a/src/glx/x11/dri2.c b/src/glx/x11/dri2.c
index dad04470a00..a0f8901d42d 100644
--- a/src/glx/x11/dri2.c
+++ b/src/glx/x11/dri2.c
@@ -380,4 +380,20 @@ DRI2CopyRegion(Display * dpy, XID drawable, XserverRegion region,
SyncHandle();
}
+void DRI2SwapBuffers(Display *dpy, XID drawable)
+{
+ XExtDisplayInfo *info = DRI2FindDisplay(dpy);
+ xDRI2SwapBuffersReq *req;
+
+ XextSimpleCheckExtension (dpy, info, dri2ExtensionName);
+
+ LockDisplay(dpy);
+ GetReq(DRI2SwapBuffers, req);
+ req->reqType = info->codes->major_opcode;
+ req->dri2ReqType = X_DRI2SwapBuffers;
+ req->drawable = drawable;
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
#endif /* GLX_DIRECT_RENDERING */
diff --git a/src/glx/x11/dri2.h b/src/glx/x11/dri2.h
index a6fe66e136d..ba6eff5e4f7 100644
--- a/src/glx/x11/dri2.h
+++ b/src/glx/x11/dri2.h
@@ -85,4 +85,7 @@ DRI2CopyRegion(Display * dpy, XID drawable,
XserverRegion region,
CARD32 dest, CARD32 src);
+extern void
+DRI2SwapBuffers(Display *dpy, XID drawable);
+
#endif
diff --git a/src/glx/x11/dri2_glx.c b/src/glx/x11/dri2_glx.c
index 89efe3ab292..114cad2ae7d 100644
--- a/src/glx/x11/dri2_glx.c
+++ b/src/glx/x11/dri2_glx.c
@@ -35,6 +35,7 @@
#include <X11/Xlib.h>
#include <X11/extensions/Xfixes.h>
#include <X11/extensions/Xdamage.h>
+#include "glapi.h"
#include "glxclient.h"
#include "glcontextmodes.h"
#include "xf86dri.h"
@@ -64,6 +65,7 @@ struct __GLXDRIdisplayPrivateRec
int driMajor;
int driMinor;
int driPatch;
+ int swapAvailable;
};
struct __GLXDRIcontextPrivateRec
@@ -240,7 +242,7 @@ dri2SwapBuffers(__GLXDRIdrawable * pdraw)
}
static void
-dri2WaitX(__GLXDRIdrawable * pdraw)
+dri2WaitX(__GLXDRIdrawable *pdraw)
{
__GLXDRIdrawablePrivate *priv = (__GLXDRIdrawablePrivate *) pdraw;
XRectangle xrect;
@@ -342,6 +344,31 @@ process_buffers(__GLXDRIdrawablePrivate * pdraw, DRI2Buffer * buffers,
}
+static void dri2SwapBuffers(__GLXDRIdrawable *pdraw)
+{
+ __GLXDRIdrawablePrivate *priv = (__GLXDRIdrawablePrivate *) pdraw;
+ __GLXdisplayPrivate *dpyPriv = __glXInitialize(priv->base.psc->dpy);
+ __GLXDRIdisplayPrivate *pdp =
+ (__GLXDRIdisplayPrivate *)dpyPriv->dri2Display;
+ __GLXscreenConfigs *psc = pdraw->psc;
+
+#ifdef __DRI2_FLUSH
+ if (pdraw->psc->f)
+ (*pdraw->psc->f->flush)(pdraw->driDrawable);
+#endif
+
+ /* Old servers can't handle swapbuffers */
+ if (!pdp->swapAvailable)
+ return dri2CopySubBuffer(pdraw, 0, 0, priv->width, priv->height);
+
+ DRI2SwapBuffers(pdraw->psc->dpy, pdraw->drawable);
+
+#if __DRI2_FLUSH_VERSION >= 2
+ if (pdraw->psc->f)
+ (*pdraw->psc->f->flushInvalidate)(pdraw->driDrawable);
+#endif
+}
+
static __DRIbuffer *
dri2GetBuffers(__DRIdrawable * driDrawable,
int *width, int *height,
@@ -559,6 +586,9 @@ dri2CreateDisplay(Display * dpy)
}
pdp->driPatch = 0;
+ pdp->swapAvailable = 0;
+ if (pdp->driMinor >= 2)
+ pdp->swapAvailable = 1;
pdp->base.destroyDisplay = dri2DestroyDisplay;
pdp->base.createScreen = dri2CreateScreen;