anv: pass image usage/flags to anv_get_image_format_features2

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Cc: mesa-stable
Reviewed-by: Nanley Chery <nanley.g.chery@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35358>
(cherry picked from commit bd959ea48f)
This commit is contained in:
Lionel Landwerlin 2025-06-04 14:04:11 +03:00 committed by Eric Engestrom
parent 7e8d243549
commit c29689a1fa
4 changed files with 28 additions and 17 deletions

View file

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

View file

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

View file

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

View file

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