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>
This commit is contained in:
Lionel Landwerlin
2023-05-12 16:20:57 +03:00
committed by Marge Bot
parent e7ec410141
commit 1a89b1a301
3 changed files with 68 additions and 0 deletions

View File

@@ -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)
{

View File

@@ -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)

View File

@@ -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 =