summaryrefslogtreecommitdiff
path: root/glx
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2013-11-21 22:48:31 -0800
committerKeith Packard <keithp@keithp.com>2013-12-05 09:51:00 -0800
commit3dd5bfe540b295bb37a2c2fd0ba4a31fb217612b (patch)
treef565f2d47ada46906df6d8cc73fac7bfcf9d5ff5 /glx
parentcde86e68fcb716f34c90f5a16eb868870f5c85e4 (diff)
present: Send GLX_BufferSwapComplete events from present extension
This allows GL to support the GLX_INTEL_swap_event extension. v2: Return GLX_BLIT_COMPLETE_INTEL for unknown swap types Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
Diffstat (limited to 'glx')
-rw-r--r--glx/Makefile.am3
-rw-r--r--glx/glxcmds.c61
-rw-r--r--glx/glxdri2.c33
-rw-r--r--glx/glxext.c3
-rw-r--r--glx/glxserver.h9
5 files changed, 86 insertions, 23 deletions
diff --git a/glx/Makefile.am b/glx/Makefile.am
index 5f28e87da..44d3a7d2a 100644
--- a/glx/Makefile.am
+++ b/glx/Makefile.am
@@ -20,7 +20,8 @@ AM_CPPFLAGS = \
-I$(top_srcdir)/hw/xfree86/os-support/bus \
-I$(top_srcdir)/hw/xfree86/common \
-I$(top_srcdir)/hw/xfree86/dri \
- -I$(top_srcdir)/mi
+ -I$(top_srcdir)/mi \
+ -I$(top_srcdir)/present
if DRI2_AIGLX
AM_CPPFLAGS += -I$(top_srcdir)/hw/xfree86/dri2
diff --git a/glx/glxcmds.c b/glx/glxcmds.c
index efa4aecb2..b8da04882 100644
--- a/glx/glxcmds.c
+++ b/glx/glxcmds.c
@@ -2468,3 +2468,64 @@ __glXDisp_ClientInfo(__GLXclientState * cl, GLbyte * pc)
return Success;
}
+
+#include <GL/glxtokens.h>
+
+void
+__glXsendSwapEvent(__GLXdrawable *drawable, int type, CARD64 ust,
+ CARD64 msc, CARD32 sbc)
+{
+ ClientPtr client = clients[CLIENT_ID(drawable->drawId)];
+
+ xGLXBufferSwapComplete2 wire = {
+ .type = __glXEventBase + GLX_BufferSwapComplete
+ };
+
+ if (!client)
+ return;
+
+ if (!(drawable->eventMask & GLX_BUFFER_SWAP_COMPLETE_INTEL_MASK))
+ return;
+
+ wire.event_type = type;
+ 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 = sbc;
+
+ WriteEventsToClient(client, 1, (xEvent *) &wire);
+}
+
+#if PRESENT
+static void
+__glXpresentCompleteNotify(WindowPtr window, CARD8 present_mode, CARD32 serial,
+ uint64_t ust, uint64_t msc)
+{
+ __GLXdrawable *drawable;
+ int glx_type;
+ int rc;
+
+ rc = dixLookupResourceByType((pointer *) &drawable, window->drawable.id,
+ __glXDrawableRes, serverClient, DixGetAttrAccess);
+
+ if (rc != Success)
+ return;
+
+ if (present_mode == PresentCompleteModeFlip)
+ glx_type = GLX_FLIP_COMPLETE_INTEL;
+ else
+ glx_type = GLX_BLIT_COMPLETE_INTEL;
+
+ __glXsendSwapEvent(drawable, glx_type, ust, msc, serial);
+}
+
+#include <present.h>
+
+void
+__glXregisterPresentCompleteNotify(void)
+{
+ present_register_complete_notify(__glXpresentCompleteNotify);
+}
+#endif
diff --git a/glx/glxdri2.c b/glx/glxdri2.c
index fbbd1fd95..e245e81ae 100644
--- a/glx/glxdri2.c
+++ b/glx/glxdri2.c
@@ -177,36 +177,25 @@ __glXdriSwapEvent(ClientPtr client, void *data, int type, CARD64 ust,
CARD64 msc, CARD32 sbc)
{
__GLXdrawable *drawable = data;
- xGLXBufferSwapComplete2 wire = {
- .type = __glXEventBase + GLX_BufferSwapComplete
- };
-
- if (!(drawable->eventMask & GLX_BUFFER_SWAP_COMPLETE_INTEL_MASK))
- return;
-
+ int glx_type;
switch (type) {
case DRI2_EXCHANGE_COMPLETE:
- wire.event_type = GLX_EXCHANGE_COMPLETE_INTEL;
+ glx_type = GLX_EXCHANGE_COMPLETE_INTEL;
break;
+ default:
+ /* unknown swap completion type,
+ * BLIT is a reasonable default, so
+ * fall through ...
+ */
case DRI2_BLIT_COMPLETE:
- wire.event_type = GLX_BLIT_COMPLETE_INTEL;
+ glx_type = GLX_BLIT_COMPLETE_INTEL;
break;
case DRI2_FLIP_COMPLETE:
- wire.event_type = GLX_FLIP_COMPLETE_INTEL;
- break;
- default:
- /* unknown swap completion type */
- wire.event_type = 0;
+ glx_type = GLX_FLIP_COMPLETE_INTEL;
break;
}
- 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 = sbc;
-
- WriteEventsToClient(client, 1, (xEvent *) &wire);
+
+ __glXsendSwapEvent(drawable, glx_type, ust, msc, sbc);
}
/*
diff --git a/glx/glxext.c b/glx/glxext.c
index 3a7de28fb..601d08afd 100644
--- a/glx/glxext.c
+++ b/glx/glxext.c
@@ -399,6 +399,9 @@ GlxExtensionInit(void)
__glXErrorBase = extEntry->errorBase;
__glXEventBase = extEntry->eventBase;
+#if PRESENT
+ __glXregisterPresentCompleteNotify();
+#endif
}
/************************************************************************/
diff --git a/glx/glxserver.h b/glx/glxserver.h
index 5e29abb28..f862b6360 100644
--- a/glx/glxserver.h
+++ b/glx/glxserver.h
@@ -120,6 +120,15 @@ void glxResumeClients(void);
void __glXsetGetProcAddress(void (*(*get_proc_address) (const char *)) (void));
void *__glGetProcAddress(const char *);
+void
+__glXsendSwapEvent(__GLXdrawable *drawable, int type, CARD64 ust,
+ CARD64 msc, CARD32 sbc);
+
+#if PRESENT
+void
+__glXregisterPresentCompleteNotify(void);
+#endif
+
/*
** State kept per client.
*/