diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/amd/vulkan/radv_android.c | 17 | ||||
-rw-r--r-- | src/amd/vulkan/radv_image.c | 18 | ||||
-rw-r--r-- | src/amd/vulkan/radv_private.h | 5 |
3 files changed, 37 insertions, 3 deletions
diff --git a/src/amd/vulkan/radv_android.c b/src/amd/vulkan/radv_android.c index f2fbeab459d..07123bf0af9 100644 --- a/src/amd/vulkan/radv_android.c +++ b/src/amd/vulkan/radv_android.c @@ -647,6 +647,23 @@ radv_import_ahb_memory(struct radv_device *device, if (!mem->bo) return VK_ERROR_OUT_OF_HOST_MEMORY; + if (mem->image) { + struct radeon_bo_metadata metadata; + device->ws->buffer_get_metadata(mem->bo, &metadata); + + struct radv_image_create_info create_info = { + .no_metadata_planes = true, + .bo_metadata = &metadata + }; + + VkResult result = radv_image_create_layout(device, create_info, mem->image); + if (result != VK_SUCCESS) { + device->ws->buffer_destroy(mem->bo); + mem->bo = NULL; + return result; + } + } + /* "If the vkAllocateMemory command succeeds, the implementation must * acquire a reference to the imported hardware buffer, which it must * release when the device memory object is freed. If the command fails, diff --git a/src/amd/vulkan/radv_image.c b/src/amd/vulkan/radv_image.c index 316f883f676..fa7f47cc8ef 100644 --- a/src/amd/vulkan/radv_image.c +++ b/src/amd/vulkan/radv_image.c @@ -1350,7 +1350,7 @@ static void radv_image_disable_htile(struct radv_image *image) image->planes[i].surface.htile_size = 0; } -static VkResult +VkResult radv_image_create_layout(struct radv_device *device, struct radv_image_create_info create_info, struct radv_image *image) @@ -1488,8 +1488,11 @@ radv_image_create(VkDevice _device, image->queue_family_mask |= 1u << pCreateInfo->pQueueFamilyIndices[i]; } - image->shareable = vk_find_struct_const(pCreateInfo->pNext, - EXTERNAL_MEMORY_IMAGE_CREATE_INFO) != NULL; + const VkExternalMemoryImageCreateInfo *external_info = + vk_find_struct_const(pCreateInfo->pNext, + EXTERNAL_MEMORY_IMAGE_CREATE_INFO) ; + + image->shareable = external_info; if (!vk_format_is_depth_or_stencil(format) && !image->shareable) { image->info.surf_index = &device->image_mrt_offset_counter; } @@ -1498,6 +1501,15 @@ radv_image_create(VkDevice _device, radv_init_surface(device, image, &image->planes[plane].surface, plane, pCreateInfo, format); } + bool delay_layout = external_info && + (external_info->handleTypes & VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID); + + if (delay_layout) { + *pImage = radv_image_to_handle(image); + assert (!(image->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT)); + return VK_SUCCESS; + } + ASSERTED VkResult result = radv_image_create_layout(device, *create_info, image); assert(result == VK_SUCCESS); diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h index 51b7d7953ef..ee69ccf6f0f 100644 --- a/src/amd/vulkan/radv_private.h +++ b/src/amd/vulkan/radv_private.h @@ -1914,6 +1914,11 @@ struct radv_image_create_info { const struct radeon_bo_metadata *bo_metadata; }; +VkResult +radv_image_create_layout(struct radv_device *device, + struct radv_image_create_info create_info, + struct radv_image *image); + VkResult radv_image_create(VkDevice _device, const struct radv_image_create_info *info, const VkAllocationCallbacks* alloc, |