Verified Commit 242cf371 authored by Simon Ser's avatar Simon Ser

xwayland: allow using linux-dmabuf with DRM_FORMAT_MOD_INVALID

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].
Signed-off-by: Simon Ser's avatarSimon Ser <contact@emersion.fr>

[1]: wayland/wayland-protocols@fb9b2a87
[2]: mesa/mesa@c376865f
parent 5bd3ea8d
Pipeline #163002 passed with stages
in 5 minutes and 2 seconds
......@@ -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[i] == 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];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment