From 156001edfa2fda1cce109f0da0fe336e528cb084 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Ondra=C4=8Dka?= Date: Wed, 25 Feb 2026 16:07:10 +0100 Subject: [PATCH] frontends/dri: fix NUM_PLANES for imported dma-buf images MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When __DRI_IMAGE_ATTRIB_NUM_PLANES falls back to the resource-handle path, it currently derives the count from the texture chain. That can report 1 for multi-plane imported formats when planes share one BO/FD. Prefer the imported fourcc mapping when available and return util_format_get_num_planes(map->pipe_format). Keep the texture-chain fallback for images without a fourcc mapping. This makes eglExportDMABUFImageQueryMESA report the expected plane count for formats such as NV12/P010/P012/P016/YUV420/YVU420. Reviewed-by: Marek Olšák Part-of: --- src/gallium/drivers/r300/ci/r300-rs740-fails.txt | 2 -- src/gallium/drivers/r300/ci/r300-rv410-fails.txt | 2 -- src/gallium/drivers/r300/ci/r300-rv530-fails.txt | 2 -- src/gallium/frontends/dri/dri2.c | 10 ++++++++++ 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/gallium/drivers/r300/ci/r300-rs740-fails.txt b/src/gallium/drivers/r300/ci/r300-rs740-fails.txt index 263f33c94f4..f111c8201fc 100644 --- a/src/gallium/drivers/r300/ci/r300-rs740-fails.txt +++ b/src/gallium/drivers/r300/ci/r300-rs740-fails.txt @@ -719,8 +719,6 @@ spec@ext_framebuffer_object@fbo-fragcoord2,Fail spec@ext_framebuffer_object@getteximage-formats init-by-clear-and-render,Fail spec@ext_framebuffer_object@getteximage-formats init-by-rendering,Fail -spec@ext_image_dma_buf_import@ext_image_dma_buf_import-export,Fail - spec@ext_texture_format_bgra8888@api-errors,Fail spec@ext_texture_snorm@fbo-alphatest-formats,Fail diff --git a/src/gallium/drivers/r300/ci/r300-rv410-fails.txt b/src/gallium/drivers/r300/ci/r300-rv410-fails.txt index f0559de8dff..0c44defa695 100644 --- a/src/gallium/drivers/r300/ci/r300-rv410-fails.txt +++ b/src/gallium/drivers/r300/ci/r300-rv410-fails.txt @@ -717,8 +717,6 @@ spec@ext_framebuffer_object@fbo-fragcoord2,Fail spec@ext_framebuffer_object@getteximage-formats init-by-clear-and-render,Fail spec@ext_framebuffer_object@getteximage-formats init-by-rendering,Fail -spec@ext_image_dma_buf_import@ext_image_dma_buf_import-export,Fail - spec@ext_texture_format_bgra8888@api-errors,Fail spec@ext_texture_snorm@fbo-alphatest-formats,Fail diff --git a/src/gallium/drivers/r300/ci/r300-rv530-fails.txt b/src/gallium/drivers/r300/ci/r300-rv530-fails.txt index 007accd7dd0..074d63c9848 100644 --- a/src/gallium/drivers/r300/ci/r300-rv530-fails.txt +++ b/src/gallium/drivers/r300/ci/r300-rv530-fails.txt @@ -541,8 +541,6 @@ spec@ext_framebuffer_object@fbo-depth-sample-compare,Fail spec@ext_framebuffer_object@getteximage-formats init-by-clear-and-render,Fail spec@ext_framebuffer_object@getteximage-formats init-by-rendering,Fail -spec@ext_image_dma_buf_import@ext_image_dma_buf_import-export,Fail - spec@ext_texture_compression_rgtc@rgtc-teximage-01,Fail spec@ext_texture_compression_rgtc@rgtc-teximage-02,Fail diff --git a/src/gallium/frontends/dri/dri2.c b/src/gallium/frontends/dri/dri2.c index 96800e89b80..5f198b18591 100644 --- a/src/gallium/frontends/dri/dri2.c +++ b/src/gallium/frontends/dri/dri2.c @@ -1096,6 +1096,16 @@ dri2_query_image_by_resource_handle(struct dri_image *image, int attrib, int *va whandle.type = WINSYS_HANDLE_TYPE_FD; break; case __DRI_IMAGE_ATTRIB_NUM_PLANES: + if (image->dri_fourcc) { + const struct dri2_format_mapping *map = + dri2_get_mapping_by_fourcc(image->dri_fourcc); + + if (map) { + *value = util_format_get_num_planes(map->pipe_format); + return true; + } + } + for (i = 0, tex = image->texture; tex; tex = tex->next) i++; *value = i;