summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorder richter <der.richter@gmx.de>2024-03-06 21:24:13 +0100
committerJan Ekström <jeebjp@gmail.com>2024-03-06 23:37:32 +0200
commit6016423427ffdad29841093a588c57374c2ad108 (patch)
treed78282aeff886ca84855a6f37d6e3de9e86a277b
parent665a47209869d7a0c4ea860b28910fcd6ca874c8 (diff)
downloadmpv-6016423427ffdad29841093a588c57374c2ad108.tar.bz2
mpv-6016423427ffdad29841093a588c57374c2ad108.tar.xz
mac/vulkan: workaround for MoltenVK problem that causes flicker
MoltenVK itself tries to work around a supposedly Metal problem that itself causes flicker, black screens or broken rendering. it sets the drawableSize to 1x1 to forcefully complete the presentation. though if 1x1 resolution frame is presented it causes a visual flicker or rather a solid coloured frame. it causes even more problems since sometimes it does not reset the drawableSize to the proper resolution and keeps rendering everything in 1x1. work around this workaround by discarding drawableSize that are <=1 in any direction. Fixes #13505
-rw-r--r--video/out/mac/metal_layer.swift11
1 files changed, 11 insertions, 0 deletions
diff --git a/video/out/mac/metal_layer.swift b/video/out/mac/metal_layer.swift
index 7cea87c0b4..9d2b5bd353 100644
--- a/video/out/mac/metal_layer.swift
+++ b/video/out/mac/metal_layer.swift
@@ -20,6 +20,17 @@ import Cocoa
class MetalLayer: CAMetalLayer {
unowned var common: MacCommon
+ // workaround for a MoltenVK workaround that sets the drawableSize to 1x1 to forcefully complete
+ // the presentation, this causes flicker and the drawableSize possibly staying at 1x1
+ override var drawableSize: CGSize {
+ get { return super.drawableSize }
+ set {
+ if Int(newValue.width) > 1 && Int(newValue.height) > 1 {
+ super.drawableSize = newValue
+ }
+ }
+ }
+
init(common com: MacCommon) {
common = com
super.init()