radv: fix missing L2 cache invalidation with streamout on GFX12

COPY_DATA emitted from the CP isn't coherent with L2, in case the
buffer filled size needs to be copied.

This fixes rare and random flickering with Mafia 3 Definitive Edition
on RDNA4.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/14697
Cc: mesa-stable
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40327>
This commit is contained in:
Samuel Pitoiset 2026-03-10 18:51:55 +01:00 committed by Marge Bot
parent 88a675c1f3
commit d9420eed9e

View file

@ -15333,10 +15333,19 @@ radv_CmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer, uint32_t firstC
assert(firstCounterBuffer + counterBufferCount <= MAX_SO_BUFFERS);
if (pdev->info.gfx_level >= GFX12)
if (pdev->info.gfx_level >= GFX12) {
radv_init_streamout_state(cmd_buffer);
else if (!pdev->use_ngg_streamout)
/* Invalidate L2 in case the buffer filled size needs to be saved because COPY_DATA isn't
* coherent with L2.
*/
if (pdev->info.cp_sdma_ge_use_system_memory_scope) {
cmd_buffer->state.flush_bits |= RADV_CMD_FLAG_INV_L2;
radv_emit_cache_flush(cmd_buffer);
}
} else if (!pdev->use_ngg_streamout) {
radv_flush_vgt_streamout(cmd_buffer);
}
ASSERTED unsigned cdw_max = radeon_check_space(device->ws, cs->b, MAX_SO_BUFFERS * 10);