From 84368032db7a96aadb3d8d181fe1f263da21c768 Mon Sep 17 00:00:00 2001 From: Olivier Fourdan Date: Wed, 25 Jul 2018 15:52:01 +0200 Subject: [PATCH v2] dri3: For 1.2, use root window instead of pixmap drawable get_supported_modifiers() and pixmap_from_buffers() requests both expect a window as drawable, passing a pixmap will fail as the Xserver will fail to match the given drawable to a window. That leads to dri3_alloc_render_buffer() to return NULL and breaks rendering when using GLX_DOUBLEBUFFER on pixmaps. Query the root window of the pixmap on first init, and use the root window instead of the pixmap drawable for get_supported_modifiers() and pixmap_from_buffers(). Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107117 Fixes: 069fdd5 ("egl/x11: Support DRI3 v1.1") Signed-off-by: Olivier Fourdan --- v2: Use the root window instead of reverting to pixmap_from_buffer() as suggested by Eric. src/loader/loader_dri3_helper.c | 31 +++++++++++++++++++++++++++++-- src/loader/loader_dri3_helper.h | 1 + 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/loader/loader_dri3_helper.c b/src/loader/loader_dri3_helper.c index f0ff2f07bd..c7ad67cd04 100644 --- a/src/loader/loader_dri3_helper.c +++ b/src/loader/loader_dri3_helper.c @@ -1091,6 +1091,21 @@ has_supported_modifier(struct loader_dri3_drawable *draw, unsigned int format, free(supported_modifiers); return found; } + +static xcb_window_t +get_root_window (struct loader_dri3_drawable *draw) +{ + xcb_get_geometry_cookie_t cookie; + xcb_get_geometry_reply_t *reply; + xcb_window_t window = draw->drawable; + + cookie = xcb_get_geometry(draw->conn, draw->drawable); + if ((reply = xcb_get_geometry_reply(draw->conn, cookie, NULL))) + window = reply->root; + free(reply); + + return window; +} #endif /** loader_dri3_alloc_render_buffer @@ -1149,7 +1164,7 @@ dri3_alloc_render_buffer(struct loader_dri3_drawable *draw, unsigned int format, uint32_t count = 0; mod_cookie = xcb_dri3_get_supported_modifiers(draw->conn, - draw->drawable, + draw->window, depth, buffer->cpp * 8); mod_reply = xcb_dri3_get_supported_modifiers_reply(draw->conn, mod_cookie, @@ -1281,7 +1296,7 @@ dri3_alloc_render_buffer(struct loader_dri3_drawable *draw, unsigned int format, buffer->modifier != DRM_FORMAT_MOD_INVALID) { xcb_dri3_pixmap_from_buffers(draw->conn, pixmap, - draw->drawable, + draw->window, num_planes, width, height, buffer->strides[0], buffer->offsets[0], @@ -1432,7 +1447,19 @@ dri3_update_drawable(__DRIdrawable *driDrawable, xcb_unregister_for_special_event(draw->conn, draw->special_event); draw->special_event = NULL; } + +#ifdef HAVE_DRI3_MODIFIERS + /* get_supported_modifiers() and pixmap_from_buffers() expect a window, + * not just a drawable, and will fail if we pass the pixmap drawable. + * So, in case of a pixmap, use the root window instead. + */ + if (draw->is_pixmap) + draw->window = get_root_window(draw); + else +#endif + draw->window = draw->drawable; } + dri3_flush_present_events(draw); mtx_unlock(&draw->mtx); return true; diff --git a/src/loader/loader_dri3_helper.h b/src/loader/loader_dri3_helper.h index 7e3d82947b..51d000343d 100644 --- a/src/loader/loader_dri3_helper.h +++ b/src/loader/loader_dri3_helper.h @@ -114,6 +114,7 @@ struct loader_dri3_drawable { xcb_connection_t *conn; __DRIdrawable *dri_drawable; xcb_drawable_t drawable; + xcb_window_t window; int width; int height; int depth; -- 2.17.1