fix(macos): guard MoltenVK heaps
This commit is contained in:
@@ -7,6 +7,7 @@ import QuartzCore
|
|||||||
import UIKit
|
import UIKit
|
||||||
#elseif os(macOS)
|
#elseif os(macOS)
|
||||||
import Cocoa
|
import Cocoa
|
||||||
|
import Metal
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
protocol MpvPlayerDelegate: AnyObject {
|
protocol MpvPlayerDelegate: AnyObject {
|
||||||
@@ -278,6 +279,7 @@ class MpvPlayerCoreBase: NSObject {
|
|||||||
func setupMpv() -> Bool {
|
func setupMpv() -> Bool {
|
||||||
#if os(macOS)
|
#if os(macOS)
|
||||||
guard let renderLayer = metalLayer else { return false }
|
guard let renderLayer = metalLayer else { return false }
|
||||||
|
configureMoltenVKPlacementHeaps()
|
||||||
#else
|
#else
|
||||||
guard let renderLayer = videoLayer else { return false }
|
guard let renderLayer = videoLayer else { return false }
|
||||||
#endif
|
#endif
|
||||||
@@ -597,6 +599,16 @@ class MpvPlayerCoreBase: NSObject {
|
|||||||
checkError(mpv_set_option_string(mpv, "target-colorspace-hint", "yes"))
|
checkError(mpv_set_option_string(mpv, "target-colorspace-hint", "yes"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if os(macOS)
|
||||||
|
private func configureMoltenVKPlacementHeaps() {
|
||||||
|
guard let device = MTLCreateSystemDefaultDevice() else { return }
|
||||||
|
let supportsPlacementHeaps = device.supportsFamily(.apple2) || device.supportsFamily(.mac2)
|
||||||
|
if !supportsPlacementHeaps {
|
||||||
|
setenv("MVK_CONFIG_USE_MTLHEAP", "0", 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
private func isManagedRendererProperty(_ name: String) -> Bool {
|
private func isManagedRendererProperty(_ name: String) -> Bool {
|
||||||
name == "vo" || name == "wid" || name == "gpu-api" || name == "gpu-context"
|
name == "vo" || name == "wid" || name == "gpu-api" || name == "gpu-context"
|
||||||
|| name == "avfoundation-composite-osd"
|
|| name == "avfoundation-composite-osd"
|
||||||
|
|||||||
Reference in New Issue
Block a user