PR #25161 opened by philipl
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25161
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25161.patch

This is the same principle as in dc54ec7a0dc.

The imported sync file is used to order access relative to the external
operations but the frame itself may have been operated on within our
Vulkan context on a different queue, and we must synchronise against those
operations as well. That means waiting at VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT
rather than VK_PIPELINE_STAGE_2_NONE.



>From 59f2be4434b056f8c331587c562a92d383443fa1 Mon Sep 17 00:00:00 2001
From: Philip Langdale <[email protected]>
Date: Mon, 31 Aug 2026 11:45:41 -0700
Subject: [PATCH] avutil/hwcontext_vulkan: wait for the frame timeline befor
 mapping drm frames

This is the same principle as in dc54ec7a0dc.

The imported sync file is used to order access relative to the external
operations but the frame itself may have been operated on within our
Vulkan context on a different queue, and we must synchronise against those
operations as well. That means waiting at VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT
rather than VK_PIPELINE_STAGE_2_NONE.
---
 libavutil/hwcontext_vulkan.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index 72e4df26c8..8e17f258f0 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -3922,8 +3922,13 @@ static int 
vulkan_map_from_drm_frame_sync(AVHWFramesContext *hwfc, AVFrame *dst,
                                     drm_sync_sem, desc->nb_objects,
                                     VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT, 1);
 
+        /* The imported DRM sync file only orders the external data, not this
+         * frame's earlier use by FFmpeg. The frame may be recycled from the
+         * pool while it is still in flight (and last used on another queue),
+         * so the map waits on its last signal, at ALL_COMMANDS, to be ordered
+         * after that previous use. */
         err = ff_vk_exec_add_dep_frame(&p->vkctx, exec, dst,
-                                       VK_PIPELINE_STAGE_2_NONE,
+                                       VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
                                        VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT);
         if (err < 0) {
             ff_vk_exec_discard(&p->vkctx, exec);
-- 
2.54.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to