XMem: place a reservation above 128 GiB when nothing below has room (#2081) #2133
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!2133
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2133"
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?
@bstillbstill on GitHub · 2026-11-29 09:48 UTC · original
bstillbstill:fix/xmem-tileheap-fallback→main· +45 −0 · 1 files · 1 commits · closed without mergingFixes #2081
What it changes
#1041 caps title memory below the by-address directory's 128 GiB (2^37). On native Windows the title's 6,236 MB TileHeap (flags
0x23) can find no hole below that, soXMemVirtualAllocis refused (os error 8) and the title stops at its start at+0x1e6c284. That's the analysis in #2081; it happens on my RTX 3090 Ti / 32 GB PC too. Before #1041 the same request landed at0x2000000000and the game ran.This does what #2081 suggests:
console_top(flags): 40 bits with no field,47 - fieldotherwise, as before #1041), with a warning in the log.the_fallback_reaches_where_the_tile_heap_went_before_the_cap.crates/victory-hle/src/modules/xmem.rsonly, +45 lines.Not fixed here: what falls back lands above 128 GiB, which is read as 0 by shaders that reach it by address (#218). So on PCs that hit the refusal this restores the pre-#1041 behaviour; it doesn't make the 6.1 GiB hole below 2^37 that #2081 also suggests making. It is marked as a
shortcut:in the code.How it was tested
-Res 1440withVICTORY_NATIVE_SIZE=2560x1440(3440x1440 monitor, #2073), DLSS (performance / ultra performance from the F1 menu), FSR 3 frame generation, ray tracing off. Release build.829188e9): every start stopped about 2 s in:XMemVirtualAlloc refused size=6538919936 kind=0x42000 flags=0x23 ... (os error 8), thenunhandled exception 0x80000003 at victory-image-b99f876b74d4a77f.dll+0x1e6c284.89a957e0): started fromscripts\play-foxhound.ps1, it reaches the game. The log showsXMemVirtualAlloc: no room below 128 GiB, placed above it as before #1041 size=6538919936 at=0x1fffff0000 flags=0x23. In game it ran at 16–18 fps, with FSR 3 frame generation on for every present (179–198 per 10 s).cargo test -p victory-hle --lib: 423 passed, 1 failed, 5 ignored. The one failure isa_read_by_range_waits_only_for_a_remapping_that_meets_it, which fails the same way on829188e9without this change (twice) and passes when run alone.heap_reuses_freed_addressesfailed once in one full run and passed in the others and alone. The new test andtitle_memory_stays_within_the_by_address_directorypass.cargo clippy -p victory-hle --all-targets -- -D warnings: fails on829188e9too, invictory-loader(unwind_copynever used) andvictory-shader(unused imports, a loop condition), not in the files this touches.Checked for overlap
address_range(), capping it at 128 GiB less 64 KiB, with no fallback, so it would hit the same refusal), #2112 (same refusal on an RTX 3090), #2073 (ultrawide start crash, separate).Written with Claude Code (Claude Opus 5.5): it found the cause, wrote the change and the test, ran the tests and the in-game starts above on my PC, and wrote this description. I reviewed it before opening.
@botto854 on GitHub · 2026-11-29 10:06 UTC · original
Confirming this on a second 24 GB card (reporter of #2081).
Setup: RTX 4090 24 GB (driver 617.14), i9-14900K, 32 GB RAM, Windows 11 build 26300 (native), 2560x1440, Series X, DLSS quality.
I built the same fallback independently on top of v2026.11.29.01 (
829188e9): capped range first, then the flags' full 40-bit range on failure. Result:XMemVirtualAlloc: no room below 2^37, placed in the flags' full range size=6538919936 at=0x1fffff0000, the same address as on your 3090 Ti.crashes.log. Without the fallback, 3/3 starts stopped at+0x1e6c284.cargo test -p victory-hle --lib xmem: same picture as yours, onlya_read_by_range_waits_only_for_a_remapping_that_meets_itfails, with and without the change.One small nit, not blocking:
requirements.HighestEndingAddress = ...writes the local directly after&raw mut requirementswent intoparameter. rustc flagged that on my build (value assigned to requirements is never read). It works in practice, but writing through the same pointer thatVirtualAlloc2reads is cleaner:(Comparison and test run with Claude Code.)
@Dukestar69 on GitHub · 2026-11-29 10:27 UTC · original · approved these changes
Tested locally merged onto
main(829188e9).crates/victory-hle/src/modules/xmem.rs.cargo test -p victory-hle --lib xmem -- --test-threads=1passed (47 passed; 0 failed; 1 ignored, including the newthe_fallback_reaches_where_the_tile_heap_went_before_the_captest).xmem.rs:273emits anunused_assignmentswarning onrequirements.HighestEndingAddress = console_top(flags) as *mut c_void;.Important fallback fix for high-address reservations when the <128 GiB range has no contiguous room. LGTM.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
@botto854 on GitHub · 2026-11-29 10:46 UTC · original
Found where the 36 + 28 GiB below 2^37 come from: DLSS (NGX) init calls into
nvcuda64, which reserves them at fixed addresses before the title asks for its TileHeap. Details, stacks and a DLSS-off cross-check: #2081@Halfect on GitHub · 2026-11-29 11:08 UTC · original · approved these changes
LGTM. The change preserves the capped range as the first choice and only widens
HighestEndingAddressafter that attempt fails. It also leaves 32-bit requests bounded, while restoring the console-defined range for the TileHeap case.Local verification at
89a957e0885af2d8ec76b826052e9725c26bf89c:cargo test --locked -p victory-hle --lib xmem -- --test-threads=1: 47 passed, 0 failed, 1 ignored, includingthe_fallback_reaches_where_the_tile_heap_went_before_the_cap.git diff --check origin/main..HEAD: clean.base.is_null()) allocations and logs when the wider range is used.I also see the non-blocking
unused_assignmentswarning at line 273; writing through the requirements pointer already stored inparameter, as suggested in the existing discussion, would avoid it.This was source and unit-test verification only, not a fresh end-to-end game run.
@P1ayer-1 on GitHub · 2026-11-29 18:20 UTC · original
Confirmed on an 8 GB card, which is a different profile from the two 24 GB confirmations so far — RTX 3060 Ti 8 GB, Ryzen 5 3600X, 48 GB RAM, Windows 11 build 26300, Series X files, 2560x1440, DLSS Quality, frame generation off.
Built this branch at
89a957e0(cargo build --release -p victory, MSVC 14.44, rustc 1.98.1). Two results:The test passes:
the_fallback_reaches_where_the_tile_heap_went_before_the_cap→ ok.In game, the TileHeap request (
size=6538919936,flags=0x23) is placed by your fallback and the run reaches rendering:XMemVirtualAlloc refused: 0 occurrences (was 1 per run without this)dstorage: file openedlines, i.e. real loading, where refused runs stop at 3–5card time … per frame over 256 frames)For contrast, same machine, same files:
v2026.11.28.030x2000000000v2026.11.29.010x0→ refusedSystem Init, 5 of 6 runsv2026.11.29.01with only theaddress_rangecap reverted0x1fffff00000x1fffff0000So it is not tied to 24 GB cards or to VRAM at all, and your version is the better shape of the fix: the bounded retry keeps everything that fits below 2^37 where it belongs, and only the request that cannot fit goes above. Nothing to change from my side.
@bstillbstill on GitHub · 2026-11-30 14:11 UTC · original
Closing this in favour of
f72cec77("XMem: keep 8 GiB of the title's window spare at start, give it back if the 6.5 GB heap is refused"), which fixes #2081 better: the TileHeap stays below 128 GiB, so #218 isn't at risk.Checked on the same PC (RTX 3090 Ti, 32 GB, Windows 11 26300) at
41adb551without this patch: on Series X the 6,538,919,936-byte request now lands at0x1800000000and the game reaches play (~19 fps); Series S also starts and plays.Thanks to everyone who tested this branch (@botto854, @P1ayer-1), and for tracking the 36 + 28 GiB reservations down to NGX/nvcuda.
(Checked with Claude Code, Claude Opus 5.5.)
Pull request closed