Skip to main content
GameDev.net gamedev.net
🔒 Locked

VSync

Started by The C modest god Oct 26, 2005 at 1:35 PM 13 replies 2.1k views
Original Post
The C modest god
The C modest god
What exatcly is VSync? and should I have an option to disable it in my game?
It's all about the wheel.Never blindly trust technoligy.I love my internal organs.Real men don't shower. Quote: Original post by Toolmaker Quote:
Caitlin
Caitlin
Vsync is when a CRT turns its electron beam off to move from the lower-right corner of the screeen to the upper-left corner in order to start another scan of the screen. This is usually a good time to "draw" the next image that you will want to appear on the screen because if you do it while the beam is scanning the screen you *might* get flicker. Im not sure whether including an option to disable it would be good or not, but by disabling it you *should* be able to get higher frame rates.
Young Doc: No wonder this circuit failed. It says "Made in Japan".Marty McFly: What do you mean, Doc? All the best stuff is made in Japan.Young Doc: Unbelievable.
mdias
mdias
Quote:
from wikipedia
Vertical synchronization (abbreviated as vertical sync or V-sync) is a method used in computer games to only allow the game to draw to the screen starting at the beginning of a video scan. This limits the frame rate of the game to the monitor's refresh frequency and also prevents page tearing.

V-sync is often found in applications where frames forming a motion sequence are rendered in real time at a variable rate, including 2D/3D games and audio/data visualizations, but does not apply to video playback.


And yes, you should include an option to enable/disable it.

[edit]Caitlin's explanation is better, however it happens with all kinds of monitors (not only CRTs). I don't know if monitors with digital input (instead of the VGA cable) are any different.
The C modest god
The C modest god
Quote:
Original post by Kamikaze15
Quote:
from wikipedia
Vertical synchronization (abbreviated as vertical sync or V-sync) is a method used in computer games to only allow the game to draw to the screen starting at the beginning of a video scan. This limits the frame rate of the game to the monitor's refresh frequency and also prevents page tearing.

V-sync is often found in applications where frames forming a motion sequence are rendered in real time at a variable rate, including 2D/3D games and audio/data visualizations, but does not apply to video playback.


And yes, you should include an option to enable/disable it.

I understood it is good for some older screens for some kind of reason?

It's all about the wheel.Never blindly trust technoligy.I love my internal organs.Real men don't shower. Quote: Original post by Toolmaker Quote:
Extrarius
Extrarius
Caitlin: It isn't flicker that is caused when you update in the middle of a redraw, but rather tearing. Tearing is where part of the screen displays the old frame (because the beam just finished drawing that part) and part of the new frame (because you sent that image to the monitor when it's in the middle of updating the screen). In many games, it literally looks like a tear in the image because there are two images that don't line up (because usually frames are similar).

The reason to tell the gfx card to wait until vsync is that it prevents the image from changing after half of it is already drawn on the monitor.

It might not be much of a problem on LCDs since they operate in an entirely different way (I don't really know enough about them to say), but it is definitely a problem on any CRT. If you haven't noticed it, it might be either because you play very fast paced games (where everything is always changing and a tear wouldn't be noticed) or very slow paced games (where frames are so similar that the tear might only be a few pixels not lining up and again not be noticed)
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
mdias
mdias
At least in theory, yes, because older screens have a lower refresh rate (number of images dipslayed per second) and page tearing would be more noticable as it would show on the screen for more time.
LilBudyWizer
LilBudyWizer
What I've been told is that LCD's work basically the same. You don't have an electron beam of course, but you do have a grid of wires. Rather than powering all the crystals at once they run down through the columns and rows.
Keys to success: Ability, ambition and opportunity.
The C modest god
The C modest god
How do I disable/enable VSync in directX?
I searched in the directX documentation for VSync and I havnt found the relevant information.
It's all about the wheel.Never blindly trust technoligy.I love my internal organs.Real men don't shower. Quote: Original post by Toolmaker Quote:
LeGreg
LeGreg
From the documentation :

IDirect3D9::CreateDevice : Creates a device to represent the display adapter.
-> D3DPRESENT_PARAMETERS : Describes the presentation parameters.
-> D3DPRESENT : Describes the relationship between the adapter refresh rate and the rate at which Present or Present operations are completed. These values also serve as flag values for the PresentationIntervals field of D3DCAPS9.

in your case if you want to enable VSync you should us one of those two values:

D3DPRESENT_INTERVAL_DEFAULT This is nearly equivalent to D3DPRESENT_INTERVAL_ONE. See remarks.
D3DPRESENT_INTERVAL_ONE The driver will wait for the vertical retrace period (the runtime will "beam follow" to prevent tearing). Present operations will not be affected more frequently than the screen refresh; the runtime will complete at most one Present operation per adapter refresh period. This is equivalent to using D3DSWAPEFFECT_COPYVSYNC in DirectX 8.1. This option is always available for both windowed and full-screen swap chains. See remarks.

Note that "TRUE" vsync is nearly impossible in windowed mode, and an approximation is used (good enough in most cases).

If you don't want your frames per seconds to drop so much with VSYNC on, you should use triple buffering, by setting the member BackBufferCount of D3DPRESENT_PARAMETER, to 2, instead of zero or one. (it will create two backbuffers instead of one, hence the triple buffering)
Note that triple buffering WITHOUT VSYNC is a total loss of memory and doesn't serve any purpose.

PS: the Presentation parameters can also be passed as arguments to Reset if you want to change settings on the fly from VSync to no VSync.
LeGreg
LeGreg
Quote:
Original post by CaitlinThis is usually a good time to "draw" the next image that you will want to appear on the screen because if you do it while the beam is scanning the screen you *might* get flicker.


VSync is not a good way to removes flicker (we're talking about modern hardware, modern games and modern OSes here, not ones that could render everything during vblank), but double buffering is.

In Direct3D they simplified things for us : there is no way to get single buffering, you'll always have at least double buffering, and so you will never have flicker (unless of course you program your game explicitely to emulate a similar effect).
The C modest god
The C modest god
So I understand that D3DPRESENT_INTERVAL_IMMEDIATE is used for disabling VSync?
It's all about the wheel.Never blindly trust technoligy.I love my internal organs.Real men don't shower. Quote: Original post by Toolmaker Quote:
The C modest god
The C modest god
Quote:
Original post by LeGreg
Quote:
Original post by The C modest godI understood it is good for some older screens for some kind of reason?


It is good for all screens. Tearing is not going to go away soon.


I ment that disabling VSync is good for some old screens.
It's all about the wheel.Never blindly trust technoligy.I love my internal organs.Real men don't shower. Quote: Original post by Toolmaker Quote:
superpig
superpig
Quote:
Original post by The C modest god
So I understand that D3DPRESENT_INTERVAL_IMMEDIATE is used for disabling VSync?


Yes. This will cause the device to present the new image ASAP, instead of waiting for the next VSync period to switch buffers.
Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.