From ec40c9538565ab2eb373d72e454f507d85f7d267 Mon Sep 17 00:00:00 2001 From: Nanley Chery Date: Mon, 18 May 2026 09:02:13 -0400 Subject: [PATCH] anv: Add transfer_src usage for ANDROID_external_format_resolve MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The android extension enables the driver to blit from single-sampled color attachments. Adding this image usage expressess that functionality and causes anv to generate the ISL_FORMAT_RAW-formatted clear color during fast-clears. This fixes an assert failure when anv tries to override the clear color format used for a blorp_blit() call to ISL_FORMAT_RAW. There are other ways to handle this, but this solution is consistent with our handling of multisample images (which may be resolved as well). Fixes: 465c186fc5f ("anv: Prepare for format width changes in blorp_copy()") Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/15463 Reviewed-by: Tapani Pälli Reviewed-by: Lionel Landwerlin Part-of: --- src/intel/vulkan/anv_image.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c index 33af7b44dfa..18382a454c1 100644 --- a/src/intel/vulkan/anv_image.c +++ b/src/intel/vulkan/anv_image.c @@ -1655,13 +1655,14 @@ choose_drm_format_mod(const struct anv_physical_device *device, } static VkImageUsageFlags -anv_image_create_usage(const VkImageCreateInfo *pCreateInfo, +anv_image_create_usage(const struct anv_device *device, + const VkImageCreateInfo *pCreateInfo, VkImageUsageFlags usage) { - /* Add TRANSFER_SRC usage for multisample attachment images. This is - * because we might internally use the TRANSFER_SRC layout on them for - * blorp operations associated with resolving those into other attachments - * at the end of a subpass. + /* Add TRANSFER_SRC usage for some attachments. This is because we might + * internally use the TRANSFER_SRC layout on them for blorp operations + * associated with resolving those into other attachments at the end of a + * subpass. * * Without this additional usage, we compute an incorrect AUX state in * anv_layout_to_aux_state(). @@ -1670,6 +1671,12 @@ anv_image_create_usage(const VkImageCreateInfo *pCreateInfo, (usage & (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT))) usage |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT; + + if (device->vk.enabled_extensions.ANDROID_external_format_resolve && + pCreateInfo->samples == VK_SAMPLE_COUNT_1_BIT && + (usage & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT)) + usage |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT; + return usage; } @@ -1855,9 +1862,10 @@ anv_image_init(struct anv_device *device, struct anv_image *image, vk_image_init(&device->vk, &image->vk, pCreateInfo); - image->vk.usage = anv_image_create_usage(pCreateInfo, image->vk.usage); + image->vk.usage = + anv_image_create_usage(device, pCreateInfo, image->vk.usage); image->vk.stencil_usage = - anv_image_create_usage(pCreateInfo, image->vk.stencil_usage); + anv_image_create_usage(device, pCreateInfo, image->vk.stencil_usage); isl_surf_usage_flags_t isl_extra_usage_flags = create_info->isl_extra_usage_flags;