summaryrefslogtreecommitdiffstats
path: root/video/out/cocoa_common.m
diff options
context:
space:
mode:
Diffstat (limited to 'video/out/cocoa_common.m')
-rw-r--r--video/out/cocoa_common.m15
1 files changed, 14 insertions, 1 deletions
diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m
index 5385460792..1e0b7abda5 100644
--- a/video/out/cocoa_common.m
+++ b/video/out/cocoa_common.m
@@ -349,6 +349,8 @@ static int create_gl_context(struct vo *vo, int gl3profile)
kCGLPFADoubleBuffer,
kCGLPFAAccelerated,
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8
+ // leave this as the last entry of the array to not break the fallback
+ // code
kCGLPFASupportsAutomaticGraphicsSwitching,
#endif
0
@@ -356,7 +358,18 @@ static int create_gl_context(struct vo *vo, int gl3profile)
CGLPixelFormatObj pix;
GLint npix;
- if ((err = CGLChoosePixelFormat(attrs, &pix, &npix)) != kCGLNoError) {
+
+ err = CGLChoosePixelFormat(attrs, &pix, &npix);
+ if (err == kCGLBadAttribute) {
+ // kCGLPFASupportsAutomaticGraphicsSwitching is probably not supported
+ // by the current hardware. Falling back to not using it.
+ MP_ERR(vo, "error creating CGL pixel format with automatic GPU "
+ "switching. falling back\n");
+ attrs[MP_ARRAY_SIZE(attrs) - 2] = 0;
+ err = CGLChoosePixelFormat(attrs, &pix, &npix);
+ }
+
+ if (err != kCGLNoError) {
MP_FATAL(s, "error creating CGL pixel format: %s (%d)\n",
CGLErrorString(err), err);
}