Repository navigation
Conversation
|
Verified on Windows: the crate is green with it, and it adds two tests - measured against
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 ( 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. |
|
Verified by MoonEyes (another person than the author) on head In-game run with the six others of a batch on AI-assisted (Claude Code). |
|
I ran a forced 128 GiB fallback check with 05ca84a merged into edf7d01 (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). |
|
RUN (independent native Windows 10 unit + in-world verification,
MEASURED. AI-assisted: Antigravity. |
KelboLive
left a comment
There was a problem hiding this comment.
The claim verifies in code: MEMORY_PAGES = 1<<21 64 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 pages 0x1_0000..=0x1F_FFFE. A native-Windows probe confirms VirtualAlloc2 accepts HighestEndingAddress = 0x1F_FFFE_FFFF and returns exactly 0x1F_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_0000 and fills [4 GiB, 132 GiB), so the concurrent preference test cannot fit and falls back to 0xffffff0000. Measured 8/30 failures on the head and 6/20 after merging main — CI's plain cargo test will be red roughly a quarter of the time. Please serialize the pair (shared Mutex) or make the big reservation start above GPU_DIRECTORY_END.
Two smaller things:
- The fallback keeps the caller's floor, so an out-of-directory 128 GiB reservation squats on the entire mappable window (the probe shows exactly that). Raising
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_highest correctly fails graphics_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.
VERIFY-2856 — Linux, Fedora 45, Rust 1.98.1 (the pinned toolchain), Wine 11.21, no GPU device, no game filesVerdict: 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 1. What it changes
const GPU_DIRECTORY_END: usize = (1usize << 37) - (64 * 1024);
fn graphics_address_range(flags: u64) -> (usize, usize) {
let (lowest, highest) = address_range(flags);
(lowest, if flags & 2 != 0 { highest.min(GPU_DIRECTORY_END - 1) } else { highest })
}
2. The bound is the sentinel's, and the arithmetic is right
For every one of the eight field values the code has ( 3. The fallback is a retry, not a silent wideninglet (_, fallback_highest) = address_range(flags);
if at.is_null() && constrained && highest < fallback_highest {
tracing::warn!(size, %error, "XMemVirtualAlloc: 37-bit reservation refused; retrying console range ...");
requirements.HighestEndingAddress = fallback_highest as *mut c_void;
...
at = unsafe { VirtualAlloc2(GetCurrentProcess(), base, size, kind, protect, &mut parameter, 1) };
}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. Red and green, run under Wine
The three that fail on both sides are:
5. What I did not check
AI-assisted: MiniMax M3.1 Flash. |
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).