mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 17:48:10 +02:00
turnip: adopt wsi_common_get_memory
Reviewed-by: Rob Clark <rob.clark@oss.qualcomm.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35875>
This commit is contained in:
parent
273df23a21
commit
f887116c49
1 changed files with 53 additions and 67 deletions
|
|
@ -906,84 +906,70 @@ tu_BindImageMemory2(VkDevice _device,
|
||||||
VK_FROM_HANDLE(tu_image, image, pBindInfos[i].image);
|
VK_FROM_HANDLE(tu_image, image, pBindInfos[i].image);
|
||||||
VK_FROM_HANDLE(tu_device_memory, mem, pBindInfos[i].memory);
|
VK_FROM_HANDLE(tu_device_memory, mem, pBindInfos[i].memory);
|
||||||
|
|
||||||
/* Ignore this struct on Android, we cannot access swapchain structures there. */
|
if (!mem) {
|
||||||
#ifdef TU_USE_WSI_PLATFORM
|
#if DETECT_OS_ANDROID
|
||||||
const VkBindImageMemorySwapchainInfoKHR *swapchain_info =
|
/* TODO handle VkNativeBufferANDROID */
|
||||||
vk_find_struct_const(pBindInfos[i].pNext, BIND_IMAGE_MEMORY_SWAPCHAIN_INFO_KHR);
|
unreachable("VkBindImageMemoryInfo with no memory");
|
||||||
|
#else
|
||||||
if (swapchain_info && swapchain_info->swapchain != VK_NULL_HANDLE) {
|
const VkBindImageMemorySwapchainInfoKHR *swapchain_info =
|
||||||
VkImage _wsi_image = wsi_common_get_image(swapchain_info->swapchain,
|
vk_find_struct_const(pBindInfos[i].pNext,
|
||||||
swapchain_info->imageIndex);
|
BIND_IMAGE_MEMORY_SWAPCHAIN_INFO_KHR);
|
||||||
VK_FROM_HANDLE(tu_image, wsi_img, _wsi_image);
|
assert(swapchain_info &&
|
||||||
|
swapchain_info->swapchain != VK_NULL_HANDLE);
|
||||||
image->bo = wsi_img->bo;
|
mem = tu_device_memory_from_handle(wsi_common_get_memory(
|
||||||
image->map = NULL;
|
swapchain_info->swapchain, swapchain_info->imageIndex));
|
||||||
image->iova = wsi_img->iova;
|
|
||||||
|
|
||||||
TU_RMV(image_bind, device, image);
|
|
||||||
|
|
||||||
vk_address_binding_report(&instance->vk, &image->vk.base,
|
|
||||||
image->iova, image->total_size,
|
|
||||||
VK_DEVICE_ADDRESS_BINDING_TYPE_BIND_EXT);
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
const VkBindMemoryStatusKHR *status =
|
const VkBindMemoryStatusKHR *status =
|
||||||
vk_find_struct_const(pBindInfos[i].pNext, BIND_MEMORY_STATUS_KHR);
|
vk_find_struct_const(pBindInfos[i].pNext, BIND_MEMORY_STATUS_KHR);
|
||||||
if (status)
|
if (status)
|
||||||
*status->pResult = VK_SUCCESS;
|
*status->pResult = VK_SUCCESS;
|
||||||
|
|
||||||
if (mem) {
|
assert(mem);
|
||||||
VkResult result;
|
VkResult result;
|
||||||
if (vk_image_is_android_hardware_buffer(&image->vk)) {
|
if (vk_image_is_android_hardware_buffer(&image->vk)) {
|
||||||
VkImageDrmFormatModifierExplicitCreateInfoEXT eci;
|
VkImageDrmFormatModifierExplicitCreateInfoEXT eci;
|
||||||
VkSubresourceLayout a_plane_layouts[TU_MAX_PLANE_COUNT];
|
VkSubresourceLayout a_plane_layouts[TU_MAX_PLANE_COUNT];
|
||||||
result = vk_android_get_ahb_layout(mem->vk.ahardware_buffer,
|
result =
|
||||||
&eci, a_plane_layouts,
|
vk_android_get_ahb_layout(mem->vk.ahardware_buffer, &eci,
|
||||||
TU_MAX_PLANE_COUNT);
|
a_plane_layouts, TU_MAX_PLANE_COUNT);
|
||||||
if (result != VK_SUCCESS) {
|
if (result != VK_SUCCESS) {
|
||||||
if (status)
|
if (status)
|
||||||
*status->pResult = result;
|
*status->pResult = result;
|
||||||
return result;
|
return result;
|
||||||
}
|
|
||||||
|
|
||||||
result = TU_CALLX(device, tu_image_update_layout)(device, image,
|
|
||||||
eci.drmFormatModifier, a_plane_layouts);
|
|
||||||
if (result != VK_SUCCESS) {
|
|
||||||
if (status)
|
|
||||||
*status->pResult = result;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
image->bo = mem->bo;
|
|
||||||
image->bo_offset = pBindInfos[i].memoryOffset;
|
|
||||||
image->iova = mem->bo->iova + pBindInfos[i].memoryOffset;
|
|
||||||
|
|
||||||
if (image->vk.usage & (VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT |
|
result = TU_CALLX(device, tu_image_update_layout)(
|
||||||
VK_IMAGE_USAGE_HOST_TRANSFER_BIT_EXT)) {
|
device, image, eci.drmFormatModifier, a_plane_layouts);
|
||||||
if (!mem->bo->map) {
|
if (result != VK_SUCCESS) {
|
||||||
result = tu_bo_map(device, mem->bo, NULL);
|
if (status)
|
||||||
if (result != VK_SUCCESS) {
|
*status->pResult = result;
|
||||||
if (status)
|
return result;
|
||||||
*status->pResult = result;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
image->map = (char *)mem->bo->map + pBindInfos[i].memoryOffset;
|
|
||||||
} else {
|
|
||||||
image->map = NULL;
|
|
||||||
}
|
}
|
||||||
#ifdef HAVE_PERFETTO
|
|
||||||
tu_perfetto_log_bind_image(device, image);
|
|
||||||
#endif
|
|
||||||
} else {
|
|
||||||
image->bo = NULL;
|
|
||||||
image->map = NULL;
|
|
||||||
image->iova = 0;
|
|
||||||
}
|
}
|
||||||
|
image->bo = mem->bo;
|
||||||
|
image->bo_offset = pBindInfos[i].memoryOffset;
|
||||||
|
image->iova = mem->bo->iova + pBindInfos[i].memoryOffset;
|
||||||
|
|
||||||
|
if (image->vk.usage & (VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT |
|
||||||
|
VK_IMAGE_USAGE_HOST_TRANSFER_BIT_EXT)) {
|
||||||
|
if (!mem->bo->map) {
|
||||||
|
result = tu_bo_map(device, mem->bo, NULL);
|
||||||
|
if (result != VK_SUCCESS) {
|
||||||
|
if (status)
|
||||||
|
*status->pResult = result;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
image->map = (char *) mem->bo->map + pBindInfos[i].memoryOffset;
|
||||||
|
} else {
|
||||||
|
image->map = NULL;
|
||||||
|
}
|
||||||
|
#ifdef HAVE_PERFETTO
|
||||||
|
tu_perfetto_log_bind_image(device, image);
|
||||||
|
#endif
|
||||||
|
|
||||||
TU_RMV(image_bind, device, image);
|
TU_RMV(image_bind, device, image);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue