Skip to content

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

d3dmetal: 32-bit direct3d 10/11 falls back to dxmt instead of wined3d

itsOwen9c82b1f01321
diff --git a/Sources/HighballKit/Bottle.swift b/Sources/HighballKit/Bottle.swift
index d8a2e25..351c298 100644
--- a/Sources/HighballKit/Bottle.swift
+++ b/Sources/HighballKit/Bottle.swift
@@ -54,6 +54,8 @@ public enum Renderer: String, Codable, CaseIterable, Sendable {
// would come back as the shim (see InstalledEngine.timestampShimDir for the layout).
env["HB_D3D12_REAL"] = "Z:" + shim.appending(path: "wine/x86_64-windows/\(InstalledEngine.shimRealName).dll").path.replacingOccurrences(of: "/", with: "\\")
}
+ // d3dmetal is 64-bit only, so 32-bit d3d10/11 falls through to dxmt instead of wined3d
+ if let dxmt = engine.rendererDir("dxmt") { overlays += ":" + dxmt.appending(path: "wine").path }
env["WINEDLLPATH_PREPEND"] = Self.withD9VK(overlays, engine: engine)
env["CX_D3DMETALPATH"] = external
env["DYLD_FALLBACK_LIBRARY_PATH+"] = external
diff --git a/Tests/HighballKitTests/EnvironmentTests.swift b/Tests/HighballKitTests/EnvironmentTests.swift
index e1c5e83..53a3ebf 100644
--- a/Tests/HighballKitTests/EnvironmentTests.swift
+++ b/Tests/HighballKitTests/EnvironmentTests.swift
@@ -166,4 +166,32 @@ final class EnvironmentTests: XCTestCase {
// The fixture engine has no renderer overlays on disk, so wined3d is the mode that resolves.
XCTAssertEqual(try bottle.environment(engine: engine, renderer: .wined3d)["CX_FWD_COMPAT_GL_CTX"], "1")
}
+
+ // an engine with the d3dmetal licence accepted and its overlay plus d9vk on disk
+ private func d3dmetalEngine() throws -> InstalledEngine {
+ var manifest = EngineManifest(id: "d3dmetal-test", displayName: "D3DMetal test",
+ arch: "x86_64", minMacOS: "14.0", components: [:])
+ manifest.acceptedLicenses = Array(EngineManifest.gatedRenderers.values)
+ let engine = InstalledEngine(manifest: manifest,
+ root: FileManager.default.temporaryDirectory.appending(path: "hb-test-d3dmetal-\(UUID().uuidString)"))
+ for r in ["d3dmetal", "d9vk"] {
+ try FileManager.default.createDirectory(at: engine.frameworksDir.appending(path: "renderer/\(r)/wine"),
+ withIntermediateDirectories: true)
+ }
+ return engine
+ }
+
+ // d3dmetal ships 64-bit only, so 32-bit direct3d 10/11 goes to dxmt after it, not to wined3d
+ func testD3DMetalFallsBackToDXMTFor32BitGames() throws {
+ let engine = try d3dmetalEngine()
+ defer { try? FileManager.default.removeItem(at: engine.root) }
+ let d3dmetal = engine.frameworksDir.appending(path: "renderer/d3dmetal/wine").path
+ let d9vk = engine.frameworksDir.appending(path: "renderer/d9vk/wine").path
+ XCTAssertEqual(try Renderer.d3dmetal.environment(engine: engine)["WINEDLLPATH_PREPEND"], "\(d3dmetal):\(d9vk)",
+ "an engine without dxmt keeps the search path as it was")
+ let dxmt = engine.frameworksDir.appending(path: "renderer/dxmt/wine")
+ try FileManager.default.createDirectory(at: dxmt, withIntermediateDirectories: true)
+ XCTAssertEqual(try Renderer.d3dmetal.environment(engine: engine)["WINEDLLPATH_PREPEND"], "\(d3dmetal):\(dxmt.path):\(d9vk)",
+ "dxmt comes after d3dmetal, so d3dmetal still serves everything it ships")
+ }
}