Run Windows games on Apple Silicon — free, open source, with an open compatibility database that tells you what actually works.
Swift apple-silicond3dmetaldxmtdxvkfexgame-porting-toolkitgamingmac-gamingmacosmetalmoltenvksteamswiftuivkd3d-protonwhisky-alternativewindows-gameswinewine-wrapper
frame generation: opengl hook on every renderer, wined3d keeps its own renderer
itsOwend034d46a0557
diff --git a/Sources/HighballKit/Bottle.swift b/Sources/HighballKit/Bottle.swiftindex a486492..70a17c1 100644--- a/Sources/HighballKit/Bottle.swift+++ b/Sources/HighballKit/Bottle.swift@@ -646,18 +646,20 @@ public struct Bottle: Sendable {let shim = engine.resolveLsfgShimDir(), let dll = losslessScalingDLL(environment: env) {let existing = (env["DYLD_LIBRARY_PATH"] ?? "").split(separator: ":").map(String.init)env["DYLD_LIBRARY_PATH"] = ([shim.path] + existing.filter { $0 != shim.path }).joined(separator: ":")- // metal renderers get the same dylib inserted to hook CAMetalLayer, wined3d moves to vulkan+ // every renderer gets the same dylib inserted: metal renderers to hook CAMetalLayer, the rest for OpenGL games+ let dylib = shim.appending(path: "libMoltenVK.dylib").path+ let inserted = (env["DYLD_INSERT_LIBRARIES"] ?? "").split(separator: ":").map(String.init)+ env["DYLD_INSERT_LIBRARIES"] = ([dylib] + inserted.filter { $0 != dylib }).joined(separator: ":")switch r {case .dxmt, .d3dmetal:env["LSFGM_METAL"] = "1"- let dylib = shim.appending(path: "libMoltenVK.dylib").path- let inserted = (env["DYLD_INSERT_LIBRARIES"] ?? "").split(separator: ":").map(String.init)- env["DYLD_INSERT_LIBRARIES"] = ([dylib] + inserted.filter { $0 != dylib }).joined(separator: ":")+ env.removeValue(forKey: "LSFGM_OPENGL")case .wined3d:- let options = (env["WINE_D3D_CONFIG"] ?? "").split(separator: ",").map(String.init)- env["WINE_D3D_CONFIG"] = (["renderer=vulkan"] + options.filter { !$0.hasPrefix("renderer=") }).joined(separator: ",")+ env.removeValue(forKey: "LSFGM_METAL")+ env["LSFGM_OPENGL"] = "1"case .dxvk, .vkd3d:env.removeValue(forKey: "LSFGM_METAL")+ env["LSFGM_OPENGL"] = "1"}env["LSFGM_MOLTENVK"] = env["LSFGM_MOLTENVK"].flatMap { $0.isEmpty ? nil : frameGenPath($0).path }?? shim.appending(path: InstalledEngine.lsfgRealDriverName).path@@ -673,6 +675,7 @@ public struct Bottle: Sendable {env.removeValue(forKey: "LSFGM_ENV")env.removeValue(forKey: "LSFGM_PROFILE")env.removeValue(forKey: "LSFGM_METAL")+ env.removeValue(forKey: "LSFGM_OPENGL")// keep unavailable settings disabledenv["DISABLE_LSFGM"] = "1"if case .unavailable(let reason) = frameGeneration { env["HB_LSFG_UNAVAILABLE"] = reason }diff --git a/Tests/HighballKitTests/FrameGenerationTests.swift b/Tests/HighballKitTests/FrameGenerationTests.swiftindex 39185cc..c0944dd 100644--- a/Tests/HighballKitTests/FrameGenerationTests.swift+++ b/Tests/HighballKitTests/FrameGenerationTests.swift@@ -110,15 +110,20 @@ private func frameGenerationChecks() throws {try check(env["DYLD_INSERT_LIBRARIES"] == dylib + ":/custom/insert.dylib", "Metal hook not inserted ahead of custom libraries")try check(env["DYLD_LIBRARY_PATH"]?.hasPrefix(shim.path) == true, "Vulkan hook (D3D9 on a Metal renderer) missing")env = try bottle.environment(engine: engine, renderer: .wined3d, extra: ["WINE_D3D_CONFIG": "csmt=0,renderer=gl"])- try check(env["LSFGM_ENV"] == "1" && env["LSFGM_METAL"] == nil, "WineD3D did not use the Vulkan hook")- try check(env["WINE_D3D_CONFIG"] == "renderer=vulkan,csmt=0", "WineD3D was not switched to its Vulkan renderer")+ try check(env["LSFGM_ENV"] == "1" && env["LSFGM_METAL"] == nil && env["LSFGM_OPENGL"] == "1", "WineD3D did not use the Vulkan and OpenGL hooks")+ try check(env["WINE_D3D_CONFIG"] == "csmt=0,renderer=gl", "WineD3D OpenGL override was replaced")+ try check(env["DYLD_INSERT_LIBRARIES"] == dylib, "WineD3D OpenGL hook was not inserted")+ env = try bottle.environment(engine: engine, renderer: .wined3d, extra: ["WINE_D3D_CONFIG": "renderer=vulkan,csmt=0"])+ try check(env["WINE_D3D_CONFIG"] == "renderer=vulkan,csmt=0", "WineD3D Vulkan override was replaced")+ env = try bottle.environment(engine: engine, renderer: .wined3d)+ try check(env["WINE_D3D_CONFIG"] == nil, "Frame generation forced a WineD3D renderer")env = try bottle.environment(engine: engine, renderer: .dxvk, extra: ["LSFGM_METAL": "1"])- try check(env["LSFGM_METAL"] == nil && env["DYLD_INSERT_LIBRARIES"] == nil, "Vulkan renderer picked up the metal hook")+ try check(env["LSFGM_METAL"] == nil && env["LSFGM_OPENGL"] == "1" && env["DYLD_INSERT_LIBRARIES"] == dylib, "Vulkan renderer picked up the metal hook or lost the OpenGL one")bottle.settings.frameGen = 1env = try bottle.environment(engine: engine, renderer: .dxvk, extra: ["LSFGM_ENV": "1", "LSFGM_MULTIPLIER": "3"])try check(env["LSFGM_ENV"] == nil && env["DISABLE_LSFGM"] == "1", "Off setting was bypassed by an override")- env = try bottle.environment(engine: engine, renderer: .dxmt, extra: ["LSFGM_METAL": "1"])- try check(env["LSFGM_METAL"] == nil && env["DISABLE_LSFGM"] == "1", "Off setting left the metal hook armed")+ env = try bottle.environment(engine: engine, renderer: .dxmt, extra: ["LSFGM_METAL": "1", "LSFGM_OPENGL": "1"])+ try check(env["LSFGM_METAL"] == nil && env["LSFGM_OPENGL"] == nil && env["DISABLE_LSFGM"] == "1", "Off setting left a hook armed")for value in [-1, 0, 999] {let settings = try JSONDecoder.highball.decode(BottleSettings.self,from: Data("{\"name\":\"old\",\"engineID\":\"e\",\"frameGen\":\(value)}".utf8))