mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 20:18:12 +02:00
lvp: properly initialize AHB image layout
AHB image layout initialization is deferred until dedicated memory import time. During vkCreateImage, only a stub is created just like aliased ANB image since the layout has to be retrieved from the AHB. Reviewed-by: Lucas Fryzek <lfryzek@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40426>
This commit is contained in:
parent
6347a0d538
commit
8fe3da38e5
4 changed files with 50 additions and 5 deletions
|
|
@ -116,8 +116,47 @@ lvp_QueueSignalReleaseImageANDROID(VkQueue _queue,
|
|||
}
|
||||
|
||||
VkResult
|
||||
lvp_import_ahb_memory(struct lvp_device *device, struct lvp_device_memory *mem)
|
||||
lvp_import_ahb_memory(struct lvp_device *device,
|
||||
const VkMemoryAllocateInfo *alloc_info,
|
||||
struct lvp_device_memory *mem)
|
||||
{
|
||||
const VkMemoryDedicatedAllocateInfo *dedicated_info =
|
||||
vk_find_struct_const(alloc_info->pNext, MEMORY_DEDICATED_ALLOCATE_INFO);
|
||||
if (dedicated_info && dedicated_info->image != VK_NULL_HANDLE) {
|
||||
VK_FROM_HANDLE(lvp_image, image, dedicated_info->image);
|
||||
VkResult result;
|
||||
|
||||
VkImageDrmFormatModifierExplicitCreateInfoEXT eci;
|
||||
VkSubresourceLayout layouts[LVP_MAX_PLANE_COUNT];
|
||||
result = vk_android_get_ahb_layout(mem->vk.ahardware_buffer, &eci,
|
||||
layouts, LVP_MAX_PLANE_COUNT);
|
||||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
|
||||
image->vk.tiling = VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT;
|
||||
const uint32_t queue_family_index = 0;
|
||||
const VkImageCreateInfo create_info = {
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
|
||||
.pNext = &eci,
|
||||
.flags = image->vk.create_flags,
|
||||
.imageType = image->vk.image_type,
|
||||
.format = image->vk.format,
|
||||
.extent = image->vk.extent,
|
||||
.mipLevels = image->vk.mip_levels,
|
||||
.arrayLayers = image->vk.array_layers,
|
||||
.samples = image->vk.samples,
|
||||
.tiling = image->vk.tiling,
|
||||
.usage = image->vk.usage,
|
||||
.sharingMode = image->vk.sharing_mode,
|
||||
.queueFamilyIndexCount = 1,
|
||||
.pQueueFamilyIndices = &queue_family_index,
|
||||
.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED,
|
||||
};
|
||||
result = lvp_image_init(device, image, &create_info);
|
||||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
}
|
||||
|
||||
const native_handle_t *handle =
|
||||
AHardwareBuffer_getNativeHandle(mem->vk.ahardware_buffer);
|
||||
int dma_buf = (handle && handle->numFds) ? handle->data[0] : -1;
|
||||
|
|
|
|||
|
|
@ -2130,7 +2130,7 @@ VKAPI_ATTR VkResult VKAPI_CALL lvp_AllocateMemory(
|
|||
}
|
||||
#if DETECT_OS_ANDROID
|
||||
else if (mem->vk.ahardware_buffer) {
|
||||
error = lvp_import_ahb_memory(device, mem);
|
||||
error = lvp_import_ahb_memory(device, pAllocateInfo, mem);
|
||||
if (error != VK_SUCCESS)
|
||||
goto fail;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -194,8 +194,12 @@ lvp_image_create(VkDevice _device,
|
|||
if (image == NULL)
|
||||
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
|
||||
/* aliased ANB image is initialized upon binding to memory */
|
||||
if (vk_image_is_android_native_buffer_alias(&image->vk))
|
||||
/* Early return here for AHB and alised ANB:
|
||||
* - aliased ANB image is initialized upon binding to memory
|
||||
* - AHB image is initialized upon dedicated memory import
|
||||
*/
|
||||
if (vk_image_is_android_native_buffer_alias(&image->vk) ||
|
||||
vk_image_is_android_hardware_buffer(&image->vk))
|
||||
goto out_success;
|
||||
|
||||
result = lvp_image_init(device, image, pCreateInfo);
|
||||
|
|
|
|||
|
|
@ -809,7 +809,9 @@ lvp_image_init(struct lvp_device *device, struct lvp_image *image,
|
|||
|
||||
#if DETECT_OS_ANDROID
|
||||
VkResult
|
||||
lvp_import_ahb_memory(struct lvp_device *device, struct lvp_device_memory *mem);
|
||||
lvp_import_ahb_memory(struct lvp_device *device,
|
||||
const VkMemoryAllocateInfo *alloc_info,
|
||||
struct lvp_device_memory *mem);
|
||||
|
||||
VkResult
|
||||
lvp_bind_anb_memory(struct lvp_device *device,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue