summaryrefslogtreecommitdiff
path: root/glx
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
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')
-rw-r--r--glx/extension_string.c1
-rw-r--r--glx/extension_string.h1
-rw-r--r--glx/glxdri2.c43
-rw-r--r--glx/glxext.c2
-rw-r--r--glx/glxscreens.c1
-rw-r--r--glx/glxserver.h2
6 files changed, 49 insertions, 1 deletions
diff --git a/glx/extension_string.c b/glx/extension_string.c
index 9d110cf98..7721cb056 100644
--- a/glx/extension_string.c
+++ b/glx/extension_string.c
@@ -82,6 +82,7 @@ static const struct extension_info known_glx_extensions[] = {
{ GLX(SGIX_fbconfig), VER(1,3), Y, },
{ GLX(SGIX_pbuffer), VER(1,3), Y, },
{ GLX(SGIX_visual_select_group), VER(0,0), Y, },
+ { GLX(INTEL_swap_event), VER(1,4), N, },
{ NULL }
};
diff --git a/glx/extension_string.h b/glx/extension_string.h
index 98e91bc18..912534a04 100644
--- a/glx/extension_string.h
+++ b/glx/extension_string.h
@@ -50,6 +50,7 @@ enum {
SGIX_fbconfig_bit,
SGIX_pbuffer_bit,
SGIX_visual_select_group_bit,
+ INTEL_swap_event_bit,
__NUM_GLX_EXTS,
};
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) {
diff --git a/glx/glxext.c b/glx/glxext.c
index 913c624f2..59bcfbed2 100644
--- a/glx/glxext.c
+++ b/glx/glxext.c
@@ -267,6 +267,7 @@ GLboolean __glXErrorOccured(void)
}
static int __glXErrorBase;
+int __glXEventBase;
int __glXError(int error)
{
@@ -403,6 +404,7 @@ void GlxExtensionInit(void)
}
__glXErrorBase = extEntry->errorBase;
+ __glXEventBase = extEntry->eventBase;
}
/************************************************************************/
diff --git a/glx/glxscreens.c b/glx/glxscreens.c
index 674e2c681..58d8ee0b4 100644
--- a/glx/glxscreens.c
+++ b/glx/glxscreens.c
@@ -181,6 +181,7 @@ static char GLXServerExtensions[] =
"GLX_SGIX_fbconfig "
"GLX_SGIX_pbuffer "
"GLX_MESA_copy_sub_buffer "
+ "GLX_INTEL_swap_event"
;
/*
diff --git a/glx/glxserver.h b/glx/glxserver.h
index 10c4889e1..1daf97758 100644
--- a/glx/glxserver.h
+++ b/glx/glxserver.h
@@ -249,4 +249,6 @@ extern int __glXImageSize(GLenum format, GLenum type,
extern unsigned glxMajorVersion;
extern unsigned glxMinorVersion;
+extern int __glXEventBase;
+
#endif /* !__GLX_server_h__ */