Retail black image: physical-page homes use up the GPU windows; memory windows from the descriptor heap (no per-access switch) #186

Closed
opened 2026-11-26 04:14:18 +00:00 by github-bot · 3 comments
Owner

@⁠RemingtonWilcox on GitHub · 2026-11-23 19:34 UTC · original

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).

  1. AllocateTitlePhysicalPages reserves a home for every page inside those windows (kernelx.rs:866): ~5.3 GiB for the retail title.
  2. 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).
  3. map_pages onto that reservation copies each page there and decommits the home's tiles (move_home_away); sparse::committed runs only for sparse targets (kernelx.rs:973-987), so nothing is mapped for the GPU.
  4. buffer_view finds 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 × stride at 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. CopyBufferRegion with 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 FirstElement at 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_heap and gpu_raw_window_view_reaches_its_top on the RX 9070? NonUniformResourceIndex on 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.

**@⁠RemingtonWilcox** on GitHub · 2026-11-23 19:34 UTC · [original](https://github.com/xcl-dev/xcl/issues/186) 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`). 1. `AllocateTitlePhysicalPages` reserves a **home** for every page inside those windows (`kernelx.rs:866`): ~5.3 GiB for the retail title. 2. 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`). 3. `map_pages` onto that reservation copies each page there and decommits the home's tiles (`move_home_away`); `sparse::committed` runs only for sparse targets (`kernelx.rs:973-987`), so nothing is mapped for the GPU. 4. `buffer_view` finds 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 ```hlsl 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 × stride` at 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. `CopyBufferRegion` with 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 `FirstElement` at 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_heap` and `gpu_raw_window_view_reaches_its_top` on the RX 9070? `NonUniformResourceIndex` on 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._
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:14:19 +00:00
Author
Owner

@⁠theaustinayers on GitHub · 2026-11-23 19:39 UTC · original

image I am working on a branch that appears to be working https://github.com/theaustinayers/xcl
**@⁠theaustinayers** on GitHub · 2026-11-23 19:39 UTC · [original](https://github.com/xcl-dev/xcl/issues/186#issuecomment-7111919618) <img width="1290" height="750" alt="image" src="https://github.com/user-attachments/assets/ab7dbfb7-3588-4362-801c-8935675b3f0c" /> I am working on a branch that appears to be working https://github.com/theaustinayers/xcl
Author
Owner

@⁠ryosen0 on GitHub · 2026-11-23 20:38 UTC · original

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 0xc0000005 write to address 0x0 at game_scarlett_master.exe+0x2215c35 at ~88 s cold / ~97 s warm (modified-build), ~106 s (retail-first-screens). 0x2215c35 is a mov dword ptr [0], 0; int3 guard taken when a global callback slot at exe+0x71bc348 reads 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 GetResourceAllocationInfo is called from +0x344188; if the returned size's high dword is non-zero the title traps at +0x344196. The bad size comes from xg::Texture::new rejecting format 118 - element() has no entry for 116..=119. With 116..=119 => (2, 1) added, that assert disappears and the next stop is +0x14a6390 (~35 s warm): a call to +0x34beb0 validates a format-capability record for format 0x76 (118) through +0x2478140 and 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 the CheckFeatureSupport/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 +0x14a6390 if it shows up on your setup past the menus.

**@⁠ryosen0** on GitHub · 2026-11-23 20:38 UTC · [original](https://github.com/xcl-dev/xcl/issues/186#issuecomment-7113349323) 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 `0xc0000005` write to address `0x0` at `game_scarlett_master.exe+0x2215c35` at ~88 s cold / ~97 s warm (modified-build), ~106 s (retail-first-screens). `0x2215c35` is a `mov dword ptr [0], 0; int3` guard taken when a global callback slot at `exe+0x71bc348` reads 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 `GetResourceAllocationInfo` is called from `+0x344188`; if the returned size's high dword is non-zero the title traps at `+0x344196`. The bad size comes from `xg::Texture::new` rejecting format 118 - `element()` has no entry for 116..=119. With `116..=119 => (2, 1)` added, that assert disappears and the next stop is `+0x14a6390` (~35 s warm): a call to `+0x34beb0` validates a format-capability record for format 0x76 (118) through `+0x2478140` and 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 the `CheckFeatureSupport`/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 `+0x14a6390` if it shows up on your setup past the menus.
Author
Owner

@⁠ivall on GitHub · 2026-11-23 20:58 UTC · original

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 window switch costs 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.

**@⁠ivall** on GitHub · 2026-11-23 20:58 UTC · [original](https://github.com/xcl-dev/xcl/issues/186#issuecomment-7113813884) 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 window `switch` costs 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.
This discussion has been locked. Commenting is limited to contributors.
No description provided.