mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-07 07:08:04 +02:00
v3dv/android: Add deferred ANB allocation support
Fixes: dEQP-VK.wsi.android.maintenance1.deferred_alloc.mailbox#basic dEQP-VK.wsi.android.maintenance1.deferred_alloc.mailbox#bind_image dEQP-VK.wsi.android.maintenance1.deferred_alloc.fifo#basic dEQP-VK.wsi.android.maintenance1.deferred_alloc.fifo#bind_image Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com> Acked-by: Iago Toral Quiroga <itoral@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41235>
This commit is contained in:
parent
d4d7055aee
commit
bdbf4ed739
2 changed files with 43 additions and 8 deletions
|
|
@ -2588,17 +2588,35 @@ v3dv_BindImageMemory2(VkDevice _device,
|
|||
const VkBindImageMemoryInfo *pBindInfos)
|
||||
{
|
||||
for (uint32_t i = 0; i < bindInfoCount; i++) {
|
||||
/* This section is removed by the optimizer for non-ANDROID builds */
|
||||
#if DETECT_OS_ANDROID
|
||||
V3DV_FROM_HANDLE(v3dv_image, image, pBindInfos[i].image);
|
||||
if (vk_image_is_android_hardware_buffer(&image->vk)) {
|
||||
if (vk_image_is_android_hardware_buffer(&image->vk) ||
|
||||
vk_image_is_android_native_buffer_alias(&image->vk)) {
|
||||
const VkNativeBufferANDROID *anb =
|
||||
vk_find_struct_const(pBindInfos[i].pNext, NATIVE_BUFFER_ANDROID);
|
||||
|
||||
V3DV_FROM_HANDLE(v3dv_device, device, _device);
|
||||
V3DV_FROM_HANDLE(v3dv_device_memory, mem, pBindInfos[i].memory);
|
||||
|
||||
VkImageDrmFormatModifierExplicitCreateInfoEXT eci;
|
||||
VkSubresourceLayout a_plane_layouts[V3DV_MAX_PLANE_COUNT];
|
||||
VkResult result = vk_android_get_ahb_layout(mem->vk.ahardware_buffer,
|
||||
&eci, a_plane_layouts,
|
||||
V3DV_MAX_PLANE_COUNT);
|
||||
VkResult result;
|
||||
|
||||
if (vk_image_is_android_native_buffer_alias(&image->vk)) {
|
||||
assert(anb && image->vk.android_deferred_create_info);
|
||||
VkNativeBufferANDROID local_anb = *anb;
|
||||
local_anb.pNext = image->vk.android_deferred_create_info->pNext;
|
||||
image->vk.android_deferred_create_info->pNext = &local_anb;
|
||||
|
||||
result = vk_android_get_anb_layout(image->vk.android_deferred_create_info,
|
||||
&eci, a_plane_layouts, V3DV_MAX_PLANE_COUNT);
|
||||
image->vk.android_deferred_create_info->pNext = NULL;
|
||||
} else {
|
||||
V3DV_FROM_HANDLE(v3dv_device_memory, mem, pBindInfos[i].memory);
|
||||
result = vk_android_get_ahb_layout(mem->vk.ahardware_buffer,
|
||||
&eci, a_plane_layouts,
|
||||
V3DV_MAX_PLANE_COUNT);
|
||||
}
|
||||
|
||||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
|
||||
|
|
@ -2607,7 +2625,21 @@ v3dv_BindImageMemory2(VkDevice _device,
|
|||
/* disjoint = */ false, &eci);
|
||||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
|
||||
if (vk_image_is_android_native_buffer_alias(&image->vk)) {
|
||||
result = vk_android_import_anb_memory(&device->vk, &image->vk, anb,
|
||||
&device->vk.alloc);
|
||||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
|
||||
VkBindImageMemoryInfo local_bind = pBindInfos[i];
|
||||
local_bind.memory = image->vk.anb_memory;
|
||||
local_bind.memoryOffset = 0;
|
||||
bind_image_memory(&local_bind);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
const VkBindImageMemorySwapchainInfoKHR *swapchain_info =
|
||||
vk_find_struct_const(pBindInfos[i].pNext,
|
||||
|
|
|
|||
|
|
@ -525,8 +525,11 @@ v3dv_image_init(struct v3dv_device *device,
|
|||
* Image layout will be filled up during vkBindImageMemory2
|
||||
* This section is removed by the optimizer for non-ANDROID builds
|
||||
*/
|
||||
if (vk_image_is_android_hardware_buffer(&image->vk))
|
||||
return VK_SUCCESS;
|
||||
if (vk_image_is_android_hardware_buffer(&image->vk) ||
|
||||
vk_image_is_android_native_buffer_alias(&image->vk)) {
|
||||
return vk_android_init_deferred_image(&device->vk, &image->vk,
|
||||
pCreateInfo, pAllocator);
|
||||
}
|
||||
|
||||
bool disjoint = image->vk.create_flags & VK_IMAGE_CREATE_DISJOINT_BIT;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue