summaryrefslogtreecommitdiff
path: root/src/amd/vulkan
diff options
context:
space:
mode:
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>2021-01-07 20:37:05 +0100
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>2021-01-11 08:31:11 +0100
commit00064713a30937d3cab93679791545d973bee91f (patch)
tree005de93833d0aa85f49443ac7e106f1c782367ba /src/amd/vulkan
parent55ccc9eca5216f860777a8b6d746cb6fbfe32d42 (diff)
radv: determine at creation if an image view can be fast cleared
This can be determined earlier than every time a clear is performed by the driver, it probably saves a bunch of CPU cycles. Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8370>
Diffstat (limited to 'src/amd/vulkan')
-rw-r--r--src/amd/vulkan/radv_image.c62
-rw-r--r--src/amd/vulkan/radv_meta_clear.c62
-rw-r--r--src/amd/vulkan/radv_private.h3
3 files changed, 67 insertions, 60 deletions
diff --git a/src/amd/vulkan/radv_image.c b/src/amd/vulkan/radv_image.c
index c9f247a5029..6ecd0ac3d7a 100644
--- a/src/amd/vulkan/radv_image.c
+++ b/src/amd/vulkan/radv_image.c
@@ -1415,6 +1415,36 @@ radv_image_print_info(struct radv_device *device, struct radv_image *image)
}
}
+/**
+ * Determine if the given image can be fast cleared.
+ */
+static bool
+radv_image_can_fast_clear(const struct radv_device *device,
+ const struct radv_image *image)
+{
+ if (device->instance->debug_flags & RADV_DEBUG_NO_FAST_CLEARS)
+ return false;
+
+ if (vk_format_is_color(image->vk_format)) {
+ if (!radv_image_has_cmask(image) && !radv_image_has_dcc(image))
+ return false;
+
+ /* RB+ doesn't work with CMASK fast clear on Stoney. */
+ if (!radv_image_has_dcc(image) &&
+ device->physical_device->rad_info.family == CHIP_STONEY)
+ return false;
+ } else {
+ if (!radv_image_has_htile(image))
+ return false;
+ }
+
+ /* Do not fast clears 3D images. */
+ if (image->type == VK_IMAGE_TYPE_3D)
+ return false;
+
+ return true;
+}
+
VkResult
radv_image_create(VkDevice _device,
const struct radv_image_create_info *create_info,
@@ -1612,6 +1642,35 @@ radv_get_aspect_format(struct radv_image *image, VkImageAspectFlags mask)
}
}
+/**
+ * Determine if the given image view can be fast cleared.
+ */
+static bool
+radv_image_view_can_fast_clear(const struct radv_device *device,
+ const struct radv_image_view *iview)
+{
+ struct radv_image *image;
+
+ if (!iview)
+ return false;
+ image = iview->image;
+
+ /* Only fast clear if the image itself can be fast cleared. */
+ if (!radv_image_can_fast_clear(device, image))
+ return false;
+
+ /* Only fast clear if all layers are bound. */
+ if (iview->base_layer > 0 ||
+ iview->layer_count != image->info.array_size)
+ return false;
+
+ /* Only fast clear if the view covers the whole image. */
+ if (!radv_image_extent_compare(image, &iview->extent))
+ return false;
+
+ return true;
+}
+
void
radv_image_view_init(struct radv_image_view *iview,
struct radv_device *device,
@@ -1738,6 +1797,9 @@ radv_image_view_init(struct radv_image_view *iview,
}
}
+ iview->support_fast_clear =
+ radv_image_view_can_fast_clear(device, iview);
+
bool disable_compression = extra_create_info ? extra_create_info->disable_compression: false;
for (unsigned i = 0; i < (iview->multiple_planes ? vk_format_get_plane_count(image->vk_format) : 1); ++i) {
VkFormat format = vk_format_get_plane_format(iview->vk_format, i);
diff --git a/src/amd/vulkan/radv_meta_clear.c b/src/amd/vulkan/radv_meta_clear.c
index 64a61855233..2c3dfb52e88 100644
--- a/src/amd/vulkan/radv_meta_clear.c
+++ b/src/amd/vulkan/radv_meta_clear.c
@@ -991,64 +991,6 @@ radv_is_fast_clear_stencil_allowed(VkClearDepthStencilValue value)
return value.stencil == 0;
}
-/**
- * Determine if the given image can be fast cleared.
- */
-static bool
-radv_image_can_fast_clear(struct radv_device *device, struct radv_image *image)
-{
- if (device->instance->debug_flags & RADV_DEBUG_NO_FAST_CLEARS)
- return false;
-
- if (vk_format_is_color(image->vk_format)) {
- if (!radv_image_has_cmask(image) && !radv_image_has_dcc(image))
- return false;
-
- /* RB+ doesn't work with CMASK fast clear on Stoney. */
- if (!radv_image_has_dcc(image) &&
- device->physical_device->rad_info.family == CHIP_STONEY)
- return false;
- } else {
- if (!radv_image_has_htile(image))
- return false;
- }
-
- /* Do not fast clears 3D images. */
- if (image->type == VK_IMAGE_TYPE_3D)
- return false;
-
- return true;
-}
-
-/**
- * Determine if the given image view can be fast cleared.
- */
-static bool
-radv_image_view_can_fast_clear(struct radv_device *device,
- const struct radv_image_view *iview)
-{
- struct radv_image *image;
-
- if (!iview)
- return false;
- image = iview->image;
-
- /* Only fast clear if the image itself can be fast cleared. */
- if (!radv_image_can_fast_clear(device, image))
- return false;
-
- /* Only fast clear if all layers are bound. */
- if (iview->base_layer > 0 ||
- iview->layer_count != image->info.array_size)
- return false;
-
- /* Only fast clear if the view covers the whole image. */
- if (!radv_image_extent_compare(image, &iview->extent))
- return false;
-
- return true;
-}
-
static bool
radv_can_fast_clear_depth(struct radv_cmd_buffer *cmd_buffer,
const struct radv_image_view *iview,
@@ -1059,7 +1001,7 @@ radv_can_fast_clear_depth(struct radv_cmd_buffer *cmd_buffer,
const VkClearDepthStencilValue clear_value,
uint32_t view_mask)
{
- if (!radv_image_view_can_fast_clear(cmd_buffer->device, iview))
+ if (!iview->support_fast_clear)
return false;
if (!radv_layout_is_htile_compressed(cmd_buffer->device, iview->image, image_layout, in_render_loop,
@@ -1629,7 +1571,7 @@ radv_can_fast_clear_color(struct radv_cmd_buffer *cmd_buffer,
{
uint32_t clear_color[2];
- if (!radv_image_view_can_fast_clear(cmd_buffer->device, iview))
+ if (!iview->support_fast_clear)
return false;
if (!radv_layout_can_fast_clear(cmd_buffer->device, iview->image, image_layout, in_render_loop,
diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h
index 8625a2449dc..09dbe148621 100644
--- a/src/amd/vulkan/radv_private.h
+++ b/src/amd/vulkan/radv_private.h
@@ -2170,6 +2170,9 @@ struct radv_image_view {
uint32_t level_count;
VkExtent3D extent; /**< Extent of VkImageViewCreateInfo::baseMipLevel. */
+ /* Whether the image iview supports fast clear. */
+ bool support_fast_clear;
+
union radv_descriptor descriptor;
/* Descriptor for use as a storage image as opposed to a sampled image.