venus: use dedicated allocation for ANB image memory import

On most platforms, deidcated allocation is preferred for the dma-buf
import done by Venus. In special cases, this is required but missed so
far.

Cc: mesa-stable

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33434>
(cherry picked from commit d92f9c3d51)
This commit is contained in:
Yiwei Zhang 2025-02-06 20:55:30 +00:00 committed by Eric Engestrom
parent f66772f1b1
commit 415338d3e1
2 changed files with 8 additions and 1 deletions

View file

@ -584,7 +584,7 @@
"description": "venus: use dedicated allocation for ANB image memory import",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null,
"notes": null

View file

@ -581,8 +581,15 @@ vn_android_image_from_anb_internal(struct vn_device *dev,
goto fail;
}
const bool prefer_dedicated =
img->requirements[0].dedicated.prefersDedicatedAllocation == VK_TRUE;
const VkMemoryDedicatedAllocateInfo dedicated_info = {
.sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO,
.image = vn_image_to_handle(img),
};
const VkImportMemoryFdInfoKHR import_fd_info = {
.sType = VK_STRUCTURE_TYPE_IMPORT_MEMORY_FD_INFO_KHR,
.pNext = prefer_dedicated ? &dedicated_info : NULL,
.handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT,
.fd = dup_fd,
};