View Full Version : vertical sync and half performance
08-04-2003, 12:18 PM
Does anyone know anything about this weird performance poblem?
With vertical sync is on, sometimes fps drops to 30 from 60. And then hops back to normal.
When i turn of vertical sync, there is NO performance decrease any kind of this, in the same circumstances. What may be causing the problem?
btw, how can i turn vertical sync of programmatically?
With V-Sync on there is the possibility, that your code runs exactly at a speed, which will cause a drop by 50%. However the possibility is VERY low, so you really have luck discovering this problem. Usually this does not happen.
To enable or disable v-sync, there is the wgl_swap_control extension. Very easy to use.
08-04-2003, 08:34 PM
This is very simple and should be expected. With vertical sync on you must complete your drawing in time for swapbuffers to be performed during the vertical retrace or you will be forced to wait on the next vertical retrace a full video frame later, even if you miss by a small amount. So draw times are always an integer multiple of the video field time.
For example, at 60Hz video refresh, you must complete all your rendering in 16.7 milliseconds (1 second/60). If you do not hardware will miss it's opportunity to issue the swapbuffers during vertical refresh. Since swap is sync'd to vertical refresh the next opportunity will be a full 16.7 milliseconds later, for a grand total of 33.3 milliseconds since the last swap 1frame/33.3ms = 30Hz framerate. So if you cannot draw at 60Hz, you WILL draw at 30Hz, there are no intermediate frame rates possible.
If you cannot complete draw in 33.3ms then you will drop to 20Hz, if you cannot complete in 50ms then you will drop to 15Hz, etc. etc.
Simple, it's exactly what vsync is supposed to do.
Things get a little more complex with a non blocking swap (I like to block, but I'm considered strange by the fps happy crowd), but don't be missled, it blocks for one frame only so unless you have an inconsistent draw time it won't greatly affect things, although it may fool you into thinking you got the occasional draw time that that wasn't a multiple of the video frame time, you didn't, you were just filling the graphics FIFO & maybe keeping the front end of the pipe busy while it was waiting on the swap, (unless you were tripple buffering, but I'm not even going there).
[This message has been edited by dorbie (edited 08-04-2003).]
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.