Originally posted by Quackdoc
View Post
Drawing with no buffering means the game will draw 1 frame, update the loop, draw next frame, and so on. All the while producing an unstable flickering mess. I have done that in my early attempts on game development, actually. So by definition latency there can be as fast as you can get it.
With double buffering you are guaranteed a worst case latency of one full screen or ~33.33 ms on 60 Hz - provided the game loop runs that fast.
With triple buffering you are guaranteed a worst case latency of REFRESH_RATE * (SCREEN_FREQUENCY / YOUR_FPS) ms. That is, if your refresh rate is ~16.66, 60 Hz and 300 FPS, you will get 16.66 * (60 / 300) = 16.66 * (0.2) = ~3 ms when the screen starts drawing. Add whatever it takes to draw a full screen (10 ms?) and...
Here is a quickly drawn scheduling trace of how things can turn out, let us assume screen is 60 Hz, screen takes 10 ms to draw (SLOOOOOOOW) and game loop draws frames in 6-11 ms (average 8ms) for an average of 91 / 102 / 125 / 167 FPS (0.1% / 1% / avg / max):
Code:
1-------2----------------1---------------2----------------1----------------2------ ... Screen buffer --------|----------------|---------------|----------------|----------------|------ ... Screen updates 2--------3----------1---------3-----2-------3------1--------3--------2---------3-- ... Ready buffer |--------|----------|---------|-----|-------|------|--------|--------|---------|-- ... Game updates 3--------1----------3---------2-----3-------1------3--------2--------3---------1-- ... Active buffer
As can be seen here, biggest latency you get in this example is 8 ms before drawing, with triple buffering. But latency does get as low as 4 ms. This gives a real latency of around 14-18 ms with Triple buffering, since the screen blits out in 10 ms. Note that the game updates has irregular periods. In theory the biggest latency this can have is 21 ms.
Comment