Repository navigation
Description
The open item in HANDOFF ("memory the GPU does not see … shaders get empty V#s") and the window switch that multiplies DXC time look like one memory layout with two symptoms. I have a working branch for both (PR to follow, linked below) and would like to know whether it fits how you want memory to go.
Why the pages in the 6 GB reservation are invisible (main @ 956a476)
The title gets 11.5 GiB of GPU-visible sparse space (windows 0–2 minus desc_range).
AllocateTitlePhysicalPagesreserves a home for every page inside those windows (kernelx.rs:866): ~5.3 GiB for the retail title.- The title's own 6 GB reservation then gets no contiguous sparse range (
sparse_reserve,uma.rs:271) and falls through to Windows memory (kernelx.rs:231/238). map_pagesonto that reservation copies each page there and decommits the home's tiles (move_home_away);sparse::committedruns only for sparse targets (kernelx.rs:973-987), so nothing is mapped for the GPU.buffer_viewfinds no UMA buffer and writes an empty V# (real.rs:1009,1500).
A page costs window space twice: its home and where it is mapped.
What the branch does
Stage 0 – say so in the log. Reservations that end up outside the windows (≥ 64 MiB or 64K pages) and physical pages mapped outside them are counted, logged once past 1 GB and every time with XCL_TRACE_MEM. XCL_SPARSE_RESERVE_MB=n (off by default) routes plain reservations of n MB or more to sparse_reserve.
Stage 1 – homes take no GPU address space. A home is a CPU reservation per allocation, committed only while a page is there; page numbers come from their own index space. MapTitlePhysicalPages with no address gets a sparse range of its own, given back when unmapped. With ~5.7 GB of homes gone from the windows, a 6 GiB reservation fits (unit test with those sizes).
Stage 2 – memory windows from the descriptor heap. Window k is a raw UAV at a fixed slot of the shared shader-visible heap; each access is
RWByteAddressBuffer m = ResourceDescriptorHeap[NonUniformResourceIndex(MEM_HEAP_BASE + (xcl_w < N ? xcl_w : 0))];instead of a switch (xcl_w) over root UAVs u2..u5. xcl_w is computed as today, so #138's carry still applies. On by default when there is more than one window; XCL_HEAP_WINDOWS=0 or a failed view creation goes back to the switch. The flag is part of the window count, so translation and DXIL cache keys change.
Measurements (RTX 3090, driver 616.92; AMD not run)
-
MaxGPUVirtualAddressBitsPerResource= 40. -
One flat aperture does not work on NVIDIA. A structured UAV of 2048-byte rows over a 16 GiB reserved buffer wraps
row × strideat 2^32 through a root UAV; a heap view's byte size is truncated to 32 bits. So I dropped the single-aperture plan I had sketched. -
Root UAV at VA + 4 GiB, tile mappings above 4 GiB: fine.
CopyBufferRegionwith a source offset ≥ 4 GiB on a reserved buffer wraps. -
A raw heap view of 4 GiB − 64 KiB reaches its top tile; with the debug layer on, view creation gives no messages. (The 2^27-element texel cap does not apply to raw views here.)
-
A 1 GiB raw view with
FirstElementat 5 GiB inside a 16 GiB reserved buffer reads and writes the right tile – a route to more than four windows later, not used yet. -
Compile time, synthetic 19 601-instruction CS, median of 3:
DXC DXIL 1 window 12.1 s 190 KB 4 windows, switch (main) 150.7 s 512 KB 4 windows, heap 12.5 s 238 KB Driver compile medians were 0.06–0.18 s because of the driver cache; first-run maxima 15.5 / 31.6 / 6.2 s.
Tests
New GPU tests: gpu_memory_windows_from_the_heap (same loads/stores/atomics across windows as gpu_memory_windows_above_4_gib, through the heap) and gpu_raw_window_view_reaches_its_top; aperture experiments in gpu/recomp/aperture_tests.rs (the compile-time one is #[ignore]). Full cargo test --workspace on the 3090: main 536 lib passed / 19 ignored, branch 541 / 21, all integration tests pass on both.
Questions
- Could you run
gpu_memory_windows_from_the_heapandgpu_raw_window_view_reaches_its_topon the RX 9070?NonUniformResourceIndexon divergent flat addresses may be a waterfall loop on AMD; the switch was one too. - Anything about window 3 (
OpenExistingHeapFromAddress, coherent) that rules out a heap view of it? - I haven't hooked
VirtualAlloc2; if the title reserves through it, Stage 0 will not see it.
AI-assisted (Claude); tests and measurements were run locally on an RTX 3090 as stated.
Activity
theaustinayers commentedon Nov 23, 2026
ryosen0 commentedon Nov 23, 2026
Reviewed the fork (modified-build and retail-first-screens) and ran both locally. Two data points.
modified-build / retail-first-screens on AMD + RTX 3060 Ti (9800X3D, 1.0.2.1, XCL_NETWORK=0): no presents, deterministic
0xc0000005write to address0x0atgame_scarlett_master.exe+0x2215c35at ~88 s cold / ~97 s warm (modified-build), ~106 s (retail-first-screens).0x2215c35is amov dword ptr [0], 0; int3guard taken when a global callback slot atexe+0x71bc348reads 0 - an initialization path that did not complete, not the depth/rect-list work itself. Neither the mirror log lines nor the rect-list expansion line appear before the stop on this machine, so the stop is upstream of them. The menus report in #195 (RTX 5090) does not reproduce here; the difference looks GPU/driver-side or a race, not the patch set.Independent trace of the +0x344196 chain (our own probes on 956a476): device #25
GetResourceAllocationInfois called from+0x344188; if the returned size's high dword is non-zero the title traps at+0x344196. The bad size comes fromxg::Texture::newrejecting format 118 -element()has no entry for 116..=119. With116..=119 => (2, 1)added, that assert disappears and the next stop is+0x14a6390(~35 s warm): a call to+0x34beb0validates a format-capability record for format 0x76 (118) through+0x2478140and asserts when the check returns 0. No placed resource with format 118 is ever created in that run (808 placements traced), so the failing path is the capability record rather than resource creation - which matches theCheckFeatureSupport/format-family direction rather than a placement fix.Not opening a PR from your branch; the above is from our own instrumented runs. Happy to compare notes on
+0x14a6390if it shows up on your setup past the menus.ivall commentedon Nov 23, 2026
Main changed a lot of this in 38b05b7. Physical pages mapped into the title's plain reservations are only reserved and committed on first CPU access (
kernelx/lazy.rs). Homes are never doubled for those, and GPU-owned textures placed at title addresses are tiled resources on 64 KiB video-memory pages (vram.rs). The retail game reaches its first menu at ~19 GB of commit (RX 9070). Still open, and your branch targets exactly this: buffers and buffer views in memory outside unified memory. Views get an empty V#, and index / vertex buffers are mirrored per draw (#195). The windowswitchcosts too: measured, it doubles DXC and driver time. Memory windows from the descriptor heap fit where this should go - a PR on current main is welcome.