frontends/dri: fix NUM_PLANES for imported dma-buf images

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 <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40066>
This commit is contained in:
Pavel Ondračka 2026-02-25 16:07:10 +01:00 committed by Marge Bot
parent 343c6ddddf
commit 156001edfa
4 changed files with 10 additions and 6 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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;