From 3deb030f7998ce1eb2d93abf92d4e00ff2b7b748 Mon Sep 17 00:00:00 2001 From: solidv Date: Thu, 10 Sep 2026 13:52:39 +0100 Subject: [PATCH] fix(linux/vulkan): use vkGetDeviceQueue2 with FFmpeg 9.0 queue flags FFmpeg 9.0 creates its Vulkan device queues with VK_DEVICE_QUEUE_CREATE_INTERNALLY_SYNCHRONIZED_BIT_KHR when VK_KHR_internally_synchronized_queues is available, and fetches them with vkGetDeviceQueue2. The Vulkan spec requires vkGetDeviceQueue2 for such queues; plain vkGetDeviceQueue returns an incompatible queue handle, which broke synchronization between the compute pipeline and the encoder and stopped Vulkan encoding from working. Retrieve the queue with vkGetDeviceQueue2 using AVVulkanDeviceContext::queue_flags on FFmpeg >= 9.0 (lavu >= 60.32.100), and fall back to vkGetDeviceQueue for older FFmpeg. --- src/platform/linux/vulkan_encode.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/platform/linux/vulkan_encode.cpp b/src/platform/linux/vulkan_encode.cpp index fef11ad48..b8ef5310e 100644 --- a/src/platform/linux/vulkan_encode.cpp +++ b/src/platform/linux/vulkan_encode.cpp @@ -20,6 +20,7 @@ extern "C" { #include #include #include +#include } #include "graphics.h" @@ -232,7 +233,19 @@ namespace vk { return -1; } +#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(60, 32, 100) + // FFmpeg 9.0+ may create its queues with VK_DEVICE_QUEUE_CREATE_INTERNALLY_SYNCHRONIZED_BIT_KHR + // (when VK_KHR_internally_synchronized_queues is available). The Vulkan spec requires + // vkGetDeviceQueue2 to retrieve such queues; plain vkGetDeviceQueue would return an + // incompatible queue handle, breaking synchronization with the encoder. + VkDeviceQueueInfo2 queue_info = {VK_STRUCTURE_TYPE_DEVICE_QUEUE_INFO_2}; + queue_info.flags = vk_dev.ctx->queue_flags; + queue_info.queueFamilyIndex = vk_dev.compute_qf; + queue_info.queueIndex = 0; + vkGetDeviceQueue2(vk_dev.dev, &queue_info, &vk_dev.compute_queue); +#else vkGetDeviceQueue(vk_dev.dev, vk_dev.compute_qf, 0, &vk_dev.compute_queue); +#endif // Load extension functions vk_dev.getMemoryFdProperties = (PFN_vkGetMemoryFdPropertiesKHR)