From 782e0d05b0ac08a1baa6011d22cb966fb46c6434 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Wed, 28 Apr 2021 13:53:02 +0200 Subject: [PATCH] radv: determine if an image support fast clears using comp-to-single Only on GFX10+ with DCC enabled. Signed-off-by: Samuel Pitoiset Reviewed-by: Bas Nieuwenhuizen Part-of: --- src/amd/vulkan/radv_image.c | 30 ++++++++++++++++++++++++++++++ src/amd/vulkan/radv_private.h | 3 +++ 2 files changed, 33 insertions(+) diff --git a/src/amd/vulkan/radv_image.c b/src/amd/vulkan/radv_image.c index beb43a7..9d370f7 100644 --- a/src/amd/vulkan/radv_image.c +++ b/src/amd/vulkan/radv_image.c @@ -1563,6 +1563,36 @@ radv_image_can_fast_clear(const struct radv_device *device, const struct radv_im return true; } +/** + * Determine if the given image can be fast cleared using comp-to-single. + */ +bool +radv_image_use_comp_to_single(const struct radv_device *device, const struct radv_image *image) +{ + /* comp-to-single is only available for GFX10+. */ + if (device->physical_device->rad_info.chip_class < GFX10) + return false; + + /* If the image can't be fast cleared, comp-to-single can't be used. */ + if (!radv_image_can_fast_clear(device, image)) + return false; + + /* If the image doesn't have DCC, it can't be fast cleared using comp-to-single */ + if (!radv_image_has_dcc(image)) + return false; + + /* TODO: DCC fast clears with MSAA aren't fully supported. */ + if (image->info.samples > 1) + return false; + + /* It seems 8bpp and 16bpp require RB+ to work. */ + unsigned bytes_per_pixel = vk_format_get_blocksize(image->vk_format); + if (bytes_per_pixel <= 2 && !device->physical_device->rad_info.rbplus_allowed) + return false; + + return false; /* TODO: will be enabled in a next commit. */ +} + static uint64_t radv_select_modifier(const struct radv_device *dev, VkFormat format, const struct VkImageDrmFormatModifierListCreateInfoEXT *mod_list) diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h index f9a1539..668af05 100644 --- a/src/amd/vulkan/radv_private.h +++ b/src/amd/vulkan/radv_private.h @@ -1581,6 +1581,9 @@ bool radv_image_use_dcc_image_stores(const struct radv_device *device, const struct radv_image *image); bool radv_image_use_dcc_predication(const struct radv_device *device, const struct radv_image *image); +bool radv_image_use_comp_to_single(const struct radv_device *device, + const struct radv_image *image); + void radv_update_fce_metadata(struct radv_cmd_buffer *cmd_buffer, struct radv_image *image, const VkImageSubresourceRange *range, bool value); -- 2.7.4