Skip to content

Commit

Permalink
wayland: fix implicit modifier selecting mess (again)
Browse files Browse the repository at this point in the history
The intention here is that if we get a matching format and modifier pair
and that modifer is not the implicit one (i.e. DRM_FORMAT_MOD_INVALID)
then that is considered supported. However if we get
DRM_FORMAT_MOD_INVALID, we also need to check the drm plane formats
because if the format isn't supported by the plane than you get broken
rendering (e.g. like my GPU). The old logic was wrong and assumed that
any modifier would work if it was on a plane but that is not correct. It
just happened to work since it is common for compositors to support both
explicit and implicit modifiers for common formats (not always the case
of course).
  • Loading branch information
Dudemanguy committed Feb 3, 2025
1 parent 0891f47 commit 12081a3
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions video/out/wayland_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -3229,20 +3229,17 @@ bool vo_wayland_valid_format(struct vo_wayland_state *wl, uint32_t drm_format, u
// anyways, but might as well start from the most preferred tranche.
struct vo_wayland_tranche *tranche;
wl_list_for_each_reverse(tranche, &wl->tranche_list, link) {
bool supported_compositor_format = false;
struct drm_format *formats = tranche->compositor_formats;
for (int i = 0; i < tranche->num_compositor_formats; ++i) {
if (formats[i].format != drm_format)
if (drm_format != formats[i].format || modifier != formats[i].modifier)
continue;
if (modifier == formats[i].modifier && modifier != DRM_FORMAT_MOD_INVALID)
if (modifier != DRM_FORMAT_MOD_INVALID)
return true;
supported_compositor_format = true;
}

if (supported_compositor_format && tranche->drm_plane_formats) {
for (int i = 0; i < tranche->num_drm_plane_formats; i++) {
if (drm_format == tranche->drm_plane_formats[i])
return true;
if (tranche->drm_plane_formats) {
for (int j = 0; j < tranche->num_drm_plane_formats; ++j) {
if (drm_format == tranche->drm_plane_formats[j])
return true;
}
}
}
}
Expand Down

0 comments on commit 12081a3

Please sign in to comment.