VkSubresourceLayout layouts[4];
VkImageDrmFormatModifierExplicitCreateInfoEXT modifier;
VkExternalMemoryImageCreateInfo external;
+ VkImageFormatListCreateInfo list;
};
static VkResult
VkResult result = VK_SUCCESS;
struct vn_android_gralloc_buffer_properties buf_props;
VkDrmFormatModifierPropertiesEXT mod_props;
+ uint32_t vcount = 0;
+ const VkFormat *vformats = NULL;
/* Android image builder is only used by ANB or AHB. For ANB, Android
* Vulkan loader will never pass the below structs. For AHB, struct
};
out_builder->create.pNext = &out_builder->external;
+ /* fill VkImageFormatListCreateInfo if needed
+ *
+ * vn_image::deferred_info only stores VkImageFormatListCreateInfo with a
+ * non-zero viewFormatCount, and that stored struct will be respected.
+ */
+ if ((create_info->flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT) &&
+ !vk_find_struct_const(create_info->pNext,
+ IMAGE_FORMAT_LIST_CREATE_INFO)) {
+ /* 12.3. Images
+ *
+ * If tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT and flags
+ * contains VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT, then the pNext chain
+ * must include a VkImageFormatListCreateInfo structure with non-zero
+ * viewFormatCount.
+ */
+ vformats =
+ vn_android_format_to_view_formats(create_info->format, &vcount);
+ if (!vformats) {
+ /* image builder struct persists through the image creation call */
+ vformats = &out_builder->create.format;
+ vcount = 1;
+ }
+ out_builder->list = (VkImageFormatListCreateInfo){
+ .sType = VK_STRUCTURE_TYPE_IMAGE_FORMAT_LIST_CREATE_INFO,
+ .pNext = out_builder->create.pNext,
+ .viewFormatCount = vcount,
+ .pViewFormats = vformats,
+ };
+ out_builder->create.pNext = &out_builder->list;
+ }
+
return VK_SUCCESS;
}
if (result != VK_SUCCESS)
goto fail;
+ assert(!(create_info->flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT));
assert(!vk_find_struct_const(create_info->pNext,
IMAGE_FORMAT_LIST_CREATE_INFO));
assert(!vk_find_struct_const(create_info->pNext,
assert(create_info->imageType == VK_IMAGE_TYPE_2D);
assert(create_info->usage == VK_IMAGE_USAGE_SAMPLED_BIT);
assert(create_info->tiling == VK_IMAGE_TILING_OPTIMAL);
+ assert(!(create_info->flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT));
local_info = *create_info;
local_info.format =