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: WineCX D3DMetal builtin model, DXMT e94c312 on both engines, engine UI
raymondchins1d99fc5aecbb
diff --git a/README.md b/README.mdindex dc80327..a8e353b 100644--- a/README.md+++ b/README.md@@ -48,9 +48,11 @@ license check is skipped only for loaders whose hash pins the free build.against. Differences from CrossOver to be aware of:- It is an x86_64 build and runs under Rosetta 2, like the Rosetta build of CrossOver.-- Direct3D 10/11 goes through [DXMT](https://github.com/3Shain/dxmt) (MIT), downloaded and pinned- alongside Wine, which translates straight to Metal. Wine's own wined3d cannot reach feature level 11- on macOS OpenGL. D3DMetal is Apple's and only works with CrossOver's Wine, so it is not used.+- Direct3D 10/11 goes through [DXMT](https://github.com/3Shain/dxmt) (master `e94c312`, LGPL-2.1+,+ see `docs/DXMT.md`), downloaded and pinned alongside Wine, which translates straight to Metal.+ Wine's own wined3d cannot reach feature level 11 on macOS OpenGL. D3DMetal is Apple's and needs+ CrossOver's Wine changes, so this engine does not use it; the WineCX engine can, with a Game+ Porting Toolkit you supply (`docs/WINECX.md`).- DXMT needs macdrv functions upstream Wine hides; NotProton ships a rebuilt `winemac.so`that exports them (see `winemac-patch/`).- D3D 12 has no fast path; vkd3d over the bundled MoltenVK is limited.diff --git a/app/Sources/NotProtonApp/Model/FreeEngine.swift b/app/Sources/NotProtonApp/Model/FreeEngine.swiftindex d5cea82..109fd09 100644--- a/app/Sources/NotProtonApp/Model/FreeEngine.swift+++ b/app/Sources/NotProtonApp/Model/FreeEngine.swift@@ -24,21 +24,38 @@ struct FreeEngineRelease: Sendable {// DXMT replaces Wine's own D3D10/11 and DXGI. Wine's wined3d goes through macOS// OpenGL 4.1, which tops out below feature level 11 and so fails any Unreal or// Unity game that needs it, and DXVK pays for a second translation through-// MoltenVK. DXMT goes to Metal directly, the way D3DMetal does, and is MIT licensed.+// MoltenVK. DXMT goes to Metal directly, the way D3DMetal does. Both free engines take+// the same build: DXMT master e94c312 (https://github.com/3Shain/dxmt/tree/e94c312f5c054263acf261cfa109edf13e757587),+// LGPL-2.1-or-later since ec357fd (v0.80 was the last MIT release), built by+// scripts/build-dxmt.sh as docs/DXMT.md describes.struct RendererRelease: Sendable {let name: Stringlet archive: Stringlet sha256: Stringlet bases: [URL]let tree: String- // 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.+ // Path inside the archive tree -> sha256 as shipped. 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]+ // The D3D DLLs again, path -> sha256 once FreeEngine.stripBuiltinMarker has run. The+ // launcher copies them into a prefix as natives, and Wine swaps any file carrying the+ // builtin marker for the lib/wine builtin of the same name (load_builtin in+ // dlls/ntdll/unix/loader.c), which would quietly run wined3d instead of DXMT.+ let natives: [String: String]- func installPath(of path: String) -> String {+ static func isWinemetal(_ path: String) -> Bool {path.hasSuffix("/winemetal.dll") || path.hasSuffix("/winemetal.so")- ? "lib/wine/\(path)" : "\(FreeEngine.dxmtDirectory)/\(path)"+ }++ func installPath(of path: String) -> String {+ Self.isWinemetal(path) ? "lib/wine/\(path)" : "\(FreeEngine.dxmtDirectory)/\(path)"+ }++ // The sha256 the file has once installed: the winemetal pair as shipped, the D3D DLLs+ // with the builtin marker stripped.+ func installedHash(of path: String) -> String? {+ Self.isWinemetal(path) ? files[path] : natives[path]}}@@ -66,26 +83,7 @@ enum FreeEngine {bases: [URL(string: "https://github.com/Gcenx/macOS_Wine_builds/releases/download/11.15")!],bundleName: "WineHQ 11.15.app",wineTree: "Wine Devel.app/Contents/Resources/wine",- renderer: RendererRelease(- name: "DXMT 0.80",- archive: "dxmt-v0.80-builtin.tar.gz",- sha256: "8f260e36b5739e68f3bad613381441385c4dc7b85b78ba8de653d5a6a264529d",- bases: [URL(string: "https://github.com/3Shain/dxmt/releases/download/v0.80")!],- tree: "v0.80",- // nvapi64 and nvngx are left out: they only serve DLSS to MetalFX, and an- // nvapi that answers makes some games take NVIDIA-only paths.- files: [- "x86_64-unix/winemetal.so": "3d50d7f39c64778c71d0af2fce1cde818d09ffbce7c4f7b8ae24ae1df567c0ca",- "x86_64-windows/d3d10core.dll": "833d26971abc8661efc8b5cc18548c70ce8e482e4ea4b1d3f69a367612264d26",- "x86_64-windows/d3d11.dll": "7ca382af0eb32d8a432f6efb14d594fefb45673663be1f7e6682254bff885c47",- "x86_64-windows/dxgi.dll": "fc58aae0aba511a1ec4d2417e5bba6adb888bb14315d0f59cccdfd27f670d544",- "x86_64-windows/winemetal.dll": "514245d533c750599614311a792c45ed600aef52948571d98c0fc70fd3df16e0",- "i386-windows/d3d10core.dll": "c5a26310d14a30c3e1700a4d0c9865be28a11351a5c4dc5b83ab1bd8fcf7662f",- "i386-windows/d3d11.dll": "9afc2b3419818618c4c87274435a28935b0df002caa4b9a8d3a88d3dc846b17d",- "i386-windows/dxgi.dll": "7df8cdf66e12a108410002abc77b01f70aa59b8a36a70fa0bc6ae3b056841319",- "i386-windows/winemetal.dll": "20a6865facebdaac92b6c06fadf37d2efb5a242b22ca1c349bb57d7ad43df8e3",- ]- ),+ renderer: dxmt,macDriver: "68d1c10cb4ec80beb2e97dcb8df5f81768f4f6e62848932d6bee5270dcf54982",stock: ["x86_64-windows/d3d10core.dll": "ff08e21a331e4160779ae140b0fd67c25f1557803b0f865467025a55e6133800",@@ -114,6 +112,38 @@ enum FreeEngine {))+ // Shared by both free engines. Hosted on NotProton's own release, since upstream+ // publishes no build of master; the per-file hashes are in docs/DXMT.md. d3d12.dll+ // (x86_64-windows-d3d12/ in the tarball) is the unfinished backend and is never staged.+ static let dxmt = RendererRelease(+ name: "DXMT e94c312",+ archive: "dxmt-e94c312.tar.gz",+ sha256: "8de0d5b7eb2b96315f6ec8e259c05423ab43212e776196147b30d9f44927f7f0",+ bases: [URL(string: "https://github.com/raymondchins/NotProton-WineHQ/releases/download/dxmt-e94c312")!],+ tree: "e94c312",+ // nvapi64 and nvngx are left out: they only serve DLSS to MetalFX, and an+ // nvapi that answers makes some games take NVIDIA-only paths.+ files: [+ "x86_64-unix/winemetal.so": "1d0a1258cbb696e1323d1fde77ebef7fedf5ea32a554bb777a9916321dedc195",+ "x86_64-windows/d3d10core.dll": "14fef5785b9c83ab1d440d9d8de9d2d875420b9ae468c282737fcd44bb75336b",+ "x86_64-windows/d3d11.dll": "f2ee8959c19548fb66c5b2a3802ff84967107d2faa3391bafb38c1363ece8a8b",+ "x86_64-windows/dxgi.dll": "75436305876c11f4b7e8535fc32b0007e157b062dbd1534c1757c310a44bd99e",+ "x86_64-windows/winemetal.dll": "33dd95086ab29ed03f876c47589b04a1e4a5891c6cbb5af6129309414aa8b0f7",+ "i386-windows/d3d10core.dll": "7cbefea0f3b766024b85413ec75a2cc32e0431bbcc5f966b0b7515b4d785f3e7",+ "i386-windows/d3d11.dll": "842b5a3868230e1b3eb829581b362f4ff56c86b318a3ce5b5307fa071485b58d",+ "i386-windows/dxgi.dll": "51d01ce7f2b9edacaaa3490d838a95bf060ff04db7f42fe746cb62174c484bca",+ "i386-windows/winemetal.dll": "6ddeb053c5510cffafdabfd27c8a67950f2e37308e6b9f9d1a0c44b9119ac456",+ ],+ natives: [+ "x86_64-windows/d3d10core.dll": "aeb43e1ca7d9f221b9f0070c8654fa3579fd767006272cf675a9113e27bc6e72",+ "x86_64-windows/d3d11.dll": "c1c8c4779686990bf343162a8804dd2d1564b2a893e64e5ddcc7db5e76ce409e",+ "x86_64-windows/dxgi.dll": "1bb4939ff43e676eac8b3f3cb0583985ab8f7b1a8e11760d14931da3fc44223b",+ "i386-windows/d3d10core.dll": "e851c39641f66d64a3e4460e7046900cd234b11f44d793826d2f094e9d2166d9",+ "i386-windows/d3d11.dll": "a654ea3851ccc128a1f33d978462872e22fa6430ea85eff6ba9549de95788652",+ "i386-windows/dxgi.dll": "91f38df103412235793f84efe06b87f6f6fc3a4791d4f8d9f8cc2e16bc137d53",+ ]+ )+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@@ -141,7 +171,9 @@ enum FreeEngine {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 in release.renderer.files.keys {+ table[release.renderer.installPath(of: path)] = release.renderer.installedHash(of: path)+ }for (path, hash) in release.dxvk.files { table["\(dxvkDirectory)/\(path)"] = hash }return table}@@ -162,7 +194,7 @@ enum FreeEngine {// 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")+ !RendererRelease.isWinemetal(path)&& Digest.sha256IfPresent(root.appending(path: "lib/wine/\(path)")) == hash}}@@ -245,13 +277,7 @@ enum FreeEngine {if let renderer {try untar(renderer, into: extracted)let tree = extracted.appending(path: release.renderer.tree, directoryHint: .isDirectory)- for (path, hash) in release.renderer.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.renderer.archive) has no pinned \(path).")- }- try place(source, at: root.appending(path: release.renderer.installPath(of: path)))- }+ try installRenderer(release.renderer, from: tree, root: root, step: step)try installMacDriver(root: root, release: release)}@@ -295,6 +321,51 @@ enum FreeEngine {return CrossOverSource.inspect(bundle: target)}+ // Lays the renderer out under root: the winemetal pair as shipped into lib/wine, the+ // D3D DLLs with the builtin marker stripped into dxmtDirectory. Every file is checked+ // against its pin before and after, so a winemetal from another build never lands+ // beside these DLLs (they share one unix-call table).+ static func installRenderer(_ renderer: RendererRelease, from tree: URL, root: URL, step: String) throws {+ for (path, hash) in renderer.files.sorted(by: { $0.key < $1.key }) {+ let source = tree.appending(path: path)+ guard Digest.sha256IfPresent(source) == hash else {+ throw StepFailure(step: step, detail: "\(renderer.archive) has no pinned \(path).")+ }+ let destination = root.appending(path: renderer.installPath(of: path))+ if RendererRelease.isWinemetal(path) {+ try place(source, at: destination)+ continue+ }+ var image = try Data(contentsOf: source)+ try stripBuiltinMarker(&image)+ guard Digest.sha256(of: image) == renderer.natives[path] else {+ throw StepFailure(step: step, detail: "\(path) from \(renderer.archive) does not match its native pin.")+ }+ try FileManager.default.createDirectory(+ at: destination.deletingLastPathComponent(), withIntermediateDirectories: true)+ try? FileManager.default.removeItem(at: destination)+ try image.write(to: destination)+ }+ }++ static let builtinMarker = Array("Wine builtin DLL".utf8) + [0]+ // The bytes winecx-gptk writes over the marker (a plain DOS stub), so DXMT 0.80 stripped+ // here hashes the same as the copy in the WineCX archive.+ static let dosStub: [UInt8] = [0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd,+ 0x21, 0xb8, 0x01, 0x4c, 0xcd, 0x21, 0x90, 0x90]++ // Wine reads the 17 bytes at 0x40 as the builtin marker. Without it the DLL is an+ // ordinary native, which is what a per-game backend in a prefix has to be.+ static func stripBuiltinMarker(_ image: inout Data) throws {+ let start = image.startIndex+ guard image.count > 0x51, image[start] == 0x4d, image[start + 1] == 0x5a,+ Array(image[(start + 0x40) ..< (start + 0x51)]) == builtinMarker+ else {+ throw StepFailure(step: step, detail: "A DXMT DLL does not carry the Wine builtin marker.")+ }+ image.replaceSubrange((start + 0x40) ..< (start + 0x50), with: dosStub)+ }+private static func place(_ source: URL, at destination: URL) throws {let fm = FileManager.defaulttry fm.createDirectory(at: destination.deletingLastPathComponent(), withIntermediateDirectories: true)diff --git a/app/Sources/NotProtonApp/Model/FreeEngineWinecx.swift b/app/Sources/NotProtonApp/Model/FreeEngineWinecx.swiftindex 0720194..ca82ffe 100644--- a/app/Sources/NotProtonApp/Model/FreeEngineWinecx.swift+++ b/app/Sources/NotProtonApp/Model/FreeEngineWinecx.swift@@ -1,8 +1,10 @@// The second free engine: WineCX, CodeWeavers' LGPL CrossOver 26.3 Wine changes rebased// onto wine-11.15 by dappermint (github.com/dappermint/winecx, wine1115 branch) and built// into a Whisky runtime by dappermint/winecx-gptk's CI. Over the WineHQ engine it adds-// msync and the CrossOver hooks Apple's D3DMetal needs, and it carries DXMT and DXVK as-// backends a game opts into instead of replacing Wine's own Direct3D. docs/WINECX.md.+// msync and the CrossOver hooks Apple's D3DMetal needs. DXMT (the same master build as the+// WineHQ engine, not the archive's 0.80) and DXVK are backends a game opts into; Wine's own+// Direct3D, or D3DMetal once a user's Game Porting Toolkit is linked, is the builtin.+// docs/WINECX.md.import Foundation@@ -24,7 +26,14 @@ struct WinecxRelease: Sendable {let bundleName: String// Path of the Wine tree inside the archive.let wineTree: String+ // DXVK, copied out of the archive. The archive's DXMT 0.80 is not used.let backends: [WinecxBackendFile]+ // DXMT, from its own tarball: the D3D DLLs as natives under lib/notproton-backends/dxmt,+ // the winemetal pair over the archive's in lib/wine.+ let renderer: RendererRelease+ // lib/wine/x86_64-windows/<name> -> sha256 of Wine's own copy, for the four DLLs a linked+ // Game Porting Toolkit replaces (WinecxD3DMetal.forwarders).+ let d3dStock: [String: String]}enum FreeEngineWinecx {@@ -46,23 +55,9 @@ enum FreeEngineWinecx {],bundleName: "WineCX 11.15.app",wineTree: "Libraries/Wine",- // The archive's DXMT 0.80 frontends already have the builtin marker stripped, so- // they load as native DLLs from a prefix. nvapi64 and nvngx are left out for the- // reason FreeEngine gives. winemetal stays where the archive put it, a builtin in- // lib/wine beside its unix half. The DXVK-macOS 1.10.3 repack ships no dxgi.+ // nvapi64 and nvngx are left out for the reason FreeEngine gives. The DXVK-macOS+ // 1.10.3 repack ships no dxgi, and its DLLs carry no builtin marker.backends: [- WinecxBackendFile(source: "DXMT/x64/d3d10core.dll", destination: "dxmt/x86_64-windows/d3d10core.dll",- sha256: "24ca320249f0683d0bded170ef135f430c5b0f310b461e68108ee3c13e7e0aac"),- WinecxBackendFile(source: "DXMT/x64/d3d11.dll", destination: "dxmt/x86_64-windows/d3d11.dll",- sha256: "8d4842aaf4fd3de3f115d1f51da13930f27764dad1bb217fc28e7d154c1612b3"),- WinecxBackendFile(source: "DXMT/x64/dxgi.dll", destination: "dxmt/x86_64-windows/dxgi.dll",- sha256: "a9686960d8341a034cdfbb46015592b1d407922f4b2686274b7865bbc4c0683c"),- WinecxBackendFile(source: "DXMT/x32/d3d10core.dll", destination: "dxmt/i386-windows/d3d10core.dll",- sha256: "e867d24efe319bbc5e54da8732cc67d4bf975a291a57782d0cf8517af11fca22"),- WinecxBackendFile(source: "DXMT/x32/d3d11.dll", destination: "dxmt/i386-windows/d3d11.dll",- sha256: "7002dac2b38c757109c2a661832d90f391a0f5cee9bda469cae539de75ff6eec"),- WinecxBackendFile(source: "DXMT/x32/dxgi.dll", destination: "dxmt/i386-windows/dxgi.dll",- sha256: "4ca0246cc6aac9f1d36ac4da495f31adca33c5a02bb42b3231bd84b940514fdd"),WinecxBackendFile(source: "DXVK/x64/d3d10core.dll", destination: "dxvk/x86_64-windows/d3d10core.dll",sha256: "0fa08bba860c63e3abeeabfc96d0e7aa327411a975f8f23d2dc63594ef5f796e"),WinecxBackendFile(source: "DXVK/x64/d3d11.dll", destination: "dxvk/x86_64-windows/d3d11.dll",@@ -71,6 +66,15 @@ enum FreeEngineWinecx {sha256: "2277187a4e13fc2049fe28cb8dd05b34b48c68031c386c3597ba0e18b0c3d327"),WinecxBackendFile(source: "DXVK/x32/d3d11.dll", destination: "dxvk/i386-windows/d3d11.dll",sha256: "f79d417f675d00008375eb4ea2318af6fcd0b27971d604d3cf345a0dcfa998a0"),+ ],+ // winecx's winemac.so already exports the macdrv_functions DXMT reads, and that+ // table is unchanged between 0.80 and master, so no winemac-patch is needed.+ renderer: FreeEngine.dxmt,+ d3dStock: [+ "d3d10.dll": "bcbd3fb8a59a5992bd3035babc5c046327f19cdc0669ce9e7c438c3ce3a9546d",+ "d3d11.dll": "84f5a337fdd7405bbbee5f0542427842a22aff749a3d061ba6334f10cf01dee4",+ "d3d12.dll": "c6e285308bb3241efca3d94da4746b16a526a9fb5113f61922e7bd86694bebf9",+ "dxgi.dll": "f1f24da777c65a583b29f74475c6a9464da35068d75def6cee806268def9ecbb",])@@ -135,7 +139,8 @@ enum FreeEngineWinecx {]// Runtime contract with compat_run.sh: the engine root says it can run msync, and the- // backends sit outside lib/wine so Wine's own Direct3D stays the builtin.+ // backends sit outside lib/wine, whose Direct3D builtins are Wine's own or, with+ // d3dmetal.enabled, Apple's (WinecxD3DMetal).static let backendsPath = "lib/notproton-backends"static let msyncMarkerPath = ".notproton-msync"@@ -157,9 +162,31 @@ enum FreeEngineWinecx {}static func hasBackends(root: URL, release: WinecxRelease = current) -> Bool {- release.backends.allSatisfy { file in- Digest.sha256IfPresent(backend(file.destination, in: root)) == file.sha256- } && FileManager.default.fileExists(atPath: msyncMarker(in: root).path(percentEncoded: false))+ layoutProblems(root: root, release: release).isEmpty+ }++ // Every pinned file NotProton lays out, relative to the engine root, with its sha256. The+ // four Direct3D DLLs D3DMetal can replace are not in here: WinecxD3DMetal.layoutProblems+ // checks them, since they are either Wine's own or links into a Game Porting Toolkit.+ static func expectedFiles(_ release: WinecxRelease = current) -> [String: String] {+ var table: [String: String] = [:]+ for file in release.backends { table["\(backendsPath)/\(file.destination)"] = file.sha256 }+ for path in release.renderer.files.keys {+ table[release.renderer.installPath(of: path)] = release.renderer.installedHash(of: path)+ }+ return table+ }++ // Files that are absent or differ from their pin, the msync marker, and a Direct3D+ // layout that is neither stock nor a complete D3DMetal link.+ static func layoutProblems(root: URL, release: WinecxRelease = current) -> [String] {+ var problems = expectedFiles(release).filter { path, hash in+ Digest.sha256IfPresent(root.appending(path: path)) != hash+ }.keys.sorted()+ if !FileManager.default.fileExists(atPath: msyncMarker(in: root).path(percentEncoded: false)) {+ problems.append(msyncMarkerPath)+ }+ return problems + WinecxD3DMetal.layoutProblems(root: root, stock: release.d3dStock)}static func backend(_ path: String, in root: URL) -> URL {@@ -192,12 +219,20 @@ enum FreeEngineWinecx {into: downloads, step: step, source: "GitHub",report: { report(.downloading($0)) })+ let renderer = try await PinnedDownload.obtain(+ file: release.renderer.archive, sha256: release.renderer.sha256, bases: release.renderer.bases,+ into: FreeEngine.downloads, step: step, source: "GitHub",+ report: { report(.downloading($0)) }+ )report(.unpacking)- return try unpack(archive, release: release, engines: engines)+ return try unpack(archive, renderer: renderer, release: release, engines: engines)}+ // Without a renderer archive (tests only) the engine gets no DXMT and does not count+ // as installed.static func unpack(_ archive: URL,+ renderer: URL?,release: WinecxRelease,engines: URL,gptkRoots: [URL] = WinecxD3DMetal.searchRoots()@@ -234,6 +269,16 @@ enum FreeEngineWinecx {try? fm.removeItem(at: destination)try fm.copyItem(at: source, to: destination)}+ // The archive's own DXMT 0.80 frontends stay out, and its winemetal pair is replaced+ // with master's: the two halves share one unix-call table and never mix versions.+ if let renderer {+ let unpacked = staging.appending(path: "renderer", directoryHint: .isDirectory)+ try fm.createDirectory(at: unpacked, withIntermediateDirectories: true)+ try untar(renderer, into: unpacked)+ try FreeEngine.installRenderer(+ release.renderer, from: unpacked.appending(path: release.renderer.tree, directoryHint: .isDirectory),+ root: root, step: step)+ }try Data("\(release.build)\n".utf8).write(to: msyncMarker(in: root))// The winecx tree keeps its unix loader beside the unix libraries the way@@ -257,7 +302,7 @@ enum FreeEngineWinecx {}// Only links, and only to a Game Porting Toolkit the user installed. An engine- // without one is complete, it just has no D3DMetal.+ // without one keeps Wine's own Direct3D and is complete, it just has no D3DMetal.WinecxD3DMetal.refresh(root: install.crossOverRoot, roots: gptkRoots)try fm.createDirectory(at: engines, withIntermediateDirectories: true)diff --git a/app/Sources/NotProtonApp/Model/FreeEngineWinecxD3DMetal.swift b/app/Sources/NotProtonApp/Model/FreeEngineWinecxD3DMetal.swiftindex a28c8eb..fe9e405 100644--- a/app/Sources/NotProtonApp/Model/FreeEngineWinecxD3DMetal.swift+++ b/app/Sources/NotProtonApp/Model/FreeEngineWinecxD3DMetal.swift@@ -2,32 +2,53 @@// run on it. Nothing of Apple's is copied or shipped: every entry is a symlink into the// user's own copy, and the marker compat_run.sh reads is written only once all of them// are in place. Apple's payload is the redist/lib tree: external/ (D3DMetal.framework and-// libd3dshared.dylib) and builtin-marked PE forwarders under wine/x86_64-windows. There-// is no i386 half, so D3DMetal is 64-bit only.+// libd3dshared.dylib), builtin-marked PE forwarders under wine/x86_64-windows, and their+// unix halves under wine/x86_64-unix, which are links to ../../external/libd3dshared.dylib+// (GPTK 4.0 beta 2; older copies without that folder get libd3dshared directly). There is+// no i386 half, so D3DMetal is 64-bit only.//-// Layout in the engine root, beside the stock Direct3D that lib/wine keeps:+// Apple's forwarders only work as builtins (only a builtin gets a unix half), and Wine+// searches its own lib/wine before anything else, so they replace Wine's builtins outright,+// the way Whisky does it:+// lib/wine/x86_64-windows/{d3d10,d3d11,d3d12,dxgi}.dll -> the user's forwarders+// lib/wine/x86_64-unix/{d3d10,d3d11,d3d12,dxgi}.so -> the user's wine/x86_64-unix/<name>.so+// Wine takes a builtin's unix half from x86_64-unix beside the PE's directory.+// lib/wine/x86_64-{windows,unix}/nvapi64.* -> the user's, when the GPTK has them. Wine has+// none of its own here. compat_run.sh disables it unless a game's conf says NVAPI=1,+// since an nvapi that answers sends some games down NVIDIA-only paths.+// nvngx-on-metalfx is not linked: it only serves DLSS through that nvapi, and CrossOver+// renames it to nvngx.dll per prefix, which NotProton does not do.// lib/external/{D3DMetal.framework,libd3dshared.dylib} -> the user's external/-// winecx's own lib/external, where its build expects the payload. Also the-// CX_APPLEGPTK_LIBD3DSHARED_PATH winecx's ntdll dlopens for non-native code regions.-// lib/notproton-backends/d3dmetal/x86_64-windows/<forwarder> -> the user's forwarder-// lib/notproton-backends/d3dmetal/x86_64-unix/<name>.so -> ../../../external/libd3dshared.dylib-// Wine takes a builtin's unix half from the x86_64-unix beside the directory the PE-// came from. A symlink rather than a copy, so libd3dshared's @loader_path rpath-// still lands beside D3DMetal.framework.+// winecx's own lib/external, and the CX_APPLEGPTK_LIBD3DSHARED_PATH winecx's ntdll+// dlopens for non-native code regions.+// lib/notproton-backends/wine-stock/x86_64-windows/<dll> Wine's originals, moved aside+// and moved back on unlink, so they come back byte for byte.// lib/notproton-backends/d3dmetal.enabled+// Without a Game Porting Toolkit none of this exists and lib/wine is as shipped. DXMT and+// DXVK still load per game as natives from the prefix either way.import Foundationenum WinecxD3DMetal {static let forwarders = ["d3d10.dll", "d3d11.dll", "d3d12.dll", "dxgi.dll"]+ // Linked when the GPTK has it, never required. Wine's tree has no file of this name.+ static let optionalForwarders = ["nvapi64.dll"]static let sharedLibrary = "libd3dshared.dylib"static let framework = "D3DMetal.framework"static let externalPath = "lib/external"- static let backendPath = "\(FreeEngineWinecx.backendsPath)/d3dmetal"+ static let builtinPath = "lib/wine/x86_64-windows"+ static let unixPath = "lib/wine/x86_64-unix"+ static let stockPath = "\(FreeEngineWinecx.backendsPath)/wine-stock/x86_64-windows"static let enabledMarkerPath = "\(FreeEngineWinecx.backendsPath)/d3dmetal.enabled"- static let unixLinkDestination = "../../../external/\(sharedLibrary)"+ // Where the first layout put the forwarders. Wine never loaded them from there; unlink+ // clears it out of engines set up before.+ static let legacyBackendPath = "\(FreeEngineWinecx.backendsPath)/d3dmetal"++ static func unixName(of forwarder: String) -> String {+ (forwarder as NSString).deletingPathExtension + ".so"+ }struct Payload: Sendable, Equatable {// The folder holding external/ and wine/.@@ -111,28 +132,47 @@ enum WinecxD3DMetal {// Every link the layout needs, as (link, destination it must resolve to).static func links(for payload: Payload, root: URL) -> [(link: URL, target: String)] {+ let fm = FileManager.defaultlet source = payload.libRoot.standardizedFileURL- let external = root.appending(path: externalPath)- let backend = root.appending(path: backendPath)+ let shared = source.appending(path: "external/\(sharedLibrary)").path(percentEncoded: false)var links: [(link: URL, target: String)] = [- (external.appending(path: framework),+ (root.appending(path: "\(externalPath)/\(framework)"),source.appending(path: "external/\(framework)").path(percentEncoded: false)),- (external.appending(path: sharedLibrary),- source.appending(path: "external/\(sharedLibrary)").path(percentEncoded: false)),+ (root.appending(path: "\(externalPath)/\(sharedLibrary)"), shared),]- for name in forwarders {- links.append((backend.appending(path: "x86_64-windows/\(name)"),+ let optional = optionalForwarders.filter { name in+ isBuiltin(source.appending(path: "wine/x86_64-windows/\(name)"))+ && !exists(root.appending(path: "\(builtinPath)/\(name)"))+ }+ for name in forwarders + optional {+ links.append((root.appending(path: "\(builtinPath)/\(name)"),source.appending(path: "wine/x86_64-windows/\(name)").path(percentEncoded: false)))- let unix = (name as NSString).deletingPathExtension + ".so"- links.append((backend.appending(path: "x86_64-unix/\(unix)"), unixLinkDestination))+ // Apple's own unix half when the GPTK ships one, which is itself a link to+ // libd3dshared, otherwise libd3dshared directly.+ let unix = source.appending(path: "wine/x86_64-unix/\(unixName(of: name))")+ links.append((root.appending(path: "\(unixPath)/\(unixName(of: name))"),+ fm.fileExists(atPath: unix.path(percentEncoded: false))+ ? unix.path(percentEncoded: false) : shared))}return links}- static func link(_ payload: Payload, root: URL) throws {+ static func link(_ payload: Payload, root: URL, stock: [String: String] = FreeEngineWinecx.current.d3dStock) throws {let fm = FileManager.defaultunlink(root: root)do {+ // Wine's originals go aside first, each checked against its pin, so unlink can+ // always put back exactly what the engine shipped.+ let saved = root.appending(path: stockPath)+ try fm.createDirectory(at: saved, withIntermediateDirectories: true)+ for name in forwarders {+ let live = root.appending(path: "\(builtinPath)/\(name)")+ guard let hash = stock[name], Digest.sha256IfPresent(live) == hash, !isSymlink(live) else {+ throw StepFailure(step: FreeEngineWinecx.step,+ detail: "\(builtinPath)/\(name) is not Wine's own. Update & Set Up the WineCX engine again.")+ }+ try fm.moveItem(at: live, to: saved.appending(path: name))+ }for entry in links(for: payload, root: root) {try fm.createDirectory(at: entry.link.deletingLastPathComponent(), withIntermediateDirectories: true)if isSymlink(entry.link) { try fm.removeItem(at: entry.link) }@@ -147,7 +187,7 @@ enum WinecxD3DMetal {"source=\(payload.libRoot.standardizedFileURL.path(percentEncoded: false))","version=\(payload.version ?? "unknown")","libd3dshared=\(externalPath)/\(sharedLibrary)",- "dllpath=\(backendPath)",+ "model=builtin",].joined(separator: "\n") + "\n"try Data(marker.utf8).write(to: enabledMarker(in: root))} catch {@@ -156,16 +196,37 @@ enum WinecxD3DMetal {}}- // Removes what link made and nothing else: the marker goes first so a consumer never- // sees it over a half-removed layout, and lib/external keeps winecx's own README.+ // Undoes link and nothing else: the marker goes first so a consumer never sees it over a+ // half-removed layout, only symlinks are removed, and Wine's originals are moved back.+ // lib/external keeps winecx's own README.static func unlink(root: URL) {let fm = FileManager.defaulttry? fm.removeItem(at: enabledMarker(in: root))- try? fm.removeItem(at: root.appending(path: backendPath))+ try? fm.removeItem(at: root.appending(path: legacyBackendPath))+ let saved = root.appending(path: stockPath)+ for name in optionalForwarders {+ for path in ["\(builtinPath)/\(name)", "\(unixPath)/\(unixName(of: name))"] {+ let link = root.appending(path: path)+ if isSymlink(link) { try? fm.removeItem(at: link) }+ }+ }+ for name in forwarders {+ let live = root.appending(path: "\(builtinPath)/\(name)")+ if isSymlink(live) { try? fm.removeItem(at: live) }+ let original = saved.appending(path: name)+ if fm.fileExists(atPath: original.path(percentEncoded: false)), !exists(live) {+ try? fm.moveItem(at: original, to: live)+ }+ let unix = root.appending(path: "\(unixPath)/\(unixName(of: name))")+ if isSymlink(unix) { try? fm.removeItem(at: unix) }+ }for name in [framework, sharedLibrary] {let link = root.appending(path: "\(externalPath)/\(name)")if isSymlink(link) { try? fm.removeItem(at: link) }}+ // rmdir only takes empty folders, so an original that could not go back stays put.+ rmdir(saved.path(percentEncoded: false))+ rmdir(saved.deletingLastPathComponent().path(percentEncoded: false))}static func isLinked(root: URL) -> Bool {@@ -173,14 +234,62 @@ enum WinecxD3DMetal {&& linksResolve(root: root)}+ // The GPTK folder a linked engine points at, as the marker records it.+ static func linkedSource(root: URL) -> String? {+ guard isLinked(root: root),+ let text = try? String(contentsOf: enabledMarker(in: root), encoding: .utf8)+ else { return nil }+ return text.split(separator: "\n").first { $0.hasPrefix("source=") }.map { String($0.dropFirst("source=".count)) }+ }++ // The two states the engine may be in, and nothing else: stock (Wine's own Direct3D in+ // lib/wine, nothing set aside) or linked (the marker, symlinks where Wine's builtins were,+ // and those originals intact in wine-stock). Links are checked as links here; a Game+ // Porting Toolkit that went away is isLinked's concern and a refresh undoes it.+ static func layoutProblems(root: URL, stock: [String: String] = FreeEngineWinecx.current.d3dStock) -> [String] {+ let fm = FileManager.default+ var problems: [String] = []+ let linked = fm.fileExists(atPath: enabledMarker(in: root).path(percentEncoded: false))+ for name in forwarders {+ let livePath = "\(builtinPath)/\(name)"+ let savedPath = "\(stockPath)/\(name)"+ let unixPath = "\(self.unixPath)/\(unixName(of: name))"+ let live = root.appending(path: livePath)+ let saved = root.appending(path: savedPath)+ let unix = root.appending(path: unixPath)+ if linked {+ if !isSymlink(live) { problems.append(livePath) }+ if isSymlink(saved) || Digest.sha256IfPresent(saved) != stock[name] { problems.append(savedPath) }+ if !isSymlink(unix) { problems.append(unixPath) }+ } else {+ if isSymlink(live) || Digest.sha256IfPresent(live) != stock[name] { problems.append(livePath) }+ if exists(saved) { problems.append(savedPath) }+ if exists(unix) { problems.append(unixPath) }+ }+ }+ for name in optionalForwarders {+ for path in ["\(builtinPath)/\(name)", "\(unixPath)/\(unixName(of: name))"] {+ let url = root.appending(path: path)+ // Linked: only ever a link. Stock: Wine has none.+ if linked ? exists(url) && !isSymlink(url) : exists(url) { problems.append(path) }+ }+ }+ if linked {+ for name in [framework, sharedLibrary] where !isSymlink(root.appending(path: "\(externalPath)/\(name)")) {+ problems.append("\(externalPath)/\(name)")+ }+ }+ return problems+ }+// fileExists follows links, so a GPTK that was moved or deleted shows up here.private static func linksResolve(root: URL) -> Bool {- let backend = root.appending(path: backendPath)- let external = root.appending(path: externalPath)- let paths = [external.appending(path: framework), external.appending(path: sharedLibrary)]- + forwarders.flatMap { name in- [backend.appending(path: "x86_64-windows/\(name)"),- backend.appending(path: "x86_64-unix/\((name as NSString).deletingPathExtension).so")]+ let linkedOptional = optionalForwarders.filter { isSymlink(root.appending(path: "\(builtinPath)/\($0)")) }+ let paths = [root.appending(path: "\(externalPath)/\(framework)"),+ root.appending(path: "\(externalPath)/\(sharedLibrary)")]+ + (forwarders + linkedOptional).flatMap { name in+ [root.appending(path: "\(builtinPath)/\(name)"),+ root.appending(path: "\(unixPath)/\(unixName(of: name))")]}return paths.allSatisfy { FileManager.default.fileExists(atPath: $0.path(percentEncoded: false)) }}@@ -190,18 +299,25 @@ enum WinecxD3DMetal {return attributes?[.type] as? FileAttributeType == .typeSymbolicLink}+ // Present as a file or as a link, dangling or not.+ private static func exists(_ url: URL) -> Bool {+ (try? FileManager.default.attributesOfItem(atPath: url.path(percentEncoded: false))) != nil+ }+// Links the first Game Porting Toolkit found, or clears the layout when there is none// or the old one went away. Only ever touches a WineCX root: a CrossOver bundle has// its own D3DMetal and is never written to.@discardableResult- static func refresh(root: URL, roots: [URL] = searchRoots()) -> Payload? {+ static func refresh(+ root: URL, roots: [URL] = searchRoots(), stock: [String: String] = FreeEngineWinecx.current.d3dStock+ ) -> Payload? {guard isWinecx(root: root) else { return nil }guard let payload = locate(in: roots) else {unlink(root: root)return nil}do {- try link(payload, root: root)+ try link(payload, root: root, stock: stock)AppLog.note("winecx: linked D3DMetal \(payload.version ?? "unknown") from "+ payload.libRoot.path(percentEncoded: false))return payloaddiff --git a/app/Sources/NotProtonApp/SystemStatus.swift b/app/Sources/NotProtonApp/SystemStatus.swiftindex cd65539..c0beec7 100644--- a/app/Sources/NotProtonApp/SystemStatus.swift+++ b/app/Sources/NotProtonApp/SystemStatus.swift@@ -25,6 +25,10 @@ struct StatusSnapshot: Sendable {var orphanedRunners: [String] = []var damagedRunners: [String] = []var installContent: DeploymentContent.Status = .unchecked+ // Free engine builds whose engine tree matches every pin, checked per engine.+ var currentFreeEngines: Set<String> = []+ // The Game Porting Toolkit folder linked into the WineCX engine, when one is.+ var gptkSource: String?static func capture(bundledVersion: String) -> StatusSnapshot {let installs = CrossOverSource.discover()@@ -35,6 +39,7 @@ struct StatusSnapshot: Sendable {let runner = RunnerStore.state()let installed = RunnerStore.installedBuilds()+ let engines = FreeEngineStatus.capture(installs)return StatusSnapshot(steam: SteamBundle.deployment(bundledVersion: bundledVersion),@@ -47,11 +52,55 @@ struct StatusSnapshot: Sendable {installedRunners: installed,orphanedRunners: RunnerStore.orphanedClones(),damagedRunners: RunnerStore.damagedClones(),- installContent: DeploymentContent.current(version: bundledVersion)+ installContent: DeploymentContent.current(version: bundledVersion),+ currentFreeEngines: engines.current,+ gptkSource: engines.gptkSource)}}+enum FreeEngineState: Sendable, Equatable {+ case missing+ // Unpacked, but not matching every pin of this NotProton: "Update & Set Up".+ case outdated+ case current+}++enum FreeEngineStatus {++ static func buildID(of install: CrossOverInstall) -> String? {+ if case .supported(let build) = install.support { return build.id }+ return nil+ }++ // Each free engine is judged against its own pins.+ static func isCurrent(_ install: CrossOverInstall) -> Bool {+ switch buildID(of: install) {+ case FreeEngine.current.build: FreeEngine.hasRenderer(root: install.crossOverRoot)+ case FreeEngineWinecx.current.build: FreeEngineWinecx.hasBackends(root: install.crossOverRoot)+ default: false+ }+ }++ static func capture(_ installs: [CrossOverInstall]) -> (current: Set<String>, gptkSource: String?) {+ var current: Set<String> = []+ var gptk: String?+ for install in installs where install.isFree {+ guard let id = buildID(of: install) else { continue }+ if isCurrent(install) { current.insert(id) }+ if id == FreeEngineWinecx.current.build, gptk == nil {+ gptk = WinecxD3DMetal.linkedSource(root: install.crossOverRoot)+ }+ }+ return (current, gptk)+ }++ static func state(build: String, installs: [CrossOverInstall], current: Set<String>) -> FreeEngineState {+ if current.contains(build) { return .current }+ return installs.contains { $0.isFree && buildID(of: $0) == build } ? .outdated : .missing+ }+}+@MainActor@Observablefinal class SystemStatus {@@ -341,7 +390,7 @@ final class SystemStatus {private func setUpRunner(from install: CrossOverInstall?, replacingExisting: Bool = false) async {guard let install else {- setFailure("No supported Wine engine found. Download the free WineHQ engine first.")+ setFailure("No supported Wine engine found. Download the free WineHQ or WineCX engine first.")AppLog.note("run refused: no supported CrossOver")outcome = nilreturn@@ -361,8 +410,10 @@ final class SystemStatus {}}- var freeEngineInstalled: Bool {- snapshot?.crossOver.contains { $0.isFree && FreeEngine.hasRenderer(root: $0.crossOverRoot) } ?? false+ func freeEngineState(_ build: String) -> FreeEngineState {+ guard let snapshot else { return .missing }+ return FreeEngineStatus.state(+ build: build, installs: snapshot.crossOver, current: snapshot.currentFreeEngines)}// Downloads the free WineHQ engine and sets the compatibility tool up from it,@@ -381,6 +432,56 @@ final class SystemStatus {}}+ // The same for WineCX. The engine links a Game Porting Toolkit while it is unpacked,+ // and the runner is cloned from it afterwards, so the copy carries the same links.+ func installWinecxEngine() async {+ guard canInstall else { return }+ await perform(from: FreeEngineWinecx.step) { progress in+ let lock = try DeploymentContent.acquireInstallationLock(for: SupportPaths.Steam.app)+ defer { close(lock) }+ try await requireInstallableContent()+ let install = try await FreeEngineWinecx.install { progress($0.label) }+ let result = try await Task.detached(priority: .userInitiated) {+ try RunnerSetup.run(from: install, replacingExisting: true) { progress($0.label) }+ }.value+ return runnerOutcome(result)+ }+ }++ static let rescanStep = "Look for the Game Porting Toolkit"++ // Looks for a Game Porting Toolkit again and links or unlinks it in the WineCX engine+ // and in the runner copied from it, so both always carry the same Direct3D.+ func rescanGameportingToolkit() async {+ guard canInstall else { return }+ await perform(from: Self.rescanStep) { _ in+ let lock = try DeploymentContent.acquireInstallationLock(for: SupportPaths.Steam.app)+ defer { close(lock) }+ try await requireInstallableContent()+ let found = await Task.detached(priority: .userInitiated) {+ Self.relinkGameportingToolkit()+ }.value+ return found.map { "Game Porting Toolkit linked from \($0)." }+ ?? "Game Porting Toolkit not found."+ }+ }++ nonisolated static func relinkGameportingToolkit(+ engines: URL = SupportPaths.engines,+ runners: URL = SupportPaths.runners,+ roots: [URL] = WinecxD3DMetal.searchRoots()+ ) -> String? {+ let engine = SupportPaths.crossOverRoot(inBundle: FreeEngineWinecx.bundle(engines: engines))+ let runner = SupportPaths.clonedRoot(forBuild: FreeEngineWinecx.current.build, runners: runners)+ var linked: String?+ for root in [engine, runner] {+ if let payload = WinecxD3DMetal.refresh(root: root, roots: roots) {+ linked = linked ?? payload.libRoot.standardizedFileURL.path(percentEncoded: false)+ }+ }+ return linked+ }+func fetchValveBinaries() async {guard canInstall else { return }await perform(from: ValveFetcher.Phase.verifying.label) { progress indiff --git a/app/Sources/NotProtonApp/Views/StatusView.swift b/app/Sources/NotProtonApp/Views/StatusView.swiftindex ae4fc4d..7a0a632 100644--- a/app/Sources/NotProtonApp/Views/StatusView.swift+++ b/app/Sources/NotProtonApp/Views/StatusView.swift@@ -532,13 +532,14 @@ struct StatusView: View {if rows.isEmpty {StatusRow(title: "Wine Engine",- value: "None found. Download the free WineHQ engine, or use CrossOver "+ value: "None found. Download the free WineHQ or WineCX engine, or use CrossOver "+ "(\(SupportedRunners.versionList)).",tone: .bad)}- if !status.freeEngineInstalled {- let outdated = snapshot.crossOver.contains(where: \.isFree)+ let winehq = status.freeEngineState(FreeEngine.current.build)+ if winehq != .current {+ let outdated = winehq == .outdatedStatusRow(title: "Free Wine Engine",value: outdated@@ -554,6 +555,40 @@ struct StatusView: View {) { Task { await status.installFreeEngine() } })}+ let winecx = status.freeEngineState(FreeEngineWinecx.current.build)+ if winecx != .current {+ let outdated = winecx == .outdated+ StatusRow(+ title: "WineCX Engine",+ value: "WineCX 11.15 with msync and D3DMetal, no CrossOver license needed.",+ tone: outdated ? .warning : .neutral,+ action: StatusAction(+ label: outdated ? "Update & Set Up" : "Download & Set Up",+ isProminent: rows.isEmpty,+ help: "Download WineCX and set the compatibility tool up from it.",+ isEnabled: status.canInstall+ ) { Task { await status.installWinecxEngine() } }+ )+ }+ if let source = snapshot.gptkSource {+ StatusRow(+ title: "Game Porting Toolkit",+ value: "Linked from \(source).",+ tone: .ok+ )+ } else {+ StatusRow(+ title: "Game Porting Toolkit",+ value: "Not found. Copy the redist/lib folder of Apple's Game Porting Toolkit to "+ + "~/Library/Application Support/notproton/gptk, then press Rescan.",+ tone: .neutral,+ action: StatusAction(+ label: "Rescan",+ help: "Look for the Game Porting Toolkit again and link it into the WineCX engine.",+ isEnabled: status.canInstall+ ) { Task { await status.rescanGameportingToolkit() } }+ )+ }let tools = SupportedRunners.tools(for: snapshot.installedRunners)ForEach(rows) { row inStatusRow(diff --git a/app/Tests/NotProtonAppTests/FreeEngineTests.swift b/app/Tests/NotProtonAppTests/FreeEngineTests.swiftindex 0e2c248..06ee819 100644--- a/app/Tests/NotProtonAppTests/FreeEngineTests.swift+++ b/app/Tests/NotProtonAppTests/FreeEngineTests.swift@@ -89,8 +89,9 @@ struct FreeEngineTests {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"]!]),+ files: ["x86_64-windows/d3d11.dll": table["dxmt-shipped"] ?? table["dxmt-d3d11"]!,+ "x86_64-windows/winemetal.dll": table["winemetal"]!],+ natives: ["x86_64-windows/d3d11.dll": table["dxmt-d3d11"]!]),macDriver: table["mac"]!,stock: ["x86_64-windows/d3d11.dll": table["stock-d3d11"]!],dxvk: BackendRelease(@@ -138,6 +139,8 @@ struct FreeEngineTests {// 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)+ // Installed without the builtin marker, so the table pins the stripped copy.+ #expect(table[release.renderer.installPath(of: path)] == release.renderer.natives[path])}}@@ -215,6 +218,94 @@ struct FreeEngineTests {}}+ @Test("DXMT is the pinned master build on NotProton's release, shared by both free engines")+ func dxmtPins() {+ let dxmt = FreeEngine.current.renderer+ #expect(dxmt.archive == "dxmt-e94c312.tar.gz")+ #expect(dxmt.sha256 == "8de0d5b7eb2b96315f6ec8e259c05423ab43212e776196147b30d9f44927f7f0")+ #expect(dxmt.tree == "e94c312")+ #expect(dxmt.bases.map(\.absoluteString)+ == ["https://github.com/raymondchins/NotProton-WineHQ/releases/download/dxmt-e94c312"])+ // docs/DXMT.md, minus nvapi64, nvngx and the WIP d3d12.+ #expect(dxmt.files == [+ "x86_64-unix/winemetal.so": "1d0a1258cbb696e1323d1fde77ebef7fedf5ea32a554bb777a9916321dedc195",+ "x86_64-windows/d3d10core.dll": "14fef5785b9c83ab1d440d9d8de9d2d875420b9ae468c282737fcd44bb75336b",+ "x86_64-windows/d3d11.dll": "f2ee8959c19548fb66c5b2a3802ff84967107d2faa3391bafb38c1363ece8a8b",+ "x86_64-windows/dxgi.dll": "75436305876c11f4b7e8535fc32b0007e157b062dbd1534c1757c310a44bd99e",+ "x86_64-windows/winemetal.dll": "33dd95086ab29ed03f876c47589b04a1e4a5891c6cbb5af6129309414aa8b0f7",+ "i386-windows/d3d10core.dll": "7cbefea0f3b766024b85413ec75a2cc32e0431bbcc5f966b0b7515b4d785f3e7",+ "i386-windows/d3d11.dll": "842b5a3868230e1b3eb829581b362f4ff56c86b318a3ce5b5307fa071485b58d",+ "i386-windows/dxgi.dll": "51d01ce7f2b9edacaaa3490d838a95bf060ff04db7f42fe746cb62174c484bca",+ "i386-windows/winemetal.dll": "6ddeb053c5510cffafdabfd27c8a67950f2e37308e6b9f9d1a0c44b9119ac456",+ ])+ #expect(!dxmt.files.keys.contains { $0.contains("d3d12") || $0.contains("nv") })+ #expect(Set(dxmt.natives.keys) == Set(dxmt.files.keys.filter { !RendererRelease.isWinemetal($0) }))+ #expect(FreeEngineWinecx.current.renderer.sha256 == dxmt.sha256)+ #expect(FreeEngineWinecx.current.renderer.files == dxmt.files)+ }++ @Test("Stripping the builtin marker turns a builtin PE into a native one and refuses anything else")+ func stripsBuiltinMarker() throws {+ var image = Data(repeating: 0, count: 0x80)+ image[0] = 0x4d+ image[1] = 0x5a+ image.replaceSubrange(0x40 ..< 0x51, with: FreeEngine.builtinMarker)+ var stripped = image+ try FreeEngine.stripBuiltinMarker(&stripped)+ #expect(Array(stripped[0x40 ..< 0x50]) == FreeEngine.dosStub)+ #expect(stripped.count == image.count)+ #expect(stripped[0x50...] == image[0x50...])+ #expect(!WinecxD3DMetal.isBuiltin(try write(stripped)))+ #expect(WinecxD3DMetal.isBuiltin(try write(image)))+ // Already native: refused, so a pin mismatch cannot be papered over.+ #expect(throws: StepFailure.self) { try FreeEngine.stripBuiltinMarker(&stripped) }+ }++ private func write(_ data: Data) throws -> URL {+ let url = FileManager.default.temporaryDirectory.appending(path: "np-pe-\(UUID().uuidString).dll")+ try data.write(to: url)+ return url+ }++ // Downloads the real tarball into NotProton's engine cache (where the app and the other+ // real-archive tests look for it) unless it is already there. NOTPROTON_OFFLINE=1 skips+ // the download, and the test then runs only against a cached copy.+ @Test("The real DXMT master tarball downloads, matches every pin and installs as natives")+ func downloadsAndUnpacksRealDxmt() async throws {+ let dxmt = FreeEngine.current.renderer+ let cached = FreeEngine.downloads.appending(path: dxmt.archive)+ if Digest.sha256IfPresent(cached) != dxmt.sha256,+ ProcessInfo.processInfo.environment["NOTPROTON_OFFLINE"] == "1" { return }+ let archive = try await PinnedDownload.obtain(+ file: dxmt.archive, sha256: dxmt.sha256, bases: dxmt.bases,+ into: FreeEngine.downloads, step: FreeEngine.step, source: "GitHub"+ )+ #expect(Digest.sha256IfPresent(archive) == dxmt.sha256)++ 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)+ let tree = work.appending(path: dxmt.tree)+ for (path, hash) in dxmt.files {+ #expect(Digest.sha256IfPresent(tree.appending(path: path)) == hash, "\(path)")+ }++ let root = work.appending(path: "root")+ try FreeEngine.installRenderer(dxmt, from: tree, root: root, step: FreeEngine.step)+ for path in dxmt.files.keys {+ let installed = root.appending(path: dxmt.installPath(of: path))+ #expect(Digest.sha256IfPresent(installed) == dxmt.installedHash(of: path), "\(path)")+ // winemetal stays a builtin beside its unix half; the D3D DLLs load as natives.+ if path.hasSuffix(".dll") {+ #expect(WinecxD3DMetal.isBuiltin(installed) == RendererRelease.isWinemetal(path), "\(path)")+ }+ }+ // The WIP D3D12 backend and the DLSS pair are never staged.+ let staged = try FileManager.default.subpathsOfDirectory(atPath: root.path(percentEncoded: false))+ #expect(!staged.contains { $0.hasSuffix("d3d12.dll") || $0.contains("nvapi") || $0.contains("nvngx") })+ }+@Test("Shipped game fixes are located in the payload and installed beside the user's own")func gamefixesDefaultInstall() throws {let work = try makeEngines()diff --git a/app/Tests/NotProtonAppTests/FreeEngineWinecxTests.swift b/app/Tests/NotProtonAppTests/FreeEngineWinecxTests.swiftindex e26eee5..d405d57 100644--- a/app/Tests/NotProtonAppTests/FreeEngineWinecxTests.swift+++ b/app/Tests/NotProtonAppTests/FreeEngineWinecxTests.swift@@ -60,24 +60,52 @@ struct FreeEngineWinecxTests {for file in backends {let parts = file.destination.split(separator: "/").map(String.init)#expect(parts.count == 3, "\(file.destination)")- #expect(["dxmt", "dxvk"].contains(parts[0]), "\(file.destination)")+ // DXMT comes from the master tarball, never the archive's 0.80.+ #expect(parts[0] == "dxvk", "\(file.destination)")+ #expect(!file.source.hasPrefix("DXMT/"))#expect(["x86_64-windows", "i386-windows"].contains(parts[1]), "\(file.destination)")#expect(!["nvapi64.dll", "nvngx.dll"].contains(parts[2]))#expect(file.sha256.count == 64 && file.sha256.allSatisfy(\.isHexDigit))#expect(FreeEngineWinecx.backend(file.destination, in: URL(filePath: "/r")).path(percentEncoded: false)== "/r/lib/notproton-backends/\(file.destination)")}- for backend in ["dxmt", "dxvk"] {- for arch in ["x86_64-windows", "i386-windows"] {- #expect(backends.contains { $0.destination == "\(backend)/\(arch)/d3d11.dll" })+ let table = FreeEngineWinecx.expectedFiles()+ for arch in ["x86_64-windows", "i386-windows"] {+ for backend in ["dxmt", "dxvk"] {+ #expect(table["lib/notproton-backends/\(backend)/\(arch)/d3d11.dll"] != nil)}+ #expect(table["lib/notproton-backends/dxmt/\(arch)/d3d11.dll"]+ == FreeEngine.dxmt.natives["\(arch)/d3d11.dll"])+ #expect(table["lib/wine/\(arch)/winemetal.dll"] == FreeEngine.dxmt.files["\(arch)/winemetal.dll"])}+ #expect(table["lib/wine/x86_64-unix/winemetal.so"] == FreeEngine.dxmt.files["x86_64-unix/winemetal.so"])+ #expect(Set(FreeEngineWinecx.current.d3dStock.keys) == Set(WinecxD3DMetal.forwarders))#expect(FreeEngineWinecx.msyncMarker(in: URL(filePath: "/r")).path(percentEncoded: false)== "/r/.notproton-msync")#expect(WinecxD3DMetal.enabledMarker(in: URL(filePath: "/r")).path(percentEncoded: false)== "/r/lib/notproton-backends/d3dmetal.enabled")}+ @Test("Each free engine is current, outdated or missing on its own pins")+ func perEngineState() throws {+ let winehqBuild = try #require(SupportedRunners.build(id: FreeEngine.current.build))+ let winecxBuild = try #require(SupportedRunners.build(id: FreeEngineWinecx.current.build))+ let winehq = CrossOverInstall(bundle: URL(filePath: "/e/WineHQ 11.15.app"), releaseVersion: nil,+ support: .supported(winehqBuild))+ let winecx = CrossOverInstall(bundle: URL(filePath: "/e/WineCX 11.15.app"), releaseVersion: nil,+ support: .supported(winecxBuild))+ let both = [winehq, winecx]+ #expect(FreeEngineStatus.state(build: winehqBuild.id, installs: both, current: [winecxBuild.id]) == .outdated)+ #expect(FreeEngineStatus.state(build: winecxBuild.id, installs: both, current: [winecxBuild.id]) == .current)+ #expect(FreeEngineStatus.state(build: winecxBuild.id, installs: [winehq], current: [winehqBuild.id]) == .missing)+ // Neither engine is judged by the other's pins: these empty trees match neither.+ #expect(!FreeEngineStatus.isCurrent(winehq) && !FreeEngineStatus.isCurrent(winecx))+ #expect(FreeEngineStatus.capture(both).current.isEmpty)+ // Steam lists one tool per engine.+ let tools = SupportedRunners.tools(for: [winehqBuild, winecxBuild]).map(\.display)+ #expect(Set(tools) == ["WineHQ 11.15 - Rosetta", "WineCX 11.15 (msync, D3DMetal)"])+ }+@Test("Downloads come only from the pinned GitHub release mirrors")func pinnedSources() {let release = FreeEngineWinecx.current@@ -108,17 +136,35 @@ struct FreeEngineWinecxTests {image[0] = 0x4dimage[1] = 0x5aif builtin { image.replaceSubrange(0x40 ..< 0x51, with: Array("Wine builtin DLL".utf8) + [0]) }- for name in WinecxD3DMetal.forwarders {+ let unix = lib.appending(path: "wine/x86_64-unix")+ try fm.createDirectory(at: unix, withIntermediateDirectories: true)+ // GPTK 4.0 beta 2: the four forwarders plus nvapi64 and nvngx-on-metalfx, each unix+ // half a relative link to libd3dshared.+ for name in WinecxD3DMetal.forwarders + ["nvapi64.dll", "nvngx-on-metalfx.dll"] {try image.write(to: pe.appending(path: name))+ try fm.createSymbolicLink(+ atPath: unix.appending(path: WinecxD3DMetal.unixName(of: name)).path(percentEncoded: false),+ withDestinationPath: "../../external/libd3dshared.dylib")}return lib}+ // Wine's four originals, as text whose hashes the test pins.+ private static let stockText = Dictionary(uniqueKeysWithValues: WinecxD3DMetal.forwarders.map { ($0, "wine's own \($0)") })+ private static let stock = stockText.mapValues { Digest.sha256(of: Data($0.utf8)) }+private func makeEngineRoot(in folder: URL) throws -> URL {+ let fm = FileManager.defaultlet root = folder.appending(path: "CrossOver")let external = root.appending(path: "lib/external")- try FileManager.default.createDirectory(at: external, withIntermediateDirectories: true)+ try fm.createDirectory(at: external, withIntermediateDirectories: true)try Data("winecx readme".utf8).write(to: external.appending(path: "README"))+ let builtins = root.appending(path: "lib/wine/x86_64-windows")+ try fm.createDirectory(at: builtins, withIntermediateDirectories: true)+ try fm.createDirectory(at: root.appending(path: "lib/wine/x86_64-unix"), withIntermediateDirectories: true)+ for (name, text) in Self.stockText {+ try Data(text.utf8).write(to: builtins.appending(path: name))+ }return root}@@ -175,7 +221,7 @@ struct FreeEngineWinecxTests {#expect(WinecxD3DMetal.locate(in: [native, partial, noFramework]) == nil)}- @Test("Linking writes only symlinks into the user's copy, then the marker")+ @Test("Linking makes Apple's forwarders the builtins, as links, with Wine's originals set aside")func linksPayload() throws {let base = try makeDirectory("link")defer { try? FileManager.default.removeItem(at: base) }@@ -183,40 +229,48 @@ struct FreeEngineWinecxTests {let lib = try makePayload(in: base.appending(path: "gptk"))let root = try makeEngineRoot(in: base)+ #expect(WinecxD3DMetal.layoutProblems(root: root, stock: Self.stock).isEmpty)let payload = try #require(WinecxD3DMetal.locate(in: [lib]))- try WinecxD3DMetal.link(payload, root: root)+ try WinecxD3DMetal.link(payload, root: root, stock: Self.stock)#expect(WinecxD3DMetal.isLinked(root: root))+ #expect(WinecxD3DMetal.linkedSource(root: root) == lib.standardizedFileURL.path(percentEncoded: false))+ #expect(WinecxD3DMetal.layoutProblems(root: root, stock: Self.stock).isEmpty)let source = lib.standardizedFileURL#expect(try destination(of: root.appending(path: "lib/external/libd3dshared.dylib"))== source.appending(path: "external/libd3dshared.dylib").path(percentEncoded: false))#expect(try destination(of: root.appending(path: "lib/external/D3DMetal.framework"))== source.appending(path: "external/D3DMetal.framework").path(percentEncoded: false))- for name in WinecxD3DMetal.forwarders {- let pe = root.appending(path: "lib/notproton-backends/d3dmetal/x86_64-windows/\(name)")- #expect(try destination(of: pe)+ for name in WinecxD3DMetal.forwarders + ["nvapi64.dll"] {+ #expect(try destination(of: root.appending(path: "lib/wine/x86_64-windows/\(name)"))== source.appending(path: "wine/x86_64-windows/\(name)").path(percentEncoded: false))- let unix = root.appending(- path: "lib/notproton-backends/d3dmetal/x86_64-unix/\((name as NSString).deletingPathExtension).so")- #expect(try destination(of: unix) == "../../../external/libd3dshared.dylib")- // The relative link has to land on the shared library through lib/external.- #expect(try Data(contentsOf: unix) == Data("dylib".utf8))+ let so = WinecxD3DMetal.unixName(of: name)+ #expect(try destination(of: root.appending(path: "lib/wine/x86_64-unix/\(so)"))+ == source.appending(path: "wine/x86_64-unix/\(so)").path(percentEncoded: false))+ // Through Apple's own relative link, onto the shared library.+ #expect(try Data(contentsOf: root.appending(path: "lib/wine/x86_64-unix/\(so)")) == Data("dylib".utf8))+ }+ for name in WinecxD3DMetal.forwarders {+ let saved = root.appending(path: "lib/notproton-backends/wine-stock/x86_64-windows/\(name)")+ #expect(Digest.sha256IfPresent(saved) == Self.stock[name])}+ // nvngx-on-metalfx is left out.+ #expect(!fm.fileExists(atPath: root.appending(path: "lib/wine/x86_64-windows/nvngx-on-metalfx.dll").path(percentEncoded: false)))+ #expect(!fm.fileExists(atPath: root.appending(path: "lib/notproton-backends/d3dmetal").path(percentEncoded: false)))#expect(fm.fileExists(atPath: root.appending(path: "lib/external/README").path(percentEncoded: false)))- // Nothing lands in lib/wine.- #expect(!fm.fileExists(atPath: root.appending(path: "lib/wine").path(percentEncoded: false)))let marker = try String(contentsOf: WinecxD3DMetal.enabledMarker(in: root), encoding: .utf8)#expect(marker.contains("version=3.0\n"))#expect(marker.contains("libd3dshared=lib/external/libd3dshared.dylib\n"))- #expect(marker.contains("dllpath=lib/notproton-backends/d3dmetal\n"))+ #expect(marker.contains("model=builtin\n"))// Relinking is idempotent.- try WinecxD3DMetal.link(payload, root: root)+ try WinecxD3DMetal.link(payload, root: root, stock: Self.stock)#expect(WinecxD3DMetal.isLinked(root: root))+ #expect(WinecxD3DMetal.layoutProblems(root: root, stock: Self.stock).isEmpty)}- @Test("A Game Porting Toolkit that went away reads as unlinked, and unlinking keeps winecx's files")+ @Test("Unlinking puts Wine's originals back byte for byte and removes only links")func unlinksCleanly() throws {let base = try makeDirectory("unlink")defer { try? FileManager.default.removeItem(at: base) }@@ -224,14 +278,23 @@ struct FreeEngineWinecxTests {let lib = try makePayload(in: base.appending(path: "gptk"))let root = try makeEngineRoot(in: base)- try WinecxD3DMetal.link(try #require(WinecxD3DMetal.locate(in: [lib])), root: root)+ try WinecxD3DMetal.link(try #require(WinecxD3DMetal.locate(in: [lib])), root: root, stock: Self.stock)try fm.removeItem(at: lib)#expect(!WinecxD3DMetal.isLinked(root: root))+ // Still the linked shape, only dangling: refresh is what clears it.+ #expect(WinecxD3DMetal.layoutProblems(root: root, stock: Self.stock).isEmpty)WinecxD3DMetal.unlink(root: root)+ #expect(WinecxD3DMetal.layoutProblems(root: root, stock: Self.stock).isEmpty)#expect(!fm.fileExists(atPath: WinecxD3DMetal.enabledMarker(in: root).path(percentEncoded: false)))- #expect(!fm.fileExists(atPath: root.appending(path: "lib/notproton-backends/d3dmetal").path(percentEncoded: false)))+ for (name, text) in Self.stockText {+ let live = root.appending(path: "lib/wine/x86_64-windows/\(name)")+ #expect((try? fm.destinationOfSymbolicLink(atPath: live.path(percentEncoded: false))) == nil)+ #expect(try Data(contentsOf: live) == Data(text.utf8))+ }+ #expect(try fm.contentsOfDirectory(atPath: root.appending(path: "lib/wine/x86_64-unix").path(percentEncoded: false)).isEmpty)+ #expect(!fm.fileExists(atPath: root.appending(path: "lib/notproton-backends/wine-stock").path(percentEncoded: false)))#expect((try? fm.destinationOfSymbolicLink(atPath: root.appending(path: "lib/external/libd3dshared.dylib").path(percentEncoded: false))) == nil)#expect(fm.fileExists(atPath: root.appending(path: "lib/external/README").path(percentEncoded: false)))@@ -243,6 +306,40 @@ struct FreeEngineWinecxTests {#expect(fm.fileExists(atPath: real.path(percentEncoded: false)))}+ @Test("Only the stock and the linked layout pass; a tampered builtin blocks linking")+ func toleratesExactlyTwoStates() throws {+ let base = try makeDirectory("states")+ defer { try? FileManager.default.removeItem(at: base) }+ let fm = FileManager.default+ let lib = try makePayload(in: base.appending(path: "gptk"))+ let root = try makeEngineRoot(in: base)+ let payload = try #require(WinecxD3DMetal.locate(in: [lib]))++ let dxgi = root.appending(path: "lib/wine/x86_64-windows/dxgi.dll")+ try Data("tampered".utf8).write(to: dxgi)+ #expect(WinecxD3DMetal.layoutProblems(root: root, stock: Self.stock) == ["lib/wine/x86_64-windows/dxgi.dll"])+ #expect(throws: StepFailure.self) { try WinecxD3DMetal.link(payload, root: root, stock: Self.stock) }+ // The failed link left nothing behind and moved nothing aside.+ #expect(!fm.fileExists(atPath: WinecxD3DMetal.enabledMarker(in: root).path(percentEncoded: false)))+ for name in ["d3d10.dll", "d3d11.dll", "d3d12.dll"] {+ #expect(Digest.sha256IfPresent(root.appending(path: "lib/wine/x86_64-windows/\(name)")) == Self.stock[name])+ }+ try Data(Self.stockText["dxgi.dll"]!.utf8).write(to: dxgi)++ // A stray unix half or a set-aside copy without the marker is neither state.+ let stray = root.appending(path: "lib/wine/x86_64-unix/d3d12.so")+ try fm.createSymbolicLink(at: stray, withDestinationURL: lib.appending(path: "external/libd3dshared.dylib"))+ #expect(WinecxD3DMetal.layoutProblems(root: root, stock: Self.stock) == ["lib/wine/x86_64-unix/d3d12.so"])+ try fm.removeItem(at: stray)++ try WinecxD3DMetal.link(payload, root: root, stock: Self.stock)+ // Linked, but one forwarder swapped for a real file: refused.+ let d3d11 = root.appending(path: "lib/wine/x86_64-windows/d3d11.dll")+ try fm.removeItem(at: d3d11)+ try Data("copied apple file".utf8).write(to: d3d11)+ #expect(WinecxD3DMetal.layoutProblems(root: root, stock: Self.stock) == ["lib/wine/x86_64-windows/d3d11.dll"])+ }+@Test("Refresh never writes into a tree that is not WineCX")func refreshOnlyTouchesWinecx() throws {let base = try makeDirectory("refresh")@@ -273,8 +370,14 @@ struct FreeEngineWinecxTests {}@Test("Unpacking the real archive yields a free, patchable engine with the runtime contract")- func unpacksRealArchive() throws {+ func unpacksRealArchive() async throws {guard let archive = Self.realArchive else { return }+ // Fetched into the engine cache the way FreeEngineWinecx.install does, when missing.+ let dxmt = FreeEngine.dxmt+ let renderer = try await PinnedDownload.obtain(+ file: dxmt.archive, sha256: dxmt.sha256, bases: dxmt.bases,+ into: FreeEngine.downloads, step: FreeEngineWinecx.step, source: "GitHub"+ )let fm = FileManager.defaultlet base = try makeDirectory("real")defer { try? fm.removeItem(at: base) }@@ -282,7 +385,7 @@ struct FreeEngineWinecxTests {let engines = base.appending(path: "engines")let gptk = try makePayload(in: base.appending(path: "gptk"))let install = try FreeEngineWinecx.unpack(- archive, release: FreeEngineWinecx.current, engines: engines, gptkRoots: [gptk]+ archive, renderer: renderer, release: FreeEngineWinecx.current, engines: engines, gptkRoots: [gptk])guard case .supported(let build) = install.support else {Issue.record("unpacked engine is \(install.support)")@@ -304,27 +407,97 @@ struct FreeEngineWinecxTests {#expect(Digest.sha256(of: patched) == build.patchedNtdll[patch.arch])}- // lib/wine keeps Wine's own Direct3D: none of it is a backend copy.- let pinned = Set(FreeEngineWinecx.current.backends.map(\.sha256))- for arch in ["x86_64-windows", "i386-windows"] {- for name in ["d3d11.dll", "dxgi.dll", "d3d10core.dll", "d3d12.dll"] {- let stock = root.appending(path: "lib/wine/\(arch)/\(name)")- let hash = try #require(Digest.sha256IfPresent(stock), "\(arch)/\(name)")- #expect(!pinned.contains(hash), "\(arch)/\(name)")- }+ #expect(FreeEngineWinecx.layoutProblems(root: root).isEmpty)+ // Master's winemetal replaced the archive's, and its DLLs are natives.+ for (path, hash) in FreeEngineWinecx.expectedFiles() {+ #expect(Digest.sha256IfPresent(root.appending(path: path)) == hash, "\(path)")}- // DXMT's builtin half and the unix loader winecx's DXMT and D3DMetal hooks live in.- #expect(fm.fileExists(atPath: root.appending(path: "lib/wine/x86_64-unix/winemetal.so").path(percentEncoded: false)))+ #expect(!WinecxD3DMetal.isBuiltin(root.appending(path: "lib/notproton-backends/dxmt/x86_64-windows/d3d11.dll")))+ #expect(WinecxD3DMetal.isBuiltin(root.appending(path: "lib/wine/x86_64-windows/winemetal.dll")))#expect(try String(contentsOf: FreeEngineWinecx.msyncMarker(in: root), encoding: .utf8) == "winecx-11.15\n")- // The fixture GPTK was linked into the real tree, through winecx's own lib/external.+ // The fixture GPTK was linked as the builtins, with Wine's own set aside under their pins.#expect(WinecxD3DMetal.isLinked(root: root))#expect(fm.fileExists(atPath: root.appending(path: "lib/external/README").path(percentEncoded: false)))- WinecxD3DMetal.unlink(root: root)- #expect(!WinecxD3DMetal.isLinked(root: root))- #expect(WinecxD3DMetal.refresh(root: root, roots: [gptk]) != nil)+ for (name, hash) in FreeEngineWinecx.current.d3dStock {+ #expect(Digest.sha256IfPresent(root.appending(path: "\(WinecxD3DMetal.stockPath)/\(name)")) == hash)+ }++ // A runner cloned from it carries the same links, and a rescan reaches both trees.+ let runners = base.appending(path: "runners")+ let cloned = try RunnerInstaller.clone(from: install, runners: runners)+ let runnerRoot = SupportPaths.clonedRoot(forBuild: cloned.id, runners: runners)+ #expect(WinecxD3DMetal.isLinked(root: runnerRoot))+ #expect(FreeEngineWinecx.layoutProblems(root: runnerRoot).isEmpty)try fm.removeItem(at: gptk)- #expect(WinecxD3DMetal.refresh(root: root, roots: [gptk]) == nil)- #expect(!fm.fileExists(atPath: WinecxD3DMetal.enabledMarker(in: root).path(percentEncoded: false)))+ #expect(SystemStatus.relinkGameportingToolkit(engines: engines, runners: runners, roots: [gptk]) == nil)+ for tree in [root, runnerRoot] {+ #expect(!WinecxD3DMetal.isLinked(root: tree))+ #expect(!fm.fileExists(atPath: WinecxD3DMetal.enabledMarker(in: tree).path(percentEncoded: false)))+ #expect(FreeEngineWinecx.layoutProblems(root: tree).isEmpty, "\(tree)")+ for (name, hash) in FreeEngineWinecx.current.d3dStock {+ #expect(Digest.sha256IfPresent(tree.appending(path: "lib/wine/x86_64-windows/\(name)")) == hash)+ }+ }+ let again = try makePayload(in: base.appending(path: "gptk2"))+ #expect(SystemStatus.relinkGameportingToolkit(engines: engines, runners: runners, roots: [again])+ == again.standardizedFileURL.path(percentEncoded: false))+ #expect(WinecxD3DMetal.isLinked(root: root) && WinecxD3DMetal.isLinked(root: runnerRoot))+ }++ // MARK: - Against the user's own Game Porting Toolkit++ // Runs only when a GPTK sits in NotProton's gptk folder. It is only read: the links go+ // into a throwaway engine tree under the repository's scratch/.+ @Test("Linking the real Game Porting Toolkit resolves every link and leaves it untouched")+ func linksRealGameportingToolkit() throws {+ let gptk = WinecxD3DMetal.userFolder+ guard WinecxD3DMetal.payloadRoot(under: gptk) != nil else { return }+ let fm = FileManager.default+ let before = try snapshot(of: gptk)++ let scratch = URL(filePath: #filePath).deletingLastPathComponent()+ .appending(path: "../../../scratch/gptk-link-test-\(UUID().uuidString)").standardizedFileURL+ try fm.createDirectory(at: scratch, withIntermediateDirectories: true)+ defer { try? fm.removeItem(at: scratch) }+ let root = try makeEngineRoot(in: scratch)++ let payload = try #require(WinecxD3DMetal.locate(in: [gptk]))+ #expect(payload.version != nil)+ try WinecxD3DMetal.link(payload, root: root, stock: Self.stock)+ #expect(WinecxD3DMetal.isLinked(root: root))+ #expect(WinecxD3DMetal.layoutProblems(root: root, stock: Self.stock).isEmpty)+ let shared = try Data(contentsOf: payload.libRoot.appending(path: "external/libd3dshared.dylib"))+ for name in WinecxD3DMetal.forwarders + ["nvapi64.dll"] {+ let pe = root.appending(path: "lib/wine/x86_64-windows/\(name)")+ #expect(WinecxD3DMetal.isBuiltin(pe), "\(name)")+ #expect(try Data(contentsOf: root.appending(path: "lib/wine/x86_64-unix/\(WinecxD3DMetal.unixName(of: name))"))+ == shared, "\(name)")+ }+ #expect(!fm.fileExists(atPath: root.appending(path: "lib/wine/x86_64-windows/nvngx-on-metalfx.dll").path(percentEncoded: false)))+ // Only links: no file in the engine tree holds Apple's bytes.+ let walker = try #require(fm.enumerator(atPath: root.path(percentEncoded: false)))+ for case let path as String in walker {+ let attributes = try fm.attributesOfItem(atPath: root.appending(path: path).path(percentEncoded: false))+ if attributes[.type] as? FileAttributeType == .typeRegular {+ #expect(!path.contains("D3DMetal") && !path.hasSuffix(".dylib"), "\(path)")+ }+ }++ WinecxD3DMetal.unlink(root: root)+ #expect(WinecxD3DMetal.layoutProblems(root: root, stock: Self.stock).isEmpty)+ #expect(try snapshot(of: gptk) == before)+ }++ // Path, type, size and modification time of everything below a folder.+ private func snapshot(of folder: URL) throws -> [String] {+ let fm = FileManager.default+ let walker = try #require(fm.enumerator(atPath: folder.path(percentEncoded: false)))+ var lines: [String] = []+ for case let path as String in walker {+ let a = try fm.attributesOfItem(atPath: folder.appending(path: path).path(percentEncoded: false))+ lines.append("\(path) \(a[.type] ?? "") \(a[.size] ?? "") \(a[.modificationDate] ?? "")")+ }+ return lines.sorted()}}diff --git a/docs/DXMT.md b/docs/DXMT.mdindex f3384dc..5f5d02a 100644--- a/docs/DXMT.md+++ b/docs/DXMT.md@@ -11,6 +11,32 @@ fixes, the WIP D3D12 backend).| Tarball | `dxmt-e94c312.tar.gz`, top-level directory `e94c312/` || License | LGPL-2.1-or-later since `ec357fd` (v0.80 was the last MIT release) |+## In NotProton++Both free engines download this tarball from+`https://github.com/raymondchins/NotProton-WineHQ/releases/download/dxmt-e94c312/` into the+engine cache (`FreeEngine.dxmt`, also `FreeEngineWinecx.current.renderer`). `winemetal.so`+and both `winemetal.dll` go into `lib/wine` as shipped. `d3d10core`, `d3d11` and `dxgi` go to+`lib/notproton-backends/dxmt/` with the 16 bytes of the Wine builtin marker at 0x40+overwritten with a DOS stub (the bytes winecx-gptk uses), because the launcher copies them+into a prefix as natives and Wine swaps a marked DLL found there for the `lib/wine` builtin+of the same name (`load_builtin` in `dlls/ntdll/unix/loader.c`). They are pinned both as+shipped (table below) and as installed:++| Installed file | sha256 |+| - | - |+| `x86_64-windows/d3d10core.dll` | `aeb43e1ca7d9f221b9f0070c8654fa3579fd767006272cf675a9113e27bc6e72` |+| `x86_64-windows/d3d11.dll` | `c1c8c4779686990bf343162a8804dd2d1564b2a893e64e5ddcc7db5e76ce409e` |+| `x86_64-windows/dxgi.dll` | `1bb4939ff43e676eac8b3f3cb0583985ab8f7b1a8e11760d14931da3fc44223b` |+| `i386-windows/d3d10core.dll` | `e851c39641f66d64a3e4460e7046900cd234b11f44d793826d2f094e9d2166d9` |+| `i386-windows/d3d11.dll` | `a654ea3851ccc128a1f33d978462872e22fa6430ea85eff6ba9549de95788652` |+| `i386-windows/dxgi.dll` | `91f38df103412235793f84efe06b87f6f6fc3a4791d4f8d9f8cc2e16bc137d53` |++The same stripping applied to v0.80 reproduces the hashes of the frontends in the WineCX+archive exactly. `nvapi64`, `nvngx` and `d3d12.dll` are not installed.+`FreeEngineTests.downloadsAndUnpacksRealDxmt` downloads the real tarball and checks all of+this.+## RebuildingDEVELOPER_DIR=/Applications/Xcode-beta.app/Contents/Developer \diff --git a/docs/GAMEFIXES.md b/docs/GAMEFIXES.mdindex a02c5f8..0682104 100644--- a/docs/GAMEFIXES.md+++ b/docs/GAMEFIXES.md@@ -25,6 +25,7 @@ logged, when:| `DLLOVERRIDES` | Wine syntax, e.g. `dinput8=n,b;xinput1_3=n` | Added to `WINEDLLOVERRIDES` after the backend's entries and before the launch options' || `MSYNC` | `0`, `1` | `1` turns msync on when the engine supports it; `0` turns it off || `RETINA` | `0`, `1` | Same as `NOTPROTON_RETINA` (High Resolution) |+| `NVAPI` | `0`, `1` | `1` turns on Apple's `nvapi64` on an engine with a linked Game Porting Toolkit, for `d3dmetal` only. Off by default, since an nvapi that answers sends some games down NVIDIA-only paths || `DXMT_*`, `DXVK_*`, `MVK_*`, `VKD3D_*`, `D3DM_*`, `STAGING_*` | any | Exported as is || `MTL_HUD_ENABLED`, `WINEDEBUG`, `WINE_LARGE_ADDRESS_AWARE`, `WINE_CPU_TOPOLOGY` | any | Exported as is |@@ -35,10 +36,10 @@ Wine uses the last entry for a DLL in `WINEDLLOVERRIDES`. The order is: backend,| Name | What runs D3D10/11 | D3D12 || --- | --- | --- |-| `dxmt` | DXMT (Metal), the default | does not work |-| `dxvk` | DXVK-macOS (MoltenVK); Wine's own `dxgi` stays builtin | vkd3d |-| `wined3d` | Wine's own DLLs | vkd3d |-| `d3dmetal` | Apple D3DMetal, only on engines that ship it | D3DMetal |+| `dxmt` | DXMT master (Metal), the default without D3DMetal | does not work |+| `dxvk` | DXVK-macOS (MoltenVK); the engine's own `dxgi` stays builtin | vkd3d, or D3DMetal |+| `wined3d` | Wine's own DLLs, not on an engine with D3DMetal | vkd3d |+| `d3dmetal` | Apple D3DMetal, on the WineCX engine with a linked Game Porting Toolkit; the default there | D3DMetal |The backend is picked in this order:@@ -49,16 +50,42 @@ The backend is picked in this order:3. `BACKEND=` in a conf file4. Auto-detect. If the game's `.exe` imports `d3d12.dll` in its PE import table, the gamegets `wined3d`. Otherwise it gets `dxmt`. Delay-loaded and `LoadLibrary` imports do not- count, and neither does a file that does not parse as a PE-5. `dxmt`+ count, and neither does a file that does not parse as a PE. On an engine with D3DMetal+ every game gets `d3dmetal`+5. `dxmt`, or `d3dmetal` on an engine with D3DMetalA backend the engine lacks falls back: `dxvk` → `dxmt` → `wined3d`, and `d3dmetal` → `dxmt`.++### WineCX with D3DMetal++When a Game Porting Toolkit is linked into the WineCX engine+(`lib/notproton-backends/d3dmetal.enabled`, see [WINECX.md](WINECX.md)), Apple's+forwarders are that engine's `dxgi`, `d3d10`, `d3d11` and `d3d12` builtins and Wine's own+are set aside. So on that engine:++- the default, and auto-detection for D3D11 and D3D12 games alike, is `d3dmetal`+- `wined3d`, from any source (launch options, the Steam panel, a conf, the last launch), is+ logged as not available and runs `d3dmetal`+- a missing `dxmt` falls back to `d3dmetal`, and so does a `dxmt` or `dxvk` that cannot be+ staged into the prefix+- `dxmt` and `dxvk` still work per game: their DLLs go into the prefix as natives (`n,b`),+ and `d3d10`/`d3d12` stay builtin, which is Apple's+- `d3dmetal` sets every D3D DLL (`d3d10`, `d3d10core`, `d3d11`, `d3d12`, `dxgi`) to `b`,+ exports `CX_GRAPHICS_BACKEND=d3dmetal` and `CX_APPLEGPTK_LIBD3DSHARED_PATH`+- Apple's `nvapi64` is set to `d` unless the conf says `NVAPI=1` and the backend is+ `d3dmetal`++Without a linked Game Porting Toolkit the WineCX engine behaves like the WineHQ one.Engines without `lib/notproton-backends` have their graphics DLLs built in. They show thebackend `dxmt-builtin` and do not swap anything.The chosen backend's DLLs are copied into the prefix's `system32` and `syswow64` and set-to `n,b`. Every other DLL that any backend ships is set to `b`. When you switch backends, a-copy left behind by another backend is replaced with Wine's own. `d3dmetal` also sets+to `n,b`. Wine swaps a DLL carrying the Wine builtin marker found in a prefix for the+`lib/wine` builtin of the same name, so a marked copy would quietly run Wine's own; the+engine install strips the marker from DXMT's DLLs for that reason.+Every other DLL that any backend ships is set to `b`. When you switch backends, a copy+left behind by another backend is replaced with Wine's own (the set-aside copy on an+engine with D3DMetal; Apple's files are never copied into a prefix). `d3dmetal` also sets`CX_GRAPHICS_BACKEND=d3dmetal`. The run log(`notproton-run.log`) shows each decision. The `notproton-backend` file in the game'scompatdata folder has the current backend and why it was picked.@@ -80,6 +107,19 @@ DLLOVERRIDES=dinput8=n,b;xinput1_3=n,bWINEDEBUG=+loaddll```+A game on the WineCX engine that runs better on DXMT than on D3DMetal:++```+BACKEND=dxmt+```++A D3DMetal game that needs an nvapi to answer:++```+BACKEND=d3dmetal+NVAPI=1+```+A DXMT game with MetalFX, msync off and High Resolution on:```diff --git a/docs/WINECX.md b/docs/WINECX.mdindex 93e6e80..a57b36b 100644--- a/docs/WINECX.md+++ b/docs/WINECX.md@@ -12,8 +12,9 @@ Compared with the WineHQ 11.15 engine it adds:- **D3DMetal support** through CrossOver's hooks (winemac `macdrv_functions`, the`libd3dshared` non-native code regions in ntdll, and the d3dkmt answers). This only workswith a Game Porting Toolkit you install yourself. NotProton never downloads or ships it.-- **DXMT 0.80 and DXVK-macOS 1.10.3** as backends a game opts into. Wine's own Direct3D stays- the builtin.+- **DXMT master and DXVK-macOS 1.10.3** as backends a game opts into. DXMT is the same+ `e94c312` build as the WineHQ engine ([DXMT.md](DXMT.md)), not the archive's 0.80. The+ builtin Direct3D is Wine's own, or D3DMetal once a Game Porting Toolkit is linked.In NotProton it is build `winecx-11.15`, tool `notproton-winecx`, shown as "WineCX 11.15(msync, D3DMetal)". Like the WineHQ engine it needs no CrossOver license. The licence check@@ -42,78 +43,124 @@ waiting on.Layout inside the archive: `Libraries/Wine` is the Wine tree (`bin/`, `lib/wine/{x86_64-unix,x86_64-windows,i386-windows}`, bundled dylibs in `lib/`, `share/wine` with wine-mono 11.2.0-and gecko). `Libraries/DXMT/{x64,x32}` holds DXMT's frontends with the builtin marker-stripped. `Libraries/DXVK/{x64,x32}` holds DXVK. DXMT's `winemetal` is already a builtin in-`lib/wine`.+and gecko). `Libraries/DXMT/{x64,x32}` holds DXMT 0.80's frontends with the builtin marker+stripped, which NotProton does not use. `Libraries/DXVK/{x64,x32}` holds DXVK. A 0.80-era+`winemetal` is a builtin in `lib/wine`, which NotProton replaces.## What NotProton lays out-The engine root (`…/WineCX 11.15.app/Contents/SharedSupport/CrossOver`, cloned into the runner)-is the archive's `Libraries/Wine`, plus:+The engine root (`…/WineCX 11.15.app/Contents/SharedSupport/CrossOver`, cloned into the runner+`runners/crossover-winecx-11.15`) is the archive's `Libraries/Wine`, plus:```.notproton-msync engine supports msync-lib/notproton-backends/dxmt/{x86_64,i386}-windows/{d3d11,d3d10core,dxgi}.dll-lib/notproton-backends/dxvk/{x86_64,i386}-windows/{d3d11,d3d10core}.dll-lib/notproton-backends/d3dmetal.enabled only when a GPTK is linked in-lib/notproton-backends/d3dmetal/x86_64-windows/{d3d10,d3d11,d3d12,dxgi}.dll -> your GPTK-lib/notproton-backends/d3dmetal/x86_64-unix/{d3d10,d3d11,d3d12,dxgi}.so -> ../../../external/libd3dshared.dylib-lib/external/{D3DMetal.framework,libd3dshared.dylib} -> your GPTK+lib/wine/x86_64-unix/winemetal.so DXMT master, replacing the archive's+lib/wine/{x86_64,i386}-windows/winemetal.dll DXMT master, replacing the archive's+lib/notproton-backends/dxmt/{x86_64,i386}-windows/{d3d11,d3d10core,dxgi}.dll DXMT master, marker stripped+lib/notproton-backends/dxvk/{x86_64,i386}-windows/{d3d11,d3d10core}.dll from the archive```-`lib/wine` is left as shipped, with Wine's own `d3d10/d3d11/d3d10core/d3d12/dxgi`. Every-backend file is pinned by sha256 (`FreeEngineWinecx.current.backends`). nvapi64 and nvngx are-left out, as they are for the WineHQ engine. The DXVK repack has no `dxgi.dll`.+DXMT comes from `dxmt-e94c312.tar.gz` (the WineHQ engine's pin, shared download cache).+`winemetal.so` and both `winemetal.dll` are replaced together, since they share one unix-call+table and never mix with 0.80. The D3D DLLs get the 16 bytes of the Wine builtin marker at+0x40 overwritten with a DOS stub, the same bytes winecx-gptk writes, so they load as natives+from a prefix: Wine swaps a marked DLL found in a prefix for the `lib/wine` builtin of the+same name (`load_builtin`, `dlls/ntdll/unix/loader.c`). Each is pinned before and after.+nvapi64, nvngx and the WIP `d3d12.dll` are left out. The DXVK repack has no `dxgi.dll`.+Every file is pinned by sha256 (`FreeEngineWinecx.expectedFiles`); a pin change makes an+installed engine show "Update & Set Up".++DXMT on this engine does **not** need `winemac-patch/`. winecx's `winemac.so` already exports+`_macdrv_functions` (`dlls/winemac.drv/d3dmetal.c`), and the table DXMT reads is unchanged+between 0.80 and master.++## D3DMetal: the builtin model++Apple's forwarders only work as builtins: only a builtin gets its unix half+(`get_builtin_unix_funcs`), and Wine searches its own `lib/wine` before any `WINEDLLPATH`+entry, swapping a marked copy in a prefix for the `lib/wine` builtin. So, as Whisky does,+a linked Game Porting Toolkit *becomes* the engine's Direct3D builtins:++```+lib/wine/x86_64-windows/{d3d10,d3d11,d3d12,dxgi}.dll -> <gptk>/wine/x86_64-windows/<name>+lib/wine/x86_64-unix/{d3d10,d3d11,d3d12,dxgi}.so -> <gptk>/wine/x86_64-unix/<name>.so+ (or <gptk>/external/libd3dshared.dylib+ when the GPTK has no unix folder)+lib/wine/x86_64-{windows,unix}/nvapi64.{dll,so} -> <gptk>, when the GPTK has it+lib/external/{D3DMetal.framework,libd3dshared.dylib} -> <gptk>/external/+lib/notproton-backends/wine-stock/x86_64-windows/{d3d10,d3d11,d3d12,dxgi}.dll Wine's originals+lib/notproton-backends/d3dmetal.enabled+```++**Link** (`WinecxD3DMetal.link`): each of Wine's four DLLs is checked against its pin+(`FreeEngineWinecx.current.d3dStock`) and moved, not copied, into `wine-stock`. A DLL that+does not match refuses the link. Then the symlinks are created, every link is checked to+resolve, and `d3dmetal.enabled` is written last. Nothing of Apple's is copied. A failure at+any step runs unlink.++**Unlink** (`WinecxD3DMetal.unlink`): the marker goes first, then only symlinks are removed,+and Wine's originals are moved back from `wine-stock`, byte for byte. A real file is never+deleted. `lib/external` keeps winecx's `README`.++The engine passes its layout check in exactly two states: stock (Wine's four DLLs in+`lib/wine` under their pins, no `wine-stock`, no `.so` for them, no marker) or linked (the+marker, symlinks in `lib/wine` and `lib/external`, Wine's four intact in `wine-stock`).+Anything else makes the engine show "Update & Set Up". A Game Porting Toolkit that was moved+or deleted leaves the linked shape with dangling links: the Status page then shows it as not+found, and Rescan unlinks.++Linking happens when the engine is installed (before the runner is cloned from it, so the+runner carries the same links) and when you press **Rescan**, which relinks or unlinks both+the engine and `runners/crossover-winecx-11.15`. It refuses while a game is running. The+32-bit side is untouched: D3DMetal has no i386 half.`d3dmetal.enabled` is a `key=value` file: `source=` (the GPTK `lib` folder), `version=`-(D3DMetal.framework's version), `libd3dshared=lib/external/libd3dshared.dylib` (the path to-export as `CX_APPLEGPTK_LIBD3DSHARED_PATH`, relative to `CX_ROOT`) and-`dllpath=lib/notproton-backends/d3dmetal`.+(D3DMetal.framework's version), `libd3dshared=lib/external/libd3dshared.dylib` (exported as+`CX_APPLEGPTK_LIBD3DSHARED_PATH`, relative to `CX_ROOT`) and `model=builtin`.-DXMT on this engine does **not** need `winemac-patch/`. winecx's `winemac.so` already exports-`_macdrv_functions` (`dlls/winemac.drv/d3dmetal.c`). Its first nine entries and the-`hwnd/cocoa_window/cocoa_view/client_cocoa_view` head of the window data are what DXMT 0.80's-`winemetal_unix.c` reads, and DXMT only uses `client_cocoa_view`.+What `compat_run.sh` does with it is in [GAMEFIXES.md](GAMEFIXES.md#winecx-with-d3dmetal):+`d3dmetal` becomes the default and the D3D12 choice, `wined3d` runs `d3dmetal`, and `dxmt`+and `dxvk` still work per game as natives.++`nvngx-on-metalfx.dll` is not linked. It only serves DLSS through Apple's nvapi, and+CrossOver renames it to `nvngx.dll` per prefix, which NotProton does not do. Apple's+`nvapi64` is linked but disabled per game unless its conf says `NVAPI=1`.## Using D3DMetal with your own Game Porting Toolkit-Apple's licence does not let NotProton redistribute D3DMetal, so you supply it. NotProton looks-in this order and links the first complete copy:+Apple's licence does not let NotProton redistribute D3DMetal, so you supply it:++1. Download the Game Porting Toolkit from Apple:+ https://developer.apple.com/download/all/?q=Game%20Porting%20Toolkit (free Apple+ developer account).+2. Open the disk image ("Evaluation environment for Windows games").+3. Copy the **contents of its `redist/lib` folder** into+ `~/Library/Application Support/notproton/gptk/`, so you end up with `gptk/external/` and+ `gptk/wine/`.+4. In NotProton's Status page, press **Rescan** on the "Game Porting Toolkit" row. It turns+ green with "Linked from <path>." If the WineCX engine is not installed yet, "Download & Set+ Up" on the "WineCX Engine" row links it during setup.-1. `~/Library/Application Support/notproton/gptk/`. Copy the **`redist/lib` folder's contents**- from Apple's "Evaluation environment for Windows games" disk image here, so you end up- with `gptk/external/` and `gptk/wine/`. The `redist` folder itself, or the whole volume,- is also accepted. `external/` alone is not enough: D3DMetal also needs Apple's four PE- forwarders from `wine/x86_64-windows`.-2. `/Applications/Game Porting Toolkit.app`. This is the default location for- `brew install --cask gcenx/wine/game-porting-toolkit`, which looks in- `Contents/Resources/wine/lib`.-3. `~/Applications/Game Porting Toolkit.app`.+NotProton looks in this order and links the first complete copy: that folder (the+`redist` folder itself, or the whole volume, is also accepted), then+`/Applications/Game Porting Toolkit.app` (`brew install --cask gcenx/wine/game-porting-toolkit`,+which keeps it in `Contents/Resources/wine/lib`), then `~/Applications/Game Porting Toolkit.app`.A copy counts only when `external/libd3dshared.dylib`, `external/D3DMetal.framework` and-`wine/x86_64-windows/{d3d10,d3d11,d3d12,dxgi}.dll` are all present, and each forwarder-carries the `Wine builtin DLL` marker. NotProton creates symlinks only, and writes the marker-last. Linking happens when the engine is installed. After you install or move a GPTK, set-the engine up again (`WinecxD3DMetal.refresh(root:)`). A GPTK that disappears leaves-dangling links, which `isLinked(root:)` reports as unlinked. A refresh then removes the-layout and the marker. D3DMetal has no i386 half, so 32-bit games cannot use it.+`wine/x86_64-windows/{d3d10,d3d11,d3d12,dxgi}.dll` are all present and each forwarder carries+the `Wine builtin DLL` marker. GPTK 4.0 beta 2 also has `wine/x86_64-unix/<name>.so` (links+to `../../external/libd3dshared.dylib`), `nvapi64` and `nvngx-on-metalfx`, `License.rtf` and+`SOURCE.txt`; the unix halves and nvapi64 are linked when present. NotProton only reads the+folder.## Risks-- **D3DMetal per game is not solved by this layout alone.** Apple's forwarders are winebuild- builtins and only work when loaded as builtins: only a builtin gets its unix half- (`get_builtin_unix_funcs`). Wine searches its own `lib/wine` before any `WINEDLLPATH` entry- (`set_dll_path` in `dlls/ntdll/unix/loader.c`, winecx `5b45f45`). A builtin-marked copy in- a prefix is swapped for the `lib/wine` builtin of the same name (`load_builtin`), and a- copy with the marker stripped loads as native with no unix half. So while `lib/wine`- keeps Wine's `d3d12/dxgi`, neither `WINEDLLPATH` nor prefix overrides reach- `lib/notproton-backends/d3dmetal`. Whisky gets around this by replacing the `lib/wine`- builtins outright (`GPTKImporter+Deployment.swift`). DXMT and DXVK do not have this problem- because they load as natives from the prefix with `n,b` overrides. The consumer- (`compat_run.sh`) needs one of two things: a per-backend loader tree, meaning a- `lib/wine` whose `ntdll.so` and loader are real clones with the forwarders in its- `x86_64-windows`, because Wine derives the DLL directory from `ntdll.so`'s real path; or- the Whisky model, with D3DMetal as the builtin and DXMT/DXVK/wined3d opted into per game.+- **D3DMetal is engine-wide.** With a GPTK linked, every game on the WineCX engine that+ does not choose `dxmt` or `dxvk` runs D3DMetal, and Wine's `wined3d` is not reachable on+ that engine (use the WineHQ engine for it). A `dxmt`/`dxvk` game still gets Apple's+ `d3d10`/`d3d12` builtins. `wineboot --update` copies `lib/wine` builtins into a prefix, so+ Apple's forwarders can end up in a prefix's `system32`, as they do under Whisky. No game was+ launched in this work.- **Upstream maturity.** The runtimes are CI builds from one maintainer, tagged automatically.The `runtime-v4.5.1xx` tags carry only a version table. The 11.15 notes([v4.5.0](https://github.com/dappermint/winecx-gptk/releases/tag/v4.5.0),@@ -140,7 +187,8 @@ layout and the marker. D3DMetal has no i386 half, so 32-bit games cannot use it.- **DXVK.** The archive's DXVK has no `dxgi.dll` for either arch. A 32-bit game on DXVK pairedwith Wine's dxgi can fail with "Adapter is not a DXVK adapter" (winecx-gptk `build.yml`comment).-- **Licences.** Wine is LGPL-2.1+, DXMT MIT, DXVK zlib, MoltenVK Apache-2.0. The tarball also+- **Licences.** Wine is LGPL-2.1+, DXMT master LGPL-2.1+ (source at+ https://github.com/3Shain/dxmt/tree/e94c312f5c054263acf261cfa109edf13e757587), DXVK zlib, MoltenVK Apache-2.0. The tarball alsobundles nixpkgs libraries: ffmpeg 7.1.1 built `--enable-gpl` with x264/x265 (GPL-3.0+),and gstreamer's fdk-aac plugin. It ships **no licence texts**, and winecx-gptk has nolicence of its own. NotProton only downloads the upstream release on the user's machinediff --git a/dylib/feats/compat_run.sh b/dylib/feats/compat_run.shindex d0f1e7e..b3fa2a8 100755--- a/dylib/feats/compat_run.sh+++ b/dylib/feats/compat_run.sh@@ -41,6 +41,12 @@ export CX_ROOTif [ -f "$CX_ROOT/lib64/apple_gptk/external/libd3dshared.dylib" ]; thenexport CX_APPLEGPTK_LIBD3DSHARED_PATH="$CX_ROOT/lib64/apple_gptk/external/libd3dshared.dylib"fi+# WineCX with a Game Porting Toolkit linked in keeps libd3dshared in its own lib/external.+if [ -z "${CX_APPLEGPTK_LIBD3DSHARED_PATH:-}" ] \+ && [ -f "$CX_ROOT/lib/notproton-backends/d3dmetal.enabled" ] \+ && [ -f "$CX_ROOT/lib/external/libd3dshared.dylib" ]; then+ export CX_APPLEGPTK_LIBD3DSHARED_PATH="$CX_ROOT/lib/external/libd3dshared.dylib"+fiwine_unix="$CX_ROOT/lib/wine/aarch64-unix"WINELOADER="$wine_unix/wine.app/Contents/MacOS/wine"@@ -81,6 +87,41 @@ fienv | grep -iE '^(Steam|SDL_)' | sort} >> "$log" 2>&1 || true+# Wine keeps its server socket in <tmp>/.wine-<uid> and the wineserver refuses to start when+# others can read it ("must not be accessible by other users"). A directory of ours with a+# looser mode goes back to 0700. A link, or a directory someone else owns, is only reported:+# it is never followed or changed.+heal_wine_tmp() {+ wine_tmp="$1/.wine-$(id -u)"+ if [ -L "$wine_tmp" ]; then+ echo "=== warning: $wine_tmp is a symlink, left alone; wineserver may refuse to start ===" >> "$log" 2>&1 || true+ return 0+ fi+ [ -e "$wine_tmp" ] || return 0+ wine_tmp_info=$(stat -f '%u %Lp %HT' "$wine_tmp" 2>/dev/null) || return 0+ wine_tmp_owner=${wine_tmp_info%% *}+ wine_tmp_rest=${wine_tmp_info#* }+ wine_tmp_mode=${wine_tmp_rest%% *}+ wine_tmp_type=${wine_tmp_rest#* }+ if [ "$wine_tmp_type" != Directory ]; then+ echo "=== warning: $wine_tmp is not a directory ($wine_tmp_type), left alone ===" >> "$log" 2>&1 || true+ return 0+ fi+ if [ "$wine_tmp_owner" != "$(id -u)" ]; then+ echo "=== warning: $wine_tmp belongs to uid $wine_tmp_owner, left alone; wineserver may refuse to start ===" >> "$log" 2>&1 || true+ return 0+ fi+ [ "$wine_tmp_mode" != 700 ] || return 0+ # -h: should the directory have been swapped for a link since the checks, the link+ # itself changes, never what it points at.+ if chmod -h 700 "$wine_tmp" 2>> "$log"; then+ echo "=== $wine_tmp was mode $wine_tmp_mode, set to 700 ===" >> "$log" 2>&1 || true+ else+ echo "=== warning: could not set $wine_tmp to mode 700 ===" >> "$log" 2>&1 || true+ fi+}+heal_wine_tmp /tmp+stage_step="startup"# shellcheck disable=SC2329 # the trap below invokes thisreport_early_exit() {@@ -112,6 +153,7 @@ gamefix_keys=""gamefix_backend=""gamefix_dlloverrides=""gamefix_msync=""+gamefix_nvapi=""gamefix_args=""gamefix_log() {@@ -143,7 +185,7 @@ gamefix_reason() {case "$1" inBACKEND)case "$2" in dxmt|dxvk|wined3d|d3dmetal) ;; *) echo "not dxmt, dxvk, wined3d or d3dmetal" ;; esac ;;- MSYNC|RETINA)+ MSYNC|RETINA|NVAPI)case "$2" in 0|1) ;; *) echo "not 0 or 1" ;; esac ;;DLLOVERRIDES)valid_dll_overrides "$2" || echo "not Wine override syntax" ;;@@ -215,6 +257,7 @@ load_gamefixes() {DLLOVERRIDES) gamefix_dlloverrides=$valuegamefix_log "DLLOVERRIDES=$value from the $from conf, launch options still win per DLL" ;;MSYNC) gamefix_msync=$value; gamefix_log "MSYNC=$value from the $from conf" ;;+ NVAPI) gamefix_nvapi=$value; gamefix_log "NVAPI=$value from the $from conf" ;;ARGS)if [ "$verb" = waitforexitandrun ]; thengamefix_args=$value@@ -250,8 +293,10 @@ resolve_msync() {}# Graphics backends. The engine keeps Wine's own dxgi/d3d11/d3d10core/d3d12 in lib/wine and-# ships the alternatives under lib/notproton-backends/<name>/<arch>-windows. An engine-# without that folder bakes its DLLs into lib/wine, so nothing is swapped there.+# ships the alternatives under lib/notproton-backends/<name>/<arch>-windows, which a game+# gets as natives in its prefix. WineCX with d3dmetal.enabled has Apple's D3DMetal as those+# builtins instead and defaults to it. An engine without that folder bakes its DLLs into+# lib/wine, so nothing is swapped there.backend_root="$CX_ROOT/lib/notproton-backends"backend=""backend_from=""@@ -261,6 +306,13 @@ graphics_log() {echo "graphics: $*" >> "$log" 2>&1 || true}+# WineCX with a Game Porting Toolkit linked in: Apple's D3DMetal forwarders are the+# dxgi/d3d10/d3d11/d3d12 builtins of lib/wine, and Wine's own are set aside in+# notproton-backends/wine-stock, so wined3d is not there to fall back on.+d3dmetal_engine() {+ [ -f "$backend_root/d3dmetal.enabled" ]+}+# The lower-case module names of the DLLs in one backend folder, winemetal left to lib/wine.backend_dlls() {for f in "$1"/*.[dD][lL][lL]; do@@ -276,7 +328,9 @@ backend_dlls() {managed_dlls() {{printf '%s\n' dxgi d3d11 d3d10core+ ! d3dmetal_engine || printf '%s\n' d3d10 d3d12for dir in "$backend_root"/*/x86_64-windows "$backend_root"/*/i386-windows; do+ case "$dir" in "$backend_root"/wine-stock/*) continue ;; esac[ ! -d "$dir" ] || backend_dlls "$dir"done} | sort -u@@ -284,8 +338,8 @@ managed_dlls() {backend_available() {case "$1" in- wined3d) return 0 ;;- d3dmetal) [ -f "$backend_root/d3dmetal.enabled" ] ;;+ wined3d) ! d3dmetal_engine ;;+ d3dmetal) d3dmetal_engine ;;dxmt|dxvk) [ -n "$(backend_dlls "$backend_root/$1/x86_64-windows")" ] ;;*) return 1 ;;esac@@ -418,17 +472,21 @@ select_backend() {wanted=$recordedbackend_from="carried over from the last launch"fi+ # D3DMetal, when the engine has it, runs D3D11 and D3D12 alike and is the default.if [ -z "$wanted" ] && [ "$verb" = waitforexitandrun ] && [ -f "$1" ]; thenif imports_d3d12 "$1"; then- wanted=wined3d+ if d3dmetal_engine; then wanted=d3dmetal; else wanted=wined3d; fibackend_from="auto-detected, the game imports d3d12.dll"+ elif d3dmetal_engine; then+ wanted=d3dmetal+ backend_from="auto-detected, the engine has D3DMetal"elsewanted=dxmtbackend_from="auto-detected, the game does not import d3d12.dll"fifiif [ -z "$wanted" ]; then- wanted=dxmt+ if d3dmetal_engine; then wanted=d3dmetal; else wanted=dxmt; fibackend_from=defaultfibackend=$wanted@@ -436,7 +494,10 @@ select_backend() {case "$backend" ind3dmetal) why="no d3dmetal.enabled marker"; next=dxmt ;;dxvk) why="no x86_64 DLLs in notproton-backends/dxvk"; next=dxmt ;;- *) why="no x86_64 DLLs in notproton-backends/$backend"; next=wined3d ;;+ wined3d) why="D3DMetal replaces Wine's Direct3D in this engine"; next=d3dmetal ;;+ *)+ why="no x86_64 DLLs in notproton-backends/$backend"+ if d3dmetal_engine; then next=d3dmetal; else next=wined3d; fi ;;esacgraphics_log "$backend is not available ($why), falling back to $next"backend_from="$backend_from, fell back from $backend"@@ -467,10 +528,14 @@ stage_backend_file() {# back to Wine's own. Anything else in the prefix is left alone.restore_stock_dll() {[ -f "$3" ] && [ ! -L "$3" ] || return 0- stock="$CX_ROOT/lib/wine/$1/$2.dll"- [ -f "$stock" ] || return 0+ # Wine's own copy, which D3DMetal moves aside. A link in lib/wine is Apple's and is+ # never copied into a prefix.+ stock="$backend_root/wine-stock/$1/$2.dll"+ [ -f "$stock" ] && [ ! -L "$stock" ] || stock="$CX_ROOT/lib/wine/$1/$2.dll"+ [ -f "$stock" ] && [ ! -L "$stock" ] || return 0! cmp -s "$stock" "$3" || return 0for theirs in "$backend_root"/*/"$1"/*.[dD][lL][lL]; do+ case "$theirs" in "$backend_root"/wine-stock/*) continue ;; esac[ -f "$theirs" ] || continuebase=${theirs##*/}[ "$(printf '%s' "${base%.*}" | tr '[:upper:]' '[:lower:]')" = "$2" ] || continue@@ -516,8 +581,9 @@ activate_backend() {donedoneif [ "$staging_failed" -eq 1 ]; then- graphics_log "$backend could not be staged, falling back to wined3d"- backend=wined3d+ if d3dmetal_engine; then next=d3dmetal; else next=wined3d; fi+ graphics_log "$backend could not be staged, falling back to $next"+ backend=$nextbackend_from="$backend_from, fell back after staging failed"activate_backendreturn@@ -532,6 +598,17 @@ activate_backend() {donebackend_overrides="${native:+$native=n,b}"[ -z "$builtin" ] || backend_overrides="${backend_overrides:+$backend_overrides;}$builtin=b"+ # A linked Game Porting Toolkit can bring Apple's nvapi64 into lib/wine. An nvapi that+ # answers sends some games down NVIDIA-only paths, so it stays disabled unless the game's+ # conf says NVAPI=1, and then only on D3DMetal, the only backend it talks to.+ if d3dmetal_engine && [ -e "$CX_ROOT/lib/wine/x86_64-windows/nvapi64.dll" ]; then+ if [ "$gamefix_nvapi" = 1 ] && [ "$backend" = d3dmetal ]; then+ backend_overrides="${backend_overrides:+$backend_overrides;}nvapi64=b"+ else+ [ "$gamefix_nvapi" != 1 ] || graphics_log "NVAPI=1 not applied, $backend is not d3dmetal"+ backend_overrides="${backend_overrides:+$backend_overrides;}nvapi64=d"+ fi+ fiif [ "$backend" = d3dmetal ]; thenif [ -n "${CX_GRAPHICS_BACKEND:-}" ] && [ "$CX_GRAPHICS_BACKEND" != d3dmetal ]; thengraphics_log "CX_GRAPHICS_BACKEND=$CX_GRAPHICS_BACKEND replaced by d3dmetal"diff --git a/dylib/tests/gamefixescheck.sh b/dylib/tests/gamefixescheck.shindex 71c22f1..9139bbc 100644--- a/dylib/tests/gamefixescheck.sh+++ b/dylib/tests/gamefixescheck.sh@@ -6,7 +6,7 @@ SRC="${1:-$(dirname "$0")/../feats/compat_run.sh}"functions=""for name in gamefix_log valid_dll_overrides gamefix_reason gamefix_read gamefix_apply_env \- load_gamefixes resolve_msync graphics_log backend_dlls managed_dlls backend_available \+ load_gamefixes resolve_msync graphics_log d3dmetal_engine backend_dlls managed_dlls backend_available \backend_record pe_word pe_words pe_rva_offset imports_d3d12 select_backend stage_backend_file restore_stock_dll \activate_backend record_backend compose_dll_overrides; dobody=$(sed -n "/^$name() {\$/,/^}\$/p" "$SRC")@@ -41,7 +41,7 @@ new_case() {"$case_dir/game"for arch in x86_64-windows i386-windows; domkdir -p "$case_dir/engine/lib/wine/$arch"- for dll in dxgi d3d11 d3d10core d3d12 d3d9; do+ for dll in dxgi d3d10 d3d11 d3d10core d3d12 d3d9; doprintf 'stock %s %s\n' "$arch" "$dll" > "$case_dir/engine/lib/wine/$arch/$dll.dll"donedone@@ -53,6 +53,18 @@ engine() {case "$file" ind3dmetal.enabled) mkdir -p "$case_dir/engine/lib/notproton-backends": > "$case_dir/engine/lib/notproton-backends/d3dmetal.enabled" ;;+ # WinecxD3DMetal.link: Wine's four set aside, Apple's forwarders linked in their place.+ d3dmetal-linked)+ stock="$case_dir/engine/lib/notproton-backends/wine-stock/x86_64-windows"+ mkdir -p "$stock" "$case_dir/gptk"+ : > "$case_dir/engine/lib/notproton-backends/d3dmetal.enabled"+ for dll in dxgi d3d10 d3d11 d3d12; do+ mv "$case_dir/engine/lib/wine/x86_64-windows/$dll.dll" "$stock/$dll.dll"+ printf 'apple %s\n' "$dll" > "$case_dir/gptk/$dll.dll"+ ln -s "$case_dir/gptk/$dll.dll" "$case_dir/engine/lib/wine/x86_64-windows/$dll.dll"+ done+ printf 'apple nvapi64\n' > "$case_dir/gptk/nvapi64.dll"+ ln -s "$case_dir/gptk/nvapi64.dll" "$case_dir/engine/lib/wine/x86_64-windows/nvapi64.dll" ;;msync) : > "$case_dir/engine/.notproton-msync" ;;empty) mkdir -p "$case_dir/engine/lib/notproton-backends" ;;*) mkdir -p "$case_dir/engine/lib/notproton-backends/${file%/*}"@@ -83,7 +95,7 @@ launch() {STEAM_COMPAT_DATA_PATH="$case_dir/data" WINEPREFIX="$case_dir/data/pfx" \sh -ec 'eval "$functions"- gamefix_keys="" gamefix_backend="" gamefix_dlloverrides="" gamefix_msync="" gamefix_args=""+ gamefix_keys="" gamefix_backend="" gamefix_dlloverrides="" gamefix_msync="" gamefix_nvapi="" gamefix_args=""backend_root="$CX_ROOT/lib/notproton-backends"load_gamefixes || trueresolve_msync@@ -265,7 +277,7 @@ new_casefull_engineengine d3dmetal.enableduser_conf 'BACKEND=dxmt'-for pair in D3DMetal:d3dmetal dxmt:dxmt DXVK:dxvk wined3d:wined3d OpenGL:wined3d wine:wined3d; do+for pair in D3DMetal:d3dmetal dxmt:dxmt DXVK:dxvk wined3d:d3dmetal OpenGL:d3dmetal wine:d3dmetal; dolaunch waitforexitandrun "$case_dir/game/game.exe" CX_GRAPHICS_BACKEND="${pair%%:*}"is "CX_GRAPHICS_BACKEND=${pair%%:*} beats the conf as ${pair#*:}" "${pair#*:}" "$(got backend)"done@@ -276,8 +288,14 @@ is "an unknown value falls through to the conf" "dxmt" "$(got backend)"has "and is logged" "CX_GRAPHICS_BACKEND is not a backend this engine maps, ignored" "$case_dir/log"launch waitforexitandrun "$case_dir/game/game.exe" CX_GRAPHICS_BACKEND=is "an empty value falls through to the conf" "dxmt" "$(got backend)"-launch waitforexitandrun "$case_dir/game/game.exe" CX_GRAPHICS_BACKEND=dxvk NOTPROTON_BACKEND=wined3d-is "NOTPROTON_BACKEND beats CX_GRAPHICS_BACKEND" "wined3d" "$(got backend)"+launch waitforexitandrun "$case_dir/game/game.exe" CX_GRAPHICS_BACKEND=dxvk NOTPROTON_BACKEND=dxmt+is "NOTPROTON_BACKEND beats CX_GRAPHICS_BACKEND" "dxmt" "$(got backend)"+new_case+full_engine+for pair in wined3d:wined3d OpenGL:wined3d wine:wined3d; do+ launch waitforexitandrun "$case_dir/game/game.exe" CX_GRAPHICS_BACKEND="${pair%%:*}"+ is "without D3DMetal CX_GRAPHICS_BACKEND=${pair%%:*} is ${pair#*:}" "${pair#*:}" "$(got backend)"+doneecho "== fallback when the engine lacks a backend"new_case@@ -304,11 +322,70 @@ engine d3dmetal.enabledlaunch waitforexitandrun "$case_dir/game/game.exe" NOTPROTON_BACKEND=d3dmetalis "d3dmetal with the marker" "d3dmetal" "$(got backend)"is "selects D3DMetal in the engine" "d3dmetal" "$(got CX_GRAPHICS_BACKEND)"-is "and keeps every backend DLL builtin" "d3d10core,d3d11,dxgi=b;$trio" "$(got WINEDLLOVERRIDES)"+is "and keeps every D3D DLL builtin, d3d10 and d3d12 too" "d3d10,d3d10core,d3d11,d3d12,dxgi=b;$trio" "$(got WINEDLLOVERRIDES)"launch waitforexitandrun "$case_dir/game/game.exe" NOTPROTON_BACKEND=d3dmetal CX_GRAPHICS_BACKEND=dxmtis "NOTPROTON_BACKEND=d3dmetal sets CX_GRAPHICS_BACKEND over the panel's" "d3dmetal" "$(got CX_GRAPHICS_BACKEND)"has "and says so" "CX_GRAPHICS_BACKEND=dxmt replaced by d3dmetal" "$case_dir/log"+echo "== WineCX with D3DMetal linked as the builtin"+new_case+full_engine+engine d3dmetal-linked+launch waitforexitandrun 'steam://rungameid/4242'+is "the default is d3dmetal" "d3dmetal" "$(got backend)"+has "logged as default" "backend=d3dmetal (default)" "$case_dir/log"+is "every D3D DLL is builtin, Apple's nvapi64 disabled" "d3d10,d3d10core,d3d11,d3d12,dxgi=b;nvapi64=d;$trio" "$(got WINEDLLOVERRIDES)"+is "CX_GRAPHICS_BACKEND is exported" "d3dmetal" "$(got CX_GRAPHICS_BACKEND)"+launch waitforexitandrun "$case_dir/game/game.exe"+is "a D3D11 game auto-detects d3dmetal" "d3dmetal" "$(got backend)"+has "with the reason" "auto-detected, the engine has D3DMetal" "$case_dir/log"+pe_fixture "$case_dir/game/game.exe" 64 import+launch waitforexitandrun "$case_dir/game/game.exe"+is "a D3D12 game auto-detects d3dmetal, not wined3d" "d3dmetal" "$(got backend)"+has "with the reason" "backend=d3dmetal (auto-detected, the game imports d3d12.dll)" "$case_dir/log"+launch waitforexitandrun "$case_dir/game/game.exe" NOTPROTON_BACKEND=wined3d+is "an explicit wined3d runs d3dmetal" "d3dmetal" "$(got backend)"+has "and says why" "wined3d is not available (D3DMetal replaces Wine's Direct3D in this engine), falling back to d3dmetal" "$case_dir/log"+user_conf 'BACKEND=wined3d'+launch waitforexitandrun "$case_dir/game/game.exe"+is "so does a conf BACKEND=wined3d" "d3dmetal" "$(got backend)"+user_conf 'BACKEND=dxmt'+launch waitforexitandrun "$case_dir/game/game.exe"+is "dxmt still works per game" "dxmt" "$(got backend)"+is "as natives, with Apple's d3d10 and d3d12 builtin" "d3d10core,d3d11,dxgi=n,b;d3d10,d3d12=b;nvapi64=d;$trio" "$(got WINEDLLOVERRIDES)"+is "dxmt dxgi is in system32" "backend dxmt/x86_64-windows/dxgi.dll" "$(sys system32 dxgi)"+is "and CX_GRAPHICS_BACKEND is left alone" "<unset>" "$(got CX_GRAPHICS_BACKEND)"+user_conf 'BACKEND=dxvk'+launch waitforexitandrun "$case_dir/game/game.exe"+is "dxvk still works per game" "d3d10core,d3d11=n,b;d3d10,d3d12,dxgi=b;nvapi64=d;$trio" "$(got WINEDLLOVERRIDES)"+is "the stale dxmt dxgi goes back to Wine's set-aside copy, never Apple's" "stock x86_64-windows dxgi" "$(sys system32 dxgi)"+user_conf ''+launch waitforexitandrun "$case_dir/game/game.exe"+is "back on d3dmetal, dxvk's d3d11 goes back to Wine's copy" "stock x86_64-windows d3d11" "$(sys system32 d3d11)"+is "and nothing of Apple's is copied into the prefix" "0" "$(grep -rl '^apple ' "$case_dir/data/pfx" | wc -l | tr -d ' ')"+user_conf 'NVAPI=1'+launch waitforexitandrun "$case_dir/game/game.exe"+is "a conf NVAPI=1 turns Apple's nvapi64 on" "d3d10,d3d10core,d3d11,d3d12,dxgi=b;nvapi64=b;$trio" "$(got WINEDLLOVERRIDES)"+user_conf 'NVAPI=1' 'BACKEND=dxmt'+launch waitforexitandrun "$case_dir/game/game.exe"+is "but not for dxmt" "d3d10core,d3d11,dxgi=n,b;d3d10,d3d12=b;nvapi64=d;$trio" "$(got WINEDLLOVERRIDES)"+has "and says so" "NVAPI=1 not applied, dxmt is not d3dmetal" "$case_dir/log"+user_conf 'NVAPI=yes'+launch waitforexitandrun "$case_dir/game/game.exe"+has "NVAPI must be 0 or 1" "rejected NVAPI: not 0 or 1" "$case_dir/log"+new_case+engine d3dmetal-linked empty+launch waitforexitandrun "$case_dir/game/game.exe" NOTPROTON_BACKEND=dxmt+is "a missing dxmt falls back to d3dmetal, not wined3d" "d3dmetal" "$(got backend)"+new_case+full_engine+engine d3dmetal-linked+chmod 500 "$case_dir/data/pfx/drive_c/windows/system32"+launch waitforexitandrun "$case_dir/game/game.exe" NOTPROTON_BACKEND=dxmt+chmod 700 "$case_dir/data/pfx/drive_c/windows/system32"+is "a backend that cannot be staged falls back to d3dmetal" "d3dmetal" "$(got backend)"+has "with the reason" "dxmt could not be staged, falling back to d3dmetal" "$case_dir/log"+echo "== legacy layout"new_caseuser_conf 'BACKEND=dxvk' 'DLLOVERRIDES=dinput8=n,b'@@ -425,6 +502,43 @@ out=$(env -i PATH="$PATH" forward="$forward" VKD3D_CONFIG=dxr MVK_CONFIG_LOG_LEVis "VKD3D_, MVK_, STAGING_ and WINE_ topology variables are forwarded" \"DXVK_HUD=fps MVK_CONFIG_LOG_LEVEL=1 STAGING_SHARED_MEMORY=1 VKD3D_CONFIG=dxr WINE_CPU_TOPOLOGY=4:0,1,2,3 WINE_LARGE_ADDRESS_AWARE=1 " "$out"+echo "== the wineserver directory self-heal"+heal=$(sed -n '/^heal_wine_tmp() {$/,/^}$/p' "$SRC")+[ -n "$heal" ] || { echo "FAIL: heal_wine_tmp not found in $SRC"; exit 1; }+first_wine=$(grep -nE '"\$WINE(LOADER|SERVER)" (-[kw]|wineboot|reg|"\$)' "$SRC" | head -1 | cut -d: -f1)+called=$(grep -n '^heal_wine_tmp /tmp$' "$SRC" | head -1 | cut -d: -f1)+is "it runs on /tmp before the first wine or wineserver call" "yes" \+ "$([ -n "$called" ] && [ -n "$first_wine" ] && [ "$called" -lt "$first_wine" ] && echo yes || echo no)"+fake_tmp="$work/tmproot"+mkdir -p "$fake_tmp"+wine_dir="$fake_tmp/.wine-$(id -u)"+heal_log="$work/heal.log"+run_heal() { : > "$heal_log"; log="$heal_log" heal="$heal" sh -ec 'eval "$heal"; heal_wine_tmp "$1"' heal "$fake_tmp"; }+run_heal+is "no directory, nothing logged" "" "$(cat "$heal_log")"+mkdir "$wine_dir"+chmod 755 "$wine_dir"+run_heal+is "a 755 directory of ours goes back to 700" "700" "$(stat -f %Lp "$wine_dir")"+has "and is logged" "was mode 755, set to 700" "$heal_log"+run_heal+is "a 700 directory is left as it is, silently" "" "$(cat "$heal_log")"+rmdir "$wine_dir"+mkdir "$work/elsewhere"+chmod 755 "$work/elsewhere"+ln -s "$work/elsewhere" "$wine_dir"+run_heal+is "a symlink is never followed" "755" "$(stat -f %Lp "$work/elsewhere")"+is "nor replaced" "yes" "$([ -L "$wine_dir" ] && echo yes || echo no)"+has "and is warned about" "is a symlink, left alone" "$heal_log"+rm "$wine_dir"+printf x > "$wine_dir"+chmod 644 "$wine_dir"+run_heal+is "a file is left alone" "644" "$(stat -f %Lp "$wine_dir")"+has "and is warned about" "is not a directory (Regular File), left alone" "$heal_log"+rm "$wine_dir"+if [ "$fails" -eq 0 ]; thenecho "==> gamefixescheck: all assertions hold"else