diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c index 14f4b47858f..7b1ca50179d 100644 --- a/src/intel/vulkan/anv_image.c +++ b/src/intel/vulkan/anv_image.c @@ -1692,9 +1692,6 @@ anv_image_init(struct anv_device *device, struct anv_image *image, image->vk.create_flags |= VK_IMAGE_CREATE_2D_VIEW_COMPATIBLE_BIT_EXT; image->vk.usage |= VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_STORAGE_BIT; - - /* TODO: enable compression on emulation plane */ - isl_extra_usage_flags |= ISL_SURF_USAGE_DISABLE_AUX_BIT; } /* Disable aux if image supports export without modifiers. */ @@ -1883,16 +1880,71 @@ anv_image_init(struct anv_device *device, struct anv_image *image, const struct anv_format_plane plane_format = anv_get_format_plane( device->physical, image->emu_plane_format, 0, image->vk.tiling); - isl_surf_usage_flags_t isl_usage = anv_image_choose_isl_surf_usage( - device->physical, image->vk.format, image->vk.create_flags, - image->vk.usage, isl_extra_usage_flags, VK_IMAGE_ASPECT_COLOR_BIT, - image->vk.compr_flags); + /* According to vk_texcompress_astc_emulation_format() and + * anv_astc_emu_process(), there are a limited number of formats the + * emulation plane will be accessed as so we can just hardcode all of + * those here. + */ + VkFormat emu_format_list[] = { + VK_FORMAT_R8G8B8A8_UINT, + VK_FORMAT_R8G8B8A8_SRGB, + VK_FORMAT_R8G8B8A8_UNORM, + }; + + VkImageFormatListCreateInfo emu_format_list_info = { + .sType = VK_STRUCTURE_TYPE_IMAGE_FORMAT_LIST_CREATE_INFO, + .pNext = NULL, + .viewFormatCount = ARRAY_SIZE(emu_format_list), + .pViewFormats = emu_format_list + }; + + VkImageFormatListCreateInfo *emu_format_list_info_ptr = + &emu_format_list_info; + + /* We don't care to provide an accurate list on the older platforms + * which need denorms flushed as they don't support compression on the + * storage image usage. + */ + if (device->physical->flush_astc_ldr_void_extent_denorms) + emu_format_list_info_ptr = NULL; + + assert(image->vk.create_flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT); + + if (device->info->ver >= 12) { + /* CCS_E is the only aux-mode supported for single sampled color + * surfaces on gfx12+. Since we hardcoded all the formats the + * emulation plane will be accessed as, CCS_E support should + * be guaranteed. + */ + assert(anv_formats_ccs_e_compatible(device->physical, + image->vk.create_flags, + image->emu_plane_format, + image->vk.tiling, + image->vk.usage, + emu_format_list_info_ptr)); + } + + isl_surf_usage_flags_t isl_usage = + anv_image_choose_isl_surf_usage(device->physical, + image->vk.format, + image->vk.create_flags, + image->vk.usage, + 0, + VK_IMAGE_ASPECT_COLOR_BIT, + image->vk.compr_flags); r = add_primary_surface(device, image, plane, plane_format, ANV_OFFSET_IMPLICIT, 0, isl_tiling_flags, isl_usage); if (r != VK_SUCCESS) goto fail; + + r = add_aux_surface_if_supported(device, image, plane, plane_format, + emu_format_list_info_ptr, + ANV_OFFSET_IMPLICIT, 0, + ANV_OFFSET_IMPLICIT); + if (r != VK_SUCCESS) + goto fail; } const VkVideoProfileListInfoKHR *video_profile =