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: DLSS in Deadlock, crackle-free CoreAudio and forced vsync (ray.23)
raymondchins6cf4b007985f
diff --git a/app/Package.swift b/app/Package.swiftindex 820bd81..6db017d 100644--- a/app/Package.swift+++ b/app/Package.swift@@ -55,6 +55,10 @@ let package = Package(.copy("Resources/ws2_32-winecx-11.17.dll"),.copy("Resources/crypt32-winecx-11.17.dll"),.copy("Resources/wintrust-winecx-11.17.dll"),+ .copy("Resources/nvapi64-shim.dll"),+ .copy("Resources/win32u-winecx-11.17.so"),+ .copy("Resources/wined3d-winecx-11.17.dll"),+ .copy("Resources/winecoreaudio-winecx-11.17.so"),.copy("Resources/libSDL2-2.0.0.dylib"),],swiftSettings: [.swiftLanguageMode(.v6)]diff --git a/app/Sources/NotProtonApp/Model/FreeEngineWinecx.swift b/app/Sources/NotProtonApp/Model/FreeEngineWinecx.swiftindex d19b94e..7b2c61c 100644--- a/app/Sources/NotProtonApp/Model/FreeEngineWinecx.swift+++ b/app/Sources/NotProtonApp/Model/FreeEngineWinecx.swift@@ -59,11 +59,15 @@ struct WinecxRelease: Sendable {// link-local addresses macOS lists first, as Windows never returns them// (ws2_32-patch/). Empty where the runtime's own ws2_32 is kept.let network: [WinecxBundledFile]- // crypt32 and wintrust rebuilt so, with NOTPROTON_NGX_SIGNER set, a signature check of- // the system32 NGX core (Apple's unsigned MetalFX bridge) is answered from an- // NVIDIA-signed Streamline module next to the game, which lets Streamline load it- // (ngx-signer-patch/). Empty where the runtime's own are kept.- let signer: [WinecxBundledFile]+ // What the NVIDIA identity D3DMetal is given needs from the engine (NVAPI=1): crypt32 and+ // wintrust that let Streamline load Apple's unsigned NGX bridge (ngx-signer-patch/), a+ // native nvapi64 reporting a current driver (nvapi-shim/), and a win32u whose display+ // class DriverVersion says the same (win32u-patch/). Empty where none of it ships.+ let nvidia: [WinecxBundledFile]+ // winecoreaudio.so rebuilt so an output stream asks CoreAudio for half a period per+ // pull, not a whole one, which Wine padded with silence and was heard as crackling+ // (winecoreaudio-patch/). Empty where the runtime's own is kept.+ let audio: [WinecxBundledFile]// The runner build this release unpacks to, keyed by its pinned loader, and the ntdll// detours for it (NtdllPatcher.byBuild).let runner: RunnerBuild@@ -160,13 +164,35 @@ enum FreeEngineWinecx {],// crypt32.dll, wintrust.dll: winecx e0aa380's PE halves with// ngx-signer-patch/winecx-ngx-signer.patch.- signer: [+ nvidia: [WinecxBundledFile(resource: "crypt32-winecx-11.17", ext: "dll",path: "lib/wine/x86_64-windows/crypt32.dll",sha256: "19330827fc085603c2a73b859b801980f494a942ae470398634fbb6e1d62ada9"),WinecxBundledFile(resource: "wintrust-winecx-11.17", ext: "dll",path: "lib/wine/x86_64-windows/wintrust.dll",sha256: "6ae3a8723bae11e5ff9ad6e23d1f1325740b1892d01b78abdeb1b77ac8bb6da8"),+ // nvapi-shim/: a native nvapi64 that reports a newer NVIDIA driver than+ // Apple's 561.09 and passes everything else to Apple's nvapi.dll.+ WinecxBundledFile(resource: "nvapi64-shim", ext: "dll",+ path: "lib/notproton-backends/nvapi-shim/x86_64-windows/nvapi64.dll",+ sha256: "a80aea6347a8b1e72542e458f410d37fdedb39e194c0fcee45a5ae6cd7f571be"),+ // win32u.so: runtime 4.7.3's, with NVIDIA's DriverVersion 35.0.15.9541 (595.41) by+ // win32u-patch/patch-driver-version.sh, signed ad hoc.+ WinecxBundledFile(resource: "win32u-winecx-11.17", ext: "so",+ path: "lib/wine/x86_64-unix/win32u.so",+ sha256: "b012382d09b2ff1b3c0750d93867f72dd04a7c902bc4179be406b6c558ab162d"),+ // wined3d.dll: winecx e0aa380's PE half with wined3d-patch/winecx-driver-version.patch+ // (NOTPROTON_DRIVER_VERSION replaces the GeForce 8 era driver version d3d9 reports).+ WinecxBundledFile(resource: "wined3d-winecx-11.17", ext: "dll",+ path: "lib/wine/x86_64-windows/wined3d.dll",+ sha256: "9298c83d927b3b80d0fa36f52bb5f2ecd60ec4daffff3c93d9b080293e59dfe9"),+ ],+ // winecoreaudio.so: winecx e0aa380 with winecoreaudio-patch/winecx-render-buffer.patch,+ // signed ad hoc under the runtime's identifier.+ audio: [+ WinecxBundledFile(resource: "winecoreaudio-winecx-11.17", ext: "so",+ path: "lib/wine/x86_64-unix/winecoreaudio.so",+ sha256: "3bef8bfcee8bc02947ffca07794ec9cb74c7d15f2d88d00f7924f5e50727b8c3"),],runner: RunnerBuild(bundleVersion: "winecx-11.17",@@ -255,7 +281,8 @@ enum FreeEngineWinecx {sdl,],network: [],- signer: [],+ nvidia: [],+ audio: [],// The hash-pinned loader is what makes it free, so a CrossOver install can never be// taken for it.runner: RunnerBuild(@@ -348,7 +375,7 @@ enum FreeEngineWinecx {// 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] = [FreeEngine.macDriverPath: release.macDriver]- for file in release.gamepad + release.network + release.signer { table[file.path] = file.sha256 }+ for file in release.gamepad + release.network + release.nvidia + release.audio { table[file.path] = file.sha256 }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)@@ -437,7 +464,7 @@ enum FreeEngineWinecx {try fm.createDirectory(at: root.deletingLastPathComponent(), withIntermediateDirectories: true)try fm.moveItem(at: wine, to: root)try FreeEngine.installMacDriver(root: root, build: release.build, sha256: release.macDriver, step: step)- try installBundled(release.gamepad + release.network + release.signer, root: root)+ try installBundled(release.gamepad + release.network + release.nvidia + release.audio, root: root)let libraries = wine.deletingLastPathComponent()for file in release.backends {diff --git a/app/Sources/NotProtonApp/Resources/nvapi64-shim.dll b/app/Sources/NotProtonApp/Resources/nvapi64-shim.dllnew file mode 100755index 0000000..f5aac92Binary files /dev/null and b/app/Sources/NotProtonApp/Resources/nvapi64-shim.dll differdiff --git a/app/Sources/NotProtonApp/Resources/win32u-winecx-11.17.so b/app/Sources/NotProtonApp/Resources/win32u-winecx-11.17.sonew file mode 100644index 0000000..47b08eaBinary files /dev/null and b/app/Sources/NotProtonApp/Resources/win32u-winecx-11.17.so differdiff --git a/app/Sources/NotProtonApp/Resources/winecoreaudio-winecx-11.17.so b/app/Sources/NotProtonApp/Resources/winecoreaudio-winecx-11.17.sonew file mode 100755index 0000000..8c27c67Binary files /dev/null and b/app/Sources/NotProtonApp/Resources/winecoreaudio-winecx-11.17.so differdiff --git a/app/Sources/NotProtonApp/Resources/wined3d-winecx-11.17.dll b/app/Sources/NotProtonApp/Resources/wined3d-winecx-11.17.dllnew file mode 100755index 0000000..36c9983Binary files /dev/null and b/app/Sources/NotProtonApp/Resources/wined3d-winecx-11.17.dll differdiff --git a/app/Tests/NotProtonAppTests/FreeEngineWinecxTests.swift b/app/Tests/NotProtonAppTests/FreeEngineWinecxTests.swiftindex 065a400..f1c2aa5 100644--- a/app/Tests/NotProtonAppTests/FreeEngineWinecxTests.swift+++ b/app/Tests/NotProtonAppTests/FreeEngineWinecxTests.swift@@ -216,10 +216,27 @@ struct FreeEngineWinecxTests {func ngxSigner(id: String) throws {let release = try #require(FreeEngineWinecx.release(build: id))let expected: Set<String> = release.build == "winecx-11.17"- ? ["lib/wine/x86_64-windows/crypt32.dll", "lib/wine/x86_64-windows/wintrust.dll"] : []- #expect(Set(release.signer.map(\.path)) == expected)+ ? ["lib/wine/x86_64-windows/crypt32.dll", "lib/wine/x86_64-windows/wintrust.dll",+ "lib/notproton-backends/nvapi-shim/x86_64-windows/nvapi64.dll",+ "lib/wine/x86_64-unix/win32u.so", "lib/wine/x86_64-windows/wined3d.dll"] : []+ #expect(Set(release.nvidia.map(\.path)) == expected)let table = FreeEngineWinecx.expectedFiles(release)- for file in release.signer {+ for file in release.nvidia {+ let bundled = try #require(Bundle.module.url(forResource: file.resource, withExtension: file.ext))+ #expect(Digest.sha256IfPresent(bundled) == file.sha256, "\(file.resource)")+ #expect(table[file.path] == file.sha256, "\(file.path)")+ }+ }++ // winecoreaudio-patch: 11.17 ships a winecoreaudio.so with half-period output pulls.+ @Test("The patched winecoreaudio ships with the app and is pinned for 11.17",+ arguments: FreeEngineWinecx.releases.map(\.build))+ func audio(id: String) throws {+ let release = try #require(FreeEngineWinecx.release(build: id))+ let expected: Set<String> = release.build == "winecx-11.17" ? ["lib/wine/x86_64-unix/winecoreaudio.so"] : []+ #expect(Set(release.audio.map(\.path)) == expected)+ let table = FreeEngineWinecx.expectedFiles(release)+ for file in release.audio {let bundled = try #require(Bundle.module.url(forResource: file.resource, withExtension: file.ext))#expect(Digest.sha256IfPresent(bundled) == file.sha256, "\(file.resource)")#expect(table[file.path] == file.sha256, "\(file.path)")diff --git a/docs/GAMEFIXES.md b/docs/GAMEFIXES.mdindex acb61c7..5e8831e 100644--- a/docs/GAMEFIXES.md+++ b/docs/GAMEFIXES.md@@ -33,6 +33,8 @@ logged, when:| `FRAMEGEN_ENGINE` | `own`, `metalfx` | Same as `NOTPROTON_FRAMEGEN_ENGINE`: the built-in optical flow (`own`, the default) or MetalFX frame interpolation || `NVAPI` | `0`, `1` | `1` turns on Apple's `nvapi64` and `nvngx` (DLSS on MetalFX) on an engine with a linked Game Porting Toolkit, for `d3dmetal` only, and makes D3DMetal report an NVIDIA GeForce RTX 4090 (`D3DM_VENDOR_ID=0x10de`, `D3DM_DEVICE_ID=0x2684`, `D3DM_DEVICE_DESCRIPTION`; a `D3DM_*` from a conf or the launch options wins), since games offer DLSS only on an NVIDIA adapter. Off by default, since an nvapi that answers sends some games down NVIDIA-only paths || `DLSS_FG` | `0`, `1` | With `NVAPI=1` on `d3dmetal`, `1` sets `CX_ACTIVE_GRAPHICS_BACKEND=d3dmetal` so WineCX reports hardware GPU scheduling, which DLSS frame generation requires. Off by default: [frankea/Whisky#231](https://github.com/frankea/Whisky/pull/231) saw MetalFX frame interpolation on an M5 with D3DMetal 4.0b2 hang WindowServer |+| `STDOUT_NULL` | `0`, `1` | `1` starts the game without a stdout handle, as Steam on Windows does. Source 2 treats any stdout as a console build (`Plat_IsConsoleApplication`) and then skips NGX, so Deadlock offers no DLSS |+| `VSYNC` | `0`, `1` | `1` makes the game's Metal layer wait for the display even when the game turns vsync off, like forcing vsync in the NVIDIA control panel. For games that lock vsync off with frame generation on (Resident Evil Requiem) and tear above the refresh rate || `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 |diff --git a/dylib/feats/compat_run.sh b/dylib/feats/compat_run.shindex 5e73c64..62d5d0a 100755--- a/dylib/feats/compat_run.sh+++ b/dylib/feats/compat_run.sh@@ -257,7 +257,7 @@ gamefix_reason() {case "$1" inBACKEND)case "$2" in dxmt|dxvk|wined3d|d3dmetal) ;; *) echo "not dxmt, dxvk, wined3d or d3dmetal" ;; esac ;;- MSYNC|RETINA|NVAPI|DLSS_FG|FRAMEGEN_UI|FRAMEGEN_FALLBACK|STEAMDECK)+ MSYNC|RETINA|NVAPI|DLSS_FG|STDOUT_NULL|VSYNC|FRAMEGEN_UI|FRAMEGEN_FALLBACK|STEAMDECK)case "$2" in 0|1) ;; *) echo "not 0 or 1" ;; esac ;;FRAMEGEN)# 1 is the 2x of the first release.@@ -341,6 +341,8 @@ load_gamefixes() {MSYNC) gamefix_msync=$value; gamefix_log "MSYNC=$value from the $from conf" ;;NVAPI) gamefix_nvapi=$value; gamefix_log "NVAPI=$value from the $from conf" ;;DLSS_FG) gamefix_dlss_fg=$value; gamefix_log "DLSS_FG=$value from the $from conf" ;;+ STDOUT_NULL) gamefix_apply_env NOTPROTON_STDOUT_NULL "$value" "$from" ;;+ VSYNC) gamefix_apply_env NOTPROTON_VSYNC "$value" "$from" ;;ARGS)if [ "$verb" = waitforexitandrun ]; thengamefix_args=$value@@ -417,7 +419,8 @@ 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+ # nvapi-shim is not a Direct3D backend; its nvapi64 is handled with NVAPI below.+ case "$dir" in "$backend_root"/wine-stock/*|"$backend_root"/nvapi-shim/*) continue ;; esac[ ! -d "$dir" ] || backend_dlls "$dir"done} | sort -u@@ -622,7 +625,7 @@ restore_stock_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+ case "$theirs" in "$backend_root"/wine-stock/*|"$backend_root"/nvapi-shim/*) continue ;; esac[ -f "$theirs" ] || continuebase=${theirs##*/}[ "$(printf '%s' "${base%.*}" | tr '[:upper:]' '[:lower:]')" = "$2" ] || continue@@ -693,7 +696,20 @@ activate_backend() {nv_dlls=nvapi64[ ! -e "$CX_ROOT/lib/wine/x86_64-windows/nvngx.dll" ] || nv_dlls="nvapi64,nvngx"if [ "$gamefix_nvapi" = 1 ] && [ "$backend" = d3dmetal ]; then- backend_overrides="${backend_overrides:+$backend_overrides;}$nv_dlls=b"+ # Apple's nvapi reports driver 561.09, which some games call out of date (Deadlock)+ # and hide DLSS for. nvapi-shim/ goes in front as a native nvapi64 and reports a newer+ # driver (NOTPROTON_NVAPI_DRIVER), passing everything else to Apple's nvapi.dll.+ # The shim reaches Apple's nvapi by its internal name nvapi.dll, which Wine only maps to+ # the lib/wine builtin when a builtin-marked placeholder of that name is in system32.+ if stage_backend_file "$CX_ROOT/lib/wine/x86_64-windows/nvapi.dll" \+ "$WINEPREFIX/drive_c/windows/system32/nvapi.dll" \+ && stage_backend_file "$backend_root/nvapi-shim/x86_64-windows/nvapi64.dll" \+ "$WINEPREFIX/drive_c/windows/system32/nvapi64.dll"; then+ backend_overrides="${backend_overrides:+$backend_overrides;}nvapi64=n,b"+ nv_dlls=${nv_dlls#nvapi64}+ nv_dlls=${nv_dlls#,}+ fi+ [ -z "$nv_dlls" ] || backend_overrides="${backend_overrides:+$backend_overrides;}$nv_dlls=b"# D3DMetal reports an AMD adapter (0x1002) on its own, and games only offer DLSS on an# NVIDIA one. A D3DM_* value from a conf or the launch options wins.export D3DM_VENDOR_ID="${D3DM_VENDOR_ID:-0x10de}" D3DM_DEVICE_ID="${D3DM_DEVICE_ID:-0x2684}"@@ -701,6 +717,9 @@ activate_backend() {# Streamline loads an NGX core only when it is NVIDIA-signed; the engine's crypt32 and# wintrust answer for Apple's bridge from a signed Streamline module (ngx-signer-patch/).export NOTPROTON_NGX_SIGNER=1+ # wined3d (wined3d-patch/) reports this instead of its table's GeForce 8 era 31.0.13.4052,+ # which games read through d3d9 (Deadlock: driver warning, no async shader creation).+ export NOTPROTON_DRIVER_VERSION="${NOTPROTON_DRIVER_VERSION:-32.0.15.9541}"# DLSS frame generation wants hardware GPU scheduling; winecx's win32u reports it on# only for CX_ACTIVE_GRAPHICS_BACKEND=d3dmetal (CW HACK 24905). Opt-in: frank Whisky# #231 saw MetalFX frame interpolation on an M5 with D3DMetal 4.0b2 hang WindowServer.@@ -2147,7 +2166,7 @@ elseecho "=== client staged no overlay renderer, overlay disabled ===" >> "$log" 2>&1 || truefiset -- --args "$shim_exe" "$@"-for name in $(env | sed -nE 's/^(CX_APPLEGPTK_LIBD3DSHARED_PATH|SDL_GAMECONTROLLERCONFIG(_FILE)?|SDL_JOYSTICK_MFI|WINE_LARGE_ADDRESS_AWARE|WINE_CPU_TOPOLOGY|Steam[A-Za-z0-9]*|(CX_GRAPHICS|D3DM_|DXMT_|DXVK_|MVK_|VKD3D_|STAGING_|MTL_|ROSETTA_)[A-Z0-9_]*|NOTPROTON_FRAMEGEN(_[A-Z]+)?|NOTPROTON_NGX_SIGNER|CX_ACTIVE_GRAPHICS_BACKEND)=.*/\1/p'); do+for name in $(env | sed -nE 's/^(CX_APPLEGPTK_LIBD3DSHARED_PATH|SDL_GAMECONTROLLERCONFIG(_FILE)?|SDL_JOYSTICK_MFI|WINE_LARGE_ADDRESS_AWARE|WINE_CPU_TOPOLOGY|Steam[A-Za-z0-9]*|(CX_GRAPHICS|D3DM_|DXMT_|DXVK_|MVK_|VKD3D_|STAGING_|MTL_|ROSETTA_)[A-Z0-9_]*|NOTPROTON_FRAMEGEN(_[A-Z]+)?|NOTPROTON_NGX_SIGNER|NOTPROTON_NVAPI_DRIVER|NOTPROTON_DRIVER_VERSION|NOTPROTON_STDOUT_NULL|NOTPROTON_VSYNC|CX_ACTIVE_GRAPHICS_BACKEND)=.*/\1/p'); doeval "value=\$$name"# shellcheck disable=SC2154 # eval assigns value on the line aboveset -- --env "$name=$value" "$@"diff --git a/dylib/tests/gamefixescheck.sh b/dylib/tests/gamefixescheck.shindex 5f7426e..f2e3b85 100644--- a/dylib/tests/gamefixescheck.sh+++ b/dylib/tests/gamefixescheck.sh@@ -67,6 +67,7 @@ engine() {doneprintf '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"+ ln -s "$case_dir/gptk/nvapi64.dll" "$case_dir/engine/lib/wine/x86_64-windows/nvapi.dll"printf 'apple nvngx-on-metalfx\n' > "$case_dir/gptk/nvngx-on-metalfx.dll"ln -s "$case_dir/gptk/nvngx-on-metalfx.dll" "$case_dir/engine/lib/wine/x86_64-windows/nvngx.dll" ;;msync) : > "$case_dir/engine/.notproton-msync" ;;@@ -112,7 +113,7 @@ launch() {eval "$bridge_line"for v in backend WINEDLLOVERRIDES WINEMSYNC msync_from NOTPROTON_RETINA NOTPROTON_FRAMEGEN \NOTPROTON_FRAMEGEN_QUALITY NOTPROTON_FRAMEGEN_UI NOTPROTON_FRAMEGEN_FALLBACK NOTPROTON_FRAMEGEN_ENGINE CX_GRAPHICS_BACKEND \- DXVK_HUD VKD3D_CONFIG WINEDEBUG MTL_HUD_ENABLED D3DM_VENDOR_ID D3DM_DEVICE_ID D3DM_DEVICE_DESCRIPTION NOTPROTON_NGX_SIGNER CX_ACTIVE_GRAPHICS_BACKEND gamefix_args; do+ DXVK_HUD VKD3D_CONFIG WINEDEBUG MTL_HUD_ENABLED D3DM_VENDOR_ID D3DM_DEVICE_ID D3DM_DEVICE_DESCRIPTION NOTPROTON_NGX_SIGNER NOTPROTON_DRIVER_VERSION CX_ACTIVE_GRAPHICS_BACKEND NOTPROTON_VSYNC gamefix_args; doeval "printf \"%s=%s\\n\" \$v \"\${$v-<unset>}\""done' launch "$target" > "$case_dir/out" 2>&1 || echo "launch exited $?" >> "$case_dir/out"@@ -385,10 +386,14 @@ user_conf 'NVAPI=1' 'D3DM_DEVICE_ID=0x2704'launch waitforexitandrun "$case_dir/game/game.exe"is "a conf's D3DM_DEVICE_ID wins over the default" "0x10de 0x2704" "$(got D3DM_VENDOR_ID) $(got D3DM_DEVICE_ID)"is "NVAPI=1 lets Streamline load Apple's NGX bridge" "1" "$(got NOTPROTON_NGX_SIGNER)"+is "and wined3d reports a current NVIDIA driver" "32.0.15.9541" "$(got NOTPROTON_DRIVER_VERSION)"is "and leaves hardware scheduling alone" "<unset>" "$(got CX_ACTIVE_GRAPHICS_BACKEND)"user_conf 'NVAPI=1' 'DLSS_FG=1'launch waitforexitandrun "$case_dir/game/game.exe"is "DLSS_FG=1 reports hardware scheduling for DLSS frame generation" "d3dmetal" "$(got CX_ACTIVE_GRAPHICS_BACKEND)"+user_conf 'VSYNC=1'+launch waitforexitandrun "$case_dir/game/game.exe"+is "VSYNC=1 asks the overlay shim to keep the layer on display sync" "1" "$(got NOTPROTON_VSYNC)"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,nvngx=d;$trio" "$(got WINEDLLOVERRIDES)"@@ -398,6 +403,16 @@ 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 nvapi-shim/x86_64-windows/nvapi64.dll+user_conf 'NVAPI=1'+launch waitforexitandrun "$case_dir/game/game.exe"+is "with the nvapi shim, nvapi64 is native in front of Apple's" "d3d10,d3d10core,d3d11,d3d12,dxgi=b;nvapi64=n,b;nvngx=b;$trio" "$(got WINEDLLOVERRIDES)"+is "and the shim is staged into system32" "backend nvapi-shim/x86_64-windows/nvapi64.dll" "$(sys system32 nvapi64)"+is "beside Apple's nvapi as the nvapi.dll placeholder it loads" "apple nvapi64" "$(sys system32 nvapi)"+user_conf 'NVAPI=0'+launch waitforexitandrun "$case_dir/game/game.exe"+is "NVAPI=0 disables it again" "d3d10,d3d10core,d3d11,d3d12,dxgi=b;nvapi64,nvngx=d;$trio" "$(got WINEDLLOVERRIDES)"+new_caseengine d3dmetal-linked emptylaunch waitforexitandrun "$case_dir/game/game.exe" NOTPROTON_BACKEND=dxmtis "a missing dxmt falls back to d3dmetal, not wined3d" "d3dmetal" "$(got backend)"diff --git a/dylib/version.h b/dylib/version.hindex a408801..2883805 100644--- a/dylib/version.h+++ b/dylib/version.h@@ -2,6 +2,6 @@#ifndef NOTPROTON_VERSION_H#define NOTPROTON_VERSION_H-#define NOTPROTON_VERSION "1.1.7-winehq.1-ray.22"+#define NOTPROTON_VERSION "1.1.7-winehq.1-ray.23"#endif // NOTPROTON_VERSION_Hdiff --git a/gamefixes/1422450.conf b/gamefixes/1422450.confnew file mode 100644index 0000000..c65b07c--- /dev/null+++ b/gamefixes/1422450.conf@@ -0,0 +1,3 @@+# Deadlock: Source 2 takes any stdout as a console build (tier0 Plat_IsConsoleApplication)+# and then skips NGX, so DLSS is never offered.+STDOUT_NULL=1diff --git a/nvapi-shim/build.sh b/nvapi-shim/build.shnew file mode 100755index 0000000..08ef826--- /dev/null+++ b/nvapi-shim/build.sh@@ -0,0 +1,9 @@+#!/bin/sh+# Builds nvapi-shim/nvapi64.dll (x86_64 PE, no Wine builtin marker, so a prefix copy loads+# as native and is not swapped for the lib/wine builtin).+set -eu+cd "$(dirname "$0")"+x86_64-w64-mingw32-gcc -O2 -shared -s -Wall -Wextra -Wno-unused-parameter \+ -Wl,--no-insert-timestamp -Wl,--build-id=none \+ -o nvapi64.dll nvapi_shim.c nvapi_shim.def+shasum -a 256 nvapi64.dlldiff --git a/nvapi-shim/nvapi_shim.c b/nvapi-shim/nvapi_shim.cnew file mode 100644index 0000000..841975d--- /dev/null+++ b/nvapi-shim/nvapi_shim.c@@ -0,0 +1,125 @@+/*+ * nvapi64.dll in front of Apple's NvAPI (Game Porting Toolkit), which reports driver+ * 561.09 (r560_88) and nothing newer. Games and engines that want a newer NVIDIA driver+ * then warn about an out-of-date driver or hide DLSS (Deadlock's Source 2 keeps a list of+ * minimum driver versions). Every call goes to Apple's nvapi, loaded under its internal+ * name nvapi.dll (the builtin WineCX links to the GPTK), and only the driver version and+ * branch it answers are replaced: 595.41 / r595_00 by default, or NOTPROTON_NVAPI_DRIVER+ * (e.g. 59541) when set.+ */+#include <windows.h>+#include <stdio.h>+#include <stdlib.h>+#include <string.h>++typedef int NvAPI_Status;+typedef void *(__cdecl *query_interface_fn)(unsigned int);++#define ID_GET_DISPLAY_DRIVER_VERSION 0xf951a4d1u+#define ID_SYS_GET_DRIVER_AND_BRANCH 0x2926aaadu+#define ID_SYS_GET_DISPLAY_DRIVER_INFO 0x721facebu++typedef struct+{+ unsigned int version;+ unsigned int drvVersion;+ unsigned int bldChangeListNum;+ char szBuildBranchString[64];+ char szAdapterString[64];+} NV_DISPLAY_DRIVER_VERSION;++/* NV_DISPLAY_DRIVER_INFO_V1/V2 start with version, driverVersion, szBuildBranch. */+typedef struct+{+ unsigned int version;+ unsigned int driverVersion;+ char szBuildBranch[64];+} NV_DISPLAY_DRIVER_INFO_HEAD;++static INIT_ONCE init_once = INIT_ONCE_STATIC_INIT;+static query_interface_fn apple_query_interface;+static unsigned int driver_version = 59541;+static char driver_branch[64];++static NvAPI_Status (__cdecl *apple_get_display_driver_version)(void *, NV_DISPLAY_DRIVER_VERSION *);+static NvAPI_Status (__cdecl *apple_sys_get_driver_and_branch)(unsigned int *, char *);+static NvAPI_Status (__cdecl *apple_sys_get_display_driver_info)(NV_DISPLAY_DRIVER_INFO_HEAD *);++static BOOL CALLBACK load_apple( INIT_ONCE *once, void *param, void **context )+{+ char value[32];+ HMODULE apple;+ DWORD len = GetEnvironmentVariableA( "NOTPROTON_NVAPI_DRIVER", value, sizeof(value) );++ if (len && len < sizeof(value))+ {+ unsigned long parsed = strtoul( value, NULL, 10 );+ if (parsed >= 10000 && parsed <= 99999) driver_version = (unsigned int)parsed;+ }+ snprintf( driver_branch, sizeof(driver_branch), "r%u_00", driver_version / 100 );++ if (!(apple = LoadLibraryW( L"nvapi.dll" ))) return TRUE;+ apple_query_interface = (query_interface_fn)(void *)GetProcAddress( apple, "nvapi_QueryInterface" );+ return TRUE;+}++static void set_branch( char *dst )+{+ memcpy( dst, driver_branch, sizeof(driver_branch) );+}++static NvAPI_Status __cdecl get_display_driver_version( void *display, NV_DISPLAY_DRIVER_VERSION *info )+{+ NvAPI_Status status = apple_get_display_driver_version( display, info );+ if (!status && info)+ {+ info->drvVersion = driver_version;+ set_branch( info->szBuildBranchString );+ }+ return status;+}++static NvAPI_Status __cdecl sys_get_driver_and_branch( unsigned int *version, char *branch )+{+ NvAPI_Status status = apple_sys_get_driver_and_branch( version, branch );+ if (!status)+ {+ if (version) *version = driver_version;+ if (branch) set_branch( branch );+ }+ return status;+}++static NvAPI_Status __cdecl sys_get_display_driver_info( NV_DISPLAY_DRIVER_INFO_HEAD *info )+{+ NvAPI_Status status = apple_sys_get_display_driver_info( info );+ if (!status && info)+ {+ info->driverVersion = driver_version;+ set_branch( info->szBuildBranch );+ }+ return status;+}++void * __cdecl nvapi_QueryInterface( unsigned int id )+{+ void *fn;++ InitOnceExecuteOnce( &init_once, load_apple, NULL, NULL );+ if (!apple_query_interface || !(fn = apple_query_interface( id ))) return NULL;+ switch (id)+ {+ case ID_GET_DISPLAY_DRIVER_VERSION:+ apple_get_display_driver_version = fn;+ return (void *)get_display_driver_version;+ case ID_SYS_GET_DRIVER_AND_BRANCH:+ apple_sys_get_driver_and_branch = fn;+ return (void *)sys_get_driver_and_branch;+ case ID_SYS_GET_DISPLAY_DRIVER_INFO:+ apple_sys_get_display_driver_info = fn;+ return (void *)sys_get_display_driver_info;+ }+ return fn;+}++/* nvapi_Direct_GetMethod is an export forwarder to nvapi.dll (nvapi_shim.def). */diff --git a/nvapi-shim/nvapi_shim.def b/nvapi-shim/nvapi_shim.defnew file mode 100644index 0000000..856b6c8--- /dev/null+++ b/nvapi-shim/nvapi_shim.def@@ -0,0 +1,4 @@+LIBRARY nvapi64.dll+EXPORTS+ nvapi_QueryInterface+ nvapi_Direct_GetMethod = nvapi.nvapi_Direct_GetMethoddiff --git a/overlay-shim/overlay_shim.m b/overlay-shim/overlay_shim.mindex 03bd58e..523e783 100644--- a/overlay-shim/overlay_shim.m+++ b/overlay-shim/overlay_shim.m@@ -159,6 +159,11 @@ typedef void (*drawable_present_after_fn)(id, SEL, CFTimeInterval);static set_pixel_format_fn next_set_pixel_format;static set_colorspace_fn next_set_colorspace;static set_device_fn next_set_device;+static void (*next_set_display_sync)(id, SEL, BOOL);+// NOTPROTON_VSYNC=1 (gamefix VSYNC): the layer always waits for the display, whatever the+// game asks D3DMetal for. The driver-level vsync of Windows, for games that lock their own+// vsync off while frame generation is on and tear past the refresh rate.+static int force_vsync;static new_pipeline_fn next_new_pipeline;static new_queue_fn next_new_queue;static new_queue_count_fn next_new_queue_count;@@ -419,6 +424,18 @@ static void hook_set_colorspace(id layer, SEL selector, CGColorSpaceRef colorspanext_set_colorspace(layer, selector, colorspace);}+static void hook_set_display_sync(id layer, SEL selector, BOOL enabled)+{+ static int last = -1;++ if ((int)enabled != last) {+ last = enabled;+ shim_log("overlay_shim hook_set_display_sync: game asks %d, layer gets %d\n", enabled,+ enabled || force_vsync);+ }+ next_set_display_sync(layer, selector, enabled || force_vsync);+}+static void hook_set_device(id layer, SEL selector, id device){next_set_device(layer, selector, device);@@ -992,6 +1009,11 @@ __attribute__((constructor)) static void overlay_shim_load(void)hooked += interpose(layer, "setColorspace:", (IMP)hook_set_colorspace,(IMP *)&next_set_colorspace);hooked += interpose(layer, "setDevice:", (IMP)hook_set_device, (IMP *)&next_set_device);+ const char *vsync = getenv("NOTPROTON_VSYNC");+ force_vsync = vsync != NULL && strcmp(vsync, "1") == 0;+ if (force_vsync)+ hooked += interpose(layer, "setDisplaySyncEnabled:", (IMP)hook_set_display_sync,+ (IMP *)&next_set_display_sync);framegen_install_layer_hooks(layer);shim_log("overlay_shim_load: pid=%d exe=%s layer_hooks=%d overlay=%s\n", getpid(),diff --git a/steam-shim/steam.cpp b/steam-shim/steam.cppindex 1feaf53..4632d2b 100644--- a/steam-shim/steam.cpp+++ b/steam-shim/steam.cpp@@ -1479,6 +1479,12 @@ run:si.hStdInput = GetStdHandle(STD_INPUT_HANDLE);si.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);si.hStdError = GetStdHandle(STD_ERROR_HANDLE);+ /* Steam on Windows starts games without a stdout. Source 2 takes any stdout as+ * a console build (tier0 Plat_IsConsoleApplication: GetFileType(stdout) != 0)+ * and then skips NGX, so Deadlock never offers DLSS. The STDOUT_NULL gamefix+ * starts the game the Windows way. */+ if (GetEnvironmentVariableW(L"NOTPROTON_STDOUT_NULL", NULL, 0))+ si.hStdOutput = NULL;if (!CreateProcessW(NULL, cmdline, NULL, NULL, TRUE, flags, NULL, NULL, &si, &pi)){diff --git a/win32u-patch/patch-driver-version.sh b/win32u-patch/patch-driver-version.shnew file mode 100755index 0000000..6c5b59e--- /dev/null+++ b/win32u-patch/patch-driver-version.sh@@ -0,0 +1,29 @@+#!/bin/sh+# Rebuilds app/Sources/NotProtonApp/Resources/win32u-winecx-11.17.so from runtime 4.7.3's+# win32u.so (winecx e0aa380). Its driver_vendor_to_version() reports NVIDIA as+# "35.0.15.6094" (560.94) in the display class key's DriverVersion; games that read it+# (Source 2 / Deadlock) call that out of date and hide DLSS behind the NVIDIA identity+# D3DMetal is given. The one copy of the string becomes "35.0.15.9541" (595.41, the+# version nvapi-shim reports), same length, and so does the DirectX key's QWORD+# DriverVersion (35.0.15.8180), then the file is signed ad hoc with its original identifier.+set -eu+src=${1:?usage: patch-driver-version.sh <runtime lib/wine/x86_64-unix/win32u.so>}+out="$(cd "$(dirname "$0")/.." && pwd)/app/Sources/NotProtonApp/Resources/win32u-winecx-11.17.so"+want=5ea985227c89b57e5f48d7422059db933d32a213e172577d68e4415d6f7c2a71+[ "$(shasum -a 256 "$src" | cut -d' ' -f1)" = "$want" ] || { echo "not runtime 4.7.3's win32u.so" >&2; exit 1; }+ident=$(codesign -dv "$src" 2>&1 | sed -n 's/^Identifier=//p')+python3 - "$src" "$out" <<'PY'+import sys+data = open(sys.argv[1], 'rb').read()+import struct+old, new = b'35.0.15.6094\x00', b'35.0.15.9541\x00'+assert data.count(old) == 1+data = data.replace(old, new)+# HKLM\Software\Microsoft\DirectX\<luid>\DriverVersion, a QWORD immediate: 35.0.15.8180+# (581.80) becomes 35.0.15.9541 too, so every place a game reads the version agrees.+old, new = struct.pack('<Q', 0x230000000f1ff4), struct.pack('<Q', 0x230000000f2545)+assert data.count(old) == 1+open(sys.argv[2], 'wb').write(data.replace(old, new))+PY+codesign -fs - -i "$ident" "$out"+shasum -a 256 "$out"diff --git a/winecoreaudio-patch/README.md b/winecoreaudio-patch/README.mdnew file mode 100644index 0000000..883686d--- /dev/null+++ b/winecoreaudio-patch/README.md@@ -0,0 +1,16 @@+# winecoreaudio render buffer patch (WineCX 11.17)++`winecoreaudio.drv` set the CoreAudio device buffer to Wine's whole 10 ms period. A render+callback then regularly asked for more frames than the client had written, and+`ca_render_cb` padded the shortfall with silence, heard as crackling (Deadlock, CS2;+CodeWeavers' Deadlock tip works around it with a 96 kHz output). `winecx-render-buffer.patch`+(against winecx `e0aa380`) asks for half a period on output streams; Wine's period stays+10 ms. Capture streams are unchanged.++Verified 2026-10-12: Deadlock at 44.1 kHz no longer crackles.++Build in the tree configured as in `winemac-patch/README.md`+(`DEVELOPER_DIR=/Applications/Xcode-beta.app/Contents/Developer`):+`make dlls/winecoreaudio.drv/winecoreaudio.so`, then sign ad hoc under the runtime's identifier:+`codesign -f -s - -i winecoreaudio-5555494448b257546f33317180481a4e0075393b winecoreaudio.so`.+Pin: `FreeEngineWinecx.v1117.audio`.diff --git a/winecoreaudio-patch/winecx-render-buffer.patch b/winecoreaudio-patch/winecx-render-buffer.patchnew file mode 100644index 0000000..fd6bd64--- /dev/null+++ b/winecoreaudio-patch/winecx-render-buffer.patch@@ -0,0 +1,18 @@+diff --git a/dlls/winecoreaudio.drv/coreaudio.c b/dlls/winecoreaudio.drv/coreaudio.c+index e5791534..52019d48 100644+--- a/dlls/winecoreaudio.drv/coreaudio.c++++ b/dlls/winecoreaudio.drv/coreaudio.c+@@ -829,7 +829,12 @@ static NTSTATUS unix_create_stream(void *args)++ stream->period_frames = max(min_period_frames, min(stream->period_frames, max_period_frames));+ stream->period = muldiv(stream->period_frames, 10000000, stream->fmt->nSamplesPerSec);+- if (FAILED(params->result = set_device_period_frame_size(stream->dev_id, stream->flow, stream->period_frames)))++ /* NotProton: with the device buffer as long as Wine's 10 ms period, a render callback++ * regularly asks for more frames than the client has written yet, and ca_render_cb++ * pads the shortfall with silence, which is heard as crackling (Deadlock, CS2). A++ * device buffer of half a period keeps each pull within what is already queued. */++ if (FAILED(params->result = set_device_period_frame_size(stream->dev_id, stream->flow,++ stream->flow == eRender ? max(min_period_frames, stream->period_frames / 2) : stream->period_frames)))+ goto end;++ stream->bufsize_frames = muldiv(params->duration, stream->fmt->nSamplesPerSec, 10000000);diff --git a/wined3d-patch/winecx-driver-version.patch b/wined3d-patch/winecx-driver-version.patchnew file mode 100644index 0000000..fe81a92--- /dev/null+++ b/wined3d-patch/winecx-driver-version.patch@@ -0,0 +1,42 @@+diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c+index d843cf2d..7ce440e3 100644+--- a/dlls/wined3d/directx.c++++ b/dlls/wined3d/directx.c+@@ -921,10 +921,37 @@ bool wined3d_driver_info_init(struct wined3d_driver_info *driver_info,+ if ((version_info = get_driver_version_info(driver, driver_model))+ || (version_info = get_driver_version_info(driver, DRIVER_MODEL_GENERIC)))+ {++ char override[32];++ unsigned int part[4] = {0}, count = 0;++ DWORD len;+++ driver_info->name = version_info->driver_name;+ driver_info->version_high = MAKEDWORD_VERSION(driver_os_version, driver_feature_level);+ driver_info->version_low = MAKEDWORD_VERSION(version_info->subversion, version_info->build);+++ /* NotProton: NOTPROTON_DRIVER_VERSION ("32.0.15.9541") replaces the version the table++ * above gives, which for a current NVIDIA GPU is the GeForce 8 era 31.0.13.4052 (340.52).++ * Games behind the NVIDIA identity D3DMetal is given read it through d3d9 (Source 2:++ * Deadlock warns of an old driver and turns off asynchronous shader creation). */++ len = GetEnvironmentVariableA("NOTPROTON_DRIVER_VERSION", override, sizeof(override));++ if (len && len < sizeof(override))++ {++ const char *c = override;++ while (count < 4)++ {++ if (*c < '0' || *c > '9') break;++ while (*c >= '0' && *c <= '9') part[count] = part[count] * 10 + (*c++ - '0');++ count++;++ if (*c != '.') break;++ c++;++ }++ if (count == 4 && !*c && part[0] < 0x10000 && part[1] < 0x10000 && part[2] < 0x10000 && part[3] < 0x10000)++ {++ driver_info->version_high = MAKEDWORD_VERSION(part[0], part[1]);++ driver_info->version_low = MAKEDWORD_VERSION(part[2], part[3]);++ }++ }+++ return true;+ }+