From 093936817d5df65bc859ddd5b569703239d68a3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Cerveau?= Date: Tue, 30 Jun 2026 18:09:03 +0200 Subject: [PATCH] VulkanDeviceContext: fix assert when getting the queue When the encoder does not find an available queue for the given codec, the encoder init exits and deinit the encoder calling MultiThreadedQueueWaitIdle. But in that method it requires to get the given queue (0) which failed to init. Validate first that there is an existing queue before trying to retrieve it. --- .../libs/VkCodecUtils/VulkanDeviceContext.h | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/common/libs/VkCodecUtils/VulkanDeviceContext.h b/common/libs/VkCodecUtils/VulkanDeviceContext.h index 7f90e316..db4a09a4 100644 --- a/common/libs/VkCodecUtils/VulkanDeviceContext.h +++ b/common/libs/VkCodecUtils/VulkanDeviceContext.h @@ -130,14 +130,24 @@ class VulkanDeviceContext : public vk::VkInterfaceFunctions { m_mutex = &devCtx->m_transferQueueMutex; break; case DECODE: - assert((queueIndex >= 0) && (queueIndex < devCtx->m_videoDecodeNumQueues)); - m_queue = &devCtx->m_videoDecodeQueues[queueIndex]; - m_mutex = &devCtx->m_videoDecodeQueueMutexes[queueIndex]; + if (devCtx->m_videoDecodeNumQueues) { + assert((queueIndex >= 0) && (queueIndex < devCtx->m_videoDecodeNumQueues)); + m_queue = &devCtx->m_videoDecodeQueues[queueIndex]; + m_mutex = &devCtx->m_videoDecodeQueueMutexes[queueIndex]; + } else { + m_queue = nullptr; + m_mutex = nullptr; + } break; case ENCODE: - assert((queueIndex >= 0) && (queueIndex < devCtx->m_videoEncodeNumQueues)); - m_queue = &devCtx->m_videoEncodeQueues[queueIndex]; - m_mutex = &devCtx->m_videoEncodeQueueMutexes[queueIndex]; + if (devCtx->m_videoEncodeNumQueues) { + assert((queueIndex >= 0) && (queueIndex < devCtx->m_videoEncodeNumQueues)); + m_queue = &devCtx->m_videoEncodeQueues[queueIndex]; + m_mutex = &devCtx->m_videoEncodeQueueMutexes[queueIndex]; + } else { + m_queue = nullptr; + m_mutex = nullptr; + } break; case PRESENT: m_queue = &devCtx->m_presentQueue;