With all my SDL/OpenGL programs, the framerate is stuck at 60fps, so looks like the vsync is enable, but not by me, nor in my code or my settings. so i would like to now if there is a way to disable it, maybe in some deep macOS settings?
3 Answers
This enabled me to get around ~700 frames per second on my MacBook Pro.
- Download Graphics Tools for Xcode - Late August 2014
- Install or just mount Graphic Tools
- Open Quartz Debug
- Go to Tools -> Show Beam Sync Tools
- Select Disable Beam Synchronization
It is not permanent either, perfect for testing/benchmarking.
-
1
-
-
1. Double check that the app you are testing can actually go over 60fps; 2. This solution was for Mavericks 10.9, untested for Yosemite or El Capitan– cevarisJun 4, 2016 at 16:09
-
1Would you mind to state in your answer that this solution is actually not working on 10.11 with xCode 7.3 (that the only one I've tried) anymore please?– NoxJul 13, 2016 at 22:56
-
Your first link is broken: it says
Your session has expired. Please log in..– RuslanAug 12, 2016 at 9:58
Welcome to SO. I outlined an approach here for a similar question. You should consider that most Mac LCDs are locked to 60Hz, and more recent hardware is limited to 120Hz. Disabling vsync may simply result in wasted CPU/GPU cycles, and possibly introduce tearing artifacts.
After YEARS looking for a workaround (and with the help of Brett Hale) this is what worked for me - I've added that piece of code at the start of my render loop (and not only in the init, as Apple seems to reset the SwapInterval settings every time...) and was finally able to have unsynchronize framerate:
#ifdef __APPLE__
GLint sync = 0;
CGLContextObj ctx = CGLGetCurrentContext();
CGLSetParameter(ctx, kCGLCPSwapInterval, &sync);
#endif
Don't forget to include <OpenGL/gl.h>
It's not the nicest solution but it's actually the only one I found that work like a charm.
-
Apparently this is broken in Mac OS 10.14 (Mojave), with vsync always disabled, (but vsync in Metal still works). SDL2.0.10+ (not yet released) will work around this bug by using CVDisplayLink instead. You can see the commit here and discussion here Mar 24, 2019 at 0:42
-
Also, the code SDL2 were previously using only seems to set this once, not every frame. Maybe because they instead called
[NSOpenGLContext setValues:&value forParameter:NSOpenGLCPSwapInterval]Mar 24, 2019 at 0:46 -
News just in, apparently OpenGL vsync is fixed in the next release, Mac OS 10.14.4 Mar 24, 2019 at 0:49
-
Confirmed working on macOS 10.14, but seems this is not working on macOS 10.15 and 11 anymore, I've tried
kCGLCPSwapInterval/NSOpenGLCPSwapInterval/CVDisplayLinkJul 24, 2021 at 12:54 -
Found out on macOS 10.15 and 11, the actual drawing code including
flushBuffer()must not be put infunc draw(_ dirtyRect: NSRect)Jul 26, 2021 at 14:16