Search code examples
c#openglopentkvsync

To use or not to use VSync


I'm deciding on whether or not to use VSync for a new game that I've been developing using OpenGL. The goal is to provide the user with the best gaming experience, and to have a good balance between performance and quality. This game is designed to run on both older (Intel/Netbook) computers and newer (NVidia/i7 desktop) computers. I am aware that the purpose of VSync is to prevent tearing, however; I have never been able to reproduce this tearing issue even with VSync turned off. To provide the best experience; should VSync be turned on, or off?


Solution

  • There are many things that can be said about this issue. Let me count the way:

    1. if you don't see tearing, you're likely vsync'ed, even if you think you're not. Reasons may vary, but ultimately, swapping buffers in the middle of the frame is very noticeable if any movement is happening (one reason might be that you're not configured to flip buffers, so something has to do a copy of your framebuffer)
    2. vsync on has noticeable artifacts too. Typically, it creates frames that display for a variable amount of time, more tied to the display refresh rate than your rendering rate. This can create micro-stuttering, and is very hard to control, as you don't know when you generate your frame which tick it will display at, so, you can't compensate for motion artifacts. This is why some people try to lock their rendering speed to the refresh rate. Always render at 60fps (or 30fps), time update is time += 16.7ms John Carmack has been asking for a mode that does "vsync at 60Hz, but don't sync if I missed the deadline" for what I assume would be this reason.
    3. vsync on saves power (important on netbooks)
    4. vsync off reduces input latency (when your input is 3 frames before display, it can start to matter). You can try to compensate some of that, but ultimately, it is hard to inject input updates at the very last minute.

    So the bottom line answer is that there is no perfect answer. It really depends on what matters more for your game. Things you need to look at: which framerate you want to achieve, how much input latency matters, how much movement is there in the game, is power going to be a concern.