hk: adopt wsi_common_get_memory

Acked-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35875>
This commit is contained in:
Yiwei Zhang 2025-07-01 18:50:01 -07:00 committed by Marge Bot
parent 7bb3f29b2a
commit 3f273eb01b

View file

@ -1360,28 +1360,17 @@ hk_BindImageMemory2(VkDevice device, uint32_t bindInfoCount,
/* Ignore this struct on Android, we cannot access swapchain structures
* there. */
#ifdef HK_USE_WSI_PLATFORM
const VkBindImageMemorySwapchainInfoKHR *swapchain_info =
vk_find_struct_const(pBindInfos[i].pNext,
BIND_IMAGE_MEMORY_SWAPCHAIN_INFO_KHR);
if (swapchain_info && swapchain_info->swapchain != VK_NULL_HANDLE) {
VkImage _wsi_image = wsi_common_get_image(swapchain_info->swapchain,
swapchain_info->imageIndex);
VK_FROM_HANDLE(hk_image, wsi_img, _wsi_image);
assert(image->plane_count == 1);
assert(wsi_img->plane_count == 1);
struct hk_image_plane *plane = &image->planes[0];
struct hk_image_plane *swapchain_plane = &wsi_img->planes[0];
/* Copy memory binding information from swapchain image to the current
* image's plane. */
plane->addr = swapchain_plane->addr;
continue;
if (!mem) {
const VkBindImageMemorySwapchainInfoKHR *swapchain_info =
vk_find_struct_const(pBindInfos[i].pNext,
BIND_IMAGE_MEMORY_SWAPCHAIN_INFO_KHR);
assert(swapchain_info && swapchain_info->swapchain != VK_NULL_HANDLE);
mem = hk_device_memory_from_handle(wsi_common_get_memory(
swapchain_info->swapchain, swapchain_info->imageIndex));
}
#endif
assert(mem);
uint64_t offset_B = pBindInfos[i].memoryOffset;
if (image->disjoint) {
const VkBindImagePlaneMemoryInfo *plane_info = vk_find_struct_const(