Digging Deeper: Galloping Horses Example

Rather than pull out a bunch of math and traditional timing diagrams, we've decided to put together a more straight forward presentation. The diagrams we will use show the frames of an actual animation that would be generated over time as well as what would be seen on the monitor for each method. Hopefully this will help illustrate the quantitative and qualitative differences between the approaches.

Our example consists of a fabricated example (based on an animation example courtesy of Wikipedia) of a "game" rendering a horse galloping across the screen. The basics of this timeline are that our game is capable of rendering at 5 times our refresh rate (it can render 5 different frames before a new one gets swapped to the front buffer). The consistency of the frame rate is not realistic either, as some frames will take longer than others. We cut down on these and other variables for simplicity sake. We'll talk about timing and lag in more detail based on a 60Hz refresh rate and 300 FPS performance, but we didn't want to clutter the diagram too much with times and labels. Obviously this is a theoretical example, but it does a good job of showing the idea of what is happening.

First up, we'll look at double buffering without vsync. In this case, the buffers are swapped as soon as the game is done drawing a frame. This immediately preempts what is being sent to the display at the time. Here's what it looks like in this case:

 


Good performance but with quality issues.


 

The timeline is labeled 0 to 15, and for those keeping count, each step is 3 and 1/3 milliseconds. The timeline for each buffer has a picture on it in the 3.3 ms interval during which the a frame is completed corresponding to the position of the horse and rider at that time in realtime. The large pictures at the bottom of the image represent the image displayed at each vertical refresh on the monitor. The only images we actually see are the frames that get sent to the display. The benefit of all the other frames are to minimize input lag in this case.

We can certainly see, in this extreme case, what bad tearing could look like. For this quick and dirty example, I chose only to composite three frames of animation, but it could be more or fewer tears in reality. The number of different frames drawn to the screen correspond to the length of time it takes for the graphics hardware to send the frame to the monitor. This will happen in less time than the entire interval between refreshes, but I'm not well versed enough in monitor technology to know how long that is. I sort of threw my dart at about half the interval being spent sending the frame for the purposes of this illustration (and thus parts of three completed frames are displayed). If I had to guess, I think I overestimated the time it takes to send a frame to the display.

For the above, FRAPS reported framerate would be 300 FPS, but the actual number of full images that get flashed up on the screen is always only a maximum of the refresh rate (in this example, 60 frames every second). The latency between when a frame is finished rendering and when it starts to appear on screen (this is input latency) is less than 3.3ms.

When we turn on vsync, the tearing goes away, but our real performance goes down and input latency goes up. Here's what we see.

 


Good quality, but bad performance and input lag.


 

If we consider each of these diagrams to be systems rendering the exact same thing starting at the exact same time, we can can see how far "behind" this rendering is. There is none of the tearing that was evident in our first example, but we pay for that with outdated information. In addition, the actual framerate in addition to the reported framerate is 60 FPS. The computer ends up doing a lot less work, of course, but it is at the expense of realized performance despite the fact that we cannot actually see more than the 60 images the monitor displays every second.

Here, the price we pay for eliminating tearing is an increase in latency from a maximum of 3.3ms to a maximum of 13.3ms. With vsync on a 60Hz monitor, the maximum latency that happens between when a rendering if finished and when it is displayed is a full 1/60 of a second (16.67ms), but the effective latency that can be incurred will be higher. Since no more drawing can happen after the next frame to be displayed is finished until it is swapped to the front buffer, the real effect of latency when using vsync will be more than a full vertical refresh when rendering takes longer than one refresh to complete.

Moving on to triple buffering, we can see how it combines the best advantages of the two double buffering approaches.

 


The best of both worlds.


 

And here we are. We are back down to a maximum of 3.3ms of input latency, but with no tearing. Our actual performance is back up to 300 FPS, but this may not be reported correctly by a frame counter that only monitors front buffer flips. Again, only 60 frames actually get pasted up to the monitor every second, but in this case, those 60 frames are the most recent frames fully rendered before the next refresh.

While there may be parts of the frames in double buffering without vsync that are "newer" than corresponding parts of the triple buffered frame, the price that is paid for that is potential visual corruption. The real kicker is that, if you don't actually see tearing in the double buffered case, then those partial updates are not different enough than the previous frame(s) to have really mattered visually anyway. In other words, only when you see the tear are you really getting any useful new information. But how useful is that new information if it only comes with tearing?

What are Double Buffering, vsync and Triple Buffering? Wrapping It Up
Comments Locked

184 Comments

View All Comments

  • The0ne - Friday, June 26, 2009 - link

    I truly believe this article and the arguments are really for the hardcore gamers. I game myself but rarely do I care for the few minor issues that occur every now and then. If you're not a hardcore gamer it's really not an issue whether you have any of these options on.
  • OblivionLord - Friday, June 26, 2009 - link

    What i would like to see in the tests is multiple passes and some custom test runs ingame using while frabs to capture the framecount.. not just complete synthetic benching using either the ingame timedemo or a custom timedemo. This way things are a bit more realistic to how the benches reflect gameplay performance.

    Also throw in the Min and Max framerates for those that want to know. Not just limit us to the AVG.

    This triple buffering issue is just small fries compared to the overall method of how this site conducts its tests to other sites.
  • ereetos - Friday, June 26, 2009 - link

    In some games, extremely high FPS will distort the physics in games (e.g. quake, call of duty)

    with your video card rendering 125 fps, you can move faster than people running 60fps, shoot faster, and jump further. When you bump that up to 250 fps, you have an increased advantage which is why multiplayer gets capped to 250fps by punkbuster software.

    If you enable triple buffer, but no vsync, will this still be the case? or will the game engine interpret it as a lower frame rate?
  • DerekWilson - Friday, June 26, 2009 - link

    it is impossible to disable vsync and enable triple buffering.

    the point of triple buffering is to allow one buffer to remained locked all the way through a vertical refresh cycle so that there is no corruption while still allowing the game to have two buffers to bounce back and forth between.

    i was unaware of the punkbuster "feature" ... i imagine that since the game would report only 60 FPS with triple buffering, even if you were getting the lag advantage of something like 300 FPS, that it would not be limited in that case.

    but i don't know how punkbuster works, so i could very well be wrong.
  • Dynotaku - Friday, June 26, 2009 - link

    So here's a question. I have a 120hz LCD. I run it with vsync disabled, and in for instance CoD4, I get around 90FPS most of the time. No tearing that I can really detect.

    So with a 120hz monitor, is triple buffering still better or is it a case where it doesn't make that much difference as long as you're getting 60+ FPS?
  • JarredWalton - Friday, June 26, 2009 - link

    If you enabled VSYNC, you'd get 60FPS, while with triple buffering you should get 90FPS still (but with perhaps slightly more latency).
  • Dynotaku - Friday, June 26, 2009 - link

    I guess my question is, is it better to disable vsync or enable triple buffering? It probably doesn't matter much at 90 FPS. I'm running without vsync and I don't see any tearing and the framerate is amazing an really fluid.
  • DerekWilson - Friday, June 26, 2009 - link

    if you have a real 120hz refresh, triple buffering would be even better as there would be no tearing and the maximum additional lag added by triple buffering would be cut in half.

    Running at 90 FPS on a 120 Hz monitor, triple buffering would still be the best option.
  • jp777cmoe - Saturday, July 18, 2009 - link

    with or without vsync on? i have a 120hz monitor.. not sure if i should go no vsync + triple buffering or vsync with triple buffering
  • vegemeister - Tuesday, August 6, 2013 - link

    He would get "90 FPS", but since his monitor is not running at 90Hz, what he would actually see is a ridiculous amount of judder.

Log in

Don't have an account? Sign up now