1
0
mirror of https://github.com/mpv-player/mpv synced 2025-02-26 18:32:08 +00:00

cocoa: fix fallback for OpenGL 2.1 hardware

This was previously done in common code but now it's left to backends. Also
remove the GL4 stuff since requesting a 3_2_Core context creates a 4.1 context
here (wtf).
This commit is contained in:
Stefano Pigozzi 2015-01-24 16:26:11 +01:00
parent 5e9f791667
commit 3dc3bcf8b6

View File

@ -58,30 +58,12 @@ static void *cocoa_glgetaddr(const char *s)
return ret; return ret;
} }
static bool create_gl_context(struct MPGLContext *ctx) static CGLError test_gl_version(CGLPixelFormatObj *pix,
CGLOpenGLProfile version)
{ {
struct cgl_context *p = ctx->priv;
CGLError err;
CGLOpenGLProfile gl_vers_map[] = {
[2] = kCGLOGLPVersion_Legacy,
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_9
[3] = kCGLOGLPVersion_GL3_Core,
[4] = kCGLOGLPVersion_GL4_Core,
#else
[3] = kCGLOGLPVersion_3_2_Core,
#endif
};
int gl_major = MPGL_VER_GET_MAJOR(ctx->requested_gl_version);
if (gl_major < 2 || gl_major >= MP_ARRAY_SIZE(gl_vers_map)) {
MP_FATAL(ctx->vo, "OpenGL major version %d not supported", gl_major);
return false;
}
CGLPixelFormatAttribute attrs[] = { CGLPixelFormatAttribute attrs[] = {
kCGLPFAOpenGLProfile, kCGLPFAOpenGLProfile,
(CGLPixelFormatAttribute) gl_vers_map[gl_major], (CGLPixelFormatAttribute) version,
kCGLPFADoubleBuffer, kCGLPFADoubleBuffer,
kCGLPFAAccelerated, kCGLPFAAccelerated,
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8 #if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8
@ -93,14 +75,32 @@ static bool create_gl_context(struct MPGLContext *ctx)
}; };
GLint npix; GLint npix;
err = CGLChoosePixelFormat(attrs, &p->pix, &npix); CGLError err;
err = CGLChoosePixelFormat(attrs, pix, &npix);
if (err == kCGLBadAttribute) { if (err == kCGLBadAttribute) {
// kCGLPFASupportsAutomaticGraphicsSwitching is probably not supported // kCGLPFASupportsAutomaticGraphicsSwitching is probably not supported
// by the current hardware. Falling back to not using it. // by the current hardware. Falling back to not using it.
MP_ERR(ctx->vo, "error creating CGL pixel format with automatic GPU "
"switching. falling back\n");
attrs[MP_ARRAY_SIZE(attrs) - 2] = 0; attrs[MP_ARRAY_SIZE(attrs) - 2] = 0;
err = CGLChoosePixelFormat(attrs, &p->pix, &npix); err = CGLChoosePixelFormat(attrs, pix, &npix);
}
return err;
}
static bool create_gl_context(struct MPGLContext *ctx)
{
struct cgl_context *p = ctx->priv;
CGLError err;
CGLOpenGLProfile gl_versions[] = {
kCGLOGLPVersion_3_2_Core,
kCGLOGLPVersion_Legacy,
};
for (int n = 0; n < MP_ARRAY_SIZE(gl_versions); n++) {
err = test_gl_version(&p->pix, gl_versions[n]);
if (err == kCGLNoError)
break;
} }
if (err != kCGLNoError) { if (err != kCGLNoError) {