From d6558477d7a264c2132bc977b51d80fc0277d1e0 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 2 Jun 2020 15:40:16 +0200 Subject: [PATCH] xwayland: allow using linux-dmabuf with DRM_FORMAT_MOD_INVALID MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the linux-dmabuf protocol is available, prefer it over the old wl_drm protocol. Previously wl_drm was used when modifiers aren't supported, however linux-dmabuf supports formats without modifiers too. In this case, linux-dmabuf will send a DRM_FORMAT_MOD_INVALID modifier for each supported format [1]. This allows compositors to better handle these buffers, getting a DMA-BUF and implementing features like direct scan-out. A similar logic has been implemented for EGL [2]. DRM_FORMAT_MOD_INVALID is now stored in the xwl_screen->formats list. glamor_get_modifiers still returns FALSE with zero modifiers if the only advertised modifier is DRM_FORMAT_MOD_INVALID. [1]: https://gitlab.freedesktop.org/wayland/wayland-protocols/commit/fb9b2a87317c77e26283da5f6c9559d709f6fdcd [2]: https://gitlab.freedesktop.org/mesa/mesa/-/commit/c376865f5eeca535c4aa8e33bcf166052c1ce2f2 Signed-off-by: Simon Ser Reviewed-by: Michel Dänzer --- hw/xwayland/xwayland-glamor-gbm.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/hw/xwayland/xwayland-glamor-gbm.c b/hw/xwayland/xwayland-glamor-gbm.c index 7336c97a7..c7731e2c8 100644 --- a/hw/xwayland/xwayland-glamor-gbm.c +++ b/hw/xwayland/xwayland-glamor-gbm.c @@ -668,7 +668,9 @@ glamor_get_modifiers(ScreenPtr screen, uint32_t format, } } - if (!xwl_format) + if (!xwl_format || + (xwl_format->num_modifiers == 1 && + xwl_format->modifiers[0] == DRM_FORMAT_MOD_INVALID)) return FALSE; *modifiers = calloc(xwl_format->num_modifiers, sizeof(uint64_t)); @@ -832,10 +834,6 @@ xwl_dmabuf_handle_modifier(void *data, struct zwp_linux_dmabuf_v1 *dmabuf, struct xwl_format *xwl_format = NULL; int i; - if (modifier_hi == (DRM_FORMAT_MOD_INVALID >> 32) && - modifier_lo == (DRM_FORMAT_MOD_INVALID & 0xffffffff)) - return; - for (i = 0; i < xwl_screen->num_formats; i++) { if (xwl_screen->formats[i].format == format) { xwl_format = &xwl_screen->formats[i];