Mesa (master): glx: decouple dri2.c and GLX, fixing Gallium EGL and d3d1x build

Luca Barbieri lb at kemper.freedesktop.org
Wed Sep 22 08:03:22 UTC 2010


Module: Mesa
Branch: master
Commit: a0e510320009766faa5ff8c0ed744e87f8095df7
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a0e510320009766faa5ff8c0ed744e87f8095df7

Author: Luca Barbieri <luca at luca-barbieri.com>
Date:   Wed Sep 22 07:44:59 2010 +0200

glx: decouple dri2.c and GLX, fixing Gallium EGL and d3d1x build

The Gallium EGL state tracker reuses dri2.c but not the GLX code.

Currently there is a bit of code in dri2.c that is incorrectly tied
to GLX: instead, make it call an helper that both GLX and Gallium EGL
implement, like dri2InvalidateBuffers.

This avoids a link error complaining that dri2GetGlxDrawableFromXDrawableId
is undefined.

Note that we might want to move the whole event translation elsewhere,
and probably stop using non-XCB DRI2 altogether, but this seems to be
the minimal fix.

---

 src/gallium/state_trackers/egl/x11/x11_screen.c |   11 +++++++++++
 src/glx/dri2.c                                  |    9 +++------
 src/glx/dri2_glx.c                              |   10 ++++++++++
 src/glx/glxclient.h                             |    1 +
 4 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/src/gallium/state_trackers/egl/x11/x11_screen.c b/src/gallium/state_trackers/egl/x11/x11_screen.c
index c07ebb7..c919b79 100644
--- a/src/gallium/state_trackers/egl/x11/x11_screen.c
+++ b/src/gallium/state_trackers/egl/x11/x11_screen.c
@@ -432,4 +432,15 @@ dri2InvalidateBuffers(Display *dpy, XID drawable)
    xscr->dri_invalidate_buffers(xscr, drawable, xscr->dri_user_data);
 }
 
+extern unsigned
+dri2GetSwapEventType(Display *dpy, XID drawable);
+
+/**
+ * This is also called from src/glx/dri2.c.
+ */
+unsigned dri2GetSwapEventType(Display *dpy, XID drawable)
+{
+   return 0;
+}
+
 #endif /* GLX_DIRECT_RENDERING */
diff --git a/src/glx/dri2.c b/src/glx/dri2.c
index 30999c8..adfd3d1 100644
--- a/src/glx/dri2.c
+++ b/src/glx/dri2.c
@@ -98,16 +98,13 @@ DRI2WireToEvent(Display *dpy, XEvent *event, xEvent *wire)
    {
       GLXBufferSwapComplete *aevent = (GLXBufferSwapComplete *)event;
       xDRI2BufferSwapComplete *awire = (xDRI2BufferSwapComplete *)wire;
-      __GLXDRIdrawable *pdraw;
-      struct glx_display *glx_dpy = __glXInitialize(dpy);
 
       /* Ignore swap events if we're not looking for them */
-      pdraw = dri2GetGlxDrawableFromXDrawableId(dpy, awire->drawable);
-      if (!pdraw || !(pdraw->eventMask & GLX_BUFFER_SWAP_COMPLETE_INTEL_MASK))
-	 return False;
+      aevent->type = dri2GetSwapEventType(dpy, awire->drawable);
+      if(!aevent->type)
+         return False;
 
       aevent->serial = _XSetLastRequestRead(dpy, (xGenericReply *) wire);
-      aevent->type = glx_dpy->codes->first_event + GLX_BufferSwapComplete;
       aevent->send_event = (awire->type & 0x80) != 0;
       aevent->display = dpy;
       aevent->drawable = awire->drawable;
diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c
index 911298b..88bb8b8 100644
--- a/src/glx/dri2_glx.c
+++ b/src/glx/dri2_glx.c
@@ -502,6 +502,16 @@ process_buffers(struct dri2_drawable * pdraw, DRI2Buffer * buffers,
 
 }
 
+unsigned dri2GetSwapEventType(Display* dpy, XID drawable)
+{
+      struct glx_display *glx_dpy = __glXInitialize(dpy);
+      __GLXDRIdrawable *pdraw;
+      pdraw = dri2GetGlxDrawableFromXDrawableId(dpy, drawable);
+      if (!pdraw || !(pdraw->eventMask & GLX_BUFFER_SWAP_COMPLETE_INTEL_MASK))
+         return 0;
+      return glx_dpy->codes->first_event + GLX_BufferSwapComplete;
+}
+
 static int64_t
 dri2SwapBuffers(__GLXDRIdrawable *pdraw, int64_t target_msc, int64_t divisor,
 		int64_t remainder)
diff --git a/src/glx/glxclient.h b/src/glx/glxclient.h
index b453e6d..324b5a6 100644
--- a/src/glx/glxclient.h
+++ b/src/glx/glxclient.h
@@ -150,6 +150,7 @@ extern __GLXDRIdisplay *driswCreateDisplay(Display * dpy);
 extern __GLXDRIdisplay *driCreateDisplay(Display * dpy);
 extern __GLXDRIdisplay *dri2CreateDisplay(Display * dpy);
 extern void dri2InvalidateBuffers(Display *dpy, XID drawable);
+extern unsigned dri2GetSwapEventType(Display *dpy, XID drawable);
 
 
 /*




More information about the mesa-commit mailing list