Mesa (main): anv: remove unnecessary Tile Cache flushes
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Jun 15 13:47:24 UTC 2021
Module: Mesa
Branch: main
Commit: 6f26a51f47e2be7ad6c0cc81d07ecf9a49fdf305
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6f26a51f47e2be7ad6c0cc81d07ecf9a49fdf305
Author: Felix DeGrood <felix.j.degrood at intel.com>
Date: Tue Mar 16 21:02:35 2021 -0700
anv: remove unnecessary Tile Cache flushes
On Gfx12+, flushing tile cache ensures color/depth values are
globally visible, but that's expensive. Most operations only
need values to be GT-visible which can be achieved with depth
or rt flush. Remove a bunch of unnecessary Tile Cache flushes.
Fast clears and slow depth clears still require Tile Cache flush.
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9834>
---
src/intel/vulkan/anv_blorp.c | 3 +++
src/intel/vulkan/anv_private.h | 10 +++++++---
src/intel/vulkan/genX_cmd_buffer.c | 27 ++++++++-------------------
3 files changed, 18 insertions(+), 22 deletions(-)
diff --git a/src/intel/vulkan/anv_blorp.c b/src/intel/vulkan/anv_blorp.c
index 2deeaa63953..8f1ee0c71a6 100644
--- a/src/intel/vulkan/anv_blorp.c
+++ b/src/intel/vulkan/anv_blorp.c
@@ -1657,6 +1657,7 @@ anv_image_clear_depth_stencil(struct anv_cmd_buffer *cmd_buffer,
*/
anv_add_pending_pipe_bits(cmd_buffer,
ANV_PIPE_RENDER_TARGET_CACHE_FLUSH_BIT |
+ ANV_PIPE_TILE_CACHE_FLUSH_BIT |
ANV_PIPE_END_OF_PIPE_SYNC_BIT,
"after clear DS");
@@ -1846,6 +1847,7 @@ anv_image_mcs_op(struct anv_cmd_buffer *cmd_buffer,
*/
anv_add_pending_pipe_bits(cmd_buffer,
ANV_PIPE_RENDER_TARGET_CACHE_FLUSH_BIT |
+ ANV_PIPE_TILE_CACHE_FLUSH_BIT |
ANV_PIPE_END_OF_PIPE_SYNC_BIT,
"before fast clear mcs");
@@ -1931,6 +1933,7 @@ anv_image_ccs_op(struct anv_cmd_buffer *cmd_buffer,
*/
anv_add_pending_pipe_bits(cmd_buffer,
ANV_PIPE_RENDER_TARGET_CACHE_FLUSH_BIT |
+ ANV_PIPE_TILE_CACHE_FLUSH_BIT |
ANV_PIPE_END_OF_PIPE_SYNC_BIT,
"before fast clear ccs");
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index f0ba263e9cf..9acc39b6885 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -2482,14 +2482,16 @@ anv_pipe_flush_bits_for_access_flags(struct anv_device *device,
* target. To make its content available to future operations, flush
* the render target cache.
*/
- pipe_bits |= ANV_PIPE_RENDER_TARGET_CACHE_FLUSH_BIT;
+ pipe_bits |= ANV_PIPE_RENDER_TARGET_CACHE_FLUSH_BIT |
+ ANV_PIPE_TILE_CACHE_FLUSH_BIT;
break;
case VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT:
/* We're transitioning a buffer that was previously used as depth
* buffer. To make its content available to future operations, flush
* the depth cache.
*/
- pipe_bits |= ANV_PIPE_DEPTH_CACHE_FLUSH_BIT;
+ pipe_bits |= ANV_PIPE_DEPTH_CACHE_FLUSH_BIT |
+ ANV_PIPE_TILE_CACHE_FLUSH_BIT;
break;
case VK_ACCESS_TRANSFER_WRITE_BIT:
/* We're transitioning a buffer that was previously used as a
@@ -2505,7 +2507,8 @@ anv_pipe_flush_bits_for_access_flags(struct anv_device *device,
* to future operations. And for depth related operations we also
* need to flush the depth cache.
*/
- pipe_bits |= ANV_PIPE_RENDER_TARGET_CACHE_FLUSH_BIT;
+ pipe_bits |= ANV_PIPE_RENDER_TARGET_CACHE_FLUSH_BIT |
+ ANV_PIPE_TILE_CACHE_FLUSH_BIT;
pipe_bits |= ANV_PIPE_DEPTH_CACHE_FLUSH_BIT;
break;
case VK_ACCESS_MEMORY_WRITE_BIT:
@@ -2546,6 +2549,7 @@ anv_pipe_invalidate_bits_for_access_flags(struct anv_device *device,
* UBO from the buffer, so we need to invalidate constant cache.
*/
pipe_bits |= ANV_PIPE_CONSTANT_CACHE_INVALIDATE_BIT;
+ pipe_bits |= ANV_PIPE_TILE_CACHE_FLUSH_BIT;
break;
case VK_ACCESS_INDEX_READ_BIT:
case VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT:
diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c
index 386add26e00..787fde6495f 100644
--- a/src/intel/vulkan/genX_cmd_buffer.c
+++ b/src/intel/vulkan/genX_cmd_buffer.c
@@ -636,7 +636,8 @@ transition_depth_buffer(struct anv_cmd_buffer *cmd_buffer,
/* Getting into the pass-through state for Depth is tricky and involves
* both a resolve and an ambiguate. We don't handle that state right now
- * as anv_layout_to_aux_state never returns it.
+ * as anv_layout_to_aux_state never returns it. Resolve/ambiguate will
+ * trigger depth clears which require tile cache flushes.
*/
assert(final_state != ISL_AUX_STATE_PASS_THROUGH);
@@ -644,10 +645,16 @@ transition_depth_buffer(struct anv_cmd_buffer *cmd_buffer,
assert(initial_hiz_valid);
anv_image_hiz_op(cmd_buffer, image, VK_IMAGE_ASPECT_DEPTH_BIT,
0, base_layer, layer_count, ISL_AUX_OP_FULL_RESOLVE);
+ anv_add_pending_pipe_bits(cmd_buffer,
+ ANV_PIPE_TILE_CACHE_FLUSH_BIT,
+ "after depth resolve");
} else if (final_needs_hiz && !initial_hiz_valid) {
assert(initial_depth_valid);
anv_image_hiz_op(cmd_buffer, image, VK_IMAGE_ASPECT_DEPTH_BIT,
0, base_layer, layer_count, ISL_AUX_OP_AMBIGUATE);
+ anv_add_pending_pipe_bits(cmd_buffer,
+ ANV_PIPE_TILE_CACHE_FLUSH_BIT,
+ "after hiz resolve");
}
}
@@ -2153,24 +2160,6 @@ genX(cmd_buffer_apply_pipe_flushes)(struct anv_cmd_buffer *cmd_buffer)
bits &= ~ANV_PIPE_NEEDS_END_OF_PIPE_SYNC_BIT;
}
- if (GFX_VER >= 12 &&
- ((bits & ANV_PIPE_DEPTH_CACHE_FLUSH_BIT) ||
- (bits & ANV_PIPE_RENDER_TARGET_CACHE_FLUSH_BIT))) {
- /* From the PIPE_CONTROL instruction table, bit 28 (Tile Cache Flush
- * Enable):
- *
- * Unified Cache (Tile Cache Disabled):
- *
- * When the Color and Depth (Z) streams are enabled to be cached in
- * the DC space of L2, Software must use "Render Target Cache Flush
- * Enable" and "Depth Cache Flush Enable" along with "Tile Cache
- * Flush" for getting the color and depth (Z) write data to be
- * globally observable. In this mode of operation it is not required
- * to set "CS Stall" upon setting "Tile Cache Flush" bit.
- */
- bits |= ANV_PIPE_TILE_CACHE_FLUSH_BIT;
- }
-
/* Wa_1409226450, Wait for EU to be idle before pipe control which
* invalidates the instruction cache
*/
More information about the mesa-commit
mailing list