glx: More hacking around versions of XCB that lack GLX_ARB_create_context support
authorIan Romanick <ian.d.romanick@intel.com>
Tue, 3 Jan 2012 19:35:59 +0000 (11:35 -0800)
committerIan Romanick <ian.d.romanick@intel.com>
Wed, 4 Jan 2012 20:43:10 +0000 (12:43 -0800)
Detect whether a new enough version of XCB is installed at configure
time.  If it is not, don't enable the extension and don't build the
unit tests.

v2: Move the AM_CONDIATION outside the case-statement so that it is
invoked even for non-GLX builds.  This prevents build failures with
osmesa, for example.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Tested-by: Robert Hooker <robert.hooker@canonical.com>
configure.ac
src/glx/clientinfo.c
src/glx/create_context.c
src/glx/glxextensions.c
tests/glx/Makefile.am

index 2d31273b9d80d7231a58db1a742254b25d4678ac..dfffdf933ef8094141157ed4350f417c8768a62a 100644 (file)
@@ -1030,12 +1030,34 @@ xyesno)
         GL_LIB_DEPS="$GL_LIB_DEPS $XCB_LIBS"
     fi
 
+    # Check to see if the xcb-glx library is new enough to support
+    # GLX_ARB_create_context.  This bit of hackery is necessary until XCB 1.8
+    # is released.
+    save_CPPFLAGS="$CPPFLAGS"
+    save_LDFLAGS="$LDFLAGS"
+    CPPFLAGS="$CPPFLAGS $X11_INCLUDES"
+    LDFLAGS="$LDFLAGS $GL_LIB_DEPS"
+    AC_CHECK_LIB(xcb-glx, xcb_glx_create_context_attribs_arb_checked,
+        [HAVE_XCB_GLX_CREATE_CONTEXT=yes],
+        [HAVE_XCB_GLX_CREATE_CONTEXT=no])
+    CPPFLAGS="$save_CPPFLAGS"
+    LDFLAGS="$save_LDFLAGS"
+
+    if test x$HAVE_XCB_GLX_CREATE_CONTEXT = xyes; then
+        X11_INCLUDES="$X11_INCLUDES -DHAVE_XCB_GLX_CREATE_CONTEXT"
+    fi
+
     # need DRM libs, -lpthread, etc.
     GL_LIB_DEPS="$GL_LIB_DEPS $LIBDRM_LIBS -lm -lpthread $DLOPEN_LIBS"
     GL_PC_LIB_PRIV="-lm -lpthread $DLOPEN_LIBS"
     ;;
 esac
 
+# This is outside the case (above) so that it is invoked even for non-GLX
+# builds.
+AM_CONDITIONAL(HAVE_XCB_GLX_CREATE_CONTEXT,
+    test x$HAVE_XCB_GLX_CREATE_CONTEXT = xyes)
+
 GLESv1_CM_LIB_DEPS="$LIBDRM_LIBS -lm -lpthread $DLOPEN_LIBS"
 GLESv1_CM_PC_LIB_PRIV="-lm -lpthread $DLOPEN_LIBS"
 GLESv2_LIB_DEPS="$LIBDRM_LIBS -lm -lpthread $DLOPEN_LIBS"
index 429e9a3bfa75b949b5f244587f5528b61ce03210..461030fce8894d776f9be01d04b33131640cf8b6 100644 (file)
@@ -123,6 +123,7 @@ __glX_send_client_info(struct glx_display *glx_dpy)
     * THE ORDER IS IMPORTANT.  We want to send the most recent version of the
     * protocol that the server can support.
     */
+#ifdef HAVE_XCB_GLX_CREATE_CONTEXT
    if (glx_dpy->majorVersion == 1 && glx_dpy->minorVersion == 4
        && any_screen_has_ARB_create_context_profile) {
       xcb_glx_set_client_info_2arb(c,
@@ -145,7 +146,9 @@ __glX_send_client_info(struct glx_display *glx_dpy)
                                  gl_versions,
                                  gl_extension_string,
                                  glx_extensions);
-   } else {
+   } else
+#endif
+   {
       xcb_glx_client_info(c,
                          GLX_MAJOR_VERSION, GLX_MINOR_VERSION,
                          gl_extension_length,
index 11f9340a2e8b3da2837a9cd4b2df3144fa85a793..714f0e59271b330c1bc934df4c7e649660e14f49 100644 (file)
@@ -94,7 +94,7 @@ glXCreateContextAttribsARB(Display *dpy, GLXFBConfig config,
     * the protocol error and handle it.  Part of handling the error is freeing
     * the possibly non-NULL value returned by this function.
     */
-#ifdef XCB_GLX_CREATE_CONTEXT_ATTRIBS_ARB
+#ifdef HAVE_XCB_GLX_CREATE_CONTEXT
    cookie =
       xcb_glx_create_context_attribs_arb_checked(c,
                                                 gc->xid,
index 0fcd8a9e8b5db066a757016371b3d46be1278f7a..86dc7d03d13d1141c7f90e52a97772b1ead2c0ab 100644 (file)
@@ -71,7 +71,7 @@ struct extension_info
 
 /* *INDENT-OFF* */
 static const struct extension_info known_glx_extensions[] = {
-#ifdef XCB_GLX_CREATE_CONTEXT_ATTRIBS_ARB
+#ifdef HAVE_XCB_GLX_CREATE_CONTEXT
    { GLX(ARB_create_context),          VER(0,0), Y, N, N, N },
    { GLX(ARB_create_context_profile),  VER(0,0), Y, N, N, N },
 #else
@@ -85,7 +85,7 @@ static const struct extension_info known_glx_extensions[] = {
    { GLX(EXT_visual_info),             VER(0,0), Y, Y, N, N },
    { GLX(EXT_visual_rating),           VER(0,0), Y, Y, N, N },
    { GLX(EXT_framebuffer_sRGB),        VER(0,0), Y, Y, N, N },
-#ifdef XCB_GLX_CREATE_CONTEXT_ATTRIBS_ARB
+#ifdef HAVE_XCB_GLX_CREATE_CONTEXT
    { GLX(EXT_create_context_es2_profile), VER(0,0), Y, N, N, Y },
 #else
    { GLX(EXT_create_context_es2_profile), VER(0,0), N, N, N, N },
index 0b061176e1acc72e4db05b535332eb6ae703421d..cdebf5d0cb15036f47376b59ddc7c6fca338cebc 100644 (file)
@@ -4,6 +4,7 @@ AM_CXXFLAGS = -I$(top_builddir)/src/glx -I$(top_builddir)/src/mapi \
        $(X11_CFLAGS) $(GTEST_CFLAGS)
 
 if HAVE_GTEST
+if HAVE_XCB_GLX_CREATE_CONTEXT
 TESTS = glx_unittest
 check_PROGRAMS = glx_unittest
 
@@ -13,4 +14,5 @@ glx_unittest_SOURCES =                        \
         fake_glx_screen.cpp
 
 glx_unittest_LDADD = $(top_builddir)/src/glx/libglx.a $(GTEST_LIBS) -lgtest_main
-endif
\ No newline at end of file
+endif
+endif