summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>2023-05-12 16:20:57 +0300
committerMarge Bot <emma+marge@anholt.net>2023-05-17 22:01:31 +0000
commit1a89b1a3012d98586fa6e9fbd85516e2f67f6817 (patch)
tree275f35ceac5a59d39e8c60e5faa108d9f21e5508
parente7ec41014165544362e1ae80f6fa99bab7621e79 (diff)
downloadmesa-1a89b1a3012d98586fa6e9fbd85516e2f67f6817.tar.gz
anv: mark images compressed for untracked layout/access
Most of the compressed writes are tracked by the driver, for instances : - blorp writes - render target writes But we don't have any tracking for storage images (which have gained compression support on DG2+). So inspect the layout transition and when we see a layout/access that can do writes outside of our driver tracking, update the image state tracking. Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Cc: mesa-stable Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/8946 Reviewed-by: Tapani Pälli <tapani.palli@intel.com> Reviewed-by: Nanley Chery <nanley.g.chery@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22988>
-rw-r--r--src/intel/vulkan/anv_image.c42
-rw-r--r--src/intel/vulkan/anv_private.h6
-rw-r--r--src/intel/vulkan/genX_cmd_buffer.c20
3 files changed, 68 insertions, 0 deletions
diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index 6c8d2c76aee..eeb8cde5d3d 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -2365,6 +2365,48 @@ anv_layout_to_fast_clear_type(const struct intel_device_info * const devinfo,
}
+/**
+ * This function determines if the layout & usage of an image can have
+ * untracked aux writes. When we see a transition that matches this criteria,
+ * we need to mark the image as compressed written so that our predicated
+ * resolves work properly.
+ *
+ * @param devinfo The device information of the Intel GPU.
+ * @param image The image that may contain a collection of buffers.
+ * @param aspect The aspect of the image to be accessed.
+ * @param layout The current layout of the image aspect(s).
+ */
+bool
+anv_layout_has_untracked_aux_writes(const struct intel_device_info * const devinfo,
+ const struct anv_image * const image,
+ const VkImageAspectFlagBits aspect,
+ const VkImageLayout layout)
+{
+ const VkImageUsageFlags image_aspect_usage =
+ vk_image_usage(&image->vk, aspect);
+ const VkImageUsageFlags usage =
+ vk_image_layout_to_usage_flags(layout, aspect) & image_aspect_usage;
+
+ /* Storage is the only usage where we do not write the image through a
+ * render target but through a descriptor. Since VK_EXT_descriptor_indexing
+ * and the update-after-bind feature, it has become impossible to track
+ * writes to images in descriptor at the command buffer build time. So it's
+ * not possible to mark an image as compressed like we do in
+ * genX_cmd_buffer.c(EndRendering) or anv_blorp.c for all transfer
+ * operations.
+ */
+ if (!(usage & VK_IMAGE_USAGE_STORAGE_BIT))
+ return false;
+
+ /* No AUX, no writes to the AUX surface :) */
+ const uint32_t plane = anv_image_aspect_to_plane(image, aspect);
+ const enum isl_aux_usage aux_usage = image->planes[plane].aux_usage;
+ if (aux_usage == ISL_AUX_USAGE_NONE)
+ return false;
+
+ return true;
+}
+
static struct anv_state
alloc_bindless_surface_state(struct anv_device *device)
{
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index e4a29bd9a5b..64392942be6 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -4080,6 +4080,12 @@ anv_layout_to_fast_clear_type(const struct intel_device_info * const devinfo,
const VkImageAspectFlagBits aspect,
const VkImageLayout layout);
+bool ATTRIBUTE_PURE
+anv_layout_has_untracked_aux_writes(const struct intel_device_info * const devinfo,
+ const struct anv_image * const image,
+ const VkImageAspectFlagBits aspect,
+ const VkImageLayout layout);
+
static inline bool
anv_image_aspects_compatible(VkImageAspectFlags aspects1,
VkImageAspectFlags aspects2)
diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c
index 3fa7a61c1c4..10c6c975ead 100644
--- a/src/intel/vulkan/genX_cmd_buffer.c
+++ b/src/intel/vulkan/genX_cmd_buffer.c
@@ -4000,6 +4000,26 @@ cmd_buffer_barrier(struct anv_cmd_buffer *cmd_buffer,
false /* will_full_fast_clear */);
}
}
+
+ /* Mark image as compressed if the destination layout has untracked
+ * writes to the aux surface.
+ */
+ VkImageAspectFlags aspects =
+ vk_image_expand_aspect_mask(&image->vk, range->aspectMask);
+ anv_foreach_image_aspect_bit(aspect_bit, image, aspects) {
+ VkImageAspectFlagBits aspect = 1UL << aspect_bit;
+ if (anv_layout_has_untracked_aux_writes(
+ cmd_buffer->device->info,
+ image, aspect,
+ img_barrier->newLayout)) {
+ for (uint32_t l = 0; l < level_count; l++) {
+ set_image_compressed_bit(cmd_buffer, image, aspect,
+ range->baseMipLevel + l,
+ base_layer, layer_count,
+ true);
+ }
+ }
+ }
}
enum anv_pipe_bits bits =