XMem: hold room below 2^37 before DLSS starts, so the TileHeap fits (#2081) #2263
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2263"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by botto854 on 2026-11-29T11:10:50Z.
Fixes #2081
What it changes
Cause (details and stacks in #2081): DLSS's NGX start goes through NVAPI into
nvcuda64, which reserves 36 + 28 GiB at fixed addresses (0xf00000000,0x1800000000) inside [4 GiB, 2^37). That happens before the title asks for its 6.1 GiB TileHeap. Since #1041 caps title memory below 2^37, no hole that size is left,XMemVirtualAllocis refused (os error 8) and the title stops at+0x1e6c284. With DLSS off the unpatched release starts.Change:
mainreserves 7 GiB in that window right after the upload pool (reserve_upload_space), before Streamline loads (xmem::reserve_headroom). That room is in CUDA's way: CUDA places its 28 GiB above 2^37 instead (CUDA memory is never read by the title's shaders), and the TileHeap fits below 2^37. If a capped request still finds no room, the held room is given back and the request is retried once (release_headroom).crates/victory-hle/src/modules/xmem.rs+76 (incl. one test),apps/victory/src/main.rs+2.Relation to #2133: complementary. #2133 keeps the game starting by placing the TileHeap above 2^37 when nothing below has room, which brings back the #218 risk for that pool. With this change the TileHeap lands below 2^37 in all my runs, so #2133's fallback is never reached. It is still a sensible safety net; the two touch different lines of
XMemVirtualAllocand should merge cleanly together.How it was tested
GPU and profile: RTX 4090 24 GB (driver 617.14), i9-14900K, 32 GB RAM, Windows 11 build 26300 (native). Series X, 2560x1440, DLAA, DLSS frame generation 2X. Release build on top of
829188e9(this branch plus the #2133-style fallback in my local build, which never triggered).Before (
829188e9): 3/3 starts refusedsize=6538919936 kind=0x42000 flags=0x23 (os error 8), then0x80000003 at +0x1e6c284.After: 3 starts, all reached the game, TileHeap below 2^37 every time, no fallback, no
crashes.logentry:0x18000000000x18000000000x222800000Memory map of the running game (run 3, VirtualQueryEx): CUDA 36 GiB at
0x1200000000, CUDA 28 GiB at0x2000000000(above 2^37), held room 7 GiB at0x1dbfff0000, TileHeap 6.09 GiB at0x222800000.Shader changes: none.
cargo test -p victory-hle --lib xmem -- --test-threads=1: 47 passed, 0 failed, 1 ignored, including the newheadroom_is_held_below_the_directory_and_given_back_once. (Without--test-threads=1,a_read_by_range_waits_only_for_a_remapping_that_meets_itfails the same way on829188e9without this change.)Not tested: Wine/Proton, AMD/Intel, cards with less VRAM (CUDA's reservation sizes probably differ), Series S.
Checked for overlap
address_range()), #2112 and #2150 (same refusal).Written with Claude Code (Claude Opus 5.5): it found the cause under cdb, wrote the change and the test, and ran the builds and tests. The in-game runs were on my PC.
🤖 Generated with Claude Code
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Ondra97 on 2026-11-29T12:29:18Z.
Independent Windows check of the exact unmodified
581bb5d2head, without the #2133 fallback. RTX 4070 Ti SUPER, driver 621.40, Series X, 2560×1440, DLSS Performance, RT requested, and FG off. The emulator image, shader, and PSO caches started empty. The existing NVIDIA driver cache was left in place.The first constrained request for the 6,236 MiB TileHeap had no room. The patch released its reservation at 0x1dbfff0000 and successfully retried at 0x1d00000000, with the whole allocation below 2^37. The BVH early reserve still got all 50 pieces (3,200 MiB), and Streamline reported 21 successful DLSS upscales. No device fault was reported. This directly exercised the release-and-retry branch on a second GPU model.
One separately reproduced cold crash on
70702bcd, which has the baseline XMem path, failed the same allocation and stopped at the known breakpoint. The matched829188e9control happened to find a hole on this attempt. The result supports the reservation/retry fix and shows that the unpatched failure is intermittent on this machine. During the 210-second candidate probe, unrelated cold PSO work stayed pending and the RT builder did not activate. This covers the TileHeap startup failure without claiming a completed cold gameplay run.Locked offline release build and serial XMem tests passed (47 passed, one ignored).
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by tippythetaidum on 2026-11-29T12:32:49Z.
Works here too, on another card. RTX 5080 16 GB (driver 621.14), Ryzen 7 9800X3D, 32 GB RAM, Windows 11 26200. Source build of
829188e9plus #1926 and #1930 (neither touches XMem). Series X 2560x1440, DLSS Performance, DLSS frame generation 4x.+0x1e6c284, one right after a full preload and one plain start, each afterXMemVirtualAlloc refused size=6538919936 kind=0x42000 flags=0x23 ... (os error 8).581bb5d2, cherry-picked): the TileHeap request was granted on its first try,6236 MB, last 0x1a00000000+0x185c00000, below 2^37. The "room held from the start given back" line never appeared, so on this PC the hold alone kept the room free and the retry wasn't needed. The game reached the start screen. XMem tests (serial): 47 passed, 1 ignored.#2133 didn't apply cleanly on top of this (both change
xmem.rs), so I tested this one alone.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by RomanFama592 on 2026-11-29T12:53:23Z.
On an RTX 4060 Ti 8 GB this start crash turned out to be #2055 (a 21:9 primary monitor), not the TileHeap placement. With
VICTORY_NATIVE_SIZE=2560x1440,mainstarts both with and without this PR. For reference, here the CUDA reservation was 12 GB at0xf00000000, and about 47 GB stayed free below 2^37 (!addressat the title's breakpoint), so the TileHeap would have fit either way.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by botto854 on 2026-11-29T14:34:49Z.
Thanks, that fits: the CUDA reservation seems to scale with VRAM. On an RTX 4090 (24 GB) here it was 36 GiB at
0xf00000000plus 28 GiB at0x1800000000, which left no 6.2 GB hole below 2^37 (3/3 starts failed). Your 8 GB card reserved 12 GB, so the TileHeap fits either way. The repros so far (4070 Ti SUPER 16 GB, 5080 16 GB, 4090 24 GB) are all 16 GB+ cards.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Thomas316 on 2026-11-29T20:29:24Z.
Validated on a second machine — RTX 4070 Ti 12 GB (driver 621.40), i7-ish 16-thread, 64 GB RAM, Windows 11 26200, native. Series X, 1440p (2560x1440 + VICTORY_NATIVE_SIZE=2560x1440), DLSS Quality + DLSS FG 2x, via victory.exe play (Play-MyRig path).
Before (stock
f889bb07): every Series X start died ~2–3s in at Frame 0 — XMemVirtualAlloc refused size=6538919936 kind=0x42000 flags=0x23 (os error 8), then 0x80000003 at victory-image-b99f876b74d4a77f.dll+0x1e6c284. Same signature as #2081. Series S started fine (smaller TileHeap).After (this PR merged onto
f889bb07): starts past System Init and runs. From the play log:no XMemVirtualAlloc refused
title memory asked for as protection 0x2004, kind 0x42000, flags 0x23: 1 times, 6236 MB, last 0x1300000000+0x185c00000 — TileHeap at 76 GB, below 128 GB as designed
DLSS Frame Generation: 19–21 presents with it on, 0 off, 38–42 frames shown (status 0x0), no static/block artifacts, vehicle panels present
VICTORY_ALIAS_TARGETS=1 + VICTORY_LAZY_TWINS=1 were also set (pre-#1041 GPU behavior) — the startup still failed without this PR and passes with it, so the fix is what made the difference, not the GPU switches.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by botto854 on 2026-11-29T20:55:26Z.
Superseded by
f72cec7(v2026.11.29.04), which is in main now. Confirmed on the RTX 4090 that hit this every start: 3/3 crashes on v2026.11.29.03, 3/3 clean starts on v2026.11.29.04 (details in #2081). Thanks!Pull request closed