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
fix: legacy CS:GO froze at map load — per-game DXVK config, async off for csgo.exe (#21)
Gauthier Piarrettee036f7bff98e
diff --git a/Sources/HighballKit/Bottle.swift b/Sources/HighballKit/Bottle.swiftindex 495a4d8..889706b 100644--- a/Sources/HighballKit/Bottle.swift+++ b/Sources/HighballKit/Bottle.swift@@ -251,7 +251,11 @@ public struct Bottle: Sendable {if settings.metalHUD { env["MTL_HUD_ENABLED"] = "1" }if settings.advertiseAVX { env["ROSETTA_ADVERTISE_AVX"] = "1" }let r = renderer ?? settings.renderer- if r == .dxvk, settings.dxvkAsync { env["DXVK_ASYNC"] = "1" }+ // The async toggle travels in the generated dxvk.conf, NOT the DXVK_ASYNC env var:+ // the async fork reads `env == "1" || config.enableAsync`, so an env 1 can never be+ // overridden for a single game, while the conf's [csgo.exe] section can (issue #21).+ // WineRunner writes the file before each dxvk launch.+ if r == .dxvk { env["DXVK_CONFIG_FILE"] = Self.dxvkConfigWindowsPath }if settings.fpsCap > 0 {switch r {case .dxvk: env["DXVK_FRAME_RATE"] = String(settings.fpsCap)@@ -266,6 +270,45 @@ public struct Bottle: Sendable {return env}+ /// Windows path of the generated DXVK config inside the prefix.+ public static let dxvkConfigWindowsPath = #"C:\highball\dxvk.conf"#+ /// Unix location of the same file.+ public var dxvkConfigURL: URL { driveC.appending(path: "highball/dxvk.conf") }++ /// Contents of the per-bottle dxvk.conf. The global line carries the bottle's async+ /// toggle. The [csgo.exe] section is the issue #21 profile: legacy CS:GO (32-bit D3D9)+ /// froze at map-load "Initializing game data" on defaults. Async compile off there+ /// (the d9vk fork's own wrapper never enables async; the first map load's pipeline+ /// burst is exactly the freeze point), 2 GB reported texture memory (DXVK's standard+ /// 32-bit address-space mitigation, cf. its built-in Vampire profile), and a real+ /// Radeon device id to pair with the AMD vendor id DXVK's built-in csgo profile+ /// already forces, so the game's dxsupport.cfg picks a concrete GPU profile instead+ /// of unknown-device failsafe. Later lines win, so the section must follow the global.+ public static func dxvkConfig(async: Bool) -> String {+ """+ # Written by Highball before each DXVK launch — edits here are overwritten.+ # The bottle's "DXVK async shader compilation" toggle sets the global line.+ dxvk.enableAsync = \(async ? "True" : "False")++ # Legacy CS:GO froze at map load with async compile on (issue #21).+ [csgo.exe]+ dxvk.enableAsync = False+ d3d9.maxAvailableMemory = 2048+ d3d9.customDeviceId = 73BF++ """+ }++ /// Writes the generated dxvk.conf into the prefix (idempotent, compare-then-write).+ public func writeDxvkConfig() throws {+ let dir = dxvkConfigURL.deletingLastPathComponent()+ try FileManager.default.createDirectory(at: dir, withIntermediateDirectories: true)+ let content = Self.dxvkConfig(async: settings.dxvkAsync)+ if (try? String(contentsOf: dxvkConfigURL, encoding: .utf8)) != content {+ try content.write(to: dxvkConfigURL, atomically: true, encoding: .utf8)+ }+ }+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 df5a7ab..5525301 100644--- a/Sources/HighballKit/WineRunner.swift+++ b/Sources/HighballKit/WineRunner.swift@@ -31,6 +31,9 @@ public struct WineRunner: Sendable {onOutput: (@Sendable (String) -> Void)? = nil) async throws -> LaunchResult {try paths.ensure()+ // The dxvk renderer reads its options from the generated conf (async toggle ++ // per-game profiles like [csgo.exe], issue #21) — refresh it before the spawn.+ if (renderer ?? bottle.settings.renderer) == .dxvk { try? bottle.writeDxvkConfig() }let env = try bottle.environment(engine: engine, renderer: renderer, extra: extraEnvironment)let stamp = ISO8601DateFormatter().string(from: Date()).replacingOccurrences(of: ":", with: "")let logURL = paths.logs.appending(path: "\(stamp)-\(bottle.name)-\(label ?? args.first ?? "wine").log")diff --git a/Sources/highball/main.swift b/Sources/highball/main.swiftindex ffafa65..f3d583a 100644--- a/Sources/highball/main.swift+++ b/Sources/highball/main.swift@@ -109,7 +109,7 @@ struct Bottle: AsyncParsableCommand {}struct Set: AsyncParsableCommand {- static let configuration = CommandConfiguration(abstract: "Change a bottle setting: renderer, winver, sync, hud, avx, dpi, dlloverrides, env KEY=VALUE")+ static let configuration = CommandConfiguration(abstract: "Change a bottle setting: renderer, winver, sync, hud, avx, dpi, dxvkasync, dlloverrides, env KEY=VALUE")@Argument var name: String@Argument var setting: String@Argument var value: String@@ -127,6 +127,7 @@ struct Bottle: AsyncParsableCommand {case "sync": guard let s = SyncMode(rawValue: value) else { fail("bad sync") }; b.settings.sync = scase "hud": b.settings.metalHUD = (value == "1" || value == "true")case "avx": b.settings.advertiseAVX = (value == "1" || value == "true")+ case "dxvkasync": b.settings.dxvkAsync = (value == "1" || value == "true")case "dlloverrides":b.settings.dllOverrides = valuecase "dpi":diff --git a/Tests/HighballKitTests/EnvironmentTests.swift b/Tests/HighballKitTests/EnvironmentTests.swiftindex e4e23eb..38fa1a0 100644--- a/Tests/HighballKitTests/EnvironmentTests.swift+++ b/Tests/HighballKitTests/EnvironmentTests.swift@@ -76,6 +76,26 @@ final class EnvironmentTests: XCTestCase {XCTAssertEqual(flat(""), [])}+ // The generated dxvk.conf: global line follows the bottle toggle, and the [csgo.exe]+ // section (issue #21: legacy CS:GO map-load freeze) must come AFTER it — later lines+ // win in DXVK's parser — carrying async off, the 32-bit memory cap, and the device id.+ func testDxvkConfigContent() {+ let on = Bottle.dxvkConfig(async: true)+ XCTAssertTrue(on.contains("dxvk.enableAsync = True"))+ let section = on.range(of: "[csgo.exe]")+ let global = on.range(of: "dxvk.enableAsync = True")+ XCTAssertNotNil(section); XCTAssertNotNil(global)+ XCTAssertTrue(global!.lowerBound < section!.lowerBound, "global line must precede the per-app section")+ let tail = String(on[section!.lowerBound...])+ XCTAssertTrue(tail.contains("dxvk.enableAsync = False"))+ XCTAssertTrue(tail.contains("d3d9.maxAvailableMemory = 2048"))+ XCTAssertTrue(tail.contains("d3d9.customDeviceId = 73BF"))++ let off = Bottle.dxvkConfig(async: false)+ XCTAssertTrue(off.contains("dxvk.enableAsync = False"))+ XCTAssertFalse(off.contains("dxvk.enableAsync = True"))+ }+// extra (per-pin environment from the program settings sheet) wins over bottle env.func testExtraEnvironmentWins() throws {var (engine, bottle) = try fixtures()@@ -102,7 +122,11 @@ final class EnvironmentTests: XCTestCase {defer { try? FileManager.default.removeItem(at: engine.root) }env = try bottle.environment(engine: engine, renderer: .dxvk)XCTAssertEqual(env["DXVK_FRAME_RATE"], "60")- XCTAssertEqual(env["DXVK_ASYNC"], "1", "dxvkAsync defaults on")+ // The async toggle travels via the generated conf, never DXVK_ASYNC: the async fork+ // reads `env == "1" || config.enableAsync`, so an env 1 would defeat the per-game+ // [csgo.exe] override that issue #21 requires.+ XCTAssertNil(env["DXVK_ASYNC"], "async must ride the conf, not the env")+ XCTAssertEqual(env["DXVK_CONFIG_FILE"], #"C:\highball\dxvk.conf"#)// d9vk must come first so DXVK's d3d9 wins the builtin search over wined3d (#21 CSM gate).XCTAssertEqual(env["WINEDLLPATH_PREPEND"], "\(d9vkWine.path):\(dxvkWine.path)")}