Skip to content

Free fork of NotProton: Windows Steam games in Mac Steam, on CodeWeavers' Wine and Apple's Game Porting Toolkit

feat(defaults): add DLSS Frame Generation, and close the panel on full-screen games (#1922)

Raymond Chin3722c7626867
diff --git a/app/Sources/BridgeplayApp/Resources/Localization/Localizable.xcstrings b/app/Sources/BridgeplayApp/Resources/Localization/Localizable.xcstrings
index 3a4028e..135d4ad 100644
--- a/app/Sources/BridgeplayApp/Resources/Localization/Localizable.xcstrings
+++ b/app/Sources/BridgeplayApp/Resources/Localization/Localizable.xcstrings
@@ -3810,6 +3810,22 @@
}
}
},
+ "DLSS Frame Generation" : {
+ "localizations" : {
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Generazione di frame DLSS"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "DLSS 帧生成"
+ }
+ }
+ }
+ },
"DLSS through MetalFX" : {
"localizations" : {
"it" : {
@@ -4930,6 +4946,38 @@
}
}
},
+ "Frame Generation Engine" : {
+ "localizations" : {
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Motore della generazione di frame"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "帧生成引擎"
+ }
+ }
+ }
+ },
+ "Frame Generation Quality" : {
+ "localizations" : {
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Qualità della generazione di frame"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "帧生成质量"
+ }
+ }
+ }
+ },
"Free software under the GPL-3.0, with no warranty." : {
"localizations" : {
"it" : {
@@ -5954,6 +6002,22 @@
}
}
},
+ "Lets games offer DLSS frame generation. Experimental: it can freeze the Mac on some setups." : {
+ "localizations" : {
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Consente ai giochi di offrire la generazione di frame DLSS. Sperimentale: su alcune configurazioni può bloccare il Mac."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "让游戏提供 DLSS 帧生成。实验性功能:在某些配置下可能导致 Mac 卡死。"
+ }
+ }
+ }
+ },
"Lets games offer DLSS, served by MetalFX. Some games take NVIDIA-only paths with it." : {
"localizations" : {
"it" : {
diff --git a/app/Sources/BridgeplayApp/Support/GameDefaults.swift b/app/Sources/BridgeplayApp/Support/GameDefaults.swift
index 86d820b..f494c9b 100644
--- a/app/Sources/BridgeplayApp/Support/GameDefaults.swift
+++ b/app/Sources/BridgeplayApp/Support/GameDefaults.swift
@@ -27,6 +27,7 @@ enum GameDefaults {
case metalHUD
case nvapi
case metalFX
+ case dlssFrameGen
case advertiseAVX
case msync
case vsync
@@ -47,6 +48,7 @@ enum GameDefaults {
case .metalHUD: ["MTL_HUD_ENABLED"]
case .nvapi: ["NVAPI"]
case .metalFX: ["D3DM_ENABLE_METALFX"]
+ case .dlssFrameGen: ["DLSS_FG"]
case .advertiseAVX: ["ROSETTA_ADVERTISE_AVX"]
case .msync: ["MSYNC"]
case .vsync: ["VSYNC", "BRIDGEPLAY_VSYNC"]
@@ -60,14 +62,14 @@ enum GameDefaults {
}
// The same setting in a game's launch options, where it wins over every conf.
- // NVAPI has no launch-option spelling, and WINEDLLOVERRIDES adds to DLLOVERRIDES
+ // NVAPI and DLSS_FG have no launch-option spelling, and WINEDLLOVERRIDES adds to DLLOVERRIDES
// per DLL instead of replacing it.
var launchKeys: [String] {
switch self {
case .backend: ["BRIDGEPLAY_BACKEND", "NOTPROTON_BACKEND", "CX_GRAPHICS_BACKEND"]
case .metalHUD, .metalFX, .advertiseAVX: keys
case .msync: ["WINEMSYNC"]
- case .nvapi, .dllOverrides: []
+ case .nvapi, .dlssFrameGen, .dllOverrides: []
case .highResolution, .vsync, .frameGen, .frameGenQuality, .frameGenUI, .frameGenFallback, .frameGenEngine:
["BRIDGEPLAY_\(keys[0])", "NOTPROTON_\(keys[0])"]
}
diff --git a/app/Sources/BridgeplayApp/Support/LaunchProgress.swift b/app/Sources/BridgeplayApp/Support/LaunchProgress.swift
index ecd278a..bd590e1 100644
--- a/app/Sources/BridgeplayApp/Support/LaunchProgress.swift
+++ b/app/Sources/BridgeplayApp/Support/LaunchProgress.swift
@@ -153,11 +153,7 @@ final class LaunchProgressWatcher {
let windows = CGWindowListCopyWindowInfo([.optionOnScreenOnly, .excludeDesktopElements], kCGNullWindowID)
as? [[String: Any]] ?? []
for window in windows {
- guard (window[kCGWindowLayer as String] as? Int) == 0,
- let pid = window[kCGWindowOwnerPID as String] as? pid_t, pid != getpid(),
- let bounds = window[kCGWindowBounds as String] as? [String: Double],
- (bounds["Width"] ?? 0) >= 32, (bounds["Height"] ?? 0) >= 32
- else { continue }
+ guard let pid = Self.windowOwner(window), pid != getpid() else { continue }
let started = Self.startTime(of: pid)
let game: Bool
if let started, let known = owners[pid], known.started == started {
@@ -171,6 +167,17 @@ final class LaunchProgressWatcher {
return false
}
+ // A full-screen game draws above layer 0 (Megabonk is on 26), so any layer counts: whose
+ // window it is decides, and the menu bar and Dock hold no game's log.
+ nonisolated static func windowOwner(_ window: [String: Any]) -> pid_t? {
+ guard let layer = window[kCGWindowLayer as String] as? Int, layer >= 0,
+ let pid = window[kCGWindowOwnerPID as String] as? pid_t,
+ let bounds = window[kCGWindowBounds as String] as? [String: Double],
+ (bounds["Width"] ?? 0) >= 32, (bounds["Height"] ?? 0) >= 32
+ else { return nil }
+ return pid
+ }
+
// Microseconds since 1970 at which the process started, nil when it cannot be read.
nonisolated static func startTime(of pid: pid_t) -> UInt64? {
var info = proc_bsdinfo()
diff --git a/app/Sources/BridgeplayApp/Views/GameDefaultsView.swift b/app/Sources/BridgeplayApp/Views/GameDefaultsView.swift
index 224d498..fdac8ef 100644
--- a/app/Sources/BridgeplayApp/Views/GameDefaultsView.swift
+++ b/app/Sources/BridgeplayApp/Views/GameDefaultsView.swift
@@ -23,6 +23,7 @@ struct GameDefaultsView: View {
Section {
choiceRow(.backend)
toggleRow(.metalFX)
+ toggleRow(.dlssFrameGen)
toggleRow(.nvapi)
choiceRow(.msync)
toggleRow(.advertiseAVX)
@@ -188,7 +189,7 @@ struct GameDefaultsView: View {
}
ForEach(overrides) { item in
StatusRow(title: item.name ?? String(localized: "App \(item.appID)"),
- value: item.settings.map(Self.title).joined(separator: ", "),
+ value: item.settings.map(Self.overrideTitle).joined(separator: ", "),
trailing: Self.place(item.place),
action: StatusAction(label: String(localized: "Open in Steam")) { Self.openInSteam(item.appID) },
menu: item.place == .conf
@@ -263,6 +264,7 @@ struct GameDefaultsView: View {
case .metalHUD: String(localized: "Metal HUD")
case .nvapi: String(localized: "Report an NVIDIA GPU")
case .metalFX: String(localized: "DLSS through MetalFX")
+ case .dlssFrameGen: String(localized: "DLSS Frame Generation")
case .advertiseAVX: String(localized: "Advertise AVX2 to Rosetta")
case .msync: "MSync"
case .vsync: String(localized: "Force VSync")
@@ -275,6 +277,15 @@ struct GameDefaultsView: View {
}
}
+ // Listed beside other settings, "Quality" alone reads as the value.
+ static func overrideTitle(_ setting: GameDefaults.Setting) -> String {
+ switch setting {
+ case .frameGenQuality: String(localized: "Frame Generation Quality")
+ case .frameGenEngine: String(localized: "Frame Generation Engine")
+ default: title(setting)
+ }
+ }
+
static func summary(_ setting: GameDefaults.Setting) -> String {
switch setting {
case .backend: String(localized: "Automatic picks D3DMetal when the Game Porting Toolkit is linked, and DXMT otherwise.")
@@ -282,6 +293,7 @@ struct GameDefaultsView: View {
case .metalHUD: String(localized: "Shows frame rate and GPU details in a corner while you play.")
case .nvapi: String(localized: "Lets games offer DLSS, served by MetalFX. Some games take NVIDIA-only paths with it.")
case .metalFX: String(localized: "Only takes effect when DLSS is switched on in the game.")
+ case .dlssFrameGen: String(localized: "Lets games offer DLSS frame generation. Experimental: it can freeze the Mac on some setups.")
case .advertiseAVX: String(localized: "Many games quit without it.")
case .msync: String(localized: "Automatic follows the engine.")
case .vsync: String(localized: "Waits for the display even when a game turns VSync off.")
diff --git a/app/Tests/BridgeplayAppTests/LaunchProgressTests.swift b/app/Tests/BridgeplayAppTests/LaunchProgressTests.swift
index 6c89dda..c68f87e 100644
--- a/app/Tests/BridgeplayAppTests/LaunchProgressTests.swift
+++ b/app/Tests/BridgeplayAppTests/LaunchProgressTests.swift
@@ -1,3 +1,4 @@
+import CoreGraphics
import Foundation
import Testing
@@ -120,4 +121,17 @@ struct LaunchProgressTests {
#expect(LaunchProgressWatcher.gameName(compatdata: compatdata + "/1") == nil)
#expect(LaunchProgressWatcher.gameName(compatdata: "/elsewhere/3372060") == nil)
}
+
+ @Test("A full-screen game's window counts, a sliver of one does not")
+ func windowOwnerTakesFullScreenLayers() {
+ func window(layer: Int, width: Double = 1512) -> [String: Any] {
+ [kCGWindowLayer as String: layer, kCGWindowOwnerPID as String: Int32(42),
+ kCGWindowBounds as String: ["Width": width, "Height": 982.0]]
+ }
+ #expect(LaunchProgressWatcher.windowOwner(window(layer: 0)) == 42)
+ #expect(LaunchProgressWatcher.windowOwner(window(layer: 26)) == 42)
+ #expect(LaunchProgressWatcher.windowOwner(window(layer: 26, width: 10)) == nil)
+ #expect(LaunchProgressWatcher.windowOwner(window(layer: -1)) == nil)
+ }
+
}