tu: Fix flushing when using a staging buffer for copies

When doing the flushing, I forgot that because the staging buffer can be
used with different formats with different cpp, we need to make sure
that CCU is properly flushed and invalidated between each copy to the
staging buffer to prevent stale cache entries from creeping in, as the
CCU seems to rely on the cpp staying the same, even on a7xx which
dropped some of the other restrictions like using the same RT
index/layer. For "normal" user-visible copies this is done via
transitioning from UNDEFINED.

Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34611>
(cherry picked from commit ee10938beed3840b9583ad4d67ff96052a9daaf1)
This commit is contained in:
Connor Abbott
2025-04-18 11:57:53 -04:00
committed by Eric Engestrom
parent a05f320447
commit 559d33b2b6
2 changed files with 9 additions and 1 deletions

View File

@@ -364,7 +364,7 @@
"description": "tu: Fix flushing when using a staging buffer for copies", "description": "tu: Fix flushing when using a staging buffer for copies",
"nominated": true, "nominated": true,
"nomination_type": 1, "nomination_type": 1,
"resolution": 0, "resolution": 1,
"main_sha": null, "main_sha": null,
"because_sha": null, "because_sha": null,
"notes": null "notes": null

View File

@@ -2999,8 +2999,16 @@ tu_copy_image_to_image(struct tu_cmd_buffer *cmd,
/* When executed by the user there has to be a pipeline barrier here, /* When executed by the user there has to be a pipeline barrier here,
* but since we're doing it manually we'll have to flush ourselves. * but since we're doing it manually we'll have to flush ourselves.
* Because we may reuse the staging buffer with different
* layouts/formats, we also have to invalidate CCU, which when executed
* by the user would be done before the next use of the staging buffer
* when transitioning from UNDEFINED. Here it's more optimal to
* invalidate right away after flushing instead of before the next copy
* using the staging buffer however, because we don't have to insert
* another WFI.
*/ */
tu_emit_event_write<CHIP>(cmd, cs, FD_CCU_CLEAN_COLOR); tu_emit_event_write<CHIP>(cmd, cs, FD_CCU_CLEAN_COLOR);
tu_emit_event_write<CHIP>(cmd, cs, FD_CCU_INVALIDATE_COLOR);
tu_emit_event_write<CHIP>(cmd, cs, FD_CACHE_INVALIDATE); tu_emit_event_write<CHIP>(cmd, cs, FD_CACHE_INVALIDATE);
tu_cs_emit_wfi(cs); tu_cs_emit_wfi(cs);