[PATCH 5/5] GLX: support generic swap events
Jesse Barnes
jbarnes at virtuousgeek.org
Tue May 3 10:59:18 PDT 2011
The existing swap event structure is too big to fit in an XEvent, so
support servers that send generic events instead. Do this by
advertising the GLX proto version we support when connecting and check
for generic events in the event stream. Convert any received events
into regular swap complete events for client compatibility.
Signed-off-by: Jesse Barnes <jbarnes at virtuousgeek.org>
---
configure.ac | 2 +-
src/glx/glxclient.h | 2 +-
src/glx/glxext.c | 55 ++++++++++++++++++++++++++++++++++++++++++++------
3 files changed, 50 insertions(+), 9 deletions(-)
diff --git a/configure.ac b/configure.ac
index 92d11af..94fb6f7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,7 +22,7 @@ LIBDRM_REQUIRED=2.4.24
LIBDRM_RADEON_REQUIRED=2.4.24
LIBDRM_INTEL_REQUIRED=2.4.24
DRI2PROTO_REQUIRED=2.4
-GLPROTO_REQUIRED=1.4.11
+GLPROTO_REQUIRED=1.4.13
LIBDRM_XORG_REQUIRED=2.4.24
LIBKMS_XORG_REQUIRED=1.0.0
diff --git a/src/glx/glxclient.h b/src/glx/glxclient.h
index 755a66d..cdef2a1 100644
--- a/src/glx/glxclient.h
+++ b/src/glx/glxclient.h
@@ -63,7 +63,7 @@
#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0]))
#define GLX_MAJOR_VERSION 1 /* current version numbers */
-#define GLX_MINOR_VERSION 4
+#define GLX_MINOR_VERSION 5
#define __GLX_MAX_TEXTURE_UNITS 32
diff --git a/src/glx/glxext.c b/src/glx/glxext.c
index 278c719..fb29711 100644
--- a/src/glx/glxext.c
+++ b/src/glx/glxext.c
@@ -104,14 +104,42 @@ XEXT_GENERATE_ERROR_STRING(__glXErrorString, __glXExtensionName,
*/
static Bool
+__glXServerSupportsSBC(Display *dpy)
+{
+ struct glx_display *glx_dpy = __glXInitialize(dpy);
+
+ return (glx_dpy->majorVersion > 1 || (glx_dpy->majorVersion == 1 &&
+ glx_dpy->minorVersion > 4));
+}
+
+static Bool
+__glXGenericEvent(Display *dpy, xGenericEvent *wire)
+{
+ struct glx_display *glx_dpy = __glXInitialize(dpy);
+
+ return wire->extension == glx_dpy->codes->major_opcode;
+}
+
+static Bool
__glXWireToEvent(Display *dpy, XEvent *event, xEvent *wire)
{
struct glx_display *glx_dpy = __glXInitialize(dpy);
+ int type;
if (glx_dpy == NULL)
return False;
- switch ((wire->u.u.type & 0x7f) - glx_dpy->codes->first_event) {
+ /* New extension will send generic events for some events */
+ if (wire->u.u.type == GenericEvent && __glXServerSupportsSBC(dpy)) {
+ xGenericEvent *wire2 = (xGenericEvent *)wire;
+ if (!__glXGenericEvent(dpy, wire2))
+ return False;
+ type = wire2->evtype;
+ } else {
+ type = (wire->u.u.type & 0x7f) - glx_dpy->codes->first_event;
+ }
+
+ switch (type) {
case GLX_PbufferClobber:
{
GLXPbufferClobberEvent *aevent = (GLXPbufferClobberEvent *)event;
@@ -133,12 +161,23 @@ __glXWireToEvent(Display *dpy, XEvent *event, xEvent *wire)
case GLX_BufferSwapComplete:
{
GLXBufferSwapComplete *aevent = (GLXBufferSwapComplete *)event;
- xGLXBufferSwapComplete *awire = (xGLXBufferSwapComplete *)wire;
- aevent->event_type = awire->event_type;
- aevent->drawable = awire->drawable;
- aevent->ust = ((CARD64)awire->ust_hi << 32) | awire->ust_lo;
- aevent->msc = ((CARD64)awire->msc_hi << 32) | awire->msc_lo;
- aevent->sbc = ((CARD64)awire->sbc_hi << 32) | awire->sbc_lo;
+ if (__glXServerSupportsSBC(dpy)) {
+ xGLXBufferSwapComplete2 *awire = (xGLXBufferSwapComplete2 *)wire;
+ /* Make it look like a regular event to clients */
+ aevent->type = glx_dpy->codes->first_event + awire->evtype;
+ aevent->event_type = awire->swap_event_type;
+ aevent->drawable = awire->drawable;
+ aevent->ust = ((CARD64)awire->ust_hi << 32) | awire->ust_lo;
+ aevent->msc = ((CARD64)awire->msc_hi << 32) | awire->msc_lo;
+ aevent->sbc = ((CARD64)awire->sbc_hi << 32) | awire->sbc_lo;
+ } else {
+ xGLXBufferSwapComplete *awire = (xGLXBufferSwapComplete *)wire;
+ aevent->event_type = awire->event_type;
+ aevent->drawable = awire->drawable;
+ aevent->ust = ((CARD64)awire->ust_hi << 32) | awire->ust_lo;
+ aevent->msc = ((CARD64)awire->msc_hi << 32) | awire->msc_lo;
+ aevent->sbc = 0;
+ }
return True;
}
default:
@@ -843,6 +882,8 @@ __glXInitialize(Display * dpy)
XESetEventToWire(dpy, dpyPriv->codes->first_event + i, __glXEventToWire);
}
+ XESetWireToEvent(dpy, GenericEvent, __glXWireToEvent);
+
XESetCloseDisplay(dpy, dpyPriv->codes->extension, __glXCloseDisplay);
XESetErrorString (dpy, dpyPriv->codes->extension,__glXErrorString);
--
1.7.4.1
More information about the xorg-devel
mailing list