egl/wayland: fallback to implicit modifiers if advertised by compositor

The Wayland protocol defines INVALID as a special marker indicating
that implicit modifiers are supported. If the driver doesn't support
explicit modifiers and the compositor advertises support for implicit
modifiers, fallback to these.

This effectively restores logic removed in 4c06515892, but only
for the specific case of Wayland instead of affecting all APIs.
(Wayland is one of the few APIs defining a special meaning for
INVALID.)

Signed-off-by: Simon Ser <contact@emersion.fr>
Fixes: 4c06515892 ("dri: revert INVALID modifier special-casing")
(cherry picked from commit da555982b3)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32730>
This commit is contained in:
Simon Ser
2024-12-07 13:15:57 +01:00
committed by Dylan Baker
parent 5457b5af74
commit 9a32249031
2 changed files with 22 additions and 1 deletions

View File

@@ -1010,6 +1010,7 @@ create_dri_image(struct dri2_egl_surface *dri2_surf,
uint64_t *modifiers;
unsigned int num_modifiers;
struct u_vector *modifiers_present;
bool implicit_mod_supported;
assert(visual_idx != -1);
@@ -1049,6 +1050,26 @@ create_dri_image(struct dri2_egl_surface *dri2_surf,
num_modifiers = u_vector_length(modifiers_present);
}
if (!dri2_dpy->dri_screen_render_gpu->base.screen->resource_create_with_modifiers &&
dri2_dpy->wl_dmabuf) {
/* We don't support explicit modifiers, check if the compositor supports
* implicit modifiers. */
implicit_mod_supported = false;
for (unsigned int i = 0; i < num_modifiers; i++) {
if (modifiers[i] == DRM_FORMAT_MOD_INVALID) {
implicit_mod_supported = true;
break;
}
}
if (!implicit_mod_supported) {
return;
}
num_modifiers = 0;
modifiers = NULL;
}
/* For the purposes of this function, an INVALID modifier on
* its own means the modifiers aren't supported. */
if (num_modifiers == 0 ||