summaryrefslogtreecommitdiff
path: root/glx/glxdri2.c
diff options
context:
space:
mode:
authorJesse Barnes <jbarnes@virtuousgeek.org>2010-01-11 14:56:24 -0500
committerJesse Barnes <jbarnes@virtuousgeek.org>2010-01-11 16:17:15 -0500
commit84956ca43b087600d9db297cffd62e960c516d9e (patch)
tree43e12fd43c620b9bc977a1823b216b182bed9d86 /glx/glxdri2.c
parent04a54f69a8085ab3fe11a8713bd8b6b16ed1db27 (diff)
GLX/DRI2: add INTEL_swap_event support
This allows clients to easily check for swap completion status in their main loop. Reviewed-by: Kristian Høgsberg <krh@bitplanet.net> Reviewed-by: Adam Jackson <ajax@nwnk.net> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'glx/glxdri2.c')
-rw-r--r--glx/glxdri2.c43
1 files changed, 42 insertions, 1 deletions
diff --git a/glx/glxdri2.c b/glx/glxdri2.c
index 58e4684fe..69fd39b3b 100644
--- a/glx/glxdri2.c
+++ b/glx/glxdri2.c
@@ -167,6 +167,43 @@ __glXDRIdrawableWaitGL(__GLXdrawable *drawable)
DRI2BufferFrontLeft, DRI2BufferFakeFrontLeft);
}
+static void
+__glXdriSwapEvent(ClientPtr client, void *data, int type, CARD64 ust,
+ CARD64 msc, CARD64 sbc)
+{
+ __GLXdrawable *drawable = data;
+ xGLXBufferSwapComplete wire;
+
+ if (!drawable->eventMask & GLX_BUFFER_SWAP_COMPLETE_INTEL_MASK)
+ return;
+
+ wire.type = __glXEventBase + GLX_BufferSwapComplete;
+ switch (type) {
+ case DRI2_EXCHANGE_COMPLETE:
+ wire.event_type = GLX_EXCHANGE_COMPLETE_INTEL;
+ break;
+ case DRI2_BLIT_COMPLETE:
+ wire.event_type = GLX_BLIT_COMPLETE_INTEL;
+ break;
+ case DRI2_FLIP_COMPLETE:
+ wire.event_type = GLX_FLIP_COMPLETE_INTEL;
+ break;
+ default:
+ /* unknown swap completion type */
+ break;
+ }
+ wire.sequenceNumber = client->sequence;
+ wire.drawable = drawable->drawId;
+ wire.ust_hi = ust >> 32;
+ wire.ust_lo = ust & 0xffffffff;
+ wire.msc_hi = msc >> 32;
+ wire.msc_lo = msc & 0xffffffff;
+ wire.sbc_hi = sbc >> 32;
+ wire.sbc_lo = sbc & 0xffffffff;
+
+ WriteEventsToClient(client, 1, (xEvent *) &wire);
+}
+
/*
* Copy or flip back to front, honoring the swap interval if possible.
*
@@ -184,7 +221,7 @@ __glXDRIdrawableSwapBuffers(ClientPtr client, __GLXdrawable *drawable)
(*screen->flush->flushInvalidate)(priv->driDrawable);
if (DRI2SwapBuffers(client, drawable->pDraw, 0, 0, 0, &unused,
- NULL, drawable->pDraw) != Success)
+ __glXdriSwapEvent, drawable->pDraw) != Success)
return FALSE;
return TRUE;
@@ -581,6 +618,10 @@ initializeExtensions(__GLXDRIscreen *screen)
"GLX_MESA_copy_sub_buffer");
LogMessage(X_INFO, "AIGLX: enabled GLX_MESA_copy_sub_buffer\n");
+ /* FIXME: only if DDX supports it */
+ __glXEnableExtension(screen->glx_enable_bits, "GLX_INTEL_swap_event");
+ LogMessage(X_INFO, "AIGLX: enabled GLX_INTEL_swap_event\n");
+
for (i = 0; extensions[i]; i++) {
#ifdef __DRI_READ_DRAWABLE
if (strcmp(extensions[i]->name, __DRI_READ_DRAWABLE) == 0) {