From bb8e22981461dae8af885f693d4468aed2991c69 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Tue, 26 Dec 2023 15:45:31 -0600 Subject: [PATCH] Swap buffers in waitToRender() instead of renderFrame() --- app/streaming/video/ffmpeg-renderers/plvk.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/streaming/video/ffmpeg-renderers/plvk.cpp b/app/streaming/video/ffmpeg-renderers/plvk.cpp index 9d671577..674778ca 100644 --- a/app/streaming/video/ffmpeg-renderers/plvk.cpp +++ b/app/streaming/video/ffmpeg-renderers/plvk.cpp @@ -593,6 +593,12 @@ bool PlVkRenderer::isSurfacePresentationSupportedByPhysicalDevice(VkPhysicalDevi void PlVkRenderer::waitToRender() { + // 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 + // it lets us wait to select a queued frame for rendering until we know that we + // can present without blocking in renderFrame(). + pl_swapchain_swap_buffers(m_Swapchain); + // Handle the swapchain being resized int vkDrawableW, vkDrawableH; SDL_Vulkan_GetDrawableSize(m_Window, &vkDrawableW, &vkDrawableH); @@ -755,7 +761,6 @@ void PlVkRenderer::renderFrame(AVFrame *frame) SDL_PushEvent(&event); goto UnmapExit; } - pl_swapchain_swap_buffers(m_Swapchain); UnmapExit: // Delete any textures that need to be destroyed