parent
4cac20aea3
commit
0ce4433686
4 changed files with 13 additions and 65 deletions
|
@ -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:
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue