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: 97f0a4494b ("vulkan: implement legacy entrypoints on top of VK_KHR_synchronization2")
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34187>
This commit is contained in:
Lars-Ivar Hesselberg Simonsen 2025-03-18 13:28:41 +01:00 committed by Marge Bot
parent 7c73b9a498
commit 20c0d169e4

View file

@ -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);