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 <mary@mary.zone>
Reviewed-by: Mohamed Ahmed <mohamedahmedegypt2001@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37671>
This commit is contained in:
Mel Henning
2025-09-16 19:37:37 -04:00
committed by Marge Bot
parent 895bbb7601
commit 515793d5bb
+5
View File
@@ -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;