summaryrefslogtreecommitdiffstats
path: root/video/out
diff options
context:
space:
mode:
Diffstat (limited to 'video/out')
-rw-r--r--video/out/cocoa-cb/video_layer.swift11
-rw-r--r--video/out/opengl/context_cocoa.c8
2 files changed, 14 insertions, 5 deletions
diff --git a/video/out/cocoa-cb/video_layer.swift b/video/out/cocoa-cb/video_layer.swift
index 90a37ae0c5..f9a195b554 100644
--- a/video/out/cocoa-cb/video_layer.swift
+++ b/video/out/cocoa-cb/video_layer.swift
@@ -39,8 +39,7 @@ let glFormatSoftwareBase: [CGLPixelFormatAttribute] = [
let glFormatOptional: [[CGLPixelFormatAttribute]] = [
[kCGLPFABackingStore],
- [kCGLPFAAllowOfflineRenderers],
- [kCGLPFASupportsAutomaticGraphicsSwitching]
+ [kCGLPFAAllowOfflineRenderers]
]
let glFormat10Bit: [CGLPixelFormatAttribute] = [
@@ -49,6 +48,10 @@ let glFormat10Bit: [CGLPixelFormatAttribute] = [
kCGLPFAColorFloat
]
+let glFormatAutoGPU: [CGLPixelFormatAttribute] = [
+ kCGLPFASupportsAutomaticGraphicsSwitching
+]
+
let attributeLookUp: [UInt32:String] = [
kCGLOGLPVersion_3_2_Core.rawValue: "kCGLOGLPVersion_3_2_Core",
kCGLOGLPVersion_Legacy.rawValue: "kCGLOGLPVersion_Legacy",
@@ -272,6 +275,10 @@ class VideoLayer: CAOpenGLLayer {
}
glFormat += glFormatOptional
+ if (libmpv.macOpts.macos_force_dedicated_gpu == 0) {
+ glFormat += [glFormatAutoGPU]
+ }
+
for index in stride(from: glFormat.count-1, through: 0, by: -1) {
let format = glFormat.flatMap { $0 } + [_CGLPixelFormatAttribute(rawValue: 0)]
err = CGLChoosePixelFormat(format, &pix, &npix)
diff --git a/video/out/opengl/context_cocoa.c b/video/out/opengl/context_cocoa.c
index b73ca9d9a2..d0fcd63d62 100644
--- a/video/out/opengl/context_cocoa.c
+++ b/video/out/opengl/context_cocoa.c
@@ -20,15 +20,15 @@
#include "options/m_config.h"
#include "video/out/cocoa_common.h"
#include "context.h"
+#include "osdep/macosx_application.h"
struct cocoa_opts {
- int cocoa_force_dedicated_gpu;
};
#define OPT_BASE_STRUCT struct cocoa_opts
const struct m_sub_options cocoa_conf = {
.opts = (const struct m_option[]) {
- OPT_FLAG("cocoa-force-dedicated-gpu", cocoa_force_dedicated_gpu, 0),
+ OPT_REPLACED("cocoa-force-dedicated-gpu", "macos-force-dedicated-gpu"),
{0}
},
.size = sizeof(struct cocoa_opts),
@@ -41,6 +41,7 @@ struct priv {
CGLContextObj ctx;
struct cocoa_opts *opts;
+ struct macos_opts *macos_opts;
};
static int set_swap_interval(int enabled)
@@ -85,7 +86,7 @@ static CGLError test_gl_version(struct ra_ctx *ctx, CGLOpenGLProfile ver)
CGLError err;
int supported_attribute = MP_ARRAY_SIZE(attrs)-1;
- if (p->opts->cocoa_force_dedicated_gpu)
+ if (p->macos_opts->macos_force_dedicated_gpu)
attrs[--supported_attribute] = 0;
err = CGLChoosePixelFormat(attrs, &p->pix, &npix);
@@ -169,6 +170,7 @@ static bool cocoa_init(struct ra_ctx *ctx)
struct priv *p = ctx->priv = talloc_zero(ctx, struct priv);
GL *gl = &p->gl;
p->opts = mp_get_config_group(ctx, ctx->global, &cocoa_conf);
+ p->macos_opts = mp_get_config_group(ctx, ctx->global, &macos_conf);
vo_cocoa_init(ctx->vo);
MP_WARN(ctx->vo, "opengl cocoa backend is deprecated, use vo=libmpv instead\n");