From 3b19aa626169150487485a5bbf9a7eca99b9c32e Mon Sep 17 00:00:00 2001 From: Yiwei Zhang Date: Wed, 20 Aug 2025 18:37:32 -0700 Subject: [PATCH] anv: avoid setting image format twice for AHB image AHB images are created with the right VkFormat when external format isn't used. When external format does get used, the proper VkFormat has already being set in the common runtime. Upon AHB props query, we resolve external format to VkFormat and set to the externalFormat field to be used by the app. The app would than chain the exact external format when creating the AHB image if it wants to go down the external format code path instead of being explicit. So in the end, the format we resolve is the format we get. Thus no need to set it twice. Reviewed-by: Lucas Fryzek Part-of: --- src/intel/vulkan/anv_android.c | 2 +- src/intel/vulkan/anv_image.c | 5 ----- src/intel/vulkan/anv_private.h | 3 --- 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/src/intel/vulkan/anv_android.c b/src/intel/vulkan/anv_android.c index c61e297001e..90bc7908ed3 100644 --- a/src/intel/vulkan/anv_android.c +++ b/src/intel/vulkan/anv_android.c @@ -32,7 +32,7 @@ #if ANDROID_API_LEVEL >= 26 #include -inline VkFormat +static inline VkFormat vk_format_from_android(unsigned android_format, unsigned android_usage) { switch (android_format) { diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c index f0620bbaaac..a71469f9737 100644 --- a/src/intel/vulkan/anv_image.c +++ b/src/intel/vulkan/anv_image.c @@ -2240,14 +2240,9 @@ resolve_ahw_image(struct anv_device *device, assert(result == VK_SUCCESS); isl_tiling_flags_t isl_tiling_flags = (1u << tiling); - /* Check format. */ - VkFormat vk_format = vk_format_from_android(desc.format, desc.usage); - assert(vk_format != VK_FORMAT_UNDEFINED); - /* Now we are able to fill anv_image fields properly and create * isl_surface for it. */ - vk_image_set_format(&image->vk, vk_format); image->n_planes = anv_get_format_planes(device->physical, image->vk.format); result = add_all_surfaces_implicit_layout(device, image, NULL, desc.stride, diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index 05d2dc6e0cb..78d85e2cfd5 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -5611,9 +5611,6 @@ bool anv_formats_ccs_e_compatible(const struct anv_physical_device *device, VkImageUsageFlags vk_usage, const VkImageFormatListCreateInfo *fmt_list); -extern VkFormat -vk_format_from_android(unsigned android_format, unsigned android_usage); - static inline VkFormat anv_get_compressed_format_emulation(const struct anv_physical_device *pdevice, VkFormat format)