Mesa (master): egl_dri2 x11: Workaround device_name xcb-dri2 bug

Kristian Høgsberg krh at kemper.freedesktop.org
Wed Mar 2 20:03:12 UTC 2011


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

Author: Benjamin Franzke <benjaminfranzke at googlemail.com>
Date:   Wed Mar  2 21:23:04 2011 +0100

egl_dri2 x11: Workaround device_name xcb-dri2 bug

This commit is basically a copy-over of the fix
Chia-I Wu's commited to wayland:
   http://cgit.freedesktop.org/wayland/wayland-demos/commit/?id=1b6c0ed95
   "Workaround an xcb-dri2 bug.
    xcb_dri2_connect_device_name generated by xcb-proto 1.6 is broken.
    It only works when the length of the driver name is a multiple of 4."

---

 configure.ac                        |    3 +++
 src/egl/drivers/dri2/platform_x11.c |   18 +++++++++++++-----
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/configure.ac b/configure.ac
index 9fa5eee..d33ca30 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1162,6 +1162,9 @@ if test "x$enable_egl" = xyes; then
                 if test "$have_libudev" = yes; then
                     DEFINES="$DEFINES -DHAVE_LIBUDEV"
                 fi
+                # workaround a bug in xcb-dri2 generated by xcb-proto 1.6
+                AC_CHECK_LIB(xcb-dri2, xcb_dri2_connect_alignment_pad, [],
+                          [DEFINES="$DEFINES -DXCB_DRI2_CONNECT_DEVICE_NAME_BROKEN"])
             fi
 	fi
 
diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c
index c7bdfa6..b3e60b8 100644
--- a/src/egl/drivers/dri2/platform_x11.c
+++ b/src/egl/drivers/dri2/platform_x11.c
@@ -478,6 +478,7 @@ dri2_connect(struct dri2_egl_display *dri2_dpy)
    xcb_dri2_connect_cookie_t connect_cookie;
    xcb_generic_error_t *error;
    xcb_screen_iterator_t s;
+   char *driver_name, *device_name;
 
    xcb_prefetch_extension_data (dri2_dpy->conn, &xcb_xfixes_id);
    xcb_prefetch_extension_data (dri2_dpy->conn, &xcb_dri2_id);
@@ -524,14 +525,21 @@ dri2_connect(struct dri2_egl_display *dri2_dpy)
       return EGL_FALSE;
    }
 
-   dri2_dpy->device_name =
-      dri2_strndup(xcb_dri2_connect_device_name (connect),
-		   xcb_dri2_connect_device_name_length (connect));
-
+   driver_name = xcb_dri2_connect_driver_name (connect);
    dri2_dpy->driver_name =
-      dri2_strndup(xcb_dri2_connect_driver_name (connect),
+      dri2_strndup(driver_name,
 		   xcb_dri2_connect_driver_name_length (connect));
 
+#if XCB_DRI2_CONNECT_DEVICE_NAME_BROKEN
+   device_name = driver_name + ((connect->driver_name_length + 3) & ~3);
+#else
+   device_name = xcb_dri2_connect_device_name (connect);
+#endif
+
+   dri2_dpy->device_name =
+      dri2_strndup(device_name,
+		   xcb_dri2_connect_device_name_length (connect));
+
    if (dri2_dpy->device_name == NULL || dri2_dpy->driver_name == NULL) {
       free(dri2_dpy->device_name);
       free(dri2_dpy->driver_name);




More information about the mesa-commit mailing list