![]() |
|
#1
|
|||
|
|||
|
How VSync works, and why people loathe it
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. Last edited by Arkalius; 07-25-2005 at 06:52 PM..
|
|
#2
|
|||
|
|||
|
Did you write this or did you copy and paste it from somewhere else? Cause that is an absolutely perfect and easy to understand description of VSYNC.
In addition I would add that enabling Tripple Buffering solves the halving of the framerate problem with VSYNC enabled.
|
|
#3
|
|||
|
|||
|
I wrote that myself. Can you elaborate on the triple buffering issue?
|
|
#4
|
|||
|
|||
|
Great essay. I just googled a random part of it and can confirm that this guy wrote it out himself. Thanks for the info!
|
|
#5
|
|||
|
|||
|
Quote:
To elaborate on Triple Buffering with VSYNC first we need to understand how it works in normal double buffering mode. In double buffering 1 frame is written to the backbuffer and then flipped over to the front buffer when it is rendered and scanned out through the DAC. When you have VSYNC enabled what is actually happening is that with double buffering the image is only copied to the front buffer when the electron gun is at the top line of the frame. If you have the refresh set at 60Hz for example and VSYNC is enabled and you are below or above that limit then the graphics card cannot draw the back buffer fast enough to complete the entire frame so the front buffer doesn't change until a complete frame is drawn, reducing the framerate in half. When you force Triple Buffering with VSYNC enabled you are creating three framebuffers, 1 front buffer and 2 back buffers. In this situation both backbuffers are rendered even before one is flipped to the front buffer, so the graphics card can render one backbuffer and start on the second backbuffer even if the electron gun hasn't got back up to the top line of the frame yet. So in effect there is no halving of the framerate. You get the benefit of VSYNC enabled (no tearing) and have no drawbacks with halving of the framerate.
|
|
#6
|
|||
|
|||
|
yea to top it off great info
|
|
#7
|
|||
|
|||
|
Wow, that was awesome, I never knew the thing about framerates haveing to at specific ratios to the refresh rate. Thanks for the great guide.
|
|
#8
|
|||
|
|||
|
awesome info in here that's easy to assimilate. bravo.
![]()
|
|
#9
|
|||
|
|||
|
i never notice tearing. is there anyway a person can get some kind of screenshot?
|
|
#10
|
|||
|
|||
|
So if I have an LCD running @ 60Hz (yah yah I know)
It is beneficial to have Vsynch off I presume? I figure this way, the Vsynch wont be limiting the FPS to 60 and 30.....etc Great read! (y)
|
|
#11
|
|||
|
|||
|
Quote:
If you can force Triple Buffering in a game though then you can run with VSYNC enabled and not have tearing and not have the framerate halving.
|
|
#12
|
|||
|
|||
|
Even with an LCD? Isnt tearing a CRT only problem? Considering the pixels on an LCD arnt being refreshed, shouldnt this make Vsynch and 3x buffering non-applicable?
|
|
#13
|
|||
|
|||
|
Quote:
It's still a matter of the video card rendering the video incorrectly, if I understand correctly.
|
|
#14
|
|||
|
|||
|
Quote:
Notice they do run at 60Hz in Windows. VSYNC is a part of games and the OS.
|
|
#15
|
|||
|
|||
|
Some people are more sensitive to tearing than others. Chances are you've gotten used to it so you don't notice it. It's usually more noticeable if your FPS is higher than your refresh rate. When it's lower, there's still tearing but it's harder to see. If you're used to it, it's hard to really point it out. The only way you can really learn to see it if you're used to it is play the same sequence of a game with VSync both on and off, then you'll probably see the difference.
Screenshots won't show tearing. Tearing is a side effect of the refresh rate, and therefore is the monitor's fault technically. Screenshots always draw a single complete frame. The following is speculative on my part: LCD's don't show tearing for an FPS less than the max refresh rate. The refresh rate on an LCD is simply the maximum rate it can update itself. Unlike CRT's they don't have to constantly update the screen. They only update when new data is available, however they can only update so fast. If the framerate is lower than the refresh rate, you're fine, however if it gets higher, it can produce tearing. Remember this is speculation on my part...
|
|
#16
|
|||
|
|||
|
Thanks a ton. Tearing has always distracted me more than a lack of AA or AF has. I should have researched it myself, but I didn't think it was that involved.
|
|
#17
|
|||
|
|||
|
I never understood the refresh rate settings for LCDs.
Its my understanding that the LCD will change its pixels when needed at the rate of FPS or its technical maximum rate. EDIT: question pretty much answered while I was typing this
|
|
#18
|
|||
|
|||
|
Quote:
|
|
#19
|
|||
|
|||
|
Quote:
Very good write up.
|
|
#20
|
|||
|
|||
|
Very nice thread. Looks like you took your time writing this one.
And, it's... STICKY WORTHY! ![]()
|
![]() |
| Thread Tools | Search this Thread |
|
|