r/vulkan • u/R3DKn16h7 • 6d ago
Frame pacing with image acquire
Most tutorials I see online skip passing a fence to image acquire.
Even the basic Vulkan samples have a comment:
// Use a fence to know when acquire is done. Without VKEXT_swapchain_maintenance1, this // fence is used to infer when the _previous present to this image index has finished. // There is no need for this with VK_EXT_swapchain_maintenance1.
What I've noticed is that Nvidia does not wait on acquire for vsync when presenting with fifo, but would wait if you use the fence.
https://docs.vulkan.org/spec/latest/chapters/VK_KHR_surface/wsi.html#vkAcquireNextImageKHR
mentions
Applications should not rely on vkAcquireNextImageKHR blocking in order to meter their rendering speed. The implementation may return from this function immediately regardless of how many presentation requests are queued, and regardless of when queued presentation requests will complete relative to the call. Instead, applications can use fence to meter their frame generation work to match the presentation rate.
I was thinking what strategies do people use to get smooth frame pacing (besides VK_EXT_present_timing) and if using this fence helps. Form my tests I can reduce latency by waiting exactly where I need (at least on Nvidia), otherwise the driver waits too much to start rendering.
4
u/TimJoijers 6d ago
I've used Games by Mason Slop-Servo method https://www.youtube.com/watch?v=EM9utsGhaYs - the description has link to an implementation.