From 20c0d169e41272d54107024be13ff1e4345c96f9 Mon Sep 17 00:00:00 2001 From: Lars-Ivar Hesselberg Simonsen Date: Tue, 18 Mar 2025 13:28:41 +0100 Subject: [PATCH] vk/sync: Fix execution only barriers With vkCmdPipelineBarrier, it's possible to specify a barrier with pipeline stages but without any memory barriers. These might not be practical, but are legal Vulkan code. Barriers like this are currently ignored in mesa, as we only convert barriers with passed memory barriers into vkCmdPipelineBarrier2. This commit adds handling of execution only barriers by converting them into a memory barrier without access masks. Fixes: 97f0a4494b9 ("vulkan: implement legacy entrypoints on top of VK_KHR_synchronization2") Reviewed-by: Faith Ekstrand Reviewed-by: Lionel Landwerlin Reviewed-by: Erik Faye-Lund Part-of: --- src/vulkan/runtime/vk_synchronization.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/vulkan/runtime/vk_synchronization.c b/src/vulkan/runtime/vk_synchronization.c index 5ec91ee7054..783e7578637 100644 --- a/src/vulkan/runtime/vk_synchronization.c +++ b/src/vulkan/runtime/vk_synchronization.c @@ -209,6 +209,21 @@ vk_common_CmdPipelineBarrier( .pImageMemoryBarriers = image_barriers, }; + VkMemoryBarrier2 exec_barrier = { + .sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER_2, + .pNext = NULL, + .srcStageMask = src_stage_mask2, + .srcAccessMask = 0x0, + .dstStageMask = dst_stage_mask2, + .dstAccessMask = 0x0, + }; + + if (memoryBarrierCount == 0 && bufferMemoryBarrierCount == 0 && + imageMemoryBarrierCount == 0) { + dep_info.memoryBarrierCount = 1; + dep_info.pMemoryBarriers = &exec_barrier; + } + device->dispatch_table.CmdPipelineBarrier2(commandBuffer, &dep_info); STACK_ARRAY_FINISH(memory_barriers);