Commit dc54ec7a0d for ffmpeg
commit dc54ec7a0dccb411313361ffd702e0e389e79748
Author: Tymur Boiko <tboiko@nvidia.com>
Date: Fri Oct 16 22:01:25 2026 +0200
lavu/vulkan: wait for the frame timeline before the export layout transition
switch_layout() submits vkCmdPipelineBarrier2 on the compute queue. The
image was last written by vkCmdDecodeVideoKHR on the video queue, which
signals the frame timeline at VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR.
The layout transition is a write, and the cross-queue order is that
semaphore wait. VK_PIPELINE_STAGE_2_NONE names no stage, so the barrier
was outside the wait and raced VK_ACCESS_2_VIDEO_DECODE_WRITE_BIT_KHR
(SYNC-HAZARD-WRITE-AFTER-WRITE). Wait at
VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT so every command in the submission,
including the transition, happens after the signal.
diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index 63d2ab5c43..72e4df26c8 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -2644,8 +2644,10 @@ static int switch_layout(AVHWFramesContext *hwfc, FFVkExecPool *ectx,
if (err < 0)
return err;
+ /* NONE does not block any stage, so this queue's layout transition
+ * races a decode write submitted on the video queue. */
err = ff_vk_exec_add_dep_frame(&p->vkctx, exec, &tmp_frame,
- VK_PIPELINE_STAGE_2_NONE,
+ VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT);
if (err < 0)
return err;