Module: Mesa Branch: main Commit: b30d5a4794ca55415fdee0dce93d16338b67564b URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b30d5a4794ca55415fdee0dce93d16338b67564b
Author: Chia-I Wu <[email protected]> Date: Thu Sep 28 10:37:11 2023 -0700 anv: advertise emulated formats Advertise required features for emulated formats. v2: no sparse residency support Signed-off-by: Chia-I Wu <[email protected]> Reviewed-by: Lionel Landwerlin <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25467> --- src/intel/vulkan/anv_formats.c | 23 +++++++++++++++++++++++ src/intel/vulkan/anv_sparse.c | 7 +++++++ 2 files changed, 30 insertions(+) diff --git a/src/intel/vulkan/anv_formats.c b/src/intel/vulkan/anv_formats.c index 03d41d26da8..79acf61d72f 100644 --- a/src/intel/vulkan/anv_formats.c +++ b/src/intel/vulkan/anv_formats.c @@ -538,6 +538,23 @@ anv_get_image_format_features2(const struct anv_physical_device *physical_device assert((isl_mod_info != NULL) == (vk_tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT)); + if (anv_is_format_emulated(physical_device, vk_format)) { + assert(isl_format_is_compressed(anv_format->planes[0].isl_format)); + + /* require optimal tiling so that we can decompress on upload */ + if (vk_tiling != VK_IMAGE_TILING_OPTIMAL) + return 0; + + /* required features for compressed formats */ + flags |= VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_BIT | + VK_FORMAT_FEATURE_2_BLIT_SRC_BIT | + VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_FILTER_LINEAR_BIT | + VK_FORMAT_FEATURE_2_TRANSFER_SRC_BIT | + VK_FORMAT_FEATURE_2_TRANSFER_DST_BIT; + + return flags; + } + const VkImageAspectFlags aspects = vk_format_aspects(vk_format); if (aspects & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) { @@ -1310,6 +1327,12 @@ anv_get_image_format_properties( !(info->flags & VK_IMAGE_CREATE_EXTENDED_USAGE_BIT)) goto unsupported; + /* We don't want emulated formats to gain unexpected usage (storage in + * particular) from its compatible view formats. + */ + if (anv_is_format_emulated(physical_device, info->format)) + goto unsupported; + /* From the Vulkan 1.3.224 spec "43.1.6. Format Compatibility Classes": * * "Each depth/stencil format is only compatible with itself." diff --git a/src/intel/vulkan/anv_sparse.c b/src/intel/vulkan/anv_sparse.c index cc494e1bd1e..37c0b2abcb4 100644 --- a/src/intel/vulkan/anv_sparse.c +++ b/src/intel/vulkan/anv_sparse.c @@ -766,6 +766,13 @@ anv_sparse_image_check_support(struct anv_physical_device *pdevice, * VK_IMAGE_TILING_LINEAR tiling is not supported." */ + /* We choose not to support sparse residency on emulated compressed + * formats due to the additional image plane. It would make the + * implementation extremely complicated. + */ + if (anv_is_format_emulated(pdevice, vk_format)) + return VK_ERROR_FORMAT_NOT_SUPPORTED; + /* While the spec itself says linear is not supported (see above), deqp-vk * tries anyway to create linear sparse images, so we have to check for it. * This is also said in VUID-VkImageCreateInfo-tiling-04121:
