Free fork of NotProton: Windows Steam games in Mac Steam, on CodeWeavers' Wine and Apple's Game Porting Toolkit
Swift apple-silicond3dmetaldxmtdxvkgame-porting-toolkitgptkmac-gamingmacosmetalfxrosetta-2steamsteam-playwinewinecx
feat(engine): split DXMT out of lib/wine, add DXVK-macOS backend, ship gamefixes defaults
raymondchins2bf989b64674
diff --git a/Makefile b/Makefileindex 7138d9d..d601b8b 100644--- a/Makefile+++ b/Makefile@@ -512,6 +512,8 @@ app-payload: $(TARGET) $(OVERLAY_SHIM) $(ICONMAKER) $(APPINFO)cp -f $(APPINFO) "$(APP_PAYLOAD)/appinfo"cp -f dylib/feats/compat_run.sh "$(APP_PAYLOAD)/run"cp -f signatures/macos.arm64/*.json "$(APP_PAYLOAD)/signatures/macos.arm64/"+ @rm -rf "$(APP_PAYLOAD)/gamefixes" && mkdir -p "$(APP_PAYLOAD)/gamefixes"+ @if ls gamefixes/*.conf >/dev/null 2>&1; then cp -f gamefixes/*.conf "$(APP_PAYLOAD)/gamefixes/"; fi@set -e; for spec in $(BRIDGE_FILES); do \src="$${spec%%:*}"; dst="$(APP_PAYLOAD)/bridge/$${spec##*:}"; \if [ -f "$$src" ]; then cp -f "$$src" "$$dst"; \diff --git a/app/Sources/NotProtonApp/Model/DeploymentContent.swift b/app/Sources/NotProtonApp/Model/DeploymentContent.swiftindex c75e22c..4ee0054 100644--- a/app/Sources/NotProtonApp/Model/DeploymentContent.swift+++ b/app/Sources/NotProtonApp/Model/DeploymentContent.swift@@ -107,7 +107,8 @@ enum DeploymentContent {static func files(payload: InstallPayload.Located, bridgePayload: BridgePayload.Located,app: URL, bridge: URL, signatures: URL, overlayShim: URL, iconmaker: URL, appinfo: URL,- compatTools: URL, tools: [InstalledTool], runners: URL+ compatTools: URL, tools: [InstalledTool], runners: URL,+ gamefixes: URL = SupportPaths.gamefixesDefault) -> [File] {var files = [File(source: payload.dylib, destination: SupportPaths.Steam.deployedDylib(inBundle: app),@@ -120,6 +121,10 @@ enum DeploymentContent {File(source: $0, destination: signatures.appending(path: $0.lastPathComponent),name: "signatures/\($0.lastPathComponent)")}+ files += payload.gamefixes.map {+ File(source: $0, destination: gamefixes.appending(path: $0.lastPathComponent),+ name: "gamefixes-default/\($0.lastPathComponent)")+ }for entry in bridgePayload.sources {files += entry.bridgePaths.map {File(source: entry.source, destination: bridge.appending(path: $0), name: "bridge/\($0)")diff --git a/app/Sources/NotProtonApp/Model/FreeEngine.swift b/app/Sources/NotProtonApp/Model/FreeEngine.swiftindex 9884fc0..d5cea82 100644--- a/app/Sources/NotProtonApp/Model/FreeEngine.swift+++ b/app/Sources/NotProtonApp/Model/FreeEngine.swift@@ -15,6 +15,10 @@ struct FreeEngineRelease: Sendable {// sha256 of the winemac.so NotProton ships for this build (winemac-patch/), which// exports the macdrv entry points DXMT needs to put Metal into a window.let macDriver: String+ // arch/file -> sha256 of Wine's own file, which stays in lib/wine untouched.+ let stock: [String: String]+ // DXVK-macOS, staged beside DXMT for games that do better on it.+ let dxvk: BackendRelease}// DXMT replaces Wine's own D3D10/11 and DXGI. Wine's wined3d goes through macOS@@ -27,7 +31,25 @@ struct RendererRelease: Sendable {let sha256: Stringlet bases: [URL]let tree: String- // arch/file -> sha256 of the file the engine should end up carrying under lib/wine.+ // Path inside the archive tree -> sha256. The winemetal pair goes into lib/wine,+ // where the unix half and its PE stub are found by the loader; the D3D DLLs go to+ // FreeEngine.dxmtDirectory, so lib/wine keeps Wine's own.+ let files: [String: String]++ func installPath(of path: String) -> String {+ path.hasSuffix("/winemetal.dll") || path.hasSuffix("/winemetal.so")+ ? "lib/wine/\(path)" : "\(FreeEngine.dxmtDirectory)/\(path)"+ }+}++// A set of D3D DLLs the launcher can swap in per game. Nothing here is loaded by default.+struct BackendRelease: Sendable {+ let name: String+ let archive: String+ let sha256: String+ let bases: [URL]+ let tree: String+ // Path inside the archive tree -> sha256, installed at FreeEngine.dxvkDirectory/<path>.let files: [String: String]}@@ -64,11 +86,42 @@ enum FreeEngine {"i386-windows/winemetal.dll": "20a6865facebdaac92b6c06fadf37d2efb5a242b22ca1c349bb57d7ad43df8e3",]),- macDriver: "68d1c10cb4ec80beb2e97dcb8df5f81768f4f6e62848932d6bee5270dcf54982"+ macDriver: "68d1c10cb4ec80beb2e97dcb8df5f81768f4f6e62848932d6bee5270dcf54982",+ stock: [+ "x86_64-windows/d3d10core.dll": "ff08e21a331e4160779ae140b0fd67c25f1557803b0f865467025a55e6133800",+ "x86_64-windows/d3d11.dll": "66d08df71bdb897b55d6f5d12f44b90846dec362641baab2100c0cdf6615c809",+ "x86_64-windows/d3d12.dll": "7dfa70d5b9ac50541c81801d8539be4cd31f37079ea1d93a495fe70c93f95d9a",+ "x86_64-windows/dxgi.dll": "ed8d22612d121415063e54283e7284ae294a07a6b6d83b65dcd91abaadde2e49",+ "i386-windows/d3d10core.dll": "7f9d10eaf361d7d7ad0a76fcedda037014184df9abe3ef0a65c4966a74bcd98d",+ "i386-windows/d3d11.dll": "9f7a4f6ed76c75e902b8f27c45ba9a8d7cadb3205d3e4ab16a6f8a29aedfd30e",+ "i386-windows/d3d12.dll": "501a94c7f2689f996b658ceee101b5b7bd44845dfc53a9336b4ece848ed343e1",+ "i386-windows/dxgi.dll": "5e7310cc1c80650a467a4022e924d34ec07ce58933383ad06f530a61c82afc9d",+ ],+ // Gcenx's repack carries d3d10core and d3d11 only: it drops dxgi and d3d9 as+ // unwanted on macOS, so DXVK games run on Wine's stock dxgi.+ dxvk: BackendRelease(+ name: "DXVK-macOS 1.10.3",+ archive: "dxvk-macOS-async-v1.10.3-20230507-repack-builtin.tar.gz",+ sha256: "810b1e5caf8ce975b784fae866a130ad23fa0ea233b0e5609cbc4a45f3ef6f00",+ bases: [URL(string: "https://github.com/Gcenx/DXVK-macOS/releases/download/v1.10.3-20230507-repack")!],+ tree: "dxvk-macOS-async-v1.10.3-20230507-repack-builtin",+ files: [+ "x86_64-windows/d3d10core.dll": "225562562050d9fae1d4d5d2ca0537020bac268c80dec9aa0633dc0d338a2840",+ "x86_64-windows/d3d11.dll": "173980cb6c51fdd53dc37b9a17f0de7c5dfdebda18f52059aa7d5a6f1871299c",+ "i386-windows/d3d10core.dll": "9e0202437af13a6d0acdb992954321f00a641b2eb98897908c41635ffddc1fc8",+ "i386-windows/d3d11.dll": "2173b081a8660dd70a089dac875a829da6cd1a6230b23fd1daa2a7d7baa1cb03",+ ]+ ))static let macDriverPath = "lib/wine/x86_64-unix/winemac.so"+ // Wine keeps its own dxgi, d3d11 and d3d10core in lib/wine. The launcher picks a+ // backend per game from these, so no game is forced onto one by the engine itself.+ static let backendsDirectory = "lib/notproton-backends"+ static let dxmtDirectory = "\(backendsDirectory)/dxmt"+ static let dxvkDirectory = "\(backendsDirectory)/dxvk"+static var downloads: URL {SupportPaths.home.appending(path: "Library/Caches/\(SupportPaths.supportDirName)/engines")}@@ -83,12 +136,35 @@ enum FreeEngine {return hasRenderer(root: install.crossOverRoot, release: release)}- // An engine unpacked before this renderer was part of it still runs, but D3D11- // games either fail on it or run slowly.+ // Every file the engine should carry, relative to its root, with its sha256: Wine's+ // stock D3D DLLs, DXMT's winemetal pair, both backends and the patched winemac.so.+ static func expectedFiles(_ release: FreeEngineRelease = current) -> [String: String] {+ var table: [String: String] = [macDriverPath: release.macDriver]+ for (path, hash) in release.stock { table["lib/wine/\(path)"] = hash }+ for (path, hash) in release.renderer.files { table[release.renderer.installPath(of: path)] = hash }+ for (path, hash) in release.dxvk.files { table["\(dxvkDirectory)/\(path)"] = hash }+ return table+ }++ // Files that are absent or differ from the pinned hash.+ static func layoutProblems(root: URL, release: FreeEngineRelease = current) -> [String] {+ expectedFiles(release).filter { path, hash in+ Digest.sha256IfPresent(root.appending(path: path)) != hash+ }.keys.sorted()+ }++ // An engine unpacked before the backends were split out still runs, but it needs+ // the new layout before the launcher can choose a renderer per game.static func hasRenderer(root: URL, release: FreeEngineRelease = current) -> Bool {- release.renderer.files.allSatisfy { path, hash in- Digest.sha256IfPresent(root.appending(path: "lib/wine/\(path)")) == hash- } && Digest.sha256IfPresent(root.appending(path: macDriverPath)) == release.macDriver+ layoutProblems(root: root, release: release).isEmpty+ }++ // The first layout baked DXMT's dxgi, d3d11 and d3d10core over Wine's in lib/wine.+ static func hasLegacyLayout(root: URL, release: FreeEngineRelease = current) -> Bool {+ release.renderer.files.contains { path, hash in+ !path.hasSuffix("winemetal.dll") && !path.hasSuffix("winemetal.so")+ && Digest.sha256IfPresent(root.appending(path: "lib/wine/\(path)")) == hash+ }}// Upstream Wine hides the macdrv functions DXMT looks up, so without this DXMT can@@ -131,12 +207,19 @@ enum FreeEngine {into: downloads, step: step, source: "GitHub",report: { report(.downloading($0)) })+ let dxvk = try await PinnedDownload.obtain(+ file: release.dxvk.archive, sha256: release.dxvk.sha256, bases: release.dxvk.bases,+ into: downloads, step: step, source: "GitHub",+ report: { report(.downloading($0)) }+ )report(.unpacking)- return try unpack(archive, renderer: renderer, release: release, engines: engines)+ // The engine is always rebuilt from the pinned archives, so an engine from the+ // first layout (DXMT over Wine's DLLs) is replaced rather than patched in place.+ return try unpack(archive, renderer: renderer, dxvk: dxvk, release: release, engines: engines)}static func unpack(- _ archive: URL, renderer: URL?, release: FreeEngineRelease, engines: URL+ _ archive: URL, renderer: URL?, dxvk: URL? = nil, release: FreeEngineRelease, engines: URL) throws -> CrossOverInstall {let fm = FileManager.defaultlet target = bundle(for: release, engines: engines)@@ -167,13 +250,23 @@ enum FreeEngine {guard Digest.sha256IfPresent(source) == hash else {throw StepFailure(step: step, detail: "\(release.renderer.archive) has no pinned \(path).")}- let destination = root.appending(path: "lib/wine/\(path)")- try? fm.removeItem(at: destination)- try fm.copyItem(at: source, to: destination)+ try place(source, at: root.appending(path: release.renderer.installPath(of: path)))}try installMacDriver(root: root, release: release)}+ if let dxvk {+ try untar(dxvk, into: extracted)+ let tree = extracted.appending(path: release.dxvk.tree, directoryHint: .isDirectory)+ for (path, hash) in release.dxvk.files.sorted(by: { $0.key < $1.key }) {+ let source = tree.appending(path: path)+ guard Digest.sha256IfPresent(source) == hash else {+ throw StepFailure(step: step, detail: "\(release.dxvk.archive) has no pinned \(path).")+ }+ try place(source, at: root.appending(path: "\(dxvkDirectory)/\(path)"))+ }+ }+// WineHQ already keeps its unix loader beside the unix libraries, where// CrossOver keeps its own, so the Wine tree needs no reshaping inside.let info: [String: Any] = [@@ -202,6 +295,13 @@ enum FreeEngine {return CrossOverSource.inspect(bundle: target)}+ private static func place(_ source: URL, at destination: URL) throws {+ let fm = FileManager.default+ try fm.createDirectory(at: destination.deletingLastPathComponent(), withIntermediateDirectories: true)+ try? fm.removeItem(at: destination)+ try fm.copyItem(at: source, to: destination)+ }+private static func untar(_ archive: URL, into directory: URL) throws {let result = try Shell.run("/usr/bin/tar", ["-xf", archive.path(percentEncoded: false), "-C", directory.path(percentEncoded: false),diff --git a/app/Sources/NotProtonApp/Model/InstallPayload.swift b/app/Sources/NotProtonApp/Model/InstallPayload.swiftindex 228a397..0a80315 100644--- a/app/Sources/NotProtonApp/Model/InstallPayload.swift+++ b/app/Sources/NotProtonApp/Model/InstallPayload.swift@@ -14,6 +14,8 @@ enum InstallPayload {let builtAt: Int64let signatures: [URL]+ // payload/gamefixes/*.conf, installed into SupportPaths.gamefixesDefault.+ var gamefixes: [URL] = []}static func root(in bundle: Bundle = .module) throws -> URL {@@ -30,6 +32,12 @@ enum InstallPayload {try locate(root: try root(in: bundle))}+ static func locateGamefixes(in root: URL) throws -> [URL] {+ ((try? FileManager.default.contentsOfDirectory(+ at: root.appending(path: "gamefixes"), includingPropertiesForKeys: nil+ )) ?? []).filter { $0.pathExtension == "conf" }.sorted { $0.lastPathComponent < $1.lastPathComponent }+ }+static func locate(root: URL) throws -> Located {let files = FileManager.default@@ -72,9 +80,12 @@ enum InstallPayload {)}+ let gamefixes = try locateGamefixes(in: root)+return Located(dylib: dylib, overlayShim: shim, iconmaker: iconmaker,- appinfo: appinfo, run: run, builtAt: builtAt, signatures: signatures+ appinfo: appinfo, run: run, builtAt: builtAt, signatures: signatures,+ gamefixes: gamefixes)}}diff --git a/app/Sources/NotProtonApp/Model/SteamInstaller.swift b/app/Sources/NotProtonApp/Model/SteamInstaller.swiftindex 69cfad7..0855a55 100644--- a/app/Sources/NotProtonApp/Model/SteamInstaller.swift+++ b/app/Sources/NotProtonApp/Model/SteamInstaller.swift@@ -100,7 +100,8 @@ enum SteamInstaller {let files = DeploymentContent.files(payload: payload, bridgePayload: bridgeLocated, app: app, bridge: bridge,signatures: signatures, overlayShim: overlayShim, iconmaker: iconmaker, appinfo: appinfo,- compatTools: compatTools, tools: tools, runners: runners)+ compatTools: compatTools, tools: tools, runners: runners,+ gamefixes: support.appending(path: "gamefixes-default"))let content = try DeploymentContent.inspect(files: files, bundled: build, installed: previousBuild,legacyVersion: SteamBundle.deployedVersion(at: deployedVersion))guard content != .newerInstalled else {@@ -149,6 +150,8 @@ enum SteamInstaller {for file in files where file.destination != dylib {try installIfChanged(file)}+ pruneGamefixes(keeping: payload.gamefixes.map(\.lastPathComponent),+ in: deployedVersion.deletingLastPathComponent().appending(path: "gamefixes-default"))var backedUp = falseif patching {@@ -216,6 +219,15 @@ enum SteamInstaller {with: JSONEncoder().encode(outcome.build), step: step)}+ // The shipped defaults are replaced as a set, so a fix dropped from the app stops applying.+ static func pruneGamefixes(keeping names: [String], in directory: URL) {+ let fm = FileManager.default+ let entries = (try? fm.contentsOfDirectory(at: directory, includingPropertiesForKeys: nil)) ?? []+ for entry in entries where !names.contains(entry.lastPathComponent) {+ try? fm.removeItem(at: entry)+ }+ }+static func installIfChanged(_ file: DeploymentContent.File) throws {if try file.matches() { return }try install(file.source, at: file.destination)diff --git a/app/Sources/NotProtonApp/Support/SupportPaths.swift b/app/Sources/NotProtonApp/Support/SupportPaths.swiftindex e5fdc75..a49a492 100644--- a/app/Sources/NotProtonApp/Support/SupportPaths.swift+++ b/app/Sources/NotProtonApp/Support/SupportPaths.swift@@ -26,6 +26,9 @@ enum SupportPaths {static var launchers: URL { support.appending(path: "launchers") }// Free WineHQ engines NotProton downloaded, laid out like a CrossOver bundle.static var engines: URL { support.appending(path: "engines") }+ // Per-game defaults NotProton ships. Replaced on every install; the user's own+ // overrides live in the sibling "gamefixes" directory, which NotProton never writes.+ static var gamefixesDefault: URL { support.appending(path: "gamefixes-default") }static var signatures: URL {support.appending(path: "signatures/macos.arm64")diff --git a/app/Tests/NotProtonAppTests/FreeEngineTests.swift b/app/Tests/NotProtonAppTests/FreeEngineTests.swiftindex 56b3c1d..2f48b86 100644--- a/app/Tests/NotProtonAppTests/FreeEngineTests.swift+++ b/app/Tests/NotProtonAppTests/FreeEngineTests.swift@@ -48,9 +48,12 @@ struct FreeEngineTests {defer { try? FileManager.default.removeItem(at: engines) }let renderer = FreeEngine.downloads.appending(path: FreeEngine.current.renderer.archive)+ let dxvkArchive = FreeEngine.downloads.appending(path: FreeEngine.current.dxvk.archive)let haveRenderer = Digest.sha256IfPresent(renderer) == FreeEngine.current.renderer.sha256+ && Digest.sha256IfPresent(dxvkArchive) == FreeEngine.current.dxvk.sha256let install = try FreeEngine.unpack(- archive, renderer: haveRenderer ? renderer : nil, release: FreeEngine.current, engines: engines+ archive, renderer: haveRenderer ? renderer : nil, dxvk: haveRenderer ? dxvkArchive : nil,+ release: FreeEngine.current, engines: engines)guard case .supported(let build) = install.support else {Issue.record("unpacked engine is \(install.support)")@@ -60,6 +63,8 @@ struct FreeEngineTests {#expect(install.isFree)#expect(FreeEngine.isInstalled(engines: engines) == haveRenderer)#expect(FreeEngine.hasRenderer(root: install.crossOverRoot) == haveRenderer)+ #expect(!FreeEngine.hasLegacyLayout(root: install.crossOverRoot))+ if haveRenderer { #expect(FreeEngine.layoutProblems(root: install.crossOverRoot).isEmpty) }#expect(CrossOverLicense.check(crossOverRoot: install.crossOverRoot).licensed)try RunnerInstaller.verifyClone(build: build, root: install.crossOverRoot)@@ -71,4 +76,175 @@ struct FreeEngineTests {#expect(Digest.sha256(of: patched) == build.patchedNtdll[patch.arch])}}++ private func touch(_ root: URL, _ path: String, _ text: String) throws {+ let url = root.appending(path: path)+ try FileManager.default.createDirectory(at: url.deletingLastPathComponent(), withIntermediateDirectories: true)+ try Data(text.utf8).write(to: url)+ }++ // Builds a tree whose files hash to whatever the test hands in.+ private func release(table: [String: String]) -> FreeEngineRelease {+ FreeEngineRelease(+ build: "t", archive: "a", sha256: "", bases: [], bundleName: "T.app", wineTree: "w",+ renderer: RendererRelease(+ name: "r", archive: "r", sha256: "", bases: [], tree: "r",+ files: ["x86_64-windows/d3d11.dll": table["dxmt-d3d11"]!,+ "x86_64-windows/winemetal.dll": table["winemetal"]!]),+ macDriver: table["mac"]!,+ stock: ["x86_64-windows/d3d11.dll": table["stock-d3d11"]!],+ dxvk: BackendRelease(+ name: "d", archive: "d", sha256: "", bases: [], tree: "d",+ files: ["x86_64-windows/d3d11.dll": table["dxvk-d3d11"]!])+ )+ }++ private func hash(_ text: String) -> String { Digest.sha256(of: Data(text.utf8)) }++ @Test("Layout paths keep Wine's D3D DLLs in lib/wine and put the backends beside it")+ func layoutPaths() {+ let r = FreeEngine.current.renderer+ #expect(r.installPath(of: "x86_64-windows/winemetal.dll") == "lib/wine/x86_64-windows/winemetal.dll")+ #expect(r.installPath(of: "i386-windows/winemetal.dll") == "lib/wine/i386-windows/winemetal.dll")+ #expect(r.installPath(of: "x86_64-unix/winemetal.so") == "lib/wine/x86_64-unix/winemetal.so")+ for name in ["dxgi", "d3d11", "d3d10core"] {+ for arch in ["x86_64-windows", "i386-windows"] {+ #expect(r.installPath(of: "\(arch)/\(name).dll")+ == "lib/notproton-backends/dxmt/\(arch)/\(name).dll")+ }+ }+ #expect(FreeEngine.dxvkDirectory == "lib/notproton-backends/dxvk")+ }++ @Test("The hash table covers stock Wine, DXMT, DXVK and the mac driver, with no overlap")+ func hashTableCoverage() {+ let release = FreeEngine.current+ let table = FreeEngine.expectedFiles(release)+ for arch in ["x86_64-windows", "i386-windows"] {+ for name in ["dxgi", "d3d11", "d3d10core", "d3d12"] {+ #expect(table["lib/wine/\(arch)/\(name).dll"] == release.stock["\(arch)/\(name).dll"])+ }+ for name in ["dxgi", "d3d11", "d3d10core"] {+ #expect(table["lib/notproton-backends/dxmt/\(arch)/\(name).dll"] != nil)+ }+ for name in ["d3d11", "d3d10core"] {+ #expect(table["lib/notproton-backends/dxvk/\(arch)/\(name).dll"] != nil)+ }+ #expect(table["lib/wine/\(arch)/winemetal.dll"] != nil)+ }+ #expect(table["lib/wine/x86_64-unix/winemetal.so"] != nil)+ #expect(table[FreeEngine.macDriverPath] == release.macDriver)+ #expect(table.count == release.stock.count + release.renderer.files.count + release.dxvk.files.count + 1)+ // DXMT's D3D DLLs must differ from Wine's, or the migration check could not tell them apart.+ for (path, hash) in release.renderer.files where !path.contains("winemetal") {+ #expect(release.stock[path] != hash)+ }+ }++ @Test("Verification reports a tampered, missing or legacy file")+ func detectsTampering() throws {+ let root = try makeEngines()+ defer { try? FileManager.default.removeItem(at: root) }+ let r = release(table: [+ "dxmt-d3d11": hash("dxmt"), "winemetal": hash("wm"), "mac": hash("mac"),+ "stock-d3d11": hash("stock"), "dxvk-d3d11": hash("dxvk"),+ ])+ #expect(!FreeEngine.hasRenderer(root: root, release: r))++ try touch(root, "lib/wine/x86_64-windows/d3d11.dll", "stock")+ try touch(root, "lib/wine/x86_64-windows/winemetal.dll", "wm")+ try touch(root, "lib/notproton-backends/dxmt/x86_64-windows/d3d11.dll", "dxmt")+ try touch(root, "lib/notproton-backends/dxvk/x86_64-windows/d3d11.dll", "dxvk")+ try touch(root, FreeEngine.macDriverPath, "mac")+ #expect(FreeEngine.hasRenderer(root: root, release: r))+ #expect(!FreeEngine.hasLegacyLayout(root: root, release: r))++ try touch(root, "lib/wine/x86_64-windows/d3d11.dll", "tampered")+ #expect(FreeEngine.layoutProblems(root: root, release: r) == ["lib/wine/x86_64-windows/d3d11.dll"])+ try touch(root, "lib/wine/x86_64-windows/d3d11.dll", "stock")+ try touch(root, "lib/notproton-backends/dxvk/x86_64-windows/d3d11.dll", "tampered")+ #expect(!FreeEngine.hasRenderer(root: root, release: r))+ try touch(root, "lib/notproton-backends/dxvk/x86_64-windows/d3d11.dll", "dxvk")+ try FileManager.default.removeItem(at: root.appending(path: "lib/notproton-backends/dxmt"))+ #expect(!FreeEngine.hasRenderer(root: root, release: r))+ }++ @Test("An engine with DXMT's DLLs baked into lib/wine is the old layout and no longer counts as installed")+ func migrationDetection() throws {+ let root = try makeEngines()+ defer { try? FileManager.default.removeItem(at: root) }+ let r = release(table: [+ "dxmt-d3d11": hash("dxmt"), "winemetal": hash("wm"), "mac": hash("mac"),+ "stock-d3d11": hash("stock"), "dxvk-d3d11": hash("dxvk"),+ ])+ try touch(root, "lib/wine/x86_64-windows/d3d11.dll", "dxmt")+ try touch(root, "lib/wine/x86_64-windows/winemetal.dll", "wm")+ try touch(root, FreeEngine.macDriverPath, "mac")+ #expect(FreeEngine.hasLegacyLayout(root: root, release: r))+ #expect(!FreeEngine.hasRenderer(root: root, release: r))+ #expect(FreeEngine.layoutProblems(root: root, release: r).contains("lib/wine/x86_64-windows/d3d11.dll"))+ // A stock engine that simply has no backends yet is not "legacy", only incomplete.+ try touch(root, "lib/wine/x86_64-windows/d3d11.dll", "stock")+ #expect(!FreeEngine.hasLegacyLayout(root: root, release: r))+ }++ @Test("DXVK is pinned to a GitHub release asset with a hash for every DLL, both architectures")+ func dxvkPins() {+ let dxvk = FreeEngine.current.dxvk+ #expect(dxvk.bases.allSatisfy { $0.host() == "github.com" && $0.path().contains("Gcenx/DXVK-macOS") })+ #expect(dxvk.sha256.count == 64)+ #expect(dxvk.archive.hasSuffix(".tar.gz"))+ #expect(Set(dxvk.files.keys) == [+ "x86_64-windows/d3d10core.dll", "x86_64-windows/d3d11.dll",+ "i386-windows/d3d10core.dll", "i386-windows/d3d11.dll",+ ])+ #expect(dxvk.files.values.allSatisfy { $0.count == 64 })+ #expect(Set(dxvk.files.values).count == dxvk.files.count)+ }++ @Test("Runs against the real DXVK archive when cached")+ func unpacksRealDxvk() throws {+ let archive = FreeEngine.downloads.appending(path: FreeEngine.current.dxvk.archive)+ guard Digest.sha256IfPresent(archive) == FreeEngine.current.dxvk.sha256 else { return }+ let work = try makeEngines()+ defer { try? FileManager.default.removeItem(at: work) }+ let result = try Shell.run("/usr/bin/tar", ["-xf", archive.path(percentEncoded: false), "-C", work.path(percentEncoded: false)])+ #expect(result.status == 0)+ for (path, hash) in FreeEngine.current.dxvk.files {+ #expect(Digest.sha256IfPresent(work.appending(path: "\(FreeEngine.current.dxvk.tree)/\(path)")) == hash)+ }+ }++ @Test("Shipped game fixes are located in the payload and installed beside the user's own")+ func gamefixesDefaultInstall() throws {+ let work = try makeEngines()+ defer { try? FileManager.default.removeItem(at: work) }+ let payload = work.appending(path: "payload")+ try touch(payload, "gamefixes/1245620.conf", "BACKEND=dxmt\n")+ try touch(payload, "gamefixes/42.conf", "BACKEND=dxvk\n")+ try touch(payload, "gamefixes/.gitkeep", "")+ try touch(payload, "gamefixes/README", "x")++ let located = try InstallPayload.locateGamefixes(in: payload)+ #expect(located.map(\.lastPathComponent) == ["1245620.conf", "42.conf"])++ let support = work.appending(path: "support")+ let defaults = support.appending(path: "gamefixes-default")+ try touch(support, "gamefixes-default/stale.conf", "old")+ try touch(support, "gamefixes/mine.conf", "KEEP=1")+ for source in located {+ try SteamInstaller.installIfChanged(DeploymentContent.File(+ source: source, destination: defaults.appending(path: source.lastPathComponent),+ name: source.lastPathComponent))+ }+ SteamInstaller.pruneGamefixes(keeping: located.map(\.lastPathComponent), in: defaults)++ let names = try FileManager.default.contentsOfDirectory(atPath: defaults.path(percentEncoded: false)).sorted()+ #expect(names == ["1245620.conf", "42.conf"])+ #expect(try String(contentsOf: defaults.appending(path: "42.conf"), encoding: .utf8) == "BACKEND=dxvk\n")+ #expect(FileManager.default.fileExists(atPath: support.appending(path: "gamefixes/mine.conf").path(percentEncoded: false)))+ #expect(SupportPaths.gamefixesDefault.lastPathComponent == "gamefixes-default")+ #expect(SupportPaths.gamefixesDefault.path(percentEncoded: false)+ == SupportPaths.support.path(percentEncoded: false) + "/gamefixes-default")+ }}diff --git a/gamefixes/.gitkeep b/gamefixes/.gitkeepnew file mode 100644index 0000000..e69de29diff --git a/gamefixes/README b/gamefixes/READMEnew file mode 100644index 0000000..442fd82--- /dev/null+++ b/gamefixes/README@@ -0,0 +1,11 @@+Per-game defaults shipped with NotProton.++One file per game, named <steam appid>.conf (for example 1245620.conf), in KEY=VALUE form.+`make app-payload` bundles every *.conf here into the app, and the installer copies them+to ~/Library/Application Support/notproton/gamefixes-default/, replacing that directory's+contents each time. Overrides belong in ~/Library/Application Support/notproton/gamefixes/,+which NotProton never touches.++Example 1245620.conf:+ # Elden Ring+ BACKEND=dxmt