radv: Allow Android image binding.
Using delayed layout of images. Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
This commit is contained in:
@@ -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,
|
||||
|
@@ -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);
|
||||
|
||||
|
@@ -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,
|
||||
|
Reference in New Issue
Block a user