Skip to content

Commit

Permalink
Fix excessive latency with Vulkan video decoding on Nvidia
Browse files Browse the repository at this point in the history
For yet unknown reasons, high frame queue delay leads to massive decode latency.
  • Loading branch information
cgutman committed Sep 17, 2024
1 parent 1caee72 commit f786e94
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/streaming/video/ffmpeg-renderers/plvk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit f786e94

Please sign in to comment.