How to limit FPS (without vsync)?

Started by
13 comments, last by Adehm 9 years, 1 month ago

I'm still confused. What input lag issue do you think exists - due to vsync? Can you please explain how you'd render your game - without tearing - at a limited framerate - in a way that that would somehow have DIFFERENT input characteristics than just turning on vsync? Sure, vsync forces the GPU to wait until vblank until it displays the next frame... but that's at most 16 ms. And unless you do that, you're going to get tearing. Tearing is way worse than an average of 8 ms of input lag. Besides - as others have said - you can keep your input and simulation running faster (and for simple games like bullet hell shooters, adjust the timing of when you sample input) to mitigate that anyway. I'll repeat the 2nd poster's question: what is the obsession with avoiding vsync?

Advertisement

Graphics APIs do a thing called "render-ahead" where depending on the CPU time taken to submit the draw call data to the API, and other per-frame processing, the CPU may run ahead of the GPU, meaning that after you submit draw calls for frame x, the GPU is only beginning to draw frame x - 2, for example. This results in apparent worse input lag, because the visible results from input, like camera movement, get to the screen delayed. Vsync makes the situation worse, as the maximum amount of frames to buffer is fixed (typically 3) but with vsync enabled there's more time between frames.

There are ways to combat the render-ahead: on D3D9 (and I guess OpenGL as well) you can manually issue a GPU query and wait on it, effectively keeping the CPU->GPU pipe flushed. This will worsen performance, though. On D3D11 you can use the API call IDXGIDevice1::SetMaximumFrameLatency().

Do you have something already playable that is at least somewhat representative of your targeted gameplay that has too much input lag?

If the answer is no, then you are well within premature optimization land.

[DELETED] - I don't know what i'm talking about, sorry.

I have also had problems with Vsync being slower and slowing buffer times. I have a long to tell me milliseconds that have passed between each frame. When enough have passed I reset it and flip a switch to allow my game loop to process. Giving me a faster more steady render time as well as increasing my buffering speed.

This topic is closed to new replies.

Advertisement