1
0
mirror of https://github.com/mpv-player/mpv synced 2025-01-01 20:32:13 +00:00

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.
This commit is contained in:
Stefano Pigozzi 2014-06-05 09:18:57 +02:00
parent 1927f4535c
commit f645e8921c

View File

@ -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);
}