From f786e94c7b2f943e24e65d7d74deb539b827fc84 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Mon, 16 Sep 2024 21:59:17 -0500 Subject: [PATCH] Fix excessive latency with Vulkan video decoding on Nvidia For yet unknown reasons, high frame queue delay leads to massive decode latency. --- app/streaming/video/ffmpeg-renderers/plvk.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/streaming/video/ffmpeg-renderers/plvk.cpp b/app/streaming/video/ffmpeg-renderers/plvk.cpp index b7089b8b..46c33361 100644 --- a/app/streaming/video/ffmpeg-renderers/plvk.cpp +++ b/app/streaming/video/ffmpeg-renderers/plvk.cpp @@ -661,11 +661,16 @@ void PlVkRenderer::waitToRender() return; } +#ifndef Q_OS_WIN32 // 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(). + // + // NB: This seems to cause performance problems with the Windows display stack + // (particularly on Nvidia) so we will only do this for non-Windows platforms. pl_swapchain_swap_buffers(m_Swapchain); +#endif // Handle the swapchain being resized int vkDrawableW, vkDrawableH; @@ -818,6 +823,12 @@ void PlVkRenderer::renderFrame(AVFrame *frame) goto UnmapExit; } +#ifdef Q_OS_WIN32 + // On Windows, we swap buffers here instead of waitToRender() + // to avoid some performance problems on Nvidia GPUs. + pl_swapchain_swap_buffers(m_Swapchain); +#endif + UnmapExit: // Delete any textures that need to be destroyed for (pl_tex texture : texturesToDestroy) {