diff options
author | Tapani Pälli <tapani.palli@intel.com> | 2018-11-08 10:37:12 +0200 |
---|---|---|
committer | Tapani Pälli <tapani.palli@intel.com> | 2018-12-19 09:38:41 +0200 |
commit | f1654fa7e313a97e8849973b6877700bbdb2ce06 (patch) | |
tree | fb41b0cc479b352eac8abaa42178dccb01d5e08f /src/intel/vulkan/anv_device.c | |
parent | 517103abf1c2ba6c540ae4f5fb1d10874e5568f6 (diff) |
anv/android: support creating images from external format
Since we don't know the exact format at creation time, some initialization
is done only when bound with memory in vkBindImageMemory.
v2: demand dedicated allocation in vkGetImageMemoryRequirements2 if
image has external format
v3: refactor prepare_ahw_image, support vkBindImageMemory2,
calculate stride correctly for rgb(x) surfaces, rename as
'resolve_ahw_image'
v4: rebase to b43f955037c changes
v5: add some assertions to verify input correctness (Lionel)
Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Diffstat (limited to 'src/intel/vulkan/anv_device.c')
-rw-r--r-- | src/intel/vulkan/anv_device.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index fa3a8a417b9..2a3919d2949 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -2712,6 +2712,12 @@ void anv_GetImageMemoryRequirements( */ uint32_t memory_types = (1ull << pdevice->memory.type_count) - 1; + /* We must have image allocated or imported at this point. According to the + * specification, external images must have been bound to memory before + * calling GetImageMemoryRequirements. + */ + assert(image->size > 0); + pMemoryRequirements->size = image->size; pMemoryRequirements->alignment = image->alignment; pMemoryRequirements->memoryTypeBits = memory_types; @@ -2752,6 +2758,12 @@ void anv_GetImageMemoryRequirements2( pMemoryRequirements->memoryRequirements.memoryTypeBits = (1ull << pdevice->memory.type_count) - 1; + /* We must have image allocated or imported at this point. According to the + * specification, external images must have been bound to memory before + * calling GetImageMemoryRequirements. + */ + assert(image->planes[plane].size > 0); + pMemoryRequirements->memoryRequirements.size = image->planes[plane].size; pMemoryRequirements->memoryRequirements.alignment = image->planes[plane].alignment; @@ -2768,7 +2780,7 @@ void anv_GetImageMemoryRequirements2( switch (ext->sType) { case VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS: { VkMemoryDedicatedRequirements *requirements = (void *)ext; - if (image->needs_set_tiling) { + if (image->needs_set_tiling || image->external_format) { /* If we need to set the tiling for external consumers, we need a * dedicated allocation. * |