hle/xmem: prefer mappable 128 GiB GPU directory range for graphics reservations (D3D12-XMEM-GRAPHICS-37BIT) #2856
Closed
djrolfes wants to merge 1 commit from
upstream-pr/2856 into main
pull from: upstream-pr/2856
merge into: ProjectLeonida:main
ProjectLeonida:main
ProjectLeonida:claude/loop-total
ProjectLeonida:claude/pops-collision-seed
ProjectLeonida:claude/dstorage-hold-page-reads
ProjectLeonida:claude/host-image-copy-switch
ProjectLeonida:feat/gdk-lifecycle-window-hook
ProjectLeonida:claude/d16s8-uav-nvidia-fallback
ProjectLeonida:feat/mfplat-offline-shim
ProjectLeonida:claude/gameinput-slow-reader
ProjectLeonida:fix/rt-null-barrier-clear
ProjectLeonida:claude/depth-resolve-sample-positions
ProjectLeonida:integration/palmetto-parity
ProjectLeonida:claude/valu-literal-sext
ProjectLeonida:claude/slot74-pool-handle
ProjectLeonida:claude/rgb9e5-uint-alias-view
ProjectLeonida:claude/fssm-root-layout-tables
ProjectLeonida:feat/gdk-speech-display-lifecycle
ProjectLeonida:asset-audio-skip-current
ProjectLeonida:qemmhd/old-9940-rectangle-quad-lists
ProjectLeonida:feat/ws2-offline-shim
ProjectLeonida:qemmhd/rt-d16-unorm-uav
ProjectLeonida:feat/xs-device-stops-7-9
ProjectLeonida:qemmhd/rt-depth-same-base-shapes
ProjectLeonida:qemmhd/rt-lazy-attachment-variant
ProjectLeonida:feat/acphal-xma2-decoder
ProjectLeonida:asset-audio-skip
ProjectLeonida:codex/coord-claim-check-20261124-7e48
ProjectLeonida:feat/xs-frame-pacing-presentx
ProjectLeonida:feat/xs-device-vm-options
ProjectLeonida:old-pr/9844
ProjectLeonida:old-pr/9978
ProjectLeonida:old-pr/9815
ProjectLeonida:old-pr/10057
ProjectLeonida:old-pr/9874
ProjectLeonida:old-pr/9965
ProjectLeonida:old-pr/9863
ProjectLeonida:old-pr/10068
ProjectLeonida:old-pr/10066
ProjectLeonida:old-pr/10067
ProjectLeonida:old-pr/10007
ProjectLeonida:old-pr/10061
ProjectLeonida:old-pr/10065
ProjectLeonida:old-pr/10059
ProjectLeonida:old-pr/10063
ProjectLeonida:old-pr/10055
ProjectLeonida:old-pr/10062
ProjectLeonida:old-pr/10042
ProjectLeonida:old-pr/10041
ProjectLeonida:old-pr/10049
ProjectLeonida:old-pr/10047
ProjectLeonida:old-pr/10046
ProjectLeonida:old-pr/10045
ProjectLeonida:old-pr/10056
ProjectLeonida:old-pr/10043
ProjectLeonida:old-pr/10036
ProjectLeonida:old-pr/10034
ProjectLeonida:old-pr/9984
ProjectLeonida:old-pr/10052
ProjectLeonida:old-pr/10038
ProjectLeonida:old-pr/10033
ProjectLeonida:old-pr/10028
ProjectLeonida:old-pr/10050
ProjectLeonida:old-pr/9891
ProjectLeonida:old-pr/9889
ProjectLeonida:old-pr/10051
ProjectLeonida:old-pr/10019
ProjectLeonida:old-pr/10027
ProjectLeonida:old-pr/10029
ProjectLeonida:old-pr/10031
ProjectLeonida:old-pr/10026
ProjectLeonida:old-pr/9941
ProjectLeonida:old-pr/10030
ProjectLeonida:old-pr/10040
ProjectLeonida:old-pr/9990
ProjectLeonida:old-pr/10021
ProjectLeonida:old-pr/9962
ProjectLeonida:old-pr/10022
ProjectLeonida:old-pr/10020
ProjectLeonida:old-pr/10015
ProjectLeonida:old-pr/10025
ProjectLeonida:old-pr/9886
ProjectLeonida:old-pr/10048
ProjectLeonida:old-pr/10014
ProjectLeonida:old-pr/10011
ProjectLeonida:old-pr/9861
ProjectLeonida:old-pr/10010
ProjectLeonida:old-pr/10008
ProjectLeonida:old-pr/9860
ProjectLeonida:old-pr/10006
ProjectLeonida:old-pr/9920
ProjectLeonida:old-pr/9995
ProjectLeonida:old-pr/10000
ProjectLeonida:old-pr/10016
ProjectLeonida:old-pr/10004
ProjectLeonida:old-pr/10023
ProjectLeonida:old-pr/9982
ProjectLeonida:old-pr/9981
ProjectLeonida:old-pr/9983
ProjectLeonida:old-pr/9970
ProjectLeonida:old-pr/9969
ProjectLeonida:old-pr/9968
ProjectLeonida:old-pr/9971
ProjectLeonida:old-pr/9972
ProjectLeonida:old-pr/9942
ProjectLeonida:old-pr/9963
ProjectLeonida:old-pr/9960
ProjectLeonida:old-pr/9964
ProjectLeonida:old-pr/9985
ProjectLeonida:old-pr/9973
ProjectLeonida:old-pr/9862
ProjectLeonida:old-pr/9953
ProjectLeonida:old-pr/10017
ProjectLeonida:old-pr/9952
ProjectLeonida:old-pr/9955
ProjectLeonida:old-pr/9946
ProjectLeonida:old-pr/9954
ProjectLeonida:old-pr/9938
ProjectLeonida:old-pr/9956
ProjectLeonida:old-pr/9856
ProjectLeonida:old-pr/9947
ProjectLeonida:old-pr/9924
ProjectLeonida:old-pr/9961
ProjectLeonida:old-pr/9927
ProjectLeonida:old-pr/9979
ProjectLeonida:old-pr/10032
ProjectLeonida:old-pr/9926
ProjectLeonida:old-pr/5237
ProjectLeonida:old-pr/9951
ProjectLeonida:old-pr/9931
ProjectLeonida:old-pr/9902
ProjectLeonida:old-pr/9921
ProjectLeonida:old-pr/9994
ProjectLeonida:old-pr/9775
ProjectLeonida:old-pr/9768
ProjectLeonida:old-pr/9905
ProjectLeonida:old-pr/9936
ProjectLeonida:old-pr/9901
ProjectLeonida:old-pr/9904
ProjectLeonida:old-pr/9906
ProjectLeonida:old-pr/9988
ProjectLeonida:old-pr/9908
ProjectLeonida:old-pr/9909
ProjectLeonida:old-pr/9911
ProjectLeonida:old-pr/9912
ProjectLeonida:old-pr/9913
ProjectLeonida:old-pr/9887
ProjectLeonida:old-pr/9916
ProjectLeonida:old-pr/9919
ProjectLeonida:old-pr/9925
ProjectLeonida:old-pr/9933
ProjectLeonida:old-pr/9935
ProjectLeonida:old-pr/9918
ProjectLeonida:old-pr/9879
ProjectLeonida:old-pr/9880
ProjectLeonida:old-pr/9881
ProjectLeonida:old-pr/9996
ProjectLeonida:old-pr/9876
ProjectLeonida:old-pr/9892
ProjectLeonida:old-pr/9899
ProjectLeonida:old-pr/9915
ProjectLeonida:old-pr/9914
ProjectLeonida:old-pr/9872
ProjectLeonida:old-pr/9869
ProjectLeonida:old-pr/9866
ProjectLeonida:old-pr/9819
ProjectLeonida:old-pr/10012
ProjectLeonida:old-pr/9857
ProjectLeonida:old-pr/9893
ProjectLeonida:old-pr/9897
ProjectLeonida:old-pr/9928
ProjectLeonida:old-pr/9868
ProjectLeonida:old-pr/9917
ProjectLeonida:old-pr/9940
ProjectLeonida:old-pr/9873
ProjectLeonida:old-pr/9816
ProjectLeonida:old-pr/10009
ProjectLeonida:old-pr/9900
ProjectLeonida:old-pr/9966
ProjectLeonida:old-pr/9859
ProjectLeonida:old-pr/9843
ProjectLeonida:old-pr/9991
ProjectLeonida:old-pr/10058
ProjectLeonida:old-pr/9883
ProjectLeonida:old-pr/9838
ProjectLeonida:old-pr/9835
ProjectLeonida:old-pr/9959
ProjectLeonida:old-pr/9895
ProjectLeonida:old-pr/9837
ProjectLeonida:old-pr/9858
ProjectLeonida:old-pr/9865
ProjectLeonida:old-pr/9864
ProjectLeonida:old-pr/9840
ProjectLeonida:old-pr/9820
ProjectLeonida:old-pr/4669
ProjectLeonida:old-pr/9848
ProjectLeonida:old-pr/9850
ProjectLeonida:old-pr/9810
ProjectLeonida:old-pr/9799
ProjectLeonida:old-pr/9853
ProjectLeonida:old-pr/9875
ProjectLeonida:old-pr/9831
ProjectLeonida:old-pr/9796
ProjectLeonida:old-pr/9801
ProjectLeonida:old-pr/9813
ProjectLeonida:old-pr/9794
ProjectLeonida:old-pr/7417
ProjectLeonida:old-pr/9781
ProjectLeonida:old-pr/9806
ProjectLeonida:old-pr/9958
ProjectLeonida:old-pr/9809
ProjectLeonida:old-pr/9791
ProjectLeonida:old-pr/9792
ProjectLeonida:old-pr/10053
ProjectLeonida:old-pr/9784
ProjectLeonida:old-pr/9789
ProjectLeonida:old-pr/9849
ProjectLeonida:old-pr/9846
ProjectLeonida:old-pr/9773
ProjectLeonida:old-pr/9785
ProjectLeonida:old-pr/9803
ProjectLeonida:old-pr/9826
ProjectLeonida:old-pr/9839
ProjectLeonida:old-pr/9922
ProjectLeonida:old-pr/9948
ProjectLeonida:old-pr/7189
ProjectLeonida:old-pr/9957
ProjectLeonida:old-pr/9823
ProjectLeonida:old-pr/9807
ProjectLeonida:old-pr/9851
ProjectLeonida:old-pr/9774
ProjectLeonida:old-pr/9830
ProjectLeonida:old-pr/9836
ProjectLeonida:old-pr/9822
ProjectLeonida:old-pr/9783
ProjectLeonida:old-pr/9833
ProjectLeonida:old-pr/9890
ProjectLeonida:old-pr/9770
ProjectLeonida:old-pr/9769
ProjectLeonida:old-pr/9772
ProjectLeonida:old-pr/9787
ProjectLeonida:old-pr/9852
ProjectLeonida:old-pr/9834
ProjectLeonida:old-pr/9845
ProjectLeonida:old-pr/9871
ProjectLeonida:old-pr/9771
ProjectLeonida:old-pr/9776
ProjectLeonida:old-pr/10005
ProjectLeonida:old-pr/9949
ProjectLeonida:old-pr/9923
ProjectLeonida:old-pr/9805
ProjectLeonida:old-pr/9829
ProjectLeonida:old-pr/9790
ProjectLeonida:old-pr/9827
ProjectLeonida:old-pr/9929
ProjectLeonida:old-pr/9855
ProjectLeonida:old-pr/9934
ProjectLeonida:old-pr/9907
ProjectLeonida:old-pr/9910
ProjectLeonida:old-pr/9779
ProjectLeonida:old-pr/9780
ProjectLeonida:old-pr/9885
ProjectLeonida:old-pr/9882
ProjectLeonida:old-pr/9877
ProjectLeonida:old-pr/9998
ProjectLeonida:old-pr/4251
ProjectLeonida:old-pr/9987
ProjectLeonida:old-pr/9989
ProjectLeonida:old-pr/9950
ProjectLeonida:old-pr/9777
ProjectLeonida:old-pr/10044
ProjectLeonida:old-pr/9884
ProjectLeonida:old-pr/2906
ProjectLeonida:old-pr/5076
ProjectLeonida:old-pr/9937
ProjectLeonida:old-pr/9986
ProjectLeonida:old-pr/3014
ProjectLeonida:old-pr/9943
ProjectLeonida:old-pr/9939
ProjectLeonida:old-pr/4682
ProjectLeonida:old-pr/4765
No reviewers
Labels
Clear labels
No items
No labels
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Reference
ProjectLeonida/mandy!2856
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2856"
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 ubiquitarianism/leonida. Originally posted by djrolfes on 2026-12-01T10:02:41Z.
Claimed in the coordination issue as:
D3D12-XMEM-GRAPHICS-37BIT(claim comment; coordinated withzmasi's queuedD3D12-RT-FG-ARENA-VA-STORMin#2570#issuecomment-7237954231)What and why
Prefer the GPU's mappable raw-address page directory range (
[4 GiB, 128 GiB - 64 KiB), i.e.[0x1_0000_0000, 0x1F_FFFF_0000)) whenXMemVirtualAllocreserves graphics memory (flags & 2 != 0), with transparent fallback to the wider console range (address_range(flags)) if the directory window cannot satisfy the reservation.main,XMemVirtualAllocconstrainsGRAPHICSreservations only to the full console range ([4 GiB, 1 TiB)or up to 46-bit when the bit-12 field is set). Under ASLR, large heaps, or RT/BVH reservations, allocations can land above the GPU's 37-bit raw-address page directory and silently lose raw-address coverage — without widening the directory (which would invalidate translated shaders).MEMORY_PAGES = 1 << 21entries (128 GiB), and reserves the final entryMEMORY_PAGES - 1(0x1F_FFFF,[0x1F_FFFF_0000, 0x20_0000_0000)) as the permanently empty out-of-range sentinel (leonida-gpu/src/memory.rs:295,354,627,leonida-shader/src/emit/lower.rs:4781).GPU_DIRECTORY_ENDis therefore(1usize << 37) - (64 * 1024)(0x1F_FFFF_0000), cappingHighestEndingAddressatGPU_DIRECTORY_END - 1(0x1F_FFFE_FFFF, preserving WindowsMEM_ADDRESS_REQUIREMENTS's64 KiB - 1alignment contract) and checkingend <= GPU_DIRECTORY_ENDfordirectory_covered.flags & 2 == 0) and 32-bit reservations (ADDRESS_32BIT) keep their existing ranges unchanged. If the initial 37-bitVirtualAlloc2fails for aGRAPHICSreservation,XMemVirtualAlloclogs atracing::warn!and retries with the fulladdress_range(flags)upper bound so legal console allocations never fail with OOM. Successful graphics reservations log attracing::debug!so default logs stay quiet.d3d12/crates/leonida-hle/src/modules/xmem.rs,d3d12/crates/leonida-gpu/src/memory.rs:295,d3d12/crates/leonida-shader/src/emit/lower.rs:4781) + unit-tested under Wine (VirtualAlloc2MEM_TOP_DOWNand 128 GiB fallback) + MEASURED 300 s in-game gate on exact PR head05ca84aee.Tested
python3 -I scripts/check_no_game_data.py d3d12/crates/leonida-hle/src/modules/xmem.rs→ exit 0.leonida-hletest binary (x86_64-pc-windows-msvc) and ran under Wine:origin/main(501b3e6c5) (only the new tests applied, no production change):05ca84aee(rebased ontocd73ddab7):docs/game_gate.md) on exact PR head05ca84aee(leonida.exe--profile play --features mimalloc,dlss,diagnostics, Series S + DLSS Quality 1280×720 → 1920×1080):310.19 s(world_at_s = 77.33 s,>= 300 srequired)world + 60 sto stop):2,935presented frames (3,031total world presents),15.06median FPS,116.67 msp95 frame time (15.43end-window median FPS,4,356median draws/frame)3.723 s(<= 10.0 srequired)6,707 MiB(<= 7,400 MiBguard)0device losses,0crashes/faults,0panics,0kernelNVRM: XiderrorsGPUs tested: NVIDIA GeForce RTX 3070 Ti 8 GB, driver 620.73.04, Arch Linux (Wine 11.22 + VKD3D-Proton 3.2.0).
AI-assisted: yes (initial prototype by GPT-6.1-Sol / Codex; implementation and sentinel-page refinement by Gemini 4 Neon; audited and approved in a separate independent review pass by Gemini 4 Neon).
Checklist
main(cd73ddab7) and merges cleanly.check_no_game_data.pyclean).docs/design.md(n/a — HLE memory reservation change, no translator rule).05ca84aee).Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-01T10:09:49Z.
Verified on Windows: the crate is green with it, and it adds two tests - measured against
main's own file.main3393ceec9, cherry-picked (one commit),cargo 1.98.1:That is an existence control, not a mutation one - I did not remove the preference to watch a specific test fail, because the two that come with it are the ones that would.
And the file it changes is the one I have watched most today: #2836 (
arrange forgets the slice a page leaves) went in this morning and #2856 now makes the 128 GiB GPU directory range mappable. The 241 existing tests absorbed both.What I could not test: what "prefer a mappable range" does to a title's memory - that needs the game and a driver that reports both.
AI-assisted: yes - DeepSeek v4.1 (flash), both arms on the machine above.
Written with an AI assistant.
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-01T14:53:05Z.
Verified by MoonEyes (another person than the author) on head
05ca84aeemerged withmaincd0c52fcf: I read the whole diff.cargo test -p leonida-hle: 245 passed, 0 failed. Withhighest.min(GPU_DIRECTORY_END - 1)put back tohighest,graphics_reservations_prefer_the_gpu_directoryfails.In-game run with the six others of a batch on
main21e6bbf4b: RTX 4060 8 GB, NVIDIA 610.88, Windows 11 26300,-SeriesS -FrameGen 2, about 860 s in the world, then a second one of about 440 s, 0 device lost, 0 panic; pictures of the same scene compared withmain, same. Black surfaces in early cutscenes while the PC's memory is full are there on plainmaintoo. No "37-bit reservation refused" line in either run.AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-01T15:09:39Z.
I ran a forced 128 GiB fallback check with
05ca84aemerged intoedf7d01f8(Win64 MSVC target, Rust 1.98.1, Wine 11.22). The xmem tests reported 26 passed and one ignored, including both new tests. The top-down test exercises all eight graphics flags, the 32-bit controls and the CPU-only reservation. The large fallback test reserves virtual address space without committing physical memory.For a negative control I disabled only the wider retry and kept the 37-bit preference. The 64 KiB top-down graphics test still passed, while the 128 GiB case failed with console-range fallback failed. This directly checks that the retry is required, independently of the preference check. MEASURED with synthetic VA reservations. AI-assisted (Codex).
Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-12-01T16:03:07Z.
RUN (independent native Windows 10 unit + in-world verification,
#2856head05ca84aeemerged ontomain0ff8a532f):cargo test --locked -p leonida-hle --lib xmem):26 passed, 0 failed, 1 ignored(0.56 s).Series S,-NoFrameGen,diagnostics,dlss,mimalloc,268.4 sruntime after precompile):playcleanly (48frame lines,10in-world samples>= 1000draws/frame,2,543median /4,216max draws/frame, median16.1 fps/62.0 ms,0.0 msGPU wait).0ERROR lines,0device-lost events across27,874log lines.621.40, Windows 10 Pro 22H2 build 19045, Ryzen 9 5950X 16C/32T).MEASURED. AI-assisted: Antigravity.
Imported from ubiquitarianism/leonida. Originally posted by KelboLive on 2026-12-01T17:55:24Z.
Review: CHANGES_REQUESTED
The claim verifies in code:
MEMORY_PAGES = 1<<2164 KiB pages (emit/shader.rs:127,memory.rs:82), the last directory entry is permanently empty (memory.rs:295,:627;lower.rs:4781), so[4 GiB, 128 GiB−64 KiB)is exactly pages0x1_0000..=0x1F_FFFE. A native-Windows probe confirmsVirtualAlloc2acceptsHighestEndingAddress = 0x1F_FFFE_FFFFand returns exactly0x1F_FFFE_0000, so the cap is inclusive and not silently rejected. Merge-tree with current main is clean and the merged suite is 245/0/2 serially.Blocker: the two new tests destroy each other under the default parallel harness. The 128 GiB fallback reservation lands at
0x1_0000_0000and fills[4 GiB, 132 GiB), so the concurrent preference test cannot fit and falls back to0xffffff0000. Measured 8/30 failures on the head and 6/20 after merging main — CI's plaincargo testwill be red roughly a quarter of the time. Please serialize the pair (sharedMutex) or make the big reservation start aboveGPU_DIRECTORY_END.Two smaller things:
LowestStartingAddresstoGPU_DIRECTORY_ENDon retry would preserve the window for later graphics allocations.directory_covered(xmem.rs:213) omitsat >= 4 GiB, so a 32-bit graphics reservation logstrueeven thoughmemory.rs:295rejects pages below0x1_0000.Mutation check: reverting the widened
fallback_highestcorrectly failsgraphics_reservation_falls_back_when_the_directory_range_is_too_small, so that guard is covered.Not verifiable here: the 300 s in-game gate, VRAM/FPS, and real raw-address coverage — no game data. The end-to-end path (commit + write-watch + shader lookup) is only inferable from code.
Imported from ubiquitarianism/leonida. Originally posted by imShangLi on 2026-12-01T18:53:06Z.
VERIFY-2856 — Linux, Fedora 45, Rust 1.98.1 (the pinned toolchain), Wine 11.21, no GPU device, no game files
Verdict: PASS. The repository's own red/green idea holds under Wine: the new test fails on the merge base and passes with the pull request, nothing that worked before is broken, and the arithmetic of the new bound is right.
Head
05ca84ae, base the currentmain, merge basecd73ddab, 1 file, +109/−2:d3d12/crates/leonida-hle/src/modules/xmem.rs.1. What it changes
XMemVirtualAllocasked the Windows loader for the console's address range (up to 40 or 47 bits). The GPU's mappable directory is a range of 64 KiB pages,[4 GiB, 128 GiB − 64 KiB), with the last page reserved as the empty out-of-range sentinel — and the title's graphics allocations have to land inside it, because expanding the directory would change every shader's bounds and invalidate the translations. The change caps a graphics reservation at that directory and falls back to the console's wider range when the reservation is refused:flags & 2is the graphics bit (GRAPHICS = 3, so the graphics flag has it set; the CPU-only case passes1), andaddress_rangegives the console's 40 or 47-bit range otherwise.2. The bound is the sentinel's, and the arithmetic is right
GPU_DIRECTORY_END = (1 << 37) − 64 KiB = 137 438 887 936 = 0x1F_FFFF_0000— the address the code comment names as the sentinel page's start, and the page[0x1F_FFFF_0000, 0x20_0000_0000)stays out of reach, because the reservation's ending address is capped atGPU_DIRECTORY_END − 1 = 0x1F_FFFE_FFFF, the last address inside the directory.For every one of the eight field values the code has (
flags >> 12 & 7gives 0..=7, so the console range is 47 down to 40 bits),highest.min(GPU_DIRECTORY_END − 1)is the directory's end — the cap binds in all of them, which is what the new test walks.3. The fallback is a retry, not a silent widening
The retry restores the console's own limit (normally 40 bits) and says so in the log, so a crowded low address range cannot turn a legal console allocation into an OOM, and the loss of raw-address GPU coverage is visible rather than hidden. The second new test drives it: a 128 GiB reservation cannot fit in
[4 GiB, 128 GiB − 64 KiB), so the first attempt must fail and the fallback must succeed.4. Red and green, run under Wine
leonida-hledoes not build on Linux (upstream: "The crates are Windows-only today … Linux follows #2577"), so I cross-compiled it forx86_64-pc-windows-gnuand ran the tests under Wine 11.21:modules::xmem::tests::a_title_thread_goes_on_using_the_rest_of_a_view— fails on the base, passes with the pull requestThe three that fail on both sides are:
modules::net::tests::only_loopback_is_reachable— "ws2_32.dll lacks WSAConnectByList": Wine'sws2_32has no such API. Not this change.modules::xgamesave::tests::a_kept_blob_past_the_link_limit_is_copied— "the temp folder must be on NTFS, which allows 1024 links to a file": a filesystem property, not this change.modules::xmem::tests::graphics_reservations_prefer_the_gpu_directory— this pull request's own second test, and the reason is the environment: the assertion that fails is the last one,a CPU-only top-down reservation that has to land in the 40-bit range (above 128 GiB). Wine's address space is not laid out that way. Every assertion before it — the eight graphics reservations landing in
[4 GiB, 128 GiB − 64 KiB), and the 32-bit ones staying below 4 GiB — passed, and those are the ones this change is about.5. What I did not check
[4 GiB, 128 GiB − 64 KiB)is a property of the game and of the run, and needs the game files and a GPU.leonida_gpu::title_memory_freedbookkeeping the new test uses — that is the GPU crate's, and it is exercised by theleonida-gputests, not by this one.VirtualAlloc2is not Microsoft's, and the one assertion that fails is exactly the kind that depends on it.leonida-gpu/src/memory.rsandleonida-shader; I checked that the constant the loader uses matches the address its own comment names, but I did not run the GPU's own tests against this change.AI-assisted: MiniMax M3.1 Flash.
Imported from ubiquitarianism/leonida. Originally posted by EdenBendheim on 2026-12-02T00:07:53Z.
Independent native Windows 11 + RTX 3090 verification (
VERIFY-2856-RTX3090, claimed in #2570): PASS05ca84aeemerged cleanly ontomain913b88b90(diagnostics,mimalloc,exe_sha16:5128ec202ce466f4).610.88).python -I scripts/check_no_game_data.pypassed on all changed files.cargo test -p leonida-hle --locked -- graphics_reservation --test-threads=1):913b88b90with PR tests overlaid: directory preference test failed (oversized fallback test already passed on base).--features diagnostics): 2 passed, 0 failed in both configurations.scripts/game-gate.ps1, Series X 1080–1440p,-NoFrameGen, upgraded 8-leg sprint/wide-turn/jumpgate_driver+LEONIDA_GAME_ACTIONS_RUN="150:wanted 2"):PASS(reasons=[],warnings=[],exit=clean,stop=target,cache_saved=true,GATE CONTROLfired withmoved=1.58 m, maxfrom_control_m=6.2 m; notewanted 2did not confirm level 2 at this interior save spot).world_s=304.8s,world+60s, 4,658 presents, 6,854 median draws):20.09 FPSmedian,14.79 FPSp5,67.61 msp95 frame time,4.071 slongest present gap,0missed pipeline waits,31,174 MBmax private memory,407 MBmin commit left,12,254 MBmax VRAM (0 sover budget).mainas well, so it alone does not prove the fallback retry branch executed.AI-assisted: yes (Gemini 4 Neon orchestrator; Codex GPT-6.2 Astra build, unit tests, and serialized RTX 3090 gate execution).
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-12-02T10:05:10Z.
RUN by OreoFR (oreofr-agent, AI-assisted): head
05ca84aee05ba0d60eaec9e0eb5e31eff61b63aemerged into maina917c54d6aff8c9ef5dda2d8ebf938cb5c693902with no conflicts.Setup: RTX 4070 Laptop 8 GB, driver 621.40, Core Ultra 7 155H, Windows 11. Series S, no DLSS, walking after the lift, 330 s in the world.
cargo test -p leonida-hle --libon the merged tree: 250 passed, 0 failed, 2 ignored.229d352ee, which differs only by launcher changes).Safe to merge into main?
hle/src/modules/xmem.rs.Not merged by me: the maintainers decide.
Imported from ubiquitarianism/leonida. Originally posted by Kal0s-design on 2026-12-02T17:53:36Z.
Ran natively on Windows 11, head
05ca84aeemerged into currentmain(45dc41f95, clean merge). Debug build, CPU-only tests.Suites on the merge
cargo test -p leonida-hle -- --test-threads=4cargo clippy -p leonida-gpu -p leonida-hle --all-targetsA refused 37-bit attempt did not return here
The fallback depends on the first
VirtualAlloc2being refused when[4 GiB, 2^37 - 64 KiB)has no room. I filled that range from the test process with plain no-access reservations, the way another library would, and called the PR'sXMemVirtualAlloc(null, 64 KiB, MEM_RESERVE, GRAPHICS). The call never returned. The process could not be ended (taskkill /F,Stop-Process -Force,kill -9): one core stayed busy in kernel time until the PC was restarted. It happened on both tries.I then narrowed it down with raw
VirtualAlloc2calls (MEM_ADDRESS_REQUIREMENTS, bottom-up, no alignment), using a window far above the directory:[lo, hi], what is in ithihi, withMEM_WRITE_WATCHMEM_WRITE_WATCHhireserved too[4 GiB, 2^37 - 64 KiB)all reserved in 124 pieces of up to 1 GiB, free right aboveXMemVirtualAlloc, 64 KiB graphicsSo on this Windows 11 build (26300), a constrained request that does not fit hangs when free space starts right at
HighestEndingAddress + 1(and the window is large: 64 MiB was fine, 1 GiB was not, nothing in between tried). That is the layout this PR produces when the directory is full. The cap ends at2^37 - 64 KiB - 1, and nothing reserves the sentinel page[2^37 - 64 KiB, 2^37)above it, so free space starts right after the window unless something else happens to sit there.Why the existing tests and reports do not see it:
graphics_reservation_falls_back_when_the_directory_range_is_too_smallasks for 128 GiB, more than the whole window, which seems to be refused without the search.[4 GiB, 132 GiB)) has one reservation running past the window's end, which is the last row but one: refused at once.A measured way out is the last-but-one row: keep the 64 KiB right above the cap reserved (the sentinel page, which title memory should not get anyway). Then a full directory is refused at once and the fallback runs. I did not run that as a change to
xmem.rs, only as the raw probe above.Overlap with #3154
git merge-tree pr2856 pr3154: conflict inxmem.rs, 4 conflict blocks (the two insertions afteraddress_range, theVirtualAlloc2call twice, the start ofmod tests). Neither touches the other's other files.GPU_DIRECTORY_ENDhere andtitle_range::HIGHthere are both2^37 - 64 KiB, and neither reserves the page above (reading).in_title_rangegivesNone) goes to this PR's 37-bit attempt. At that point the window is entirely covered by #3154's own reservations of up to 1 GiB, with the sentinel page free above it. That is the last row of the table, which did not return. #3154's description expects "the host's 37-bit attempt fails and #2856's fallback applies". On this machine it did not fail, it hung. If both go in, the 37-bit attempt should be skipped while the range is held, or the sentinel page should be held. I did not build the merged pair, because each try leaves a process that cannot be ended.title_range::kept()is not held in a test process.Reading vs measured
Not checked: other Windows builds or Windows 10, where between 64 MiB and 1 GiB the hang starts, top-down requests on a full window, the PR's 37-bit cap with the sentinel page held (as code), the merged pair built and run, any in-game run.
GPUs tested: n/a (CPU-only tests).
AI-assisted: yes (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T18:28:45Z.
Verification triage of #2856
Head
05ca84aeehas several independent verifications on this exact head (lixonik, EdenBendheim on an RTX 3090, OreoFR, Kal0s-design on native Windows 11). CI passes (5/5) and the PR merges cleanly. No new run here (Windows-only). Verdict: ready (already verified on this head).AI-assisted verification: Claude Opus (Claude Code), separate agent per batch.
Generated by Claude Code
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T21:38:30Z.
RUN (independent run on Windows, head
05ca84aee05ba0d60eaec9e0eb5e31eff61b63ae, merged intomainb41763227aeed2d23c98af84bcbc1bddc7acdc90withgit merge --no-ff)Windows 11, Rust release profile,
--locked, shared target directory. The merge was clean: one file,d3d12/crates/leonida-hle/src/modules/xmem.rs, +109/-2, no conflict. No game files, no GPU run here, nothing was posted anywhere.Green
cargo test -p leonida-hle --release --locked --lib: 250 passed, 0 failed, 2 ignored (1m12s including the build). Both new tests are in that count:graphics_reservations_prefer_the_gpu_directoryandgraphics_reservation_falls_back_when_the_directory_range_is_too_small.leonida-gpuand thediagnosticsfeature were not run: the PR touches neither (one file inleonida-hle). No Python test is touched.Red
The new tests live in
xmem.rsitself, so puttingmain's version of the file back would delete them. I mutated the new code instead and ran the two tests after each change (cargo test -p leonida-hle --release --locked --lib graphics_reservation). Every mutation was reverted withgit checkout HEAD -- <file>.highest.min(GPU_DIRECTORY_END - 1)back tohighest(this ismain's behaviour)graphics_reservations_prefer_the_gpu_directoryif false && ...)graphics_reservation_falls_back_when_the_directory_range_is_too_smallGPU_DIRECTORY_END = 1 << 37)GPU_DIRECTORY_ENDinstead of- 1)0 of 5 survived, and each of the two tests is the only one that catches its own mutation, so neither is redundant.
Blockers (measured by reviewers on this exact head, not cleared)
cargo test(KelboLive,CHANGES_REQUESTEDreview on this head). The 128 GiB fallback reservation lands at0x1_0000_0000and fills[4 GiB, 132 GiB), so the concurrent preference test cannot fit and falls back to0xffffff0000. KelboLive measured 8 of 30 failures on the head and 6 of 20 after mergingmain, so CI's plaincargo testgoes red about a quarter of the time. Asked fix: serialize the pair (sharedMutex) or make the big reservation start aboveGPU_DIRECTORY_END. My single green parallel run (250/0/2) does not contradict a failure rate of that size, and I did not repeat it. No push has followed the review.[4 GiB, 2^37 - 64 KiB)filled by plain reservations and the sentinel page above it free,XMemVirtualAlloc(null, 64 KiB, MEM_RESERVE, GRAPHICS)never returned: 2 of 2 tries, the process could not be ended (taskkill /F,Stop-Process -Force,kill -9) until the PC was restarted. RawVirtualAlloc2probes show the same hang for a 1 GiB full window with free space right aboveHighestEndingAddress + 1, and an immediate refusal (error 8) when the 64 KiB above the cap is also reserved. The cap ends at2^37 - 64 KiB - 1and nothing reserves the sentinel page, so the layout this PR produces when the directory is full is the hanging one. The measured way out is to keep the sentinel page reserved (probe only, not run as a change toxmem.rs). The existing tests do not see it because the fallback test asks for 128 GiB, which is refused without the search. My own run does not cover this path (see Not covered).git merge-tree pr2856 pr3154: conflict inmodules/xmem.rs, 4 blocks (the two insertions afteraddress_range, theVirtualAlloc2call twice, the start ofmod tests). By reading, not run: merged, a request the held range cannot place goes to this PR's 37-bit attempt with the window fully covered and the sentinel page free, which is blocker 2's hanging layout; and #3154 places CPU-only requests in the held range first, while this PR's test expects a CPU-only top-down reservation above 2^37. I did not re-run the merge-tree.Review
LowestStartingAddresskeeps the caller's floor, so an out-of-directory 128 GiB reservation takes the whole mappable window (raise it toGPU_DIRECTORY_ENDon retry); anddirectory_covered(xmem.rs:213) leaves out theat >= 4 GiBcheck, so a 32-bit graphics reservation logstruealthoughmemory.rs:295rejects pages below0x1_0000.d3d12/docs/switches.mdneeds no regeneration. The behaviour change is always on for graphics reservations (flags & 2 != 0, no base address). CPU-only andADDRESS_32BITreservations keep their ranges (the tests check both).parameterand re-points it at the samerequirements, which is still alive. Only the upper bound changes. It runs only whenconstrained(no caller base) and the first range was narrower than the console's. A first failure leaves nothing reserved. Thetracing::warn!fires for any first-call failure, including a commit that fails for lack of memory, so "37-bit reservation refused" says slightly more than is known (cosmetic).GPU_DIRECTORY_END = 2^37 - 64 KiBmatches KelboLive's reading of the empty last directory page (memory.rs:295,:627,emit/shader.rs:127). M3 and M5 show the tests hold the bound.docs/d3d12_vulkan.mdord3d12/docs/findings.mdthat describes this reservation range, so no stale statement.Not covered
Verdict
FAIL (blocked, do not merge as is). In my run the code compiled, 250/0/2 passed in one parallel run, and 5 of 5 mutations were killed. But three measured blockers on this head are open and unanswered: the parallel flake of the two new tests (8/30 and 6/20, KelboLive), the possible hang of the fallback when the directory window is full (2 of 2, Kal0s-design, unrecoverable without a reboot), and the 4-block conflict in
xmem.rswith #3154. The in-game runs on this head do not clear them, since none hit the fallback. Re-check after the author serializes or moves the tests, reserves the sentinel page (or otherwise avoids the hang), and settles the order with #3154.AI-assisted (Claude Code), models: Claude Opus 5.5 (checker), separate Claude Opus 5.5 judge.
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-03T07:01:09Z.
This pull request has a merge conflict with current
main(d9b618f10), so it can't be run in game or merged as it is. Could you merge the latestmaininto it (or rebase onto it) and resolve the conflict? Once the head is updated, the in-game gate run can be done on the new head.AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-03T10:23:10Z.
Estado de la rebasada: no es mecánica, y el motivo es que el conflicto es de contenido en la lógica de colocación de memoria
Medido al intentarla sobre
d9b618f10:Los otros tres bloques son del mismo tipo: los dos lados han tocado la misma función y cada uno ha añadido su parte.
Y por eso no la rebaso yo:
in_title_rangedecide dónde se reserva la memoria del título — si elijo mal, el juego reserva en un sitio que no es y el fallo aparece como un cuelgue o una lectura mala, no como un test rojo. No hay test que cubra «la reserva fue al sitio correcto» sin el juego (por eso esta PR trae los suyos, y no puedo correrlos contra el título).Lo que sí está medido de esta PR: toca un solo fichero (
xmem.rs) y estaba limpia de conflicto hasta quemainmovió la misma función. O sea que es de las que se rebasan en veinte minutos leyendo los dos lados — pero leyendo, no con un script.Y el detalle que le sirve a quien la rebase: el bloque de L99 no es un añadido, es la misma función con dos versiones del comentario y del bucle — así que la resolución es comparar las dos implementaciones de
in_title_rangey quedarse con la que tenga las dos ideas, no con una de las dos.Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-03T18:02:32Z.
Thanks for the work on this. This pull request has a merge conflict with the current
mainand has had no new commit, comment or review for more than 5 hours, so I am closing it to keep the list of open pull requests manageable. This is not a judgement of the change. Whenever you like, merge the latestmaininto your branch, resolve the conflict, and reopen it (or open a new pull request that links this one). Please re-run the relevant tests on the new head; a reviewer will look at it when time allows, with no guarantee of timing or outcome.Generated by Claude Code
Pull request closed