From 9dba176e8d0ceee456de2aa9ac91908b740628e2 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Sun, 11 Jul 2021 19:43:51 +0200 Subject: [PATCH] render/gles2: set has_alpha for DMA-BUFs Use our internal pixel format table to figure out whether an imported DMA-BUF has alpha. --- render/gles2/texture.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/render/gles2/texture.c b/render/gles2/texture.c index b6b8ba57..417d4c1b 100644 --- a/render/gles2/texture.c +++ b/render/gles2/texture.c @@ -248,11 +248,19 @@ static struct wlr_texture *gles2_texture_from_dmabuf( if (texture == NULL) { return NULL; } - texture->has_alpha = true; texture->drm_format = DRM_FORMAT_INVALID; // texture can't be written anyways texture->inverted_y = (attribs->flags & WLR_DMABUF_ATTRIBUTES_FLAGS_Y_INVERT) != 0; + const struct wlr_pixel_format_info *drm_fmt = + drm_get_pixel_format_info(attribs->format); + if (drm_fmt != NULL) { + texture->has_alpha = drm_fmt->has_alpha; + } else { + // We don't know, assume the texture has an alpha channel + texture->has_alpha = true; + } + struct wlr_egl_context prev_ctx; wlr_egl_save_context(&prev_ctx); wlr_egl_make_current(renderer->egl);