SDL + OpenGL, inconsistent VSync. NVidia card

I’m writing with SDL and OpenGL, and I have an NVidia graphics card. For some reason, VSync is all messed up. I cannot even explain it well. Sometimes the card forces Vsync on me, and sudenly it stops doing so. It isn’t consistent at all, and it changes from having VSync on and off from minute to minute. Also, restarting the program does nothing, if it was previously “VSynced” it keeps being like that until it randomly changes. I’ve tried switching VSync off and on in my driver settings and both settings behave the same. I wouldn’t mind much if it just forced VSync and that’s it, but it is just an inconsistent mess. I’ve tried all the combinations of SDL calls to set the VSync options and driver options, and nothing seems to stick.

What I’ve been trying to use in SDL is SDL_GL_SetSwapInterval. The first time I used it it worked, but after a while the program returned to VSync mode and the function did nothing anymore, not even if I restarted the program.

This is happening in windowed mode, and I want my program to preferably NOT have VSync.

I’m sorry if the explanation is a mess, but so is the problem. I’m really lost here.

Could it be
http://www.geforce.com/hardware/technology/adaptive-vsync/technology ,
possibly enforced by the driver?
As far as I understand it, it enforcese vsync if you get >=60fps, but
not if you’re below, so you can have e.g. 40fps instead of 30 (with
normal vsync to 60fps).

Cheers,
DanielOn 02/27/2015 07:58 PM, ShiroAisu wrote:

I’m writing with SDL and OpenGL, and I have an NVidia graphics card. For
some reason, VSync is all messed up. I cannot even explain it well.
Sometimes the card forces Vsync on me, and sudenly it stops doing so. It
isn’t consistent at all, and it changes from having VSync on and off
from minute to minute. Also, restarting the program does nothing, if it
was previously “VSynced” it keeps being like that until it randomly
changes. I’ve tried switching VSync off and on in my driver settings and
both settings behave the same. I wouldn’t mind much if it just forced
VSync and that’s it, but it is just an inconsistent mess. I’ve tried all
the combinations of SDL calls to set the VSync options and driver
options, and nothing seems to stick.

What I’ve been trying to use in SDL is SDL_GL_SetSwapInterval. The first
time I used it it worked, but after a while the program returned to
VSync mode and the function did nothing anymore, not even if I restarted
the program.

This is happening in windowed mode, and I want my program to preferably
NOT have VSync.

I’m sorry if the explanation is a mess, but so is the problem. I’m
really lost here.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Daniel Gibson wrote:

Could it be
http://www.geforce.com/hardware/technology/adaptive-vsync/technology ,
possibly enforced by the driver?

That’s cool and all but I SPECIFICALLY have VSync set to off in the drivers options. The option to turn on adaptive-vsync is also a thing, so I doubt it would be enforced just by default. I even created an exception for my program, and set it, once again, as off. I tried getting control with wglSwapIntervalEXT() but it didn’t change a thing.

I have the same issue, vsync works randomly with the same setup Nvidia, OpenGL. Sometimes it forces 60 FPS on my 60Hz monitor, sometimes it logs 0 0 0 0 0 1000 0 0 0 0 0 FPS and so on with this code:

auto start_time = SDL_GetTicks();
.. glDraw ...
SDL_GL_SwapWindow(..)
auto frame_time = SDL_GetTicks() - start_time;
auto fps = (frame_time > 0) ? 1000.0f / frame_time : 0.0f;
LOG_INFO("SDL FPS: %.2f", fps);