summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbruvzg <7645683+bruvzg@users.noreply.github.com>2019-11-21 11:01:47 +0200
committerbruvzg <7645683+bruvzg@users.noreply.github.com>2019-11-21 11:01:47 +0200
commite423e1c663b31676b6b6fa4c2246773daeb568c2 (patch)
tree85ea60ac166ca27b5237dbd593468ad0dab9aec4
parent083d088de3fe7cd5d825cebebc46ce32fc87b4b0 (diff)
[macOS] Remove CVDisplayLink v-sync hack.
-rw-r--r--platform/osx/os_osx.h3
-rw-r--r--platform/osx/os_osx.mm54
2 files changed, 2 insertions, 55 deletions
diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h
index 09a871f26c..a61b9234d1 100644
--- a/platform/osx/os_osx.h
+++ b/platform/osx/os_osx.h
@@ -113,9 +113,6 @@ public:
NSOpenGLContext *context;
bool layered_window;
- bool waiting_for_vsync;
- NSCondition *vsync_condition;
- CVDisplayLinkRef displayLink;
CursorShape cursor_shape;
NSCursor *cursors[CURSOR_MAX];
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index ba3ac9862e..e5166d102b 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -115,21 +115,6 @@ static Vector2 get_mouse_pos(NSPoint locationInWindow, CGFloat backingScaleFacto
return Vector2(mouse_x, mouse_y);
}
-// DisplayLinkCallback is called from our DisplayLink OS thread informing us right before
-// a screen update is required. We can use it to work around the broken vsync.
-static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeStamp *now, const CVTimeStamp *outputTime, CVOptionFlags flagsIn, CVOptionFlags *flagsOut, void *displayLinkContext) {
- OS_OSX *os = (OS_OSX *)displayLinkContext;
-
- // Set flag so we know we can output our next frame and signal our conditional lock
- // if we're not doing vsync this will be ignored
- [os->vsync_condition lock];
- os->waiting_for_vsync = false;
- [os->vsync_condition signal];
- [os->vsync_condition unlock];
-
- return kCVReturnSuccess;
-}
-
@interface GodotApplication : NSApplication
@end
@@ -1581,15 +1566,6 @@ Error OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
[context makeCurrentContext];
- // setup our display link, this will inform us when a refresh is needed
- CVDisplayLinkCreateWithActiveCGDisplays(&displayLink);
- CVDisplayLinkSetOutputCallback(displayLink, &DisplayLinkCallback, this);
- CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext(displayLink, context.CGLContextObj, pixelFormat.CGLPixelFormatObj);
- CVDisplayLinkStart(displayLink);
-
- // initialise a conditional lock object
- vsync_condition = [[NSCondition alloc] init];
-
set_use_vsync(p_desired.use_vsync);
[NSApp activateIgnoringOtherApps:YES];
@@ -1682,11 +1658,6 @@ void OS_OSX::finalize() {
midi_driver.close();
#endif
- if (displayLink) {
- CVDisplayLinkRelease(displayLink);
- }
- [vsync_condition release];
-
CFNotificationCenterRemoveObserver(CFNotificationCenterGetDistributedCenter(), NULL, kTISNotifySelectedKeyboardInputSourceChanged, NULL);
CGDisplayRemoveReconfigurationCallback(displays_arrangement_changed, NULL);
@@ -2258,18 +2229,6 @@ String OS_OSX::get_locale() const {
}
void OS_OSX::swap_buffers() {
- if (is_vsync_enabled()) {
- // Wait until our DisplayLink callback unsets our flag...
- [vsync_condition lock];
- while (waiting_for_vsync)
- [vsync_condition wait];
-
- // Make sure we wait again next frame around
- waiting_for_vsync = true;
-
- [vsync_condition unlock];
- }
-
[context flushBuffer];
}
@@ -3009,20 +2968,11 @@ Error OS_OSX::move_to_trash(const String &p_path) {
}
void OS_OSX::_set_use_vsync(bool p_enable) {
- // CGLCPSwapInterval broke in OSX 10.14 and it seems Apple is not interested in fixing
- // it as OpenGL is now deprecated and Metal solves this differently.
- // Following SDLs example we're working around this using DisplayLink
- // When vsync is enabled we set a flag "waiting_for_vsync" to true.
- // This flag is set to false when DisplayLink informs us our display is about to refresh.
-
- /* CGLContextObj ctx = CGLGetCurrentContext();
+ CGLContextObj ctx = CGLGetCurrentContext();
if (ctx) {
GLint swapInterval = p_enable ? 1 : 0;
CGLSetParameter(ctx, kCGLCPSwapInterval, &swapInterval);
- }*/
-
- ///TODO Maybe pause/unpause display link?
- waiting_for_vsync = p_enable;
+ }
}
OS_OSX *OS_OSX::singleton = NULL;