From 9a32249031d45c7e92250d21031b3c5d99009755 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Sat, 7 Dec 2024 13:15:57 +0100 Subject: [PATCH] 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 4c065158927d, 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 Fixes: 4c065158927d ("dri: revert INVALID modifier special-casing") (cherry picked from commit da555982b3e1a369bf7bb8a69554af8036d0f4ad) Part-of: --- .pick_status.json | 2 +- src/egl/drivers/dri2/platform_wayland.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/.pick_status.json b/.pick_status.json index 2363525174d..d5ef51ea904 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -24,7 +24,7 @@ "description": "egl/wayland: fallback to implicit modifiers if advertised by compositor", "nominated": true, "nomination_type": 2, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "4c065158927d7bacc5eb1e4f2491b1db93f1dc12", "notes": null diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c index 472665a36b0..9c60a89e902 100644 --- a/src/egl/drivers/dri2/platform_wayland.c +++ b/src/egl/drivers/dri2/platform_wayland.c @@ -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 ||