[osg-users] Enabling Vsync gives dramatic increase in latency

Björn Blissing bjorn.blissing at vti.se
Fri Apr 17 09:55:48 PDT 2015


Jan Ciger wrote:
> 
> Yes, but not consistently for every frame. Assuming that each frame you are drawing takes the same time, you need "to get lucky" for that to happen and then the next frame is going to have a much higher latency.


Of course! I am certainly not claiming that hitting optimal latency is possible in every frame. 


Jan Ciger wrote:
> When you do get lucky, the next frame buffer swap will happen slightly earlier now relative to the start of the scanout, because you didn't start drawing after the vsync event but earlier. This will keep going on for several frames, shifting the buffer swap point earlier and earlier relative to the scanout cycle until you, again, hit that sweet spot where you measure the low latency. Your measurement shows this "beating" between the scanout/display update frequency and your buffer swaps (when you are starting the timer, I presume) quite nicely. 


Yes, this pretty much shows the phase difference between the frequency of frame calls from the CPU and the screen refresh frequency.


Jan Ciger wrote:
> The best you can do from the latency point of view is to synchronize to the scanout using the fences. Then you will have always at most one frame latency (the GPU is scanning out the previous frame from the front buffer while you are drawing the current one in the back buffer) if you can fit your drawing calls within the duration of a single frame.


Yes, this was my goal, but the problem was that I initially saw much higher values and was trying to get then down to around one frame of added latency when using Vsync On. The NVIDIA settings are not that helpful and even with the SYNC_SWAP_BUFFERS I still is unable to hit as low latencies as if I use the custom settings (whose inner workings are hidden).

My example is very synthetic and very far from normal rendering, but my idea was to find any latency bottlenecks which was caused by application- and driver settings.


Jan Ciger wrote:
> Don't get confused by the "late latching" tricks that Oculus is promoting. That has nothing to do with display latency but user input/tracking one. There they incorporate the tracking data at the very end of the rendering process just before the buffer swap, achieving very low apparent input latency relative to when the frame is going to be scanned out. But the display latency (the time from buffer swap to pixels changing on the screen) is unaffected by that.
> 


Valve is using another idea, which Alex Vlachos presented at GDC. They start rendering of a new frame 2 ms before VSync. Using some clever tricks to detect when Vsync is about to occur:

See page 14-23 in the PDF at:
http://media.steampowered.com/apps/valve/2015/Alex_Vlachos_Advanced_VR_Rendering_GDC2015.pdf

Regards
Björn

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=63462#63462








More information about the osg-users mailing list