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
Add DLSS to MetalFX toggle
Matias G.a431fd0423d8
diff --git a/Sources/HighballApp/BottleView.swift b/Sources/HighballApp/BottleView.swiftindex c15d2ce..db705fa 100644--- a/Sources/HighballApp/BottleView.swift+++ b/Sources/HighballApp/BottleView.swift@@ -282,6 +282,7 @@ struct BottleSettingsSheet: View {private var currentRenderer: Renderer { liveBottle.settings.renderer }private var engine: InstalledEngine? { state.engine(for: liveBottle) }private var d3dmetalAvailable: Bool { engine?.rendererDir("d3dmetal") != nil }+ private var dlssAvailable: Bool { engine.map { liveBottle.supportsDLSS(engine: $0) } ?? false }private var vkd3dAvailable: Bool { engine?.rendererDir("vkd3d") != nil }private var d3dmetalPossible: Bool {guard let engine else { return false }@@ -319,6 +320,10 @@ struct BottleSettingsSheet: View {if vkd3dAvailable || currentRenderer == .vkd3d { Text(L("vkd3d-proton — D3D12 → Vulkan (experimental)")).tag(Renderer.vkd3d) }Text(L("WineD3D — slow fallback")).tag(Renderer.wined3d)}+ Toggle(L("Enable DLSS (MetalFX)"), isOn: binding(\.dlssEnabled))+ .disabled(!dlssAvailable && !liveBottle.settings.dlssEnabled)+ Text(L("Lets games that support DLSS use the MetalFX translation in DXMT or D3DMetal. Turn DLSS on in the game's own graphics settings too. Stop and relaunch the environment after changing this."))+ .font(.caption).foregroundStyle(.secondary)if !d3dmetalAvailable, currentRenderer == .d3dmetal, let engine, let why = Renderer.d3dmetal.unavailableReason(in: engine) {Text(String(format: L("Programs here start with %@ until this is resolved: %@"), GamePageCopy.plainName(Renderer.fallback(for: .d3dmetal, in: engine)), why)).font(.caption).foregroundStyle(.secondary)diff --git a/Sources/HighballApp/L10n.swift b/Sources/HighballApp/L10n.swiftindex 8be7a43..4fe0c8d 100644--- a/Sources/HighballApp/L10n.swift+++ b/Sources/HighballApp/L10n.swift@@ -127,6 +127,9 @@ enum L10n {"Connecting your Epic account": "Connexion de votre compte Epic","Loading your Epic library…": "Chargement de votre bibliothèque Epic…","Advanced": "Avancé",+ "Enable DLSS (MetalFX)": "Activer DLSS (MetalFX)",+ "Lets games that support DLSS use the MetalFX translation in DXMT or D3DMetal. Turn DLSS on in the game's own graphics settings too. Stop and relaunch the environment after changing this.":+ "Permet aux jeux compatibles DLSS d'utiliser la conversion MetalFX de DXMT ou D3DMetal. Activez aussi DLSS dans les réglages graphiques du jeu. Arrêtez puis relancez l'environnement après ce changement.","DLL overrides": "Surcharges de DLL","Extra Wine DLL overrides for this bottle, semicolon separated. Mods like Cyber Engine Tweaks need version=n,b.":"Surcharges de DLL Wine supplémentaires pour cette bouteille, séparées par des points-virgules. Des mods comme Cyber Engine Tweaks demandent version=n,b.",diff --git a/Sources/HighballKit/Bottle.swift b/Sources/HighballKit/Bottle.swiftindex 45227a5..5ee19ed 100644--- a/Sources/HighballKit/Bottle.swift+++ b/Sources/HighballKit/Bottle.swift@@ -334,6 +334,8 @@ public struct BottleSettings: Codable, Sendable {/// through d9vk on an M1 Pro gave −0.1%, p = 0.43. Turn it on per game with a recipe/// dxvkconfig step if a title ever demonstrates a win.public var dxvkAsync: Bool = false+ /// Route the game's DLSS requests through the active Metal renderer's extension bridge.+ public var dlssEnabled: Bool = false/// Cap the frame rate (0 = uncapped). Applied per renderer (DXVK_FRAME_RATE / DXMT_CONFIG).public var fpsCap: Int = 0/// frame generation multiplier; 1 disables it@@ -398,7 +400,7 @@ public struct BottleSettings: Codable, Sendable {public var recipes: [String] = []public var created: Date = Date()- enum CodingKeys: String, CodingKey { case formatVersion, name, engineID, renderer, rendererExplicit, windowsVersion, sync, metalHUD, advertiseAVX, dxvkAsync, fpsCap, frameGen, frameGenAdaptive, frameGenFlowScale, frameGenPerformance, frameGenForceVsync, commandIsControl, commandIsControlSynced, dpiScale, retinaAt100, dllOverrides, dxvkAppConfig, dllOverridesSynced, engineAppDefaultsSynced, keepFilesInside, environment, gameEnvironment, pins, recipes, created }+ enum CodingKeys: String, CodingKey { case formatVersion, name, engineID, renderer, rendererExplicit, windowsVersion, sync, metalHUD, advertiseAVX, dxvkAsync, dlssEnabled, fpsCap, frameGen, frameGenAdaptive, frameGenFlowScale, frameGenPerformance, frameGenForceVsync, commandIsControl, commandIsControlSynced, dpiScale, retinaAt100, dllOverrides, dxvkAppConfig, dllOverridesSynced, engineAppDefaultsSynced, keepFilesInside, environment, gameEnvironment, pins, recipes, created }/// The variables `gameID`'s recipe scoped to it; empty for a game without any, or with no id.public func environment(forGame gameID: String?) -> [String: String] {@@ -431,6 +433,7 @@ public struct BottleSettings: Codable, Sendable {metalHUD = try c.decodeIfPresent(Bool.self, forKey: .metalHUD) ?? falseadvertiseAVX = try c.decodeIfPresent(Bool.self, forKey: .advertiseAVX) ?? falsedxvkAsync = try c.decodeIfPresent(Bool.self, forKey: .dxvkAsync) ?? false+ dlssEnabled = try c.decodeIfPresent(Bool.self, forKey: .dlssEnabled) ?? falsefpsCap = try c.decodeIfPresent(Int.self, forKey: .fpsCap) ?? 0let decodedFrameGen = try c.decodeIfPresent(Int.self, forKey: .frameGen) ?? 1frameGen = (1...4).contains(decodedFrameGen) ? decodedFrameGen : 1@@ -728,6 +731,26 @@ public struct Bottle: Sendable {merge(&env, settings.environment)merge(&env, try effective.environment(engine: engine))merge(&env, extra)+ // CrossOver's DLSS switch enables the renderer's NVIDIA extension bridge. DXMT ships+ // its DLLs under their normal names; Apple's D3DMetal bridge is named nvngx-on-metalfx+ // and is exposed as nvngx.dll in this bottle at launch (see prepareDLSSBridge).+ // Gate the environment by the effective renderer, including per-game overrides.+ if settings.dlssEnabled, supportsDLSS(engine: engine, renderer: r) {+ switch r {+ case .dxmt:+ env["DXMT_ENABLE_NVEXT"] = "1"+ merge(&env, ["WINEDLLOVERRIDES+": "nvapi64,nvngx=n,b"])+ case .d3dmetal:+ env["D3DM_ENABLE_METALFX"] = "1"+ if needsDLSSBridgeAliases(engine: engine) {+ let aliases = url.appending(path: ".highball-dlss/wine").path+ merge(&env, ["WINEDLLPATH_PREPEND+": aliases])+ }+ merge(&env, ["WINEDLLOVERRIDES+": "nvapi64,nvngx=n,b"])+ default:+ break+ }+ }// apply frame generation after all overridesenv.removeValue(forKey: "HB_LSFG_UNAVAILABLE")let shimDir = engine.resolveLsfgShimDir()@@ -773,6 +796,36 @@ public struct Bottle: Sendable {return env}+ /// The renderer-specific bridge files that make the DLSS switch actionable in this engine.+ public func supportsDLSS(engine: InstalledEngine, renderer: Renderer? = nil) -> Bool {+ let selected = renderer ?? settings.renderer+ guard let dir = engine.rendererDir(selected.rawValue) else { return false }+ switch selected {+ case .dxmt:+ return FileManager.default.fileExists(atPath: dir.appending(path: "wine/x86_64-windows/nvngx.dll").path)+ case .d3dmetal:+ let windows = ["nvngx.dll", "nvngx-on-metalfx.dll"].contains {+ FileManager.default.fileExists(atPath: dir.appending(path: "wine/x86_64-windows/\($0)").path)+ }+ let unix = ["nvngx.so", "nvngx-on-metalfx.so"].contains {+ FileManager.default.fileExists(atPath: dir.appending(path: "wine/x86_64-unix/\($0)").path)+ }+ return windows && unix+ default:+ return false+ }+ }++ private func needsDLSSBridgeAliases(engine: InstalledEngine) -> Bool {+ guard let dir = engine.rendererDir("d3dmetal") else { return false }+ let wine = dir.appending(path: "wine")+ let needsWindowsAlias = !FileManager.default.fileExists(atPath: wine.appending(path: "x86_64-windows/nvngx.dll").path)+ && FileManager.default.fileExists(atPath: wine.appending(path: "x86_64-windows/nvngx-on-metalfx.dll").path)+ let needsUnixAlias = !FileManager.default.fileExists(atPath: wine.appending(path: "x86_64-unix/nvngx.so").path)+ && FileManager.default.fileExists(atPath: wine.appending(path: "x86_64-unix/nvngx-on-metalfx.so").path)+ return needsWindowsAlias || needsUnixAlias+ }+/// Windows path of the generated DXVK config inside the prefix.public static let dxvkConfigWindowsPath = #"C:\highball\dxvk.conf"#/// Unix location of the same file.@@ -846,6 +899,37 @@ public struct Bottle: Sendable {}}+ /// Apple's GPTK ships the MetalFX NGX bridge under its descriptive filename. Wine looks+ /// for the standard nvngx module name, so expose aliases inside this bottle (never the shared+ /// engine or Windows system32). The aliases are only put on the DLL search path when the+ /// setting is enabled and D3DMetal is the effective renderer.+ public func prepareDLSSBridge(engine: InstalledEngine, renderer: Renderer) throws {+ guard settings.dlssEnabled, renderer == .d3dmetal,+ let dir = engine.rendererDir("d3dmetal") else { return }+ let sources = [+ (dir.appending(path: "wine/x86_64-windows/nvngx.dll"), dir.appending(path: "wine/x86_64-windows/nvngx-on-metalfx.dll"), "x86_64-windows/nvngx.dll"),+ (dir.appending(path: "wine/x86_64-unix/nvngx.so"), dir.appending(path: "wine/x86_64-unix/nvngx-on-metalfx.so"), "x86_64-unix/nvngx.so"),+ ]+ let fm = FileManager.default+ let wineDir = url.appending(path: ".highball-dlss/wine", directoryHint: .isDirectory)+ for (direct, renamed, relativeTarget) in sources {+ if fm.fileExists(atPath: direct.path) { continue }+ guard fm.fileExists(atPath: renamed.path) else {+ throw HighballError.missing("D3DMetal's DLSS-to-MetalFX bridge (nvngx-on-metalfx)")+ }+ let target = wineDir.appending(path: relativeTarget)+ try fm.createDirectory(at: target.deletingLastPathComponent(), withIntermediateDirectories: true)+ if let existing = try? fm.destinationOfSymbolicLink(atPath: target.path),+ URL(fileURLWithPath: existing, relativeTo: target.deletingLastPathComponent()).standardizedFileURL == renamed.standardizedFileURL {+ continue+ }+ if fm.fileExists(atPath: target.path) || (try? fm.destinationOfSymbolicLink(atPath: target.path)) != nil {+ try fm.removeItem(at: target)+ }+ try fm.createSymbolicLink(at: target, withDestinationURL: renamed)+ }+ }+private func merge(_ env: inout [String: String], _ add: [String: String]) {for (k, v) in add {if k.hasSuffix("+") {diff --git a/Sources/HighballKit/WineRunner.swift b/Sources/HighballKit/WineRunner.swiftindex a103a5a..df93841 100644--- a/Sources/HighballKit/WineRunner.swift+++ b/Sources/HighballKit/WineRunner.swift@@ -120,6 +120,7 @@ public struct WineRunner: Sendable {// A bottle set to a renderer its engine cannot run degrades to one it can (#61); the// note goes in the header and to the caller so the substitution is never silent.let resolved = try bottle.effectiveRenderer(requested: renderer, engine: engine)+ try bottle.prepareDLSSBridge(engine: engine, renderer: resolved.renderer)if resolved.renderer != .wined3d { try? bottle.writeDxvkConfig() }var env = try bottle.environment(engine: engine, renderer: renderer, extra: extraEnvironment)// Wine fixes the sync mode when the prefix's wineserver starts; a process started with a