Mesa (main): radv: determine if an image support fast clears using comp-to-single
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Aug 10 08:46:40 UTC 2021
Module: Mesa
Branch: main
Commit: 782e0d05b0ac08a1baa6011d22cb966fb46c6434
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=782e0d05b0ac08a1baa6011d22cb966fb46c6434
Author: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Date: Wed Apr 28 13:53:02 2021 +0200
radv: determine if an image support fast clears using comp-to-single
Only on GFX10+ with DCC enabled.
Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10518>
---
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 beb43a7d8db..9d370f77e14 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 f9a15391f2c..668af053abd 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);
More information about the mesa-commit
mailing list