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
fix(dlss): link Apple's nvapi64 as nvapi too and report an NVIDIA adapter with NVAPI=1
raymondchins4a4ec3e8f8d2
diff --git a/app/Sources/NotProtonApp/Model/FreeEngineWinecxD3DMetal.swift b/app/Sources/NotProtonApp/Model/FreeEngineWinecxD3DMetal.swiftindex 5eb5c9b..9e7bab3 100644--- a/app/Sources/NotProtonApp/Model/FreeEngineWinecxD3DMetal.swift+++ b/app/Sources/NotProtonApp/Model/FreeEngineWinecxD3DMetal.swift@@ -16,6 +16,8 @@// 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.+// lib/wine/x86_64-{windows,unix}/nvapi.* -> the user's nvapi64.* again, under the internal+// name Wine resolves Apple's nvapi64 builtin by.// lib/wine/x86_64-{windows,unix}/nvngx.* -> the user's nvngx-on-metalfx.*, DLSS served// by MetalFX. CrossOver copies it into each prefix as nvngx.dll; linking it under// that name here lets the prefix's placeholder nvngx.dll resolve to it. compat_run.sh@@ -35,9 +37,12 @@ enum 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 these names.- static let optionalForwarders = ["nvapi64.dll", "nvngx.dll"]+ // nvapi.dll is nvapi64.dll again: Apple's nvapi64 carries the internal name nvapi.dll, and+ // Wine looks its builtin up by that name, so without it nvapi64 loads with no unix half+ // and its DllMain fails.+ static let optionalForwarders = ["nvapi64.dll", "nvapi.dll", "nvngx.dll"]// The GPTK file an optional forwarder links to, when its name differs.- static let optionalSources = ["nvngx.dll": "nvngx-on-metalfx.dll"]+ static let optionalSources = ["nvapi.dll": "nvapi64.dll", "nvngx.dll": "nvngx-on-metalfx.dll"]static let sharedLibrary = "libd3dshared.dylib"static let framework = "D3DMetal.framework"diff --git a/app/Tests/NotProtonAppTests/FreeEngineWinecxTests.swift b/app/Tests/NotProtonAppTests/FreeEngineWinecxTests.swiftindex 7fcf7da..4679d71 100644--- a/app/Tests/NotProtonAppTests/FreeEngineWinecxTests.swift+++ b/app/Tests/NotProtonAppTests/FreeEngineWinecxTests.swift@@ -93,7 +93,7 @@ struct FreeEngineWinecxTests {#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(!["nvapi64.dll", "nvapi.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)")@@ -373,7 +373,7 @@ struct FreeEngineWinecxTests {== 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 + ["nvapi64.dll", "nvngx.dll"] {+ for name in WinecxD3DMetal.forwarders + ["nvapi64.dll", "nvapi.dll", "nvngx.dll"] {let from = WinecxD3DMetal.sourceName(of: name)#expect(try destination(of: root.appending(path: "lib/wine/x86_64-windows/\(name)"))== source.appending(path: "wine/x86_64-windows/\(from)").path(percentEncoded: false))@@ -603,7 +603,7 @@ struct FreeEngineWinecxTests {#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", "nvngx.dll"] {+ for name in WinecxD3DMetal.forwarders + ["nvapi64.dll", "nvapi.dll", "nvngx.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))"))diff --git a/docs/GAMEFIXES.md b/docs/GAMEFIXES.mdindex 90da649..2f3de83 100644--- a/docs/GAMEFIXES.md+++ b/docs/GAMEFIXES.md@@ -31,7 +31,7 @@ logged, when:| `FRAMEGEN_UI` | `0`, `1` | Same as `NOTPROTON_FRAMEGEN_UI`, Protect UI: keeps static HUD and menus sharp. On when unset || `FRAMEGEN_FALLBACK` | `0`, `1` | Same as `NOTPROTON_FRAMEGEN_FALLBACK`, Fast-motion fallback: skips generated frames that would smear. On when unset || `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. Off by default, since an nvapi that answers sends some games down NVIDIA-only paths |+| `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 || `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/docs/WINECX.md b/docs/WINECX.mdindex ba86bb8..6404c9d 100644--- a/docs/WINECX.md+++ b/docs/WINECX.md@@ -217,6 +217,7 @@ lib/wine/x86_64-unix/{d3d10,d3d11,d3d12,dxgi}.so -> <gptk>/wine/x86_64-unix(or <gptk>/external/libd3dshared.dylibwhen the GPTK has no unix folder)lib/wine/x86_64-{windows,unix}/nvapi64.{dll,so} -> <gptk>, when the GPTK has it+lib/wine/x86_64-{windows,unix}/nvapi.{dll,so} -> <gptk>/…/nvapi64.*, the internal name Wine finds Apple's nvapi64 bylib/external/{D3DMetal.framework,libd3dshared.dylib} -> <gptk>/external/lib/notproton-backends/wine-stock/x86_64-windows/{d3d10,d3d11,d3d12,dxgi}.dll Wine's originalslib/notproton-backends/d3dmetal.enableddiff --git a/dylib/feats/compat_run.sh b/dylib/feats/compat_run.shindex c082c45..22014b5 100755--- a/dylib/feats/compat_run.sh+++ b/dylib/feats/compat_run.sh@@ -692,7 +692,11 @@ activate_backend() {[ ! -e "$CX_ROOT/lib/wine/x86_64-windows/nvngx.dll" ] || nv_dlls="nvapi64,nvngx"if [ "$gamefix_nvapi" = 1 ] && [ "$backend" = d3dmetal ]; thenbackend_overrides="${backend_overrides:+$backend_overrides;}$nv_dlls=b"- graphics_log "NVAPI=1: $nv_dlls on"+ # 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}"+ export D3DM_DEVICE_DESCRIPTION="${D3DM_DEVICE_DESCRIPTION:-NVIDIA GeForce RTX 4090}"+ graphics_log "NVAPI=1: $nv_dlls on, adapter $D3DM_VENDOR_ID:$D3DM_DEVICE_ID ($D3DM_DEVICE_DESCRIPTION)"else[ "$gamefix_nvapi" != 1 ] || graphics_log "NVAPI=1 not applied, $backend is not d3dmetal"backend_overrides="${backend_overrides:+$backend_overrides;}$nv_dlls=d"diff --git a/dylib/tests/gamefixescheck.sh b/dylib/tests/gamefixescheck.shindex d0c9151..281b646 100644--- a/dylib/tests/gamefixescheck.sh+++ b/dylib/tests/gamefixescheck.sh@@ -112,7 +112,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 gamefix_args; do+ DXVK_HUD VKD3D_CONFIG WINEDEBUG MTL_HUD_ENABLED D3DM_VENDOR_ID D3DM_DEVICE_ID D3DM_DEVICE_DESCRIPTION gamefix_args; doeval "printf \"%s=%s\\n\" \$v \"\${$v-<unset>}\""done' launch "$target" > "$case_dir/out" 2>&1 || echo "launch exited $?" >> "$case_dir/out"@@ -379,9 +379,15 @@ is "and nothing of Apple's is copied into the prefix" "0" "$(grep -rl '^apple 'user_conf 'NVAPI=1'launch waitforexitandrun "$case_dir/game/game.exe"is "a conf NVAPI=1 turns Apple's nvapi64 and nvngx (DLSS) on" "d3d10,d3d10core,d3d11,d3d12,dxgi=b;nvapi64,nvngx=b;$trio" "$(got WINEDLLOVERRIDES)"+is "and D3DMetal reports an NVIDIA adapter" "0x10de 0x2684 NVIDIA GeForce RTX 4090" \+ "$(got D3DM_VENDOR_ID) $(got D3DM_DEVICE_ID) $(got D3DM_DEVICE_DESCRIPTION)"+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)"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)"+is "nor its adapter" "<unset>" "$(got D3DM_VENDOR_ID)"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"diff --git a/dylib/version.h b/dylib/version.hindex 3cc04ae..da4479d 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.16"+#define NOTPROTON_VERSION "1.1.7-winehq.1-ray.17"#endif // NOTPROTON_VERSION_H