From 6c0e72ba5af6120797c7d91c76eb39ddec6c037a Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Sun, 6 Jul 2025 12:15:58 +0200 Subject: [PATCH] dri: Don't pretend we can lower NV15/NV20 when we can't If the plane formats are __DRI_IMAGE_FORMAT_NONE (AKA PIPE_FORMAT_NONE), we can't lower the planar-YUV. I guess this code relies on ::is_format_supported(PIPE_FORMAT_NONE, PIPE_BIND_SAMPLER_VIEW) returning false, but it's not obvious to me that it should, and panfrost has been returning true on this one for quite a long time. It could be that panfrost is wrong, and this case should be rejected, but it's just as simple to reject the lowering if the plane format is __DRI_IMAGE_FORMAT_NONE instead of deferring this check to the driver, because ultimately we can't lower NV15/NV20 unless the driver supports NV15/NV20 or R10_G10B10_{420,422}. Signed-off-by: Boris Brezillon Acked-by: Daniel Stone Part-of: --- src/gallium/frontends/dri/dri_helpers.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/gallium/frontends/dri/dri_helpers.c b/src/gallium/frontends/dri/dri_helpers.c index c6cf873069d..558eb68890f 100644 --- a/src/gallium/frontends/dri/dri_helpers.c +++ b/src/gallium/frontends/dri/dri_helpers.c @@ -762,8 +762,13 @@ dri2_yuv_dma_buf_supported(struct dri_screen *screen, return false; for (unsigned i = 0; i < map->nplanes; i++) { - if (!pscreen->is_format_supported(pscreen, map->planes[i].dri_format, - screen->target, 0, 0, PIPE_BIND_SAMPLER_VIEW)) + /* Some planar-YUV formats can't be lowered unless the HW supports + * specific YUV-as-RGB formats. Those have their plane format set + * to __DRI_IMAGE_FORMAT_NONE. */ + if (map->planes[i].dri_format == __DRI_IMAGE_FORMAT_NONE || + !pscreen->is_format_supported(pscreen, map->planes[i].dri_format, + screen->target, 0, 0, + PIPE_BIND_SAMPLER_VIEW)) return false; } return true;