Skip to content

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

An engine can keep Direct3D 9 on Wine's own Direct3D in the automatic modes; r11 and r12 do

Gauthier Piarrette39c5b607e193
diff --git a/Sources/HighballApp/AppState.swift b/Sources/HighballApp/AppState.swift
index 004d63a..a77bca7 100644
--- a/Sources/HighballApp/AppState.swift
+++ b/Sources/HighballApp/AppState.swift
@@ -611,6 +611,9 @@ final class AppState {
let n = LogPruner.prune(directory: paths.logs)
if n > 0 { appendLog("pruned \(n) old log file(s)") }
}
+ // Facts a newer bundled manifest states about an installed engine reach its installed
+ // manifest here, before the engines are read (the r11/r12 Direct3D 9 rule, highball#198).
+ engineStore.adoptKnownFacts(known: Self.knownManifests)
engines = (try? engineStore.installedEngines()) ?? []
lsfgShimDirs = Dictionary(engines.compactMap { e in e.resolveLsfgShimDir().map { (e.id, $0) } }, uniquingKeysWith: { a, _ in a })
bottles = (try? bottleStore.list()) ?? []
diff --git a/Sources/HighballKit/Bottle.swift b/Sources/HighballKit/Bottle.swift
index bb862df..e4fe970 100644
--- a/Sources/HighballKit/Bottle.swift
+++ b/Sources/HighballKit/Bottle.swift
@@ -93,6 +93,9 @@ public enum Renderer: String, Codable, CaseIterable, Sendable {
/// default renderer's path, and an engine missing d9vk should still run D3D11 titles. The
/// dxvk case keeps its hard failure, because there D3D9 is the whole point.
private static func withD9VK(_ path: String, engine: InstalledEngine) -> String {
+ // An engine can say Direct3D 9 is faster on Wine's own (the Wine 11 tree, highball#198);
+ // then the automatic modes leave d9vk off and the explicit DXVK mode below keeps it.
+ if engine.direct3D9UsesWined3d { return path }
guard let d9vk = engine.rendererDir("d9vk") else { return path }
return [path, d9vk.appending(path: "wine").path].joined(separator: ":")
}
diff --git a/Sources/HighballKit/EngineStore.swift b/Sources/HighballKit/EngineStore.swift
index fdbf24a..d09b2ea 100644
--- a/Sources/HighballKit/EngineStore.swift
+++ b/Sources/HighballKit/EngineStore.swift
@@ -152,6 +152,24 @@ public struct EngineStore: Sendable {
return InstalledEngine(manifest: m, root: root)
}
+ /// Copies facts a newer bundled manifest states about an engine into the installed copy of
+ /// that engine's manifest, so an engine installed before the fact was known behaves as the
+ /// app now knows it should (the r11 and r12 Direct3D 9 rule, highball#198). Only fields the
+ /// installed manifest does not set are written; returns the ids updated.
+ @discardableResult
+ public func adoptKnownFacts(known: [EngineManifest]) -> [String] {
+ var updated: [String] = []
+ for engine in (try? installedEngines()) ?? [] {
+ guard let fact = known.first(where: { $0.id == engine.id }) else { continue }
+ var m = engine.manifest
+ var changed = false
+ if m.direct3D9 == nil, let d9 = fact.direct3D9 { m.direct3D9 = d9; changed = true }
+ guard changed else { continue }
+ if (try? m.save(to: engine.root.appending(path: "manifest.json"))) != nil { updated.append(engine.id) }
+ }
+ return updated
+ }
+
// MARK: Install
/// Installs every component of `manifest`. Optional components are skipped unless their
@@ -438,6 +456,9 @@ public struct InstalledEngine: Sendable {
public let root: URL
public var id: String { manifest.id }
+ /// Direct3D 9 stays with Wine's own Direct3D in the automatic modes on this engine (see
+ /// `EngineManifest.direct3D9`).
+ public var direct3D9UsesWined3d: Bool { manifest.direct3D9 == "wined3d" }
/// Short human name for UI ("Wine 10.0 (Sikarugir)" beats a manifest id).
public var displayName: String {
manifest.components["wine"]?.version ?? manifest.displayName
diff --git a/Sources/HighballKit/Manifest.swift b/Sources/HighballKit/Manifest.swift
index c688c39..fd81648 100644
--- a/Sources/HighballKit/Manifest.swift
+++ b/Sources/HighballKit/Manifest.swift
@@ -63,6 +63,14 @@ public struct EngineManifest: Codable, Sendable, Identifiable {
}
public var requires: [String]?
public var notes: [String]?
+ /// Which Direct3D 9 a game gets in the automatic modes (DXMT, D3DMetal): nil attaches DXVK's
+ /// d3d9 (the d9vk overlay) beside the Metal backend, "wined3d" leaves Direct3D 9 to Wine's
+ /// own, because on this engine that is the fast path. Measured on the Wine 11 tree: Half-Life
+ /// 2 131 fps on wined3d against 17 on DXVK's d3d9, Five Nights at Freddy's 40 fps on DXVK's
+ /// d3d9 where the Wine 10 engine gives 76 (highball#198, 2026-09-25). The explicit DXVK mode
+ /// keeps DXVK's d3d9 whatever this says: there Direct3D 9 through DXVK is the point (CS:GO
+ /// Legacy's CSM check needs it, highball#21).
+ public var direct3D9: String?
public var components: [String: Component]
public var baseEnv: [String: String]?
/// License ids that gate optional renderers (e.g. `apple-gptk-license-2023-08-17` → d3dmetal).
diff --git a/Sources/highball/main.swift b/Sources/highball/main.swift
index bed24e9..60db55c 100644
--- a/Sources/highball/main.swift
+++ b/Sources/highball/main.swift
@@ -375,6 +375,19 @@ struct PinCommand: AsyncParsableCommand {
}
}
+/// The engine manifests a repo checkout ships (`spike/engine-manifest.json`, `spike/engines/*.json`),
+/// found from the current directory as the recipe and database paths are. Facts they state
+/// about an installed engine are adopted into it before a launch, so a CLI launch matches the
+/// app's (the r11/r12 Direct3D 9 rule, highball#198). Nothing outside a checkout: no manifests.
+func adoptKnownEngineFacts() {
+ var urls = [URL(fileURLWithPath: "spike/engine-manifest.json")]
+ if let more = try? FileManager.default.contentsOfDirectory(at: URL(fileURLWithPath: "spike/engines"), includingPropertiesForKeys: nil) {
+ urls += more.filter { $0.pathExtension == "json" }
+ }
+ let known = urls.compactMap { try? EngineManifest.load(from: $0) }
+ if !known.isEmpty { EngineStore().adoptKnownFacts(known: known) }
+}
+
struct Run: AsyncParsableCommand {
static let configuration = CommandConfiguration(abstract: "Run a program in a bottle: a pin name, a Windows path, or a Unix path.")
@Argument var bottle: String
@@ -385,6 +398,7 @@ struct Run: AsyncParsableCommand {
func run() async throws {
let b = try BottleStore().get(bottle)
+ adoptKnownEngineFacts()
let eng = try EngineStore().engine(b.settings.engineID)
let runner = WineRunner(engine: eng, bottle: b)
await BottleStore.preflight(runner: runner, bottle: b) { print($0) }
@@ -534,6 +548,7 @@ struct Verify: AsyncParsableCommand {
func run() async throws {
let b = try BottleStore().get(bottle)
+ adoptKnownEngineFacts()
let eng = try EngineStore().engine(b.settings.engineID)
var library = SteamLibrary.games(in: b).filter(\.isReady)
if !games.isEmpty { library = library.filter { games.contains($0.appid) } }
diff --git a/Tests/HighballKitTests/EngineDirect3D9RuleTests.swift b/Tests/HighballKitTests/EngineDirect3D9RuleTests.swift
new file mode 100644
index 0000000..c4e5507
--- /dev/null
+++ b/Tests/HighballKitTests/EngineDirect3D9RuleTests.swift
@@ -0,0 +1,79 @@
+import XCTest
+@testable import HighballKit
+
+/// An engine can say Direct3D 9 belongs to Wine's own Direct3D in the automatic modes
+/// (`EngineManifest.direct3D9 == "wined3d"`): on the Wine 11 tree DXVK's d3d9 is the slow path
+/// (highball#198). The explicit DXVK mode keeps DXVK's d3d9, since there it is the point (#21).
+final class EngineDirect3D9RuleTests: XCTestCase {
+
+ private func engine(direct3D9: String?) throws -> InstalledEngine {
+ let manifestURL = URL(fileURLWithPath: #filePath)
+ .deletingLastPathComponent().deletingLastPathComponent().deletingLastPathComponent()
+ .appending(path: "spike/engine-manifest.json")
+ var manifest = try EngineManifest.load(from: manifestURL)
+ manifest.direct3D9 = direct3D9
+ let root = FileManager.default.temporaryDirectory.appending(path: "hb-d3d9-engine-\(UUID().uuidString)")
+ for dir in ["d9vk/wine", "dxvk/wine", "dxmt/wine"] {
+ try FileManager.default.createDirectory(at: root.appending(path: "renderers/\(dir)"), withIntermediateDirectories: true)
+ }
+ return InstalledEngine(manifest: manifest, root: root)
+ }
+
+ func testAutomaticModeLeavesDirect3D9ToWineOnAFlaggedEngine() throws {
+ let flagged = try engine(direct3D9: "wined3d")
+ defer { try? FileManager.default.removeItem(at: flagged.root) }
+ let bottle = Bottle(url: URL(fileURLWithPath: "/tmp/hb-d3d9-bottle"), settings: BottleSettings(name: "t", engineID: flagged.id))
+ let env = try bottle.environment(engine: flagged, renderer: .dxmt)
+ XCTAssertFalse(env["WINEDLLPATH_PREPEND"]!.contains("d9vk"), "DXMT on a flagged engine must not attach DXVK's d3d9: \(env["WINEDLLPATH_PREPEND"]!)")
+ XCTAssertTrue(env["WINEDLLPATH_PREPEND"]!.contains("dxmt/wine"))
+ // The explicit DXVK mode is untouched: both overlays, d9vk first.
+ let dxvk = try bottle.environment(engine: flagged, renderer: .dxvk)
+ XCTAssertEqual(dxvk["WINEDLLPATH_PREPEND"], "\(flagged.renderersDir.appending(path: "d9vk/wine").path):\(flagged.renderersDir.appending(path: "dxvk/wine").path)")
+ }
+
+ func testAnUnflaggedEngineStillAttachesDXVKsDirect3D9() throws {
+ let plain = try engine(direct3D9: nil)
+ defer { try? FileManager.default.removeItem(at: plain.root) }
+ XCTAssertFalse(plain.direct3D9UsesWined3d)
+ let bottle = Bottle(url: URL(fileURLWithPath: "/tmp/hb-d3d9-bottle"), settings: BottleSettings(name: "t", engineID: plain.id))
+ let env = try bottle.environment(engine: plain, renderer: .dxmt)
+ XCTAssertTrue(env["WINEDLLPATH_PREPEND"]!.hasSuffix(plain.renderersDir.appending(path: "d9vk/wine").path), "d9vk appended after the backend as before")
+ }
+
+ func testInstalledManifestsAdoptTheFlagFromTheBundledOneOnce() throws {
+ let home = FileManager.default.temporaryDirectory.appending(path: "hb-d3d9-home-\(UUID().uuidString)")
+ defer { try? FileManager.default.removeItem(at: home) }
+ let paths = HighballPaths(home: home)
+ let store = EngineStore(paths: paths)
+ // Two installed engines: r11 without the flag (installed before the rule), r9 unaffected.
+ let manifestURL = URL(fileURLWithPath: #filePath)
+ .deletingLastPathComponent().deletingLastPathComponent().deletingLastPathComponent()
+ .appending(path: "spike/engine-manifest.json")
+ var base = try EngineManifest.load(from: manifestURL)
+ base.direct3D9 = nil
+ for id in ["x64-crossover26.3-r11", "x64-sikarugir10.0_6-r9"] {
+ var m = base; m.id = id
+ let dir = paths.engine(id)
+ try FileManager.default.createDirectory(at: dir, withIntermediateDirectories: true)
+ try m.save(to: dir.appending(path: "manifest.json"))
+ }
+ var known = base; known.id = "x64-crossover26.3-r11"; known.direct3D9 = "wined3d"
+ XCTAssertEqual(store.adoptKnownFacts(known: [known]), ["x64-crossover26.3-r11"])
+ XCTAssertTrue(try store.engine("x64-crossover26.3-r11").direct3D9UsesWined3d)
+ XCTAssertFalse(try store.engine("x64-sikarugir10.0_6-r9").direct3D9UsesWined3d)
+ XCTAssertEqual(store.adoptKnownFacts(known: [known]), [], "a second pass changes nothing")
+ }
+
+ func testShippedWine11ManifestsCarryTheRule() throws {
+ let dir = URL(fileURLWithPath: #filePath)
+ .deletingLastPathComponent().deletingLastPathComponent().deletingLastPathComponent()
+ .appending(path: "spike/engines")
+ for id in ["x64-crossover26.3-r11", "x64-crossover26.3-r12"] {
+ let m = try EngineManifest.load(from: dir.appending(path: "\(id).json"))
+ XCTAssertEqual(m.direct3D9, "wined3d", id)
+ }
+ // The default engine (Wine 10) keeps DXVK's d3d9: FNAF runs at 76 fps on it.
+ let def = try EngineManifest.load(from: dir.deletingLastPathComponent().appending(path: "engine-manifest.json"))
+ XCTAssertNil(def.direct3D9)
+ }
+}
diff --git a/spike/engines/x64-crossover26.3-r11.json b/spike/engines/x64-crossover26.3-r11.json
index e60450e..e728f7f 100644
--- a/spike/engines/x64-crossover26.3-r11.json
+++ b/spike/engines/x64-crossover26.3-r11.json
@@ -125,7 +125,8 @@
"Three patches make the tree behave like the default engine: the Windows user follows the macOS user (CrossOver hack 12735 reverted), WINEDLLPATH_PREPEND is honoured so the renderer overlays apply, and wined3d's automatic renderer is OpenGL first as upstream. winemac.so exports macdrv_functions, so the DXMT and D3DMetal bridges work. This engine ships no winemetal.dll of its own; the DXMT overlay carries it. Wine Mono and Gecko are included.",
"DXMT here is Highball's branch (cross-process swapchains, DXMT_ALLOW_CROSS_PROCESS_SWAPCHAIN=1), needed by the EA client. D3DMetal is the Template's 3.0 with the timestamp shim in front, as on the default engine. Accepted licences carry over when a bottle moves.",
"Moving a bottle here re-runs the Windows setup (different Wine build); moving back is the same step. Nothing installed in the bottle is removed either way.",
- "r11, the base environment (2026-09-18): DXMT_ALLOW_CROSS_PROCESS_SWAPCHAIN=1 for every process. On the Wine 11 tree, browser UIs whose GPU process draws into another process's window need it or DXMT refuses the swapchain: Rockstar's sign-in then paints (verified 2026-09-05 and 2026-09-18), Battle.net's client stops crashing but its window stays black, and Steam's window comes into being where two cold starts without the flag created none, but it too stays black (measured on r10, 2026-09-18). So the flag is necessary on Wine 11 and not sufficient for Steam or Battle.net; the black browser is a separate Wine 11 problem still open."
+ "r11, the base environment (2026-09-18): DXMT_ALLOW_CROSS_PROCESS_SWAPCHAIN=1 for every process. On the Wine 11 tree, browser UIs whose GPU process draws into another process's window need it or DXMT refuses the swapchain: Rockstar's sign-in then paints (verified 2026-09-05 and 2026-09-18), Battle.net's client stops crashing but its window stays black, and Steam's window comes into being where two cold starts without the flag created none, but it too stays black (measured on r10, 2026-09-18). So the flag is necessary on Wine 11 and not sufficient for Steam or Battle.net; the black browser is a separate Wine 11 problem still open.",
+ "Direct3D 9 on this engine (0.9.38): in the automatic modes, DXMT and D3DMetal, a Direct3D 9 game uses Wine's own Direct3D, because DXVK's d3d9 on this tree is the slow path (Half-Life 2 131 fps on wined3d against 17 on DXVK, Five Nights at Freddy's 40 fps on DXVK against 76 with the Wine 10 engine's DXVK, measured 2026-09-24/25, highball#198). The explicit DXVK mode still gets DXVK's d3d9."
],
"requires": [
"rosetta2"
@@ -135,5 +136,6 @@
"macos": "27.0",
"chip": "Apple M1 Pro",
"result": "The Last Flame Prologue (Unity 2021.3, Steam 2517810): menu video plays under DXMT (0 null-handle lines), Embark starts a run, the board is playable, quit through the menu is clean and the run's save is written, all with 0 IOException lines; on r10 the same click threw IOException Unknown error on the missing save and never started. 86 fps on DXMT at 1728x1117 on the board; DXVK also reaches the board but at 20 fps (45 ms GPU) and without the menu video. The lasterr probes (spike/lasterr) read GetLastError, the TEB and %gs:0x68 in step (2/2/2 and 7/7/7); on r10 %gs:0x68 held a heap pointer."
- }
+ },
+ "direct3D9": "wined3d"
}
diff --git a/spike/engines/x64-crossover26.3-r12.json b/spike/engines/x64-crossover26.3-r12.json
index b0e76ae..a65dbe0 100644
--- a/spike/engines/x64-crossover26.3-r12.json
+++ b/spike/engines/x64-crossover26.3-r12.json
@@ -127,7 +127,8 @@
"Three patches make the tree behave like the default engine: the Windows user follows the macOS user (CrossOver hack 12735 reverted), WINEDLLPATH_PREPEND is honoured so the renderer overlays apply, and wined3d's automatic renderer is OpenGL first as upstream. winemac.so exports macdrv_functions, so the DXMT and D3DMetal bridges work. This engine ships no winemetal.dll of its own; the DXMT overlay carries it. Wine Mono and Gecko are included.",
"DXMT here is Highball's branch (cross-process swapchains, DXMT_ALLOW_CROSS_PROCESS_SWAPCHAIN=1), needed by the EA client. D3DMetal is the Template's 3.0 with the timestamp shim in front, as on the default engine. Accepted licences carry over when a bottle moves.",
"Moving a bottle here re-runs the Windows setup (different Wine build); moving back is the same step. Nothing installed in the bottle is removed either way.",
- "r11, the base environment (2026-09-18): DXMT_ALLOW_CROSS_PROCESS_SWAPCHAIN=1 for every process. On the Wine 11 tree, browser UIs whose GPU process draws into another process's window need it or DXMT refuses the swapchain: Rockstar's sign-in then paints (verified 2026-09-05 and 2026-09-18), Battle.net's client stops crashing but its window stays black, and Steam's window comes into being where two cold starts without the flag created none, but it too stays black (measured on r10, 2026-09-18). So the flag is necessary on Wine 11 and not sufficient for Steam or Battle.net; the black browser is a separate Wine 11 problem still open."
+ "r11, the base environment (2026-09-18): DXMT_ALLOW_CROSS_PROCESS_SWAPCHAIN=1 for every process. On the Wine 11 tree, browser UIs whose GPU process draws into another process's window need it or DXMT refuses the swapchain: Rockstar's sign-in then paints (verified 2026-09-05 and 2026-09-18), Battle.net's client stops crashing but its window stays black, and Steam's window comes into being where two cold starts without the flag created none, but it too stays black (measured on r10, 2026-09-18). So the flag is necessary on Wine 11 and not sufficient for Steam or Battle.net; the black browser is a separate Wine 11 problem still open.",
+ "Direct3D 9 on this engine (0.9.38): in the automatic modes, DXMT and D3DMetal, a Direct3D 9 game uses Wine's own Direct3D, because DXVK's d3d9 on this tree is the slow path (Half-Life 2 131 fps on wined3d against 17 on DXVK, Five Nights at Freddy's 40 fps on DXVK against 76 with the Wine 10 engine's DXVK, measured 2026-09-24/25, highball#198). The explicit DXVK mode still gets DXVK's d3d9."
],
"requires": [
"rosetta2"
@@ -137,5 +138,6 @@
"macos": "27.0",
"chip": "M1 Pro",
"result": "Installed end to end from this manifest here (every component's hash checked by the installer). Smoke on a clone of the re-w11 environment moved to this engine and repaired: The Last Flame Prologue on DXMT draws (window in 45 s, frames changing, no crash dialog), Five Nights at Freddy's (32-bit, Direct3D 9 on Wine's own Direct3D) draws, and the 32-bit game runs as one process with no start.exe in front of it, launched through Steam. Not tried on this build: DXVK, which does not start for Direct3D 9 on r11's MoltenVK either (highball#198); D3DMetal; the x87 sidecar itself, which is not shipped."
- }
+ },
+ "direct3D9": "wined3d"
}