summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorStefano Pigozzi <stefano.pigozzi@gmail.com>2014-06-05 09:18:57 +0200
committerStefano Pigozzi <stefano.pigozzi@gmail.com>2014-06-15 08:20:06 +0200
commitf645e8921c8f8704ce8b41bc2d7ae80bdcfd6590 (patch)
tree41161130b296cadd3a15fff55ac0cee1c7b1f9a0 /video
parent1927f4535c5c76bae293ea0eddb69f73e01c0206 (diff)
downloadmpv-f645e8921c8f8704ce8b41bc2d7ae80bdcfd6590.tar.bz2
mpv-f645e8921c8f8704ce8b41bc2d7ae80bdcfd6590.tar.xz
cocoa: add fallback for automatic GPU switching
Not all the hardware supports kCGLPFASupportsAutomaticGraphicsSwitching (apparently all Mid-2010 and before MacBooks do not work with it), so fallback to not asking for this attribute in the GL pixel format.
Diffstat (limited to 'video')
-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);
}