Reputation: 1074
How does an OpenGL application with double buffering achieve more than 60 fps (dislay refresh limit)?
Does it depend on driver implementation, namely whether it uses double or tripple buffering?
Consider next application main loop:
while (1) {
draw_scene();
swap_buffers();
}
The second statement in the loop is mandatory if I don't use some fancy synchronization with display vsync and don't want to tearings when displaying images. With such a loop my fps is correlated with driver implementation: with double buffering the pipeline would stall and I archive about 60 fps while with tripple buffrering no stall would occur and my fps depend only on my videocard throughput. So if there is a need to archive high fps opengl application I should have tripple buffering implementation inside application. Am I right?
Upvotes: 0
Views: 1522
Reputation: 162164
How OpenGL application with double buffering archive more than 60 fps (dislay refresh limit)?
By disable synchronisation with the display vertical retrace.
with double buffering the pipeline would stall and I archive about 60 fps while with tripple buffrering no stall would occur and my fps depend only on my videocard throughput.
The only difference between double and triple buffering is the amount of frames "in the queue" for displaying. Effectively it adds another frame of latency. However the total framerate does not increase. Also there's little sense it trying to render more frames per second than the display device can process.
The buffer swap doesn't stall the pipeline! Stalling the pipeline means, that some operation within the pipeline forces the device to flush the whole pipeline and has to replay a significant amount of operations, thereby reducing total throughput. The buffer swap however is a synchronization point, which means that it waits for the pipeline to complete. This is actually desireable, because it gives your GPU and the drivers some time to do other things like cleaning up memory marked for deallocation and similar. The duration SwapBuffers blocks is also beneficial for your programs process, as this gives other threads in your program CPU time, that can be used to process user input, to I/O, networking, etc.
Upvotes: 2