Change #264139
| Category | ffmpeg |
| Changed by | Tymur Boiko <tboiko@nvidia.com> |
| Changed at | Fri 10 Apr 2026 13:39:40 |
| Repository | https://git.ffmpeg.org/ffmpeg.git |
| Project | ffmpeg |
| Branch | master |
| Revision | 25e187f8494966377a4b9d077260ce7b501a911c |
Comments
vulkan: fix DRM map, decode barriers, and video frame setup for modifier output When mapping Vulkan Video frames to DMA-BUF, synchronize using an exportable binary semaphore and sync_fd where supported. Submit a lightweight exec that waits on each plane's timeline semaphore at the current value, signals a SYNC_FD-exportable binary semaphore, then export with vkGetSemaphoreFdKHR. Store that binary semaphore in AVVkFrameInternal and reuse it across maps instead of creating and destroying each time: for VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT, copy transference means a successful vkGetSemaphoreFdKHR unsignals the semaphore like a wait, so it can be signaled again on the next map submit. If export is unavailable, fall back to vkWaitSemaphores. Moved drm_sync_sem destroy to vulkan_free_internal Export dma-buf fds with GetMemoryFdKHR for each populated f->mem[i], iterating up to the sw_format plane count instead of stopping at the image count, so multi-memory bindings are not skipped. Describe DRM layers using max(sw planes, image count) and query subresource layout with the correct aspect and image index when one VkImage backs multiple planes. Reference the source hw_frames_ctx on the mapped frame and close dma-buf fds on failure paths. For DMA-BUF-capable pools, honor VK_EXTERNAL_MEMORY_FEATURE_DEDICATED_ONLY_BIT from format export queries when binding memory. With DRM modifiers and a video profile in create_pnext, preserve caller usage and image flags instead of overwriting them from generic supported_usage probing; use the modifier list create info when probing export flags for modifier tiling. Include VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR from the output frames context's usage together with DST (fixes VUID-VkVideoBeginCodingInfoKHR-slotIndex-07245) instead of adding DPB usage only when !is_current. In ff_vk_decode_add_slice, pass VkVideoProfileListInfoKHR (from the output frames context's create_pnext) as the pNext argument to ff_vk_get_pooled_buffer instead of the full create_pnext chain. In ff_vk_frame_params, set tiling to OPTIMAL only when it is not already DRM_FORMAT_MODIFIER_EXT. In ff_vk_decode_init, when the output pool's create_pnext includes VkImageDrmFormatModifierListCreateInfoEXT, initialize the DPB pool with that modifier-list pNext and DRM_FORMAT_MODIFIER_EXT tiling; otherwise use VkVideoProfileListInfoKHR and OPTIMAL as before. When VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_DISTINCT_BIT_KHR is unset, the output and DPB pools cannot use different layouts or tiling, so the DPB pool must match the output pool. Also fix av_hwframe_map ioctl sync_fd export, multi-planar semaphore handling, and related failure-path cleanup. Signed-off-by: Tymur Boiko <tboiko@nvidia.com>
Changed files
- libavcodec/vulkan_decode.c
- libavutil/hwcontext_vulkan.c