diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-12-12 21:56:23 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-11 12:06:31 +0100 |
commit | 2db8f40bd7323dc89e25e2a43dcd95009332dac3 (patch) | |
tree | ebeb1bc8b0e5ca549b030411487d891c922eab7f | |
parent | 4cac20aea32043c45304faca2eaf57da69525a88 (diff) | |
parent | 0ce44336866582ffa132fb440163066ad66b18c1 (diff) |
Merge pull request #34307 from bruvzg/macos_rebase_fixes
[Vulkan] Restore parts of #33783 and #32809 missing after rebase.
-rw-r--r-- | .travis.yml | 2 | ||||
-rw-r--r-- | platform/osx/context_gl_osx.h | 4 | ||||
-rw-r--r-- | platform/osx/context_gl_osx.mm | 60 | ||||
-rw-r--r-- | platform/osx/os_osx.mm | 14 |
4 files changed, 14 insertions, 66 deletions
diff --git a/.travis.yml b/.travis.yml index 348b8e5798..4d53e3f819 100644 --- a/.travis.yml +++ b/.travis.yml @@ -70,7 +70,7 @@ matrix: - name: macOS editor (debug, Clang) stage: build - env: PLATFORM=osx TOOLS=yes TARGET=debug CACHE_NAME=${PLATFORM}-tools-clang EXTRA_ARGS="warnings=extra werror=yes" + env: PLATFORM=osx TOOLS=yes TARGET=debug CACHE_NAME=${PLATFORM}-tools-clang EXTRA_ARGS="warnings=extra" # werror=yes os: osx compiler: clang addons: diff --git a/platform/osx/context_gl_osx.h b/platform/osx/context_gl_osx.h index 831a813fe9..6fb6b53275 100644 --- a/platform/osx/context_gl_osx.h +++ b/platform/osx/context_gl_osx.h @@ -51,10 +51,6 @@ class ContextGL_OSX { NSOpenGLContext *context; public: - bool waiting_for_vsync; - NSCondition *vsync_condition; - CVDisplayLinkRef displayLink; - void release_current(); void make_current(); diff --git a/platform/osx/context_gl_osx.mm b/platform/osx/context_gl_osx.mm index 425c9b0ac4..013c34ff2e 100644 --- a/platform/osx/context_gl_osx.mm +++ b/platform/osx/context_gl_osx.mm @@ -32,21 +32,6 @@ #if defined(OPENGL_ENABLED) || defined(GLES_ENABLED) -// 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) { - ContextGL_OSX *gl_ctx = (ContextGL_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 - [gl_ctx->vsync_condition lock]; - gl_ctx->waiting_for_vsync = false; - [gl_ctx->vsync_condition signal]; - [gl_ctx->vsync_condition unlock]; - - return kCVReturnSuccess; -} - void ContextGL_OSX::release_current() { [NSOpenGLContext clearCurrentContext]; @@ -79,31 +64,17 @@ int ContextGL_OSX::get_window_height() { void ContextGL_OSX::swap_buffers() { - if (use_vsync) { - // 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]; } void ContextGL_OSX::set_use_vsync(bool p_use) { - // 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. - - ///TODO Maybe pause/unpause display link? - use_vsync = p_use; - waiting_for_vsync = p_use; + + CGLContextObj ctx = CGLGetCurrentContext(); + if (ctx) { + GLint swapInterval = p_use ? 1 : 0; + CGLSetParameter(ctx, kCGLCPSwapInterval, &swapInterval); + use_vsync = p_use; + } } bool ContextGL_OSX::is_using_vsync() const { @@ -186,15 +157,6 @@ Error ContextGL_OSX::initialize() { [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]; - return OK; } @@ -205,12 +167,6 @@ ContextGL_OSX::ContextGL_OSX(id p_view, bool p_opengl_3_context) { use_vsync = false; } -ContextGL_OSX::~ContextGL_OSX() { - - if (displayLink) { - CVDisplayLinkRelease(displayLink); - } - [vsync_condition release]; -} +ContextGL_OSX::~ContextGL_OSX() {} #endif diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index fa1de631f0..87ab8b3420 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -1548,7 +1548,11 @@ Error OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_a #endif [window_object setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary]; } else { - [window_view setWantsBestResolutionOpenGLSurface:NO]; +#if defined(OPENGL_ENABLED) + if (video_driver_index == VIDEO_DRIVER_GLES2) { + [window_view setWantsBestResolutionOpenGLSurface:NO]; + } +#endif } [window_object setContentView:window_view]; @@ -2995,14 +2999,6 @@ Error OS_OSX::move_to_trash(const String &p_path) { } void OS_OSX::_set_use_vsync(bool p_enable) { - // FIXME: Commented out during rebase of vulkan branch on master. - /* - CGLContextObj ctx = CGLGetCurrentContext(); - if (ctx) { - GLint swapInterval = p_enable ? 1 : 0; - CGLSetParameter(ctx, kCGLCPSwapInterval, &swapInterval); - } - */ #if defined(OPENGL_ENABLED) if (video_driver_index == VIDEO_DRIVER_GLES2) { if (context_gles2) |