VSync - How it works

Discussion in 'Videocards - NVIDIA GeForce Drivers Section' started by djjonastybe, Feb 15, 2012.

  1. djjonastybe

    djjonastybe Master Guru

    Messages:
    725
    Likes Received:
    0
    GPU:
    HD6950(70) 885/1350
    I recently learned that how I thought vsync worked was wrong, and now knowing the way it really does work, I think it would be worthwhile to make sure everyone here understands it.

    What is VSync? VSync stands for Vertical Synchronization. The basic idea is that synchronizes your FPS with your monitor's refresh rate. The purpose is to eliminate something called "tearing". I will describe all these things here.

    Every CRT monitor has a refresh rate. It's specified in Hz (Hertz, cycles per second). It is the number of times the monitor updates the display per second. Different monitors support different refresh rates at different resolutions. They range from 60Hz at the low end up to 100Hz and higher. Note that this isn't your FPS as your games report it. If your monitor is set at a specific refresh rate, it always updates the screen at that rate, even if nothing on it is changing. On an LCD, things work differently. Pixels on an LCD stay lit until they are told to change; they don't have to be refreshed. However, because of how VGA (and DVI) works, the LCD must still poll the video card at a certain rate for new frames. This is why LCD's still have a "refresh rate" even though they don't actually have to refresh.

    I think everyone here understands FPS. It's how many frames the video card can draw per second. Higher is obviously better. However, during a fast paced game, your FPS rarely stays the same all the time. It moves around as the complexity of the image the video card has to draw changes based on what you are seeing. This is where tearing comes in.

    Tearing is a phenomenon that gives a disjointed image. The idea is as if you took a photograph of something, then rotated your vew maybe just 1 degree to the left and took a photograph of that, then cut the two pictures in half and taped the top half of one to the bottom half of the other. The images would be similar but there would be a notable difference in the top half from the bottom half. This is what is called tearing on a visual display. It doesn't always have to be cut right in the middle. It can be near the top or the bottom and the separation point can actually move up or down the screen, or seem to jump back and forth between two points.

    Why does this happen? Lets take a specific example. Let's say your monitor is set to a refresh rate of 75Hz. You're playing your favorite game and you're getting 100FPS right now. That means that the mointor is updating itself 75 times per second, but the video card is updating the display 100 times per second, that's 33% faster than the mointor. So that means in the time between screen updates, the video card has drawn one frame and a third of another one. That third of the next frame will overwrite the top third of the previous frame and then get drawn on the screen. The video card then finishes the last 2 thirds of that frame, and renders the next 2 thirds of the next frame and then the screen updates again. As you can see this would cause this tearing effect as 2 out of every 3 times the screen updates, either the top third or bottom third is disjointed from the rest of the display. This won't really be noticeable if what is on the screen isn't changing much, but if you're looking around quickly or what not this effect will be very apparant.

    Now this is where the common misconception comes in. Some people think that the solution to this problem is to simply create an FPS cap equal to the refresh rate. So long as the video card doesn't go faster than 75 FPS, everything is fine, right? Wrong.

    Before I explain why, let me talk about double-buffering. Double-buffering is a technique that mitigates the tearing problem somewhat, but not entirely. Basically you have a frame buffer and a back buffer. Whenever the monitor grabs a frame to refresh with, it pulls it from the frame buffer. The video card draws new frames in the back buffer, then copies it to the frame buffer when it's done. However the copy operation still takes time, so if the monitor refreshes in the middle of the copy operation, it will still have a torn image.

    VSync solves this problem by creating a rule that says the back buffer can't copy to the frame buffer until right after the monitor refreshes. With a framerate higher than the refresh rate, this is fine. The back buffer is filled with a frame, the system waits, and after the refresh, the back buffer is copied to the frame buffer and a new frame is drawn in the back buffer, effectively capping your framerate at the refresh rate.

    That's all well and good, but now let's look at a different example. Let's say you're playing the sequel to your favorite game, which has better graphics. You're at 75Hz refresh rate still, but now you're only getting 50FPS, 33% slower than the refresh rate. That means every time the monitor updates the screen, the video card draws 2/3 of the next frame. So lets track how this works. The monitor just refreshed, and frame 1 is copied into the frame buffer. 2/3 of frame 2 gets drawn in the back buffer, and the monitor refreshes again. It grabs frame 1 from the frame buffer for the first time. Now the video card finishes the last third of frame 2, but it has to wait, because it can't update until right after a refresh. The monitor refreshes, grabbing frame 1 the second time, and frame 2 is put in the frame buffer. The video card draws 2/3 of frame 3 in the back buffer, and a refresh happens, grabbing frame 2 for the first time. The last third of frame 3 is draw, and again we must wait for the refresh, and when it happens, frame 2 is grabbed for the second time, and frame 3 is copied in. We went through 4 refresh cycles but only 2 frames were drawn. At a refresh rate of 75Hz, that means we'll see 37.5FPS. That's noticeably less than 50FPS which the video card is capable of. This happens because the video card is forced to waste time after finishing a frame in the back buffer as it can't copy it out and it has nowhere else to draw frames.

    Essentially this means that with double-buffered VSync, the framerate can only be equal to a discrete set of values equal to Refresh / N where N is some positive integer. That means if you're talking about 60Hz refresh rate, the only framerates you can get are 60, 30, 20, 15, 12, 10, etc etc. You can see the big gap between 60 and 30 there. Any framerate between 60 and 30 your video card would normally put out would get dropped to 30.

    Now maybe you can see why people loathe it. Let's go back to the original example. You're playing your favorite game at 75Hz refresh and 100FPS. You turn VSync on, and the game limits you to 75FPS. No problem, right? Fixed the tearing issue, it looks better. You get to an area that's particularly graphically intensive, an area that would drop your FPS down to about 60 without VSync. Now your card cannot do the 75FPS it was doing before, and since VSync is on, it has to do the next highest one on the list, which is 37.5FPS. So now your game which was running at 75FPS just halved it's framerate to 37.5 instantly. Whether or not you find 37.5FPS smooth doesn't change the fact that the framerate just cut in half suddenly, which you would notice. This is what people hate about it.

    If you're playing a game that has a framerate that routinely stays above your refresh rate, then VSync will generally be a good thing. However if it's a game that moves above and below it, then VSync can become annoying. Even worse, if the game plays at an FPS that is just below the refresh rate (say you get 65FPS most of the time on a refresh rate of 75Hz), the video card will have to settle for putting out much less FPS than it could (37.5FPS in that instance). This second example is where the percieved drop in performance comes in. It looks like VSync just killed your framerate. It did, technically, but it isn't because it's a graphically intensive operation. It's simply the way it works.

    All hope is not lost however. There is a technique called triple-buffering that solves this VSync problem. Lets go back to our 50FPS, 75Hz example. Frame 1 is in the frame buffer, and 2/3 of frame 2 are drawn in the back buffer. The refresh happens and frame 1 is grabbed for the first time. The last third of frame 2 are drawn in the back buffer, and the first third of frame 3 is drawn in the second back buffer (hence the term triple-buffering). The refresh happens, frame 1 is grabbed for the second time, and frame 2 is copied into the frame buffer and the first part of frame 3 into the back buffer. The last 2/3 of frame 3 are drawn in the back buffer, the refresh happens, frame 2 is grabbed for the first time, and frame 3 is copied to the frame buffer. The process starts over. This time we still got 2 frames, but in only 3 refresh cycles. That's 2/3 of the refresh rate, which is 50FPS, exactly what we would have gotten without it. Triple-buffering essentially gives the video card someplace to keep doing work while it waits to transfer the back buffer to the frame buffer, so it doesn't have to waste time. Unfortunately, triple-buffering isn't available in every game, and in fact it isn't too common. It also can cost a little performance to utilize, as it requires extra VRAM for the buffers, and time spent copying all of them around. However, triple-buffered VSync really is the key to the best experience as you eliminate tearing without the downsides of normal VSync (unless you consider the fact that your FPS is capped a downside... which is silly because you can't see an FPS higher than your refresh anyway).

    I hope this was informative, and will help people understand the intracacies of VSync (and hopefully curb the "VSync, yes or no?" debates!). Generally, if triple buffering isn't available, you have to decide whether the discrete framerate limitations of VSync and the issues that can cause are worth the visual improvement of the elimination of tearing. It's a personal preference, and it's entirely up to you.

    http://hardforum.com/showthread.php?t=928593
    Source

    Don't know if it's true, felt like I needed to share this.
     
  2. wasteomind

    wasteomind Master Guru

    Messages:
    375
    Likes Received:
    7
    GPU:
    EVGA RTX 2080 ti
    Hasn't this been posted like 400 times before? Thanks for the refresher course, but I think a simple search would turn up this info 90% of the time. Glad you learned something. I use vsync 99% of the time. Can't stand tearing and would gladly take a little bit of input lag to make the screen pleasing to look at.
     
  3. Pill Monster

    Pill Monster Banned

    Messages:
    25,216
    Likes Received:
    7
    GPU:
    7950 Vapor-X 1100/1500
    Yeah there's already about 500 threads related to vsync....thx anyway.



    edit:
    The author never explained why a fps cap is a bad idea (in his/her opinion).

     
    Last edited: Feb 15, 2012
  4. IcE

    IcE Don Snow Staff Member

    Messages:
    10,693
    Likes Received:
    73
    GPU:
    Zotac GTX 1070 Mini
    500 times? Yeah, okay. We have had lots of threads discussing Vsync, but none in years that have actually fully explained what is going on. Not everyone knows this. He does need to add in why frame caps don't fix it though, and then it's sticky worthy so people stop asking questions.
     

  5. dnottis

    dnottis Master Guru

    Messages:
    699
    Likes Received:
    0
    GPU:
    EVGA SSC 970 GTX 4GB
    Buy 120hz LCD. Problem solved.
     
  6. Noisiv

    Noisiv Ancient Guru

    Messages:
    6,664
    Likes Received:
    504
    GPU:
    2070 Super
    and while you're there, take out my left eye
    TN - never again :bang:

    Wait a sec....120hz for tear-FREE display?

    LOL you're a lucky one - heavy blindo, right?

    :)
     
    Last edited: Feb 15, 2012
  7. sovietdoc

    sovietdoc Master Guru

    Messages:
    643
    Likes Received:
    0
    GPU:
    GTX 1080 Ti
    240hz IPS - ya ya ya ya
     
  8. Pill Monster

    Pill Monster Banned

    Messages:
    25,216
    Likes Received:
    7
    GPU:
    7950 Vapor-X 1100/1500
    Or a good quality CRT..?

    My Sony Trintrons do 1600x1200 @100Hz or 1920x1080/2048x1536 @85Hz...:eyebrows:

    I don't get why crt's aren't more popular...especially with gamers. It's a real shame they aren't manufactured anymore imho.



    Hmmm, for once I actually agree with you...

    Then maybe we can delete all the crap "human eye can only see 60 fps bla bla" threads...
     
    Last edited: Feb 15, 2012
  9. nakquada

    nakquada Master Guru

    Messages:
    352
    Likes Received:
    0
    GPU:
    Gigabyte GTX 1080 FE
    Well done to the author for the write-up
     
  10. Dranzerk

    Dranzerk Active Member

    Messages:
    59
    Likes Received:
    0
    I never notice tearing at all in games. So no problem here.
     

  11. TheDeeGee

    TheDeeGee Ancient Guru

    Messages:
    6,294
    Likes Received:
    696
    GPU:
    MSI GTX 1070
    I really liked my last owned CRT aswell. The thing i really had to get used to by swapping to LCD was being stuck at the native resolution.

    Yes you can still change but the picture isn't sharp anymore then.
     
  12. TheDeeGee

    TheDeeGee Ancient Guru

    Messages:
    6,294
    Likes Received:
    696
    GPU:
    MSI GTX 1070
    Perhaps you never played with V-Sync to notice a world of difference.

    Or you're in denial.
     
  13. Dranzerk

    Dranzerk Active Member

    Messages:
    59
    Likes Received:
    0
    Nope, lots of people don't notice a difference. Its the same with AA in games. Lots of people don't notice on or off a difference.

    Lots of graphic technology are shortcuts, something the mind fixes itself as you play. The same principle applies to looking at a picture and some people notice subtle changes while most people won't. With technology as it is today, its not like going from Doom to Bf3 anymore. The changes are so small most don't notice.
     
  14. Phroster

    Phroster Master Guru

    Messages:
    280
    Likes Received:
    4
    GPU:
    Asus Strix 980 Ti
    there a few great examples of blindness here :p
    ignorance is bliss :stewpid:
     
  15. Hlafordlaes

    Hlafordlaes Active Member

    Messages:
    78
    Likes Received:
    0
    GPU:
    GTX 1080 TI 11GB
    Nice summary. Sticky-worthy if the author adds a paragraph on the use of D3DOverrider.

    ...

    I, too, love my CRT, and dream of finding a used Sony FW900 within local shipping distance (Spain, anyone?). In no hurry to use an LCD and lose my multi-sync lifestyle. A lot of FPS issues are handled by adjusting native resolution to what my system can handle for that game.
     

  16. Vash63

    Vash63 Active Member

    Messages:
    62
    Likes Received:
    0
    GPU:
    EVGA GTX 580 SC 1.5GB x2
    Uh, I was under the impression that frame buffers are never copied, they just swap the pointers so buffer 0 becomes buffer 1 and vice versa. Why would they ever copy buffer 1 to buffer 0? Seems wasteful.
     
  17. NiColaoS

    NiColaoS Master Guru

    Messages:
    582
    Likes Received:
    39
    GPU:
    1060 6GB Armor OC
    BF3 - I play on Medium Settings with SSAO disabled to be able to keep the game VSynced most of the time.

    On BFBC2 the input lag was very noticable and could be solved by capping the FPS at 59FPS. On BF3 the input lag is not so noticable... It's extremely smooth.

    Otherwise, I could eliminate the tearing almost completely by Capping the game at exactly 51FPS and playing on High Settings with HBAO disabled.
     
    Last edited: Feb 17, 2012
  18. Raiga

    Raiga Maha Guru

    Messages:
    1,099
    Likes Received:
    0
    GPU:
    GPU
    Almost is the right word*. ;)

    Because 60 frames are still pumped to the display from the Video card (on a 60 hertz display) even if its 51 frames inside the game*.

    Most mis-conception is the above.

    Even if its 30 FPS in the game the video card still sends in 60 frames to the display, with 30 of them containing updated frames from the API's buffer_Direct X/Open GL and the rest would be non-updated frames which are displayed between transitions of rendered ones.

    For some odd reason, putting up a lower FPS cap doesn't do anything for some games*. I honestly don't know the reason, it may be due to uneven frame rendering time not syncing with frames being pumped, anyone who has technical knowledge about this can probably shed light if this is related purely to hardware or completely on software firmwares_drivers_OS_API_or_game_itself.
     
    Last edited: Feb 17, 2012
  19. rewt

    rewt Maha Guru

    Messages:
    1,267
    Likes Received:
    13
    GPU:
    Yes
    FPS capping doesn't prevent the video card flipping the front and back buffers during the monitor's refresh, so that's why tearing can still be an issue with vsync disabled.
     
  20. VultureX

    VultureX Banned

    Messages:
    2,577
    Likes Received:
    0
    GPU:
    MSI GTX970 SLI
    It's right in the next part:

    The videocard might not produce frames faster than the screen's refresh rate, but it can still tear the image when the monitor refresh and frame buffer copy operations are not synced.
    That's where Vertical Synchronization comes in to definitely take care of torn images.
     

Share This Page