[FFmpeg-cvslog] hwcontext_vulkan: wait on semaphores when exporting to DRM

Lynne git at videolan.org
Fri Dec 10 18:18:49 EET 2021


ffmpeg | branch: master | Lynne <dev at lynne.ee> | Fri Dec 10 17:16:49 2021 +0100| [0c1d47a6b39ba19c0883e6322ca509eb8e73e875] | committer: Lynne

hwcontext_vulkan: wait on semaphores when exporting to DRM

There is no synchronization method for DRM yet.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0c1d47a6b39ba19c0883e6322ca509eb8e73e875
---

 libavutil/hwcontext_vulkan.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index 507c4f4454..83a7527198 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -3301,6 +3301,11 @@ static int vulkan_map_to_drm(AVHWFramesContext *hwfc, AVFrame *dst,
     VkImageDrmFormatModifierPropertiesEXT drm_mod = {
         .sType = VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_PROPERTIES_EXT,
     };
+    VkSemaphoreWaitInfo wait_info = {
+        .sType          = VK_STRUCTURE_TYPE_SEMAPHORE_WAIT_INFO,
+        .flags          = 0x0,
+        .semaphoreCount = planes,
+    };
 
     AVDRMFrameDescriptor *drm_desc = av_mallocz(sizeof(*drm_desc));
     if (!drm_desc)
@@ -3310,6 +3315,12 @@ static int vulkan_map_to_drm(AVHWFramesContext *hwfc, AVFrame *dst,
     if (err < 0)
         goto end;
 
+    /* Wait for the operation to finish so we can cleanly export it. */
+    wait_info.pSemaphores = f->sem;
+    wait_info.pValues     = f->sem_value;
+
+    vk->WaitSemaphores(hwctx->act_dev, &wait_info, UINT64_MAX);
+
     err = ff_hwframe_map_create(src->hw_frames_ctx, dst, src, &vulkan_unmap_to_drm, drm_desc);
     if (err < 0)
         goto end;



More information about the ffmpeg-cvslog mailing list