tu: bind aliased wsi image at memory offset zero

The vulkan spec says that we should ignore memoryOffset when
VkBindImageMemorySwapchainInfoKHR is present. wsi common assumes that we
bind the wsi image at offset 0, so set the offset to 0. This change
aligns with common wsi, and also obeys dedicated alloc requirement.

Fixes: f887116c49 ("turnip: adopt wsi_common_get_memory")
Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37099>
(cherry picked from commit cef48af271)
This commit is contained in:
Yiwei Zhang 2025-08-30 07:28:35 +00:00 committed by Eric Engestrom
parent ec27b06cf6
commit 46d835f823
2 changed files with 9 additions and 4 deletions

View file

@ -9704,7 +9704,7 @@
"description": "tu: bind aliased wsi image at memory offset zero",
"nominated": true,
"nomination_type": 2,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "f887116c499e658604aef933f142ba00233950ae",
"notes": null

View file

@ -912,6 +912,7 @@ tu_BindImageMemory2(VkDevice _device,
for (uint32_t i = 0; i < bindInfoCount; ++i) {
VK_FROM_HANDLE(tu_image, image, pBindInfos[i].image);
VK_FROM_HANDLE(tu_device_memory, mem, pBindInfos[i].memory);
uint64_t offset = pBindInfos[i].memoryOffset;
if (!mem) {
#if DETECT_OS_ANDROID
@ -925,6 +926,10 @@ tu_BindImageMemory2(VkDevice _device,
swapchain_info->swapchain != VK_NULL_HANDLE);
mem = tu_device_memory_from_handle(wsi_common_get_memory(
swapchain_info->swapchain, swapchain_info->imageIndex));
/* memoryOffset is ignored when VkBindImageMemorySwapchainInfoKHR is
* present, so we follow common wsi to set the offset to 0 here.
*/
offset = 0;
#endif
}
@ -956,8 +961,8 @@ tu_BindImageMemory2(VkDevice _device,
}
}
image->bo = mem->bo;
image->bo_offset = pBindInfos[i].memoryOffset;
image->iova = mem->bo->iova + pBindInfos[i].memoryOffset;
image->bo_offset = offset;
image->iova = mem->bo->iova + offset;
if (image->vk.usage & (VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT |
VK_IMAGE_USAGE_HOST_TRANSFER_BIT_EXT)) {
@ -970,7 +975,7 @@ tu_BindImageMemory2(VkDevice _device,
}
}
image->map = (char *) mem->bo->map + pBindInfos[i].memoryOffset;
image->map = (char *) mem->bo->map + offset;
} else {
image->map = NULL;
}