From 515793d5bbe392dc5b5bcea136eb3817f6b32302 Mon Sep 17 00:00:00 2001 From: Mel Henning Date: Tue, 16 Sep 2025 19:37:37 -0400 Subject: [PATCH] nvk: Fix execution deps in pipeline barriers We were under-synchronizing before. In particular, `stages` form execution barriers even in the absence of a memory barrier in the `access` flags. The particular issue that prompted this was one where we weren't waiting on a pipeline barrier in Baldur's Gate 3 with: srcStageMask == VK_PIPELINE_STAGE_2_FRAGMENT_SHADER_BIT && srcAccessMask == VK_ACCESS_2_SHADER_READ_BIT && dstStageMask == (VK_PIPELINE_STAGE_2_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_2_LATE_FRAGMENT_TESTS_BIT) && dstAccessMask == (VK_ACCESS_2_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_2_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT) Based on the spec and discussion in https://github.com/KhronosGroup/Vulkan-Docs/issues/131 the read bit in srcAccessMask doesn't really matter here - what matters is that there's an execution barrier on the fragment stage which needs to prevent the fragment shader exection from overlapping with the later call's fragment tests (which write to the depth attachment). Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/13909 Reviewed-by: Mary Guillemard Reviewed-by: Mohamed Ahmed Part-of: --- src/nouveau/vulkan/nvk_cmd_buffer.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/nouveau/vulkan/nvk_cmd_buffer.c b/src/nouveau/vulkan/nvk_cmd_buffer.c index 59620b5a2dd..3fec5b944d3 100644 --- a/src/nouveau/vulkan/nvk_cmd_buffer.c +++ b/src/nouveau/vulkan/nvk_cmd_buffer.c @@ -22,6 +22,7 @@ #include "clb097.h" #include "clcb97.h" #include "nv_push_cl906f.h" +#include "nv_push_cla16f.h" #include "nv_push_cl9097.h" #include "nv_push_cl90b5.h" #include "nv_push_cla097.h" @@ -452,6 +453,10 @@ nvk_barrier_flushes_waits(VkPipelineStageFlags2 stages, enum nvk_barrier barriers = 0; + if (stages & + vk_expand_pipeline_stage_flags2(VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT)) + barriers |= NVK_BARRIER_WFI; + if (access & VK_ACCESS_2_SHADER_STORAGE_WRITE_BIT) { barriers |= NVK_BARRIER_FLUSH_SHADER_DATA;