Jesse,

Can you take a look at the attached patch?  I'd really like to be able
to build mesa and the DRI drivers on current distros (eg Ubuntu 9.10)
without having to pull in heaps of dependencies.  The patch adds
#ifdefs to protect against the newer DRI2 protocol changes, meaning I
can build-test linux-dri and related targets with just the
distro-supplied packages.

Keith
commit d7b57f4061b82322cbcae176125913d9f0dea6c1
Author: Keith Whitwell <kei...@vmware.com>
Date:   Thu Feb 4 12:46:21 2010 +0000

    glx: permit building with older protocol headers
    
    I'd like to be able to build mesa on current distro releases without
    having to upgrade from the standard dri2proto and glproto headers.  With
    this change I'm able to build on ancient releases such as Ubuntu 9-10...
    
    In general, it would be nice to be able to build-test mesa to check for
    unintended breakages without having to follow the external dependencies
    of every group working on the codebase.

diff --git a/src/glx/x11/dri2.c b/src/glx/x11/dri2.c
index 832935a..91053d3 100644
--- a/src/glx/x11/dri2.c
+++ b/src/glx/x11/dri2.c
@@ -94,6 +94,8 @@ DRI2WireToEvent(Display *dpy, XEvent *event, xEvent *wire)
    XextCheckExtension(dpy, info, dri2ExtensionName, False);
 
    switch ((wire->u.u.type & 0x7f) - info->codes->first_event) {
+
+#ifdef X_DRI2SwapBuffers
    case DRI2_BufferSwapComplete:
    {
       GLXBufferSwapComplete *aevent = (GLXBufferSwapComplete *)event;
@@ -123,6 +125,8 @@ DRI2WireToEvent(Display *dpy, XEvent *event, xEvent *wire)
       aevent->sbc = ((CARD64)awire->sbc_hi << 32) | awire->sbc_lo;
       return True;
    }
+#endif
+
    default:
       /* client doesn't support server event */
       break;
@@ -455,6 +459,7 @@ DRI2CopyRegion(Display * dpy, XID drawable, XserverRegion region,
    SyncHandle();
 }
 
+#ifdef X_DRI2SwapBuffers
 static void
 load_swap_req(xDRI2SwapBuffersReq *req, CARD64 target, CARD64 divisor,
 	     CARD64 remainder)
@@ -496,7 +501,9 @@ void DRI2SwapBuffers(Display *dpy, XID drawable, CARD64 target_msc,
     UnlockDisplay(dpy);
     SyncHandle();
 }
+#endif
 
+#ifdef X_DRI2GetMSC
 Bool DRI2GetMSC(Display *dpy, XID drawable, CARD64 *ust, CARD64 *msc,
 		CARD64 *sbc)
 {
@@ -527,7 +534,9 @@ Bool DRI2GetMSC(Display *dpy, XID drawable, CARD64 *ust, CARD64 *msc,
 
     return True;
 }
+#endif
 
+#ifdef X_DRI2WaitMSC
 static void
 load_msc_req(xDRI2WaitMSCReq *req, CARD64 target, CARD64 divisor,
 	     CARD64 remainder)
@@ -571,7 +580,9 @@ Bool DRI2WaitMSC(Display *dpy, XID drawable, CARD64 target_msc, CARD64 divisor,
 
     return True;
 }
+#endif
 
+#ifdef X_DRI2WaitSBC
 static void
 load_sbc_req(xDRI2WaitSBCReq *req, CARD64 target)
 {
@@ -610,7 +621,9 @@ Bool DRI2WaitSBC(Display *dpy, XID drawable, CARD64 target_sbc, CARD64 *ust,
 
     return True;
 }
+#endif
 
+#ifdef X_DRI2SwapInterval
 void DRI2SwapInterval(Display *dpy, XID drawable, int interval)
 {
     XExtDisplayInfo *info = DRI2FindDisplay(dpy);
@@ -627,5 +640,6 @@ void DRI2SwapInterval(Display *dpy, XID drawable, int interval)
     UnlockDisplay(dpy);
     SyncHandle();
 }
+#endif
 
 #endif /* GLX_DIRECT_RENDERING */
diff --git a/src/glx/x11/dri2_glx.c b/src/glx/x11/dri2_glx.c
index 7a5740a..6200df9 100644
--- a/src/glx/x11/dri2_glx.c
+++ b/src/glx/x11/dri2_glx.c
@@ -380,8 +380,10 @@ dri2SwapBuffers(__GLXDRIdrawable *pdraw, int64_t target_msc, int64_t divisor,
        return 0;
     }
 
+#ifdef X_DRI2SwapBuffers
     DRI2SwapBuffers(pdraw->psc->dpy, pdraw->xDrawable, target_msc, divisor,
 		    remainder, &ret);
+#endif
 
 #if __DRI2_FLUSH_VERSION >= 2
     if (pdraw->psc->f)
@@ -576,18 +578,24 @@ dri2CreateScreen(__GLXscreenConfigs * psc, int screen,
    psp->swapBuffers = dri2SwapBuffers;
    psp->waitGL = dri2WaitGL;
    psp->waitX = dri2WaitX;
+   psp->getDrawableMSC = NULL;
+   psp->waitForMSC = NULL;
+   psp->waitForSBC = NULL;
+   psp->setSwapInterval = NULL;
+   psp->getSwapInterval = NULL;
+
    if (pdp->driMinor >= 2) {
+#ifdef X_DRI2GetMSC
       psp->getDrawableMSC = dri2DrawableGetMSC;
+#endif
+#ifdef X_DRI2WaitMSC
       psp->waitForMSC = dri2WaitForMSC;
       psp->waitForSBC = dri2WaitForSBC;
+#endif
+#ifdef X_DRI2SwapInterval
       psp->setSwapInterval = dri2SetSwapInterval;
       psp->getSwapInterval = dri2GetSwapInterval;
-   } else {
-      psp->getDrawableMSC = NULL;
-      psp->waitForMSC = NULL;
-      psp->waitForSBC = NULL;
-      psp->setSwapInterval = NULL;
-      psp->getSwapInterval = NULL;
+#endif
    }
 
    /* DRI2 suports SubBuffer through DRI2CopyRegion, so it's always
@@ -643,8 +651,10 @@ dri2CreateDisplay(Display * dpy)
 
    pdp->driPatch = 0;
    pdp->swapAvailable = 0;
+#ifdef X_DRI2SwapBuffers
    if (pdp->driMinor >= 2)
       pdp->swapAvailable = 1;
+#endif
 
    pdp->base.destroyDisplay = dri2DestroyDisplay;
    pdp->base.createScreen = dri2CreateScreen;
diff --git a/src/glx/x11/glxext.c b/src/glx/x11/glxext.c
index 1b4ab71..dde694b 100644
--- a/src/glx/x11/glxext.c
+++ b/src/glx/x11/glxext.c
@@ -158,6 +158,16 @@ __glXWireToEvent(Display *dpy, XEvent *event, xEvent *wire)
       aevent->count = awire->count;
       return True;
    }
+   /* No easy symbol to test for this, as GLX_BufferSwapComplete is
+    * defined in the local glx.h header, but the
+    * xGLXBufferSwapComplete typedef is only available in new versions
+    * of the external glxproto.h header, which doesn't have any
+    * testable versioning define.
+    *
+    * I'll use the related DRI2 define, in the hope that we won't
+    * receive these events unless we know how to ask for them:
+    */
+#ifdef X_DRI2SwapBuffers
    case GLX_BufferSwapComplete:
    {
       GLXBufferSwapComplete *aevent = (GLXBufferSwapComplete *)event;
@@ -169,6 +179,7 @@ __glXWireToEvent(Display *dpy, XEvent *event, xEvent *wire)
       aevent->sbc = ((CARD64)awire->sbc_hi << 32) | awire->sbc_lo;
       return True;
    }
+#endif
    default:
       /* client doesn't support server event */
       break;
------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Mesa3d-dev mailing list
Mesa3d-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

Reply via email to