anv: advertise emulated formats

Advertise required features for emulated formats.

v2: no sparse residency support

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25467>
This commit is contained in:
Chia-I Wu 2023-09-28 10:37:11 -07:00 committed by Marge Bot
parent 8352b61ffa
commit b30d5a4794
2 changed files with 30 additions and 0 deletions

View file

@ -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."

View file

@ -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: