From 7f8c5eae38a4b0d3edb9714ae772ec2e5e3b4144 Mon Sep 17 00:00:00 2001 From: Emma Anholt Date: Fri, 24 Sep 2021 10:04:49 -0700 Subject: [PATCH] gallium/dri: Make YUV formats we're going to emulate external-only. If we're going to have to bind them as separate planes with colorspace conversion for sampling on the frontend, then we need to report that they're only for external-image samplers, otherwise the lowering won't be applied. Fixes: 4e3a7dcf ("gallium: enable EGL_EXT_image_dma_buf_import_modifiers unconditionally") Reviewed-by: Jose Maria Casanova Crespo Part-of: (cherry picked from commit c530510514633236138b2b2501c135d34569b1bf) --- .pick_status.json | 2 +- src/gallium/frontends/dri/dri2.c | 20 ++++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index c8321fdd653..847d1dc6092 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -742,7 +742,7 @@ "description": "gallium/dri: Make YUV formats we're going to emulate external-only.", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "4e3a7dcf6ee4946c46ae8b35e7883a49859ef6fb" }, diff --git a/src/gallium/frontends/dri/dri2.c b/src/gallium/frontends/dri/dri2.c index ebc18a73c86..f98b511d783 100644 --- a/src/gallium/frontends/dri/dri2.c +++ b/src/gallium/frontends/dri/dri2.c @@ -1536,16 +1536,24 @@ dri2_query_dma_buf_modifiers(__DRIscreen *_screen, int fourcc, int max, format = map->pipe_format; + bool native_sampling = pscreen->is_format_supported(pscreen, format, screen->target, 0, 0, + PIPE_BIND_SAMPLER_VIEW); if (pscreen->is_format_supported(pscreen, format, screen->target, 0, 0, - PIPE_BIND_RENDER_TARGET) || - pscreen->is_format_supported(pscreen, format, screen->target, 0, 0, - PIPE_BIND_SAMPLER_VIEW) || - dri2_yuv_dma_buf_supported(screen, map)) { - if (pscreen->query_dmabuf_modifiers != NULL) + PIPE_BIND_RENDER_TARGET) || + native_sampling || + dri2_yuv_dma_buf_supported(screen, map)) { + if (pscreen->query_dmabuf_modifiers != NULL) { pscreen->query_dmabuf_modifiers(pscreen, format, max, modifiers, external_only, count); - else + if (!native_sampling && external_only) { + /* To support it using YUV lowering, we need it to be samplerExternalOES. + */ + for (int i = 0; i < *count; i++) + external_only[i] = true; + } + } else { *count = 0; + } return true; } return false;