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>
(cherry picked from commit 20c0d169e4)
This commit is contained in:
Lars-Ivar Hesselberg Simonsen 2025-03-18 13:28:41 +01:00 committed by Eric Engestrom
parent f3db21ec11
commit 60a2b66f63
2 changed files with 16 additions and 1 deletions

View file

@ -2084,7 +2084,7 @@
"description": "vk/sync: Fix execution only barriers",
"nominated": true,
"nomination_type": 2,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "97f0a4494b97d89146cf66dfa0c9b1946bf3fc22",
"notes": null

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