Skip to content

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

launch: forward-compatible OpenGL core contexts on every launch, the Mac driver refuses them otherwise (#136)

Gauthier Piarrette39e256d0547c
diff --git a/Sources/HighballKit/Bottle.swift b/Sources/HighballKit/Bottle.swift
index 3ad3d57..d8a2e25 100644
--- a/Sources/HighballKit/Bottle.swift
+++ b/Sources/HighballKit/Bottle.swift
@@ -469,6 +469,12 @@ public struct Bottle: Sendable {
}
if settings.metalHUD { env["MTL_HUD_ENABLED"] = "1" }
if settings.advertiseAVX { env["ROSETTA_ADVERTISE_AVX"] = "1" }
+ // OpenGL games that ask for a 3.2+ core context without the forward-compatible bit get NULL
+ // from Wine's Mac driver ("OS X only supports forward-compatible 3.2+ contexts") and crash
+ // on the first GL call. macOS makes every 3.2+ core context forward-compatible anyway, so the
+ // CrossOver switch the engine's winemac.so carries adds the bit for them (Tomb Raider IV-VI
+ // Remastered, highball#136). It touches nothing that succeeded before.
+ env["CX_FWD_COMPAT_GL_CTX"] = "1"
let r = effective
// 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
diff --git a/Sources/HighballKit/WineRunner.swift b/Sources/HighballKit/WineRunner.swift
index a1bd91e..53b721f 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", "ROSETTA_ADVERTISE_AVX", "MTL_HUD_ENABLED", "DXVK_CONFIG_FILE", "DXVK_LOG_PATH"] {
+ for key in ["WINEDLLPATH_PREPEND", "WINEDLLOVERRIDES", "ROSETTA_ADVERTISE_AVX", "MTL_HUD_ENABLED", "CX_FWD_COMPAT_GL_CTX", "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/EnvironmentTests.swift b/Tests/HighballKitTests/EnvironmentTests.swift
index 9f43ea8..da08e35 100644
--- a/Tests/HighballKitTests/EnvironmentTests.swift
+++ b/Tests/HighballKitTests/EnvironmentTests.swift
@@ -158,4 +158,13 @@ final class EnvironmentTests: XCTestCase {
XCTAssertThrowsError(try bottle.environment(engine: engine, renderer: .dxvk),
"dxvk present but d9vk missing must throw, not fall back to wined3d")
}
+
+ /// OpenGL games asking for a 3.2+ core context without the forward-compatible bit crash on
+ /// macOS unless Wine adds it; the engine's Mac driver reads this switch (highball#136).
+ func testForwardCompatibleGLContextsAreOnForEveryLaunch() throws {
+ let (engine, bottle) = try fixtures()
+ for r in [Renderer.dxvk, .dxmt, .wined3d] {
+ XCTAssertEqual(try bottle.environment(engine: engine, renderer: r)["CX_FWD_COMPAT_GL_CTX"], "1", "\(r)")
+ }
+ }
}