linux-dmabuf-v1: filter out LINEAR if implicit

If only INVALID and LINEAR are valid modifiers, we need to filter out
LINEAR since Xwayland won't be able to allocate a BO with the explicit
linear modifier on hardware that does not support explicit modifiers.
The addition of LINEAR is an internal implementation detail which
simplifies the wlroots architecture for now.

Evntually Xwayland should be fixed to filter out modifiers that are not
supported by the GBM implementation, see [1]. This could be done by
querying EGL for the supported modifiers.

[1]: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1166
This commit is contained in:
Rouven Czerwinski 2021-11-27 19:08:18 +01:00
parent 254ab890e7
commit d37eb5c2ea
1 changed files with 10 additions and 0 deletions

View File

@ -434,6 +434,16 @@ static void linux_dmabuf_send_modifiers(struct wl_resource *resource,
return;
}
// In case only INVALID and LINEAR are advertised, send INVALID only due to XWayland:
// https://gitlab.freedesktop.org/xorg/xserver/-/issues/1166
if (fmt->len == 2 && wlr_drm_format_has(fmt, DRM_FORMAT_MOD_INVALID)
&& wlr_drm_format_has(fmt, DRM_FORMAT_MOD_INVALID)) {
uint64_t mod = DRM_FORMAT_MOD_INVALID;
zwp_linux_dmabuf_v1_send_modifier(resource, fmt->format,
mod >> 32, mod & 0xFFFFFFFF);
return;
}
for (size_t i = 0; i < fmt->len; i++) {
uint64_t mod = fmt->modifiers[i];
zwp_linux_dmabuf_v1_send_modifier(resource, fmt->format,