From e5e108706cca096a42585c3ed34b5d8d0cb0c549 Mon Sep 17 00:00:00 2001 From: msizanoen Date: Tue, 4 Jun 2024 22:32:41 +0700 Subject: [PATCH] egl/wayland: Fix direct scanout with EGL_EXT_present_opaque We select the feedback tranche according to the image format but not the actual format that we will use for presentation. This breaks direct scanout in cases where the application selected a visual with an alpha channel but using EGL_EXT_present_opaque which previously worked as expected. Fix this by selecting the feedback tranche according to the actual presentation format. Fixes: 9ea9a963aa1 ("egl/wayland: Fix EGL_EXT_present_opaque") Part-of: --- src/egl/drivers/dri2/platform_wayland.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c index 0c2f7d1faad..63de619ee4d 100644 --- a/src/egl/drivers/dri2/platform_wayland.c +++ b/src/egl/drivers/dri2/platform_wayland.c @@ -530,11 +530,18 @@ surface_dmabuf_feedback_tranche_formats( { struct dri2_egl_surface *dri2_surf = data; struct dmabuf_feedback *feedback = &dri2_surf->pending_dmabuf_feedback; + uint32_t present_format = dri2_surf->format; uint64_t *modifier_ptr, modifier; uint32_t format; uint16_t *index; int visual_idx; + if (dri2_surf->base.PresentOpaque) { + visual_idx = dri2_wl_visual_idx_from_fourcc(present_format); + if (visual_idx != -1) + present_format = dri2_wl_visuals[visual_idx].opaque_wl_drm_format; + } + /* Compositor may advertise or not a format table. If it does, we use it. * Otherwise, we steal the most recent advertised format table. If we don't * have a most recent advertised format table, compositor did something @@ -564,7 +571,7 @@ surface_dmabuf_feedback_tranche_formats( /* Skip formats that are not the one the surface is already using. We * can't switch to another format. */ - if (format != dri2_surf->format) + if (format != present_format) continue; /* We are sure that the format is supported because of the check above. */