From aaf634cc24d621216a25430b6bec69cd962eef4e Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Thu, 20 Feb 2025 10:58:34 +0100 Subject: [PATCH] radv: rework radv_fast_clear_flush_image_inplace() FMASK_DECOMPRESS also implies FAST_CLEAR_ELIMINATE, so it can run first. The only exception is fast-clear for color images that have DCC and FMASK but without comp-to-single (only GFX10) because FMASK_DECOMPRESS can't eliminate DCC fast-clears. Signed-off-by: Samuel Pitoiset Part-of: --- src/amd/vulkan/meta/radv_meta_fast_clear.c | 27 +++++++++++++--------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/amd/vulkan/meta/radv_meta_fast_clear.c b/src/amd/vulkan/meta/radv_meta_fast_clear.c index 2db318b9a0d..47046970568 100644 --- a/src/amd/vulkan/meta/radv_meta_fast_clear.c +++ b/src/amd/vulkan/meta/radv_meta_fast_clear.c @@ -441,20 +441,25 @@ void radv_fast_clear_flush_image_inplace(struct radv_cmd_buffer *cmd_buffer, struct radv_image *image, const VkImageSubresourceRange *subresourceRange) { - if (radv_image_has_fmask(image) && !image->tc_compatible_cmask) { - if (radv_image_has_dcc(image) && radv_image_has_cmask(image) && !image->support_comp_to_single) { - /* MSAA images with DCC and CMASK might have been fast-cleared and might require a FCE but - * FMASK_DECOMPRESS can't eliminate DCC fast clears. - */ + /* FMASK_DECOMPRESS is only required for MSAA images that don't support TC-compat CMASK. */ + const bool needs_fmask_decompress = radv_image_has_fmask(image) && !image->tc_compatible_cmask; + + /* FCE is only required for color images that don't support comp-to-single fast clears. */ + const bool needs_fce = !image->support_comp_to_single; + + if (needs_fmask_decompress) { + /* MSAA images with DCC and CMASK might have been fast-cleared and might require a FCE but + * FMASK_DECOMPRESS can't eliminate DCC fast clears. Only GFX10 is affected because it has few + * restrictions related to comp-to-single. + */ + const bool needs_dcc_fce = + radv_image_has_dcc(image) && radv_image_has_cmask(image) && !image->support_comp_to_single; + + if (needs_dcc_fce) radv_fast_clear_eliminate(cmd_buffer, image, subresourceRange); - } radv_fmask_decompress(cmd_buffer, image, subresourceRange); - } else { - /* Skip fast clear eliminate for images that support comp-to-single fast clears. */ - if (image->support_comp_to_single) - return; - + } else if (needs_fce) { radv_fast_clear_eliminate(cmd_buffer, image, subresourceRange); } }