Skip to content

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

Recipes never override an explicit renderer choice (#29)

Gauthier Piarrette4802e1cd98e5
diff --git a/Sources/HighballApp/BottleView.swift b/Sources/HighballApp/BottleView.swift
index 51ff233..10feb0e 100644
--- a/Sources/HighballApp/BottleView.swift
+++ b/Sources/HighballApp/BottleView.swift
@@ -545,7 +545,16 @@ struct BottleSettingsSheet: View {
Divider()
Form {
Section(L("Graphics")) {
- Picker(L("Renderer"), selection: binding(\.renderer)) {
+ // Not the generic binding: picking a renderer here is an explicit choice,
+ // which recipes must never clobber afterwards (#29).
+ Picker(L("Renderer"), selection: Binding(
+ get: { (state.bottles.first { $0.name == bottle.name } ?? bottle).settings.renderer },
+ set: { newValue in
+ var copy = state.bottles.first { $0.name == bottle.name } ?? bottle
+ copy.settings.renderer = newValue
+ copy.settings.rendererExplicit = true
+ Task { @MainActor in state.update(copy) }
+ })) {
Text(L("DXMT — D3D10/11 → Metal (default)")).tag(Renderer.dxmt)
if d3dmetalAvailable { Text(L("D3DMetal — D3D11/12, Apple")).tag(Renderer.d3dmetal) }
Text(L("DXVK — D3D9/10/11 → Vulkan")).tag(Renderer.dxvk)
diff --git a/Sources/HighballKit/Bottle.swift b/Sources/HighballKit/Bottle.swift
index 889706b..1865094 100644
--- a/Sources/HighballKit/Bottle.swift
+++ b/Sources/HighballKit/Bottle.swift
@@ -148,6 +148,10 @@ public struct BottleSettings: Codable, Sendable {
public var name: String
public var engineID: String
public var renderer: Renderer = .dxmt
+ /// True once the user explicitly chose a renderer (settings picker, CLI set/create flag).
+ /// Recipes then keep their hands off it: a launcher recipe silently replacing an explicit
+ /// choice cost a debugging session (issue #29, the AC-on-DXMT black screen).
+ public var rendererExplicit: Bool = false
public var windowsVersion: WindowsVersion = .win10
public var sync: SyncMode = .msync
public var metalHUD: Bool = false
@@ -184,6 +188,7 @@ public struct BottleSettings: Codable, Sendable {
name = try c.decode(String.self, forKey: .name)
engineID = try c.decode(String.self, forKey: .engineID)
renderer = try c.decodeIfPresent(Renderer.self, forKey: .renderer) ?? .dxmt
+ rendererExplicit = try c.decodeIfPresent(Bool.self, forKey: .rendererExplicit) ?? false
windowsVersion = try c.decodeIfPresent(WindowsVersion.self, forKey: .windowsVersion) ?? .win10
sync = try c.decodeIfPresent(SyncMode.self, forKey: .sync) ?? .msync
metalHUD = try c.decodeIfPresent(Bool.self, forKey: .metalHUD) ?? false
diff --git a/Sources/HighballKit/Recipe.swift b/Sources/HighballKit/Recipe.swift
index 39777eb..4db4d29 100644
--- a/Sources/HighballKit/Recipe.swift
+++ b/Sources/HighballKit/Recipe.swift
@@ -157,6 +157,12 @@ public struct RecipeRunner: Sendable {
self.paths = paths; self.engine = engine; self.bottle = bottle; self.store = EngineStore(paths: paths)
}
+ /// The renderer a recipe may set, or nil when the user's explicit choice must stand (#29).
+ public static func rendererToApply(recipeRenderer: Renderer?, settings: BottleSettings) -> Renderer? {
+ guard let r = recipeRenderer, !settings.rendererExplicit else { return nil }
+ return r
+ }
+
/// Runs every step. Returns the notes the UI should show afterwards.
public mutating func apply(_ recipe: Recipe, log: (@Sendable (String) -> Void)? = nil) async throws -> [String] {
if let b = recipe.blocked {
@@ -165,7 +171,15 @@ public struct RecipeRunner: Sendable {
throw HighballError.invalid(msg)
}
var notes: [String] = []
- if let r = recipe.renderer { bottle.settings.renderer = r }
+ // A recipe's renderer is a default, never an override: an explicit user choice wins
+ // (issue #29 — the Steam recipe silently reset a d3dmetal bottle to dxmt).
+ if let r = recipe.renderer {
+ if let applied = Self.rendererToApply(recipeRenderer: r, settings: bottle.settings) {
+ bottle.settings.renderer = applied
+ } else {
+ notes.append("Kept this bottle's renderer (\(bottle.settings.renderer.rawValue)); the recipe suggests \(r.rawValue).")
+ }
+ }
for (i, step) in recipe.steps.enumerated() {
// The app parses these two lines into its progress display (#31): the step line
// becomes the stage, the hint line the "this is slow, don't worry" text under it.
diff --git a/Sources/highball/main.swift b/Sources/highball/main.swift
index 74554ca..0b50476 100644
--- a/Sources/highball/main.swift
+++ b/Sources/highball/main.swift
@@ -85,7 +85,7 @@ struct Bottle: AsyncParsableCommand {
struct Create: AsyncParsableCommand {
@Argument var name: String
@Option(help: "Engine id (default: first installed).") var engine: String?
- @Option(help: "Renderer: wined3d|dxmt|d3dmetal|dxvk") var renderer: HighballKit.Renderer = .dxmt
+ @Option(help: "Renderer: wined3d|dxmt|d3dmetal|dxvk (explicit choice; recipes won't override it)") var renderer: HighballKit.Renderer?
@Option(help: "Apply this recipe after creation (id or path).") var recipe: String?
func run() async throws {
@@ -93,7 +93,11 @@ struct Bottle: AsyncParsableCommand {
let eng = try engine.map { try store.engine($0) } ?? store.installedEngines().first
guard let eng else { fail("no engine installed") }
print("creating bottle '\(name)' with \(eng.id) (wineboot takes ~90 s the first time)…")
- let bottle = try await BottleStore().create(name: name, engine: eng, renderer: renderer)
+ var bottle = try await BottleStore().create(name: name, engine: eng, renderer: renderer ?? .dxmt)
+ if renderer != nil { // a flag the user typed is an explicit choice (#29)
+ bottle.settings.rendererExplicit = true
+ try bottle.save()
+ }
print("created \(bottle.url.path)")
if let recipe {
var r = RecipeRunner(engine: eng, bottle: bottle)
@@ -118,7 +122,10 @@ struct Bottle: AsyncParsableCommand {
let bs = BottleStore()
var b = try bs.get(name)
switch setting {
- case "renderer": guard let r = HighballKit.Renderer(rawValue: value) else { fail("bad renderer") }; b.settings.renderer = r
+ case "renderer":
+ guard let r = HighballKit.Renderer(rawValue: value) else { fail("bad renderer") }
+ b.settings.renderer = r
+ b.settings.rendererExplicit = true // recipes must not clobber this (#29)
case "winver":
guard let v = WindowsVersion(rawValue: value) else { fail("bad winver") }
b.settings.windowsVersion = v
diff --git a/Tests/HighballKitTests/RegressionTests.swift b/Tests/HighballKitTests/RegressionTests.swift
index aa8d07d..5852714 100644
--- a/Tests/HighballKitTests/RegressionTests.swift
+++ b/Tests/HighballKitTests/RegressionTests.swift
@@ -332,4 +332,22 @@ extension RegressionTests {
XCTAssertTrue(EpicStore.isInstalled(path: "/tmp/bottles/actest/drive_c", inDriveC: a),
"drive_c itself counts as inside")
}
+
+ // Issue #29: a recipe's renderer is a default, never an override — the Steam recipe
+ // silently reset an explicitly-d3dmetal bottle to dxmt, black-screening AC.
+ func testRecipeRendererNeverOverridesExplicitChoice() {
+ var s = BottleSettings(name: "t", engineID: "e")
+ XCTAssertEqual(RecipeRunner.rendererToApply(recipeRenderer: .dxmt, settings: s), .dxmt,
+ "default bottle: recipe renderer applies")
+ s.rendererExplicit = true
+ s.renderer = .d3dmetal
+ XCTAssertNil(RecipeRunner.rendererToApply(recipeRenderer: .dxmt, settings: s),
+ "explicit choice: recipe renderer must not apply")
+ XCTAssertNil(RecipeRunner.rendererToApply(recipeRenderer: nil, settings: s))
+ // Old bottles without the field decode as not-explicit (recipes keep working).
+ let decoded = try? JSONDecoder.highball.decode(
+ BottleSettings.self,
+ from: Data(#"{"name":"o","engineID":"e"}"#.utf8))
+ XCTAssertEqual(decoded?.rendererExplicit, false)
+ }
}