Skip to content

Run Windows games on Apple Silicon — free, open source, with an open compatibility database that tells you what actually works.

steam launch: a changed AVX or Metal HUD toggle restarts the running client, and the launch header records both (highball-db#48)

Gauthier Piarrette2820bcebac43
diff --git a/Sources/HighballKit/SteamRestart.swift b/Sources/HighballKit/SteamRestart.swift
index 4f4ce01..3bf326b 100644
--- a/Sources/HighballKit/SteamRestart.swift
+++ b/Sources/HighballKit/SteamRestart.swift
@@ -9,8 +9,11 @@ import Foundation
/// wrong renderer, while its log header claims otherwise (UX plan 0.6, issue #54).
public enum SteamRestart {
/// Pure: why the running client (environment `live`) cannot serve a launch that needs
- /// `wanted`, in words for the log, or nil when it can. Only the renderer overlay path and
- /// the sync mode matter; everything else in the environment is per-launch noise.
+ /// `wanted`, in words for the log, or nil when it can. The renderer overlay path, the sync mode
+ /// and the inherited per-process toggles matter; everything else in the environment is per-launch noise.
+ /// Per-process settings the game inherits from the client and cannot change afterwards.
+ static let inherited: [(String, String)] = [("ROSETTA_ADVERTISE_AVX", "AVX advertised"), ("MTL_HUD_ENABLED", "the Metal HUD")]
+
public static func reason(live: [String: String], wanted: [String: String], wantedRenderer: String) -> String? {
var reasons: [String] = []
if live["WINEDLLPATH_PREPEND"] != wanted["WINEDLLPATH_PREPEND"] {
@@ -20,6 +23,12 @@ public enum SteamRestart {
if liveSync != wantedSync {
reasons.append("it runs with sync \(liveSync.rawValue) and the game wants \(wantedSync.rawValue)")
}
+ // Rosetta reads these at process start and the game inherits them from the client, so a
+ // toggle flipped while the client runs would otherwise never reach the game while the
+ // settings page says it is on (highball-db#48, Hogwarts Legacy crashed on the "AVX" run).
+ for (key, what) in inherited where (live[key] == "1") != (wanted[key] == "1") {
+ reasons.append("it runs with \(what) \(live[key] == "1" ? "on" : "off") and the game wants it \(wanted[key] == "1" ? "on" : "off")")
+ }
return reasons.isEmpty ? nil : reasons.joined(separator: "; ")
}
}
diff --git a/Sources/HighballKit/WineRunner.swift b/Sources/HighballKit/WineRunner.swift
index 399ee4d..70f9403 100644
--- a/Sources/HighballKit/WineRunner.swift
+++ b/Sources/HighballKit/WineRunner.swift
@@ -77,7 +77,7 @@ public struct WineRunner: Sendable {
out += "# sync=\(Self.effectiveSync(env: env, settings: bottle.settings))"
out += " winver=\(bottle.settings.windowsVersion.rawValue) dpi=\(bottle.settings.dpiScale)"
out += " dxvkAsync=\(bottle.settings.dxvkAsync)\n"
- for key in ["WINEDLLPATH_PREPEND", "WINEDLLOVERRIDES", "DXVK_CONFIG_FILE", "DXVK_LOG_PATH"] {
+ for key in ["WINEDLLPATH_PREPEND", "WINEDLLOVERRIDES", "ROSETTA_ADVERTISE_AVX", "MTL_HUD_ENABLED", "DXVK_CONFIG_FILE", "DXVK_LOG_PATH"] {
if let value = env[key] { out += "# \(key)=\(value)\n" }
}
// The generated dxvk.conf decides per-game behaviour, so quote it rather than making the
diff --git a/Tests/HighballKitTests/SteamRestartTests.swift b/Tests/HighballKitTests/SteamRestartTests.swift
index 856452c..0ced0bd 100644
--- a/Tests/HighballKitTests/SteamRestartTests.swift
+++ b/Tests/HighballKitTests/SteamRestartTests.swift
@@ -36,4 +36,19 @@ final class SteamRestartTests: XCTestCase {
var live = dxvk; live["DXVK_LOG_PATH"] = "C:\\other"; live["STEAM_COMPAT"] = "1"
XCTAssertNil(SteamRestart.reason(live: live, wanted: dxvk, wantedRenderer: "dxvk"))
}
+
+ func testAVXToggleFlippedWhileTheClientRunsRestartsIt() {
+ var wanted = dxvk; wanted["ROSETTA_ADVERTISE_AVX"] = "1"
+ XCTAssertEqual(SteamRestart.reason(live: dxvk, wanted: wanted, wantedRenderer: "dxvk"),
+ "it runs with AVX advertised off and the game wants it on")
+ XCTAssertEqual(SteamRestart.reason(live: wanted, wanted: dxvk, wantedRenderer: "dxvk"),
+ "it runs with AVX advertised on and the game wants it off")
+ XCTAssertNil(SteamRestart.reason(live: wanted, wanted: wanted, wantedRenderer: "dxvk"))
+ }
+
+ func testMetalHUDToggleFlippedWhileTheClientRunsRestartsIt() {
+ var wanted = dxvk; wanted["MTL_HUD_ENABLED"] = "1"
+ XCTAssertEqual(SteamRestart.reason(live: dxvk, wanted: wanted, wantedRenderer: "dxvk"),
+ "it runs with the Metal HUD off and the game wants it on")
+ }
}