aboutsummaryrefslogtreecommitdiffhomepage
path: root/video
diff options
context:
space:
mode:
authorGravatar Akemi <der.richter@gmx.de>2018-07-22 23:07:32 +0200
committerGravatar Jan Ekström <jeebjp@gmail.com>2018-09-30 17:13:34 +0300
commit8d2d0f06403b6777e4b591fa84df57b55e9b7809 (patch)
tree64924f3a148e688f3702849c1495051c0212ff8a /video
parent44e49aee3ccd48459b9c242d296bf7056d2fcdb3 (diff)
cocoa-cb: add Apple Software Renderer support
by default the pixel format creation falls back to software renderer when everything fails. this is mostly needed for VMs. additionally one can directly request an sw renderer or exclude it entirely.
Diffstat (limited to 'video')
-rw-r--r--video/out/cocoa-cb/video_layer.swift29
-rw-r--r--video/out/opengl/common.c3
2 files changed, 29 insertions, 3 deletions
diff --git a/video/out/cocoa-cb/video_layer.swift b/video/out/cocoa-cb/video_layer.swift
index b3893273b1..d6456abe9b 100644
--- a/video/out/cocoa-cb/video_layer.swift
+++ b/video/out/cocoa-cb/video_layer.swift
@@ -32,6 +32,7 @@ class VideoLayer: CAOpenGLLayer {
var needsFlip: Bool = false
var canDrawOffScreen: Bool = false
var cglContext: CGLContextObj? = nil
+ var cglPixelFormat: CGLPixelFormatObj? = nil
var surfaceSize: NSSize?
enum Draw: Int { case normal = 1, atomic, atomicEnd }
@@ -62,7 +63,8 @@ class VideoLayer: CAOpenGLLayer {
autoresizingMask = [.layerWidthSizable, .layerHeightSizable]
backgroundColor = NSColor.black.cgColor
- CGLCreateContext(copyCGLPixelFormat(forDisplayMask: 0), nil, &cglContext)
+ cglPixelFormat = copyCGLPixelFormat(forDisplayMask: 0)
+ CGLCreateContext(cglPixelFormat!, nil, &cglContext)
var i: GLint = 1
CGLSetParameter(cglContext!, kCGLCPSwapInterval, &i)
CGLSetCurrentContext(cglContext!)
@@ -147,6 +149,8 @@ class VideoLayer: CAOpenGLLayer {
}
override func copyCGLPixelFormat(forDisplayMask mask: UInt32) -> CGLPixelFormatObj {
+ if cglPixelFormat != nil { return cglPixelFormat! }
+
let glVersions: [CGLOpenGLProfile] = [
kCGLOGLPVersion_3_2_Core,
kCGLOGLPVersion_Legacy
@@ -157,6 +161,8 @@ class VideoLayer: CAOpenGLLayer {
var npix: GLint = 0
verLoop : for ver in glVersions {
+ if mpv.macOpts!.cocoa_cb_sw_renderer == 1 { break }
+
var glAttributes: [CGLPixelFormatAttribute] = [
kCGLPFAOpenGLProfile, CGLPixelFormatAttribute(ver.rawValue),
kCGLPFAAccelerated,
@@ -177,9 +183,28 @@ class VideoLayer: CAOpenGLLayer {
}
}
+ if (err != kCGLNoError || pix == nil) && mpv.macOpts!.cocoa_cb_sw_renderer != 0 {
+ if mpv.macOpts!.cocoa_cb_sw_renderer == -1 {
+ let errS = String(cString: CGLErrorString(err))
+ mpv.sendWarning("Couldn't create hardware accelerated CGL " +
+ "pixel format, falling back to software " +
+ "renderer: \(errS) (\(err.rawValue))")
+ }
+
+ let glAttributes: [CGLPixelFormatAttribute] = [
+ kCGLPFAOpenGLProfile, CGLPixelFormatAttribute(kCGLOGLPVersion_3_2_Core.rawValue),
+ kCGLPFARendererID, CGLPixelFormatAttribute(UInt32(kCGLRendererGenericFloatID)),
+ kCGLPFADoubleBuffer,
+ kCGLPFABackingStore,
+ _CGLPixelFormatAttribute(rawValue: 0)
+ ]
+
+ err = CGLChoosePixelFormat(glAttributes, &pix, &npix)
+ }
+
if err != kCGLNoError || pix == nil {
let errS = String(cString: CGLErrorString(err))
- mpv.sendError("Couldn't create CGL pixel format: \(errS) (\(err.rawValue))")
+ mpv.sendError("Couldn't create any CGL pixel format: \(errS) (\(err.rawValue))")
exit(1)
}
return pix!
diff --git a/video/out/opengl/common.c b/video/out/opengl/common.c
index 4b0cbcc1c4..00692f0350 100644
--- a/video/out/opengl/common.c
+++ b/video/out/opengl/common.c
@@ -42,7 +42,8 @@ static bool is_software_gl(GL *gl)
strcmp(renderer, "Software Rasterizer") == 0 ||
strstr(renderer, "llvmpipe") ||
strcmp(vendor, "Microsoft Corporation") == 0 ||
- strcmp(renderer, "Mesa X11") == 0;
+ strcmp(renderer, "Mesa X11") == 0 ||
+ strcmp(renderer, "Apple Software Renderer") == 0;
}
static void GLAPIENTRY dummy_glBindFramebuffer(GLenum target, GLuint framebuffer)