From c29689a1fa1aa51dfedd8bede53e9ae168260291 Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Wed, 4 Jun 2025 14:04:11 +0300 Subject: [PATCH] anv: pass image usage/flags to anv_get_image_format_features2 Signed-off-by: Lionel Landwerlin Cc: mesa-stable Reviewed-by: Nanley Chery Part-of: (cherry picked from commit bd959ea48f90b726dd144ddd2716c593494201b4) --- .pick_status.json | 2 +- src/intel/vulkan/anv_android.c | 3 ++- src/intel/vulkan/anv_formats.c | 37 +++++++++++++++++++++------------- src/intel/vulkan/anv_private.h | 3 ++- 4 files changed, 28 insertions(+), 17 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 7811e1c8469..315249b383f 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -1014,7 +1014,7 @@ "description": "anv: pass image usage/flags to anv_get_image_format_features2", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/intel/vulkan/anv_android.c b/src/intel/vulkan/anv_android.c index d5bff9458d9..0eff9f5caf2 100644 --- a/src/intel/vulkan/anv_android.c +++ b/src/intel/vulkan/anv_android.c @@ -187,7 +187,8 @@ get_ahw_buffer_format_properties2( p->formatFeatures = anv_get_image_format_features2(device->physical, p->format, anv_format, - tiling, false /* is_sparse */, NULL); + tiling, 0 /* usage */, 0 /* flags */, + NULL); /* "Images can be created with an external format even if the Android hardware * buffer has a format which has an equivalent Vulkan format to enable diff --git a/src/intel/vulkan/anv_formats.c b/src/intel/vulkan/anv_formats.c index 80ceb391b60..b6b0497d099 100644 --- a/src/intel/vulkan/anv_formats.c +++ b/src/intel/vulkan/anv_formats.c @@ -634,11 +634,16 @@ anv_get_image_format_features2(const struct anv_physical_device *physical_device VkFormat vk_format, const struct anv_format *anv_format, VkImageTiling vk_tiling, - bool is_sparse, + VkImageUsageFlags usage, + VkImageCreateFlags create_flags, const struct isl_drm_modifier_info *isl_mod_info) { const struct intel_device_info *devinfo = &physical_device->info; VkFormatFeatureFlags2 flags = 0; + const bool is_sparse = (create_flags & + (VK_IMAGE_CREATE_SPARSE_BINDING_BIT | + VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | + VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0; if (anv_format == NULL) return 0; @@ -1084,7 +1089,7 @@ get_drm_format_modifier_properties_list(const struct anv_physical_device *physic VkFormatFeatureFlags2 features2 = anv_get_image_format_features2(physical_device, vk_format, anv_format, VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT, - false /* is_sparse */, + 0 /* usage */, 0 /* create_flags */, isl_mod_info); VkFormatFeatureFlags features = vk_format_features2_to_features(features2); if (!features) @@ -1120,7 +1125,7 @@ get_drm_format_modifier_properties_list_2(const struct anv_physical_device *phys VkFormatFeatureFlags2 features2 = anv_get_image_format_features2(physical_device, vk_format, anv_format, VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT, - false /* is_sparse */, + 0 /* usage */, 0 /* create_flags */, isl_mod_info); if (!features2) continue; @@ -1153,10 +1158,12 @@ void anv_GetPhysicalDeviceFormatProperties2( VkFormatFeatureFlags2 linear2, optimal2, buffer2; linear2 = anv_get_image_format_features2(physical_device, vk_format, anv_format, VK_IMAGE_TILING_LINEAR, - false /* is_sparse */, NULL); + 0 /* usage */, + 0 /* create_flags */, NULL); optimal2 = anv_get_image_format_features2(physical_device, vk_format, anv_format, VK_IMAGE_TILING_OPTIMAL, - false /* is_sparse */, NULL); + 0 /* usage */, + 0 /* create_flags */, NULL); buffer2 = get_buffer_format_features2(physical_device, vk_format, anv_format); pFormatProperties->formatProperties = (VkFormatProperties) { @@ -1338,8 +1345,11 @@ anv_formats_gather_format_features( VkImageTiling tiling, const struct isl_drm_modifier_info *isl_mod_info, const VkImageFormatListCreateInfo *format_list_info, - bool allow_texel_compatible) + VkImageUsageFlags usage, + VkImageCreateFlags create_flags) { + const bool allow_texel_compatible = + (create_flags & VK_IMAGE_CREATE_BLOCK_TEXEL_VIEW_COMPATIBLE_BIT) != 0; VkFormatFeatureFlags2 all_formats_feature_flags = 0; /* We need to check that each of the usage bits are allowed for at least @@ -1366,7 +1376,7 @@ anv_formats_gather_format_features( anv_get_image_format_features2(physical_device, possible_anv_format->vk_format, possible_anv_format, tiling, - false /* is_sparse */, + usage, create_flags, isl_mod_info); all_formats_feature_flags |= view_format_features; } @@ -1385,7 +1395,7 @@ anv_formats_gather_format_features( VkFormatFeatureFlags2 view_format_features = anv_get_image_format_features2(physical_device, vk_view_format, anv_view_format, - tiling, false /* is_sparse */, + tiling, usage, create_flags, isl_mod_info); all_formats_feature_flags |= view_format_features; } @@ -1449,7 +1459,6 @@ static VkResult anv_get_image_format_properties( struct anv_physical_device *physical_device, const VkPhysicalDeviceImageFormatInfo2 *info, - bool is_sparse, VkImageFormatProperties2 *props) { VkFormatFeatureFlags2 format_feature_flags; @@ -1614,7 +1623,8 @@ anv_get_image_format_properties( format_feature_flags = anv_get_image_format_features2(physical_device, info->format, format, info->tiling, - is_sparse, + info->usage, + info->flags, isl_mod_info); if (!anv_format_supports_usage(format_feature_flags, info->usage)) { @@ -1647,7 +1657,8 @@ anv_get_image_format_properties( anv_formats_gather_format_features(physical_device, format, info->tiling, isl_mod_info, format_list_info, - info->flags & VK_IMAGE_CREATE_BLOCK_TEXEL_VIEW_COMPATIBLE_BIT); + info->usage, + info->flags); if (!anv_format_supports_usage(all_formats_feature_flags, info->usage)) goto unsupported; @@ -2025,7 +2036,6 @@ VkResult anv_GetPhysicalDeviceImageFormatProperties2( return anv_get_image_format_properties(physical_device, pImageFormatInfo, - false /* is_sparse */, pImageFormatProperties); } @@ -2062,8 +2072,7 @@ void anv_GetPhysicalDeviceSparseImageFormatProperties2( }; VkImageFormatProperties2 img_props = {}; if (anv_get_image_format_properties(physical_device, - &img_info, true /* is_sparse */, - &img_props) != VK_SUCCESS) + &img_info, &img_props) != VK_SUCCESS) return; if ((pFormatInfo->samples & diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index adb763b8b2a..d98e8791f61 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -6290,7 +6290,8 @@ anv_get_image_format_features2(const struct anv_physical_device *physical_device VkFormat vk_format, const struct anv_format *anv_format, VkImageTiling vk_tiling, - bool is_sparse, + VkImageUsageFlags usage, + VkImageCreateFlags create_flags, const struct isl_drm_modifier_info *isl_mod_info); void anv_fill_buffer_surface_state(struct anv_device *device,