Fix some error handling in the libplacebo renderer

This commit is contained in:
Cameron Gutman committed 2026-10-24 22:41:06 -05:00
1 parent 6fc7e81683
commit ac296864ac
1 file changed
+11
@@ -769,6 +769,7 @@ bool PlVkRenderer::populateQueues(int videoFormat)
vkDeviceContext->nb_comp_queues = m_Vulkan->queue_compute.count; vkDeviceContext->nb_comp_queues = m_Vulkan->queue_compute.count;
// Select a video decode queue that is capable of decoding our chosen format // Select a video decode queue that is capable of decoding our chosen format
vkDeviceContext->queue_family_decode_index = -1;
for (uint32_t i = 0; i < queueFamilyCount; i++) { for (uint32_t i = 0; i < queueFamilyCount; i++) {
if (queueFamilies[i].queueFamilyProperties.queueFlags & VK_QUEUE_VIDEO_DECODE_BIT_KHR) { if (queueFamilies[i].queueFamilyProperties.queueFlags & VK_QUEUE_VIDEO_DECODE_BIT_KHR) {
if (videoFormat & VIDEO_FORMAT_MASK_H264) { if (videoFormat & VIDEO_FORMAT_MASK_H264) {
@@ -897,6 +898,16 @@ void PlVkRenderer::waitToRender()
return; return;
} }
// If a swapchain (re)creation failed, m_Swapchain is NULL. We can't render
// or resize it, and a device reset has already been requested, so skip this
// frame and let the main thread recreate the renderer.
if (m_Swapchain == nullptr) {
SDL_Event event;
event.type = SDL_RENDER_DEVICE_RESET;
SDL_PushEvent(&event);
return;
}
#ifndef Q_OS_WIN32 #ifndef Q_OS_WIN32
// With libplacebo's Vulkan backend, all swap_buffers does is wait for queued // With libplacebo's Vulkan backend, all swap_buffers does is wait for queued
// presents to finish. This happens to be exactly what we want to do here, since // presents to finish. This happens to be exactly what we want to do here, since