Skip to content

D3D12.X: GPU-only buffers placed outside the memory windows live in them - #2799

Open
MacieGx wants to merge 2 commits into
xcl-dev:mainfrom
MacieGx:d3d12x/outside-buffers
Open

MacieGx wants to merge 2 commits into
xcl-dev:mainfrom
MacieGx:d3d12x/outside-buffers

Conversation

@MacieGx

@MacieGx MacieGx commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Stacked on #2798; only the top commit belongs here.

A buffer the title places with CreatePlacedResourceX outside every memory window became a committed resource of its own. Every view of it got an empty V# ("not in UMA"), so shaders read zeros and their writes were dropped. The newer retail title places all its compute buffers outside the windows, in plain reservations above its GPU views: light, ray and tile lists, BVH data, 128+ buffers, about 580 MB. Its final gather therefore had an empty tile list and wrote nothing, and its targets kept other targets' bytes.

Such a buffer, at an address with no committed CPU pages (so only the GPU uses it), now gets an address in the sparse windows. It is placed lazily (previous PR), and:

  • its views name that address;
  • root CBV / SRV / UAV addresses into it are rewritten to it;
  • it gets video memory when it is first used: when a draw or dispatch names it (a root address, or a buffer V# in the first 64 slots of a bound table), or when a copy or an ExecuteIndirect uses it.

A range with committed pages is placed as before. Part of #505.

What is in it

  • crates/xcl/src/hle/d3d12x/real.rs: place_outside_buffer, has_cpu_pages, the title address -> window address map (dropped on the buffer's release), use_buffer; tests of the page check and the address map.
  • crates/xcl/src/hle/d3d12x/device_x.rs: create_placed_resource_x tries it after place_at_title_address.
  • crates/xcl/src/hle/d3d12x/bind.rs: outside_buffers_in_use in bind_abi (root addresses rewritten; buffers named by the root addresses and the tables' V#s get their memory), use_buffer for ExecuteIndirect's argument and count buffers; tests of table_addresses and the root address rewrite.
  • crates/xcl/src/hle/d3d12x/list_x.rs: use_buffer for CopyBufferRegion.
  • crates/xcl/src/hle/d3d12x/sparse.rs: lazy_pending.

Tested

  • NVIDIA GeForce RTX 5080 16 GB, driver 621.24, Windows 11 Pro 26200, Rust stable MSVC, debug.
  • cargo test -p xcl --lib -- outside_buffer table_addresses root_addresses_in_outside --test-threads=4: 4 passed, 0 failed.
  • cargo test -p xcl --lib -- hle::d3d12x --test-threads=4 (with the logging PR on top): 260 passed, 0 failed, 2 ignored, no SKIPPED lines.
  • NVIDIA GeForce RTX 5080 16 GB (driver 621.24 = 32.0.16.2124), AMD Ryzen 7 5800X3D, 32 GB, Windows 11 Pro 10.0.26200, Rust 1.100.0 stable-x86_64-pc-windows-msvc, release.
  • cargo build --release --workspace && cargo test --release --workspace --no-fail-fast -- --test-threads=4 on 321ada6: 1437 passed, 4 failed, 47 ignored. The 4 failures are gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3 (CreateComputePipelineState: out of memory (0x8007000E)), which fail on main as well. SKIPPED (the same as on main): 21 "no wave64", 3 refused by the per-lane form, heap_window_out_of_memory_falls_back_to_the_switch_form, pso_measurement_compiles_an_exact_synthetic_record.
  • The same logic in a lab tree (an older main + open PRs + lab work, not this branch), in the newer retail title:
    • "empty V#" warnings went from hundreds a run to 0;
    • the final gather's tile list was filled; before, it wrote none of its six outputs;
    • the player character was drawn in gameplay for the first time;
    • 108 buffers / 526 MB were in use 25 s into the world, and 573 of 578 MB by 365 s.
    • It also made the world about 2.7x slower in presents a second (O2 against Q4): the compute passes now do real work. Timestamps put most of that time between the dispatches, not in them; it was not broken down further.

Regression run
main:

xcl-smoke v1
commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb
gpu: NVIDIA GeForce RTX 5080
title: 16b5e5d4
seconds: 60
exit: 0x0
frames shown: 1383 (PresentX 1383)
presents per 2 s (last 3): 35 52 56
device removals: 0
crashes: 0
peak commit: 19703 MB

this PR:

xcl-smoke v1
commit: 321ada6adef2953aeb0f49720b7f929fee1693a9
gpu: NVIDIA GeForce RTX 5080
title: 16b5e5d4
seconds: 60
exit: 0x0
frames shown: 1615 (PresentX 1615)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14458 MB

Not tested

  • This branch in the retail title (only the lab tree above).
  • What these buffers miss: V#s the title writes into memory itself with an outside address, buffer views made by address (CreateShaderResourceView / CBV by GPU address), and V#s past the first 64 slots of a table. They are not rewritten or mapped here, and the lab did not handle them either.
  • The per-draw CPU cost of the table scan, which runs only while some buffer still waits for its memory. It was not measured on its own.
  • AMD and Intel GPUs; tier-1 tiled-resource GPUs, where reading an unmapped tile is undefined.

AI use

  • Claude Code with Claude Opus 5.5: ported the lab's outside buffers onto main, added the CPU-page check, wrote the tests and this description; Claude Opus 5.5 (coordinating) ran the full suite and the regression runs and reviewed the diff.

🤖 Generated with Claude Code

MacieGx and others added 2 commits November 26, 2026 13:42
Preparation for buffers a title places outside the memory windows
(xcl-dev#505), not called yet: `sparse::place_buffer_when(.., lazy)` makes
the reserved resource without tiles and `sparse::use_range(va, len)`
gives the lazily placed buffers there the window's video memory when
a list is about to use an address of them. `place_buffer` is
`place_buffer_when(.., false)` and behaves as before.

The newer retail title places 128+ GPU-only buffers (~580 MB) at
start; in a lab tree that gave them all video memory at once it ran
out of RAM before the world, and lazily it had 108 / 526 MB in use
25 s into the world. `use_range` checks two atomics before it takes
the sparse state's lock, so a call for an address outside every lazy
buffer costs nothing. A lazy buffer released before its first use
leaves the list in `forget_in`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A buffer the title places (CreatePlacedResourceX) outside every memory
window became a committed resource of its own, and every view of it
an empty V#: shaders read zeros and their writes were dropped. The
newer retail title (xcl-dev#505) places all its compute buffers - light, ray
and tile lists, BVH data, 128+ buffers, ~580 MB - in plain
reservations above its GPU views, so its final gather had no tiles
and wrote nothing, and its targets kept other targets' bytes.

Such a buffer, at an address with no committed CPU pages (only the
GPU uses it), now gets an address in the sparse windows, placed
lazily (`sparse::place_buffer_when`): its views name that address,
root CBV / SRV / UAV addresses into it are rewritten to it, and it
gets video memory when a draw or dispatch names it (a root address or
a buffer V# in the first 64 slots of a bound table), a copy or an
ExecuteIndirect uses it. A range with committed pages is placed as
before.

Measured in a lab tree with the same logic (RTX 5080): "empty V#"
warnings went from hundreds to 0, the final gather's tile list was
filled, and 573 of 578 MB of these buffers were in use by 365 s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ettehn

ettehn commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Independent Windows/NVIDIA check of sparse::use_range on 321ada6adef2953aeb0f49720b7f929fee1693a9. The only local change was a synthetic test using the existing reserved-resource fixture. I put two one-tile D3D12 reserved buffers on the lazy list, with an unused tile between them.

  • Touching the gap inside the aggregate bounds left both buffers pending, with zero mapped tiles and fence value 0.
  • Touching four bytes inside the second buffer mapped only that buffer’s tile. The first buffer stayed pending. The mapping queue advanced to fence value 2 and completed it. Repeating the same use left the fence at 2.
  • Forgetting the untouched buffer cleared the pending state without mapping its tile.

Windows 11 build 26200, Ryzen 9 8945HX, RTX 5070 Ti Laptop GPU (12 GB, driver 621.24, device confirmed by DXGI LUID), Rust 1.97.1 MSVC debug:

cargo test --locked --offline -p xcl --lib -j 2 -- first_use_maps_only_the_overlapping_reserved_buffer a_lazy_buffer_gets_its_tiles_at_its_first_use use_range_outside_the_lazy_buffers_does_not_wait_for_the_state outside_buffer_tests root_addresses_in_outside_buffers_name_their_address_in_the_windows table_addresses_follow_the_table_arguments --test-threads=1 --nocapture

7 passed, 0 failed, 0 ignored, no reported skips. This checks mapping and GPU queue completion on the isolated path plus the existing address and table tests. Shader data readback through the alias, the full suite, and a retail title were outside this run.

OpenAI Codex assisted with the synthetic test and verification. The exact model identifier was unavailable in this session.

@Aniseto

Aniseto commented Nov 26, 2026

Copy link
Copy Markdown

Ran the outside-buffer tests at 321ada6:

Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC 14.44.35207, DXC 1.9.2609.5, debug build.

XCL_ADAPTER=nvidia cargo test -p xcl --lib -- outside_buffer table_addresses root_addresses_in_outside --test-threads=4
4 passed; 0 failed; 0 ignored; 1338 filtered out      (exit 0)

All four pass here: the CPU-page check, the title-address-to-window map, the root address rewrite and the descriptor-table address tracking. These are unit tests; I did not run a title with these buffers.

What this adds: the author tested an RTX 5080 (16 GB, same driver) and did the title measurements in a separate lab tree. This is a second Blackwell host with a different DXC version; the thread has no report from another machine.

Not tested: this branch in a retail title, the ~580 MB buffer set described in the PR, AMD and Intel GPUs, tier-1 tiled-resource GPUs, the full workspace suite, a paired smoke run, Wine, release profile, title data.

AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.

@Decodere

Copy link
Copy Markdown
Contributor

Independent RTX 4060 (8 GB) / Windows 11 release verification of PR #2799 at 321ada6adef2953aeb0f49720b7f929fee1693a9 (stacked on PR #2798 1b11d3d54f2380d9a680192a8214246b97fc6ee8; merge-base origin/main b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7). Measurements and targeted test results only; not a full source review.

Setup

  • GPU: NVIDIA GeForce RTX 4060 (8 GB / 7956 MiB reported by D3D12), driver 32.0.16.2114 (NVIDIA 621.14, WDDM 3.2)
  • CPU / RAM / OS: Intel Core i5-11400F (6 cores / 12 threads), 32 GB RAM (31.9 GiB usable), Windows 11 Home 26200
  • Toolchain / caches: rustc 1.100.0 (0ef1bc386 2026-11-09), DXC 1.9.2609.5, release builds, warm DXIL/pipeline caches, quiet machine (zero concurrent builds/tests during timed runs)
  • Workload: Retail workload title: 29640639 via scripts/smoke.ps1 -Seconds 60 (XCL_NETWORK=0 XCL_ACTIVITY=1, default flags, no input)

Targeted RTX 4060 release unit tests (321ada6a)

  • cargo test --release -p xcl --lib table_addresses_follow_the_table_arguments -- --nocapture: 1 passed, 0 failed, 0 ignored (0.00 s, exit 0).
  • cargo test --release -p xcl --lib root_addresses_in_outside_buffers_name_their_address_in_the_windows -- --nocapture: 1 passed, 0 failed, 0 ignored (0.00 s, exit 0).
  • cargo test --release -p xcl --lib cpu_pages_are_found_anywhere_in_the_range -- --nocapture: 1 passed, 0 failed, 0 ignored (0.00 s, exit 0).
  • cargo test --release -p xcl --lib outside_buffer_addresses_keep_their_offset -- --nocapture: 1 passed, 0 failed, 0 ignored (0.00 s, exit 0).
  • cargo test --release -p xcl --lib hle::d3d12x::sparse:: -- --test-threads=4: 19 passed, 0 failed, 1 ignored (0.37 s, early_commit_timing ignored, 0 skipped, exit 0).
  • cargo test --release -p xcl --lib hle::d3d12x::bind:: -- --test-threads=4: 10 passed, 0 failed, 0 ignored (0.30 s, 0 skipped, exit 0).
  • cargo test --release -p xcl --lib hle::d3d12x::device_x:: -- --test-threads=4: 14 passed, 0 failed, 0 ignored (0.19 s, 0 skipped, exit 0).
  • cargo test --release -p xcl --lib hle::d3d12x::list_x:: -- --test-threads=4: 40 passed, 0 failed, 0 ignored (0.66 s, 0 skipped, exit 0).
  • cargo test --release -p xcl --lib hle::d3d12x::real:: -- --test-threads=4: 62 passed, 0 failed, 0 ignored (0.64 s, 0 skipped, exit 0).

Live 8 GB RTX 4060 memory impact (XCL_ACTIVITY=1, 60 s)

Comparing exact parent PR #2798 (1b11d3d5) vs PR #2799 (321ada6a) on the same 8 GB RTX 4060 and retail workload title: 29640639:

Metric (60 s quiet run, MB) Parent #2798 (1b11d3d5) PR #2799 (321ada6a) Delta
Peak process commit 14,019 13,386 -633 MB (-632 MB vs main b49be183)
Peak local VRAM (t ~ 18 s) 6,176 5,610 -566 MB
End local VRAM (t ~ 58 s) 6,115 5,550 -565 MB
End non-local VRAM (t ~ 58 s) 4,685 4,650 -35 MB
target pages / arenas / sparse mapped (t ~ 58 s) 3541 / 401 / 838 3540 / 401 / 838 unchanged
  • Lazy sparse placement of GPU-only outside-window buffers cut steady-state and peak local VRAM by ~565 MB and peak process commit by 633 MB on this 8 GB RTX 4060 right in the first 60 s, while keeping steady 60/2 s pacing (1583 frames shown, 60 60 60, 0 device removals, 0 crashes, exit: 0x0).

Paired 60 s RTX 4060 smoke (b49be183 / 1b11d3d5 vs 321ada6a)

Merge-base origin/main (b49be183):

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1518 (PresentX 1518)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14018 MB

Parent PR #2798 (1b11d3d5):

xcl-smoke v1
commit: 1b11d3d54f2380d9a680192a8214246b97fc6ee8
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1558 (PresentX 1558)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14019 MB

PR #2799 head (321ada6a):

xcl-smoke v1
commit: 321ada6adef2953aeb0f49720b7f929fee1693a9
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1583 (PresentX 1583)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13386 MB

Limits of coverage

  • Full workspace test suite was not re-run on 321ada6a (only all 145 targeted release tests across sparse::, bind::, device_x::, list_x::, and real:: plus paired quiet 60 s smokes).
  • The 60 s no-input menu/intro smoke confirms substantial local VRAM / commit savings (-566 MB / -633 MB) with zero crashes or removals; visual inspection under extended interactive world-load compute dispatches was not performed on this host.
  • Single discrete NVIDIA 8 GB GPU (RTX 4060) on native Windows 11; no AMD, Intel, or Wine/Linux run on this host.

AI use

Ran the targeted release unit tests, paired quiet 60 s smoke runs, and xcl.log memory comparisons with assistance from Google Antigravity (Gemini 4 Neon); all test counts, memory figures, and smoke blocks were extracted directly from cargo test, xcl.log, and scripts/smoke.ps1 outputs.

@safesearch77

Copy link
Copy Markdown

Reviewed 321ada6a against main (8b957bec). Relocating GPU-only CreatePlacedResourceX buffers
outside UMA into lazy sparse-window allocations (place_outside_buffer) is a clean fit for #505,
but tracing OUTSIDE_BUFFERS and sparse::use_range across the rest of the D3D12.X buffer/view and
copy hooks turns up four concrete gaps where lazy outside buffers stay unmapped (0 tiles, reading 0
and dropping writes) or emit empty V#s:

  1. BVH (RAYTRACING_ACCELERATION_STRUCTURE) SRVs neither translate outside_buffer_address nor
    map their lazy sparse tiles — outside_buffers_in_use passes p >> 8 (256x too low) to
    sparse::use_range (real.rs:2320-2331, desc.rs:708-711, bind.rs:1058-1061).

    • The commit message notes #505 places its BVH data in these outside buffers. When the title
      calls CreateShaderResourceView with Dimension == RAYTRACING_ACCELERATION_STRUCTURE
      (pResource == NULL), dev_create_srv_x (real.rs:2322 in 321ada6a) checks
      u.contains(va) without outside_buffer_address(va): if Location is the title's placement
      VA (0x15_...), XCL writes [0; 8] (null BVH descriptor).
    • Even when Location is the sparse-window VA p (e.g. 0x4_8000_0000 from
      GetGPUVirtualAddress), desc::bvh_words(p, true) (gpu/desc.rs:708-711) encodes 256-byte
      units [(p >> 8) as u32, ((p >> 40) as u32 & 0xFF) | (1 << 31), u32::MAX, 0], which has
      d[3] == 0. In outside_buffers_in_use (bind.rs:1058-1061), d[3] >> 30 == 0 && (d[0] | d[1]) != 0 treats that BVH SRSRC as a byte-addressed buffer V# and calls
      sparse::use_range(((d[1] as usize & 0xFFFF) << 32) | d[0] as usize, 1) = p >> 8
      (0x0480_0000, outside every sparse window), so a table-bound lazy BVH buffer never gets its
      tiles mapped. Detecting Scarlett BVH descriptors ((d[1] & (1 << 31)) != 0 && d[2] == u32::MAX && d[3] == 0) and shifting back by 8 ((((d[1] as usize & 0xFF) << 40) | ((d[0] as usize) << 8))) recovers p.
  2. By-address CBV, SRV (#70), and UAV (#71) view hooks do not consult
    outside_buffer_address (real.rs:1997-2009, 2446-2478 in 321ada6a).

    • dev_create_cbv_x (real.rs:1998) checks u.contains(va) without
      outside_buffer_address(va), writing [0; 4] for any CBV built from the title's placement
      address.
    • dev_create_srv_at_x and dev_create_uav_at_x (device slots #70 / #71, real.rs:2446-2478,
      which #505 uses to build buffer views directly from a 64-bit GPU VA at view + 0x28) pass
      raw va straight to buffer_words_at(va, ...) without outside_buffer_address(va), writing
      V#s pointing at 0x15_... outside all windows.
  3. CopyResource / CopyResourceX always skips use_buffer, and ClearUnorderedAccessView*,
    CopyTextureRegion, ResolveQueryData, console_list::close, and VA-based GPU list ops never
    map lazy outside buffers (list_x.rs, real.rs:202, 213, console_list.rs).

    • list_x::copy_resource_x (list_x.rs:4488-4496 in 321ada6a) runs:
      let (dd, sd) = (real::buffer_delta(dst), real::buffer_delta(src));
      if dd == 0 && sd == 0 {
          return pc::<unsafe extern "system" fn(*mut c_void, usize, usize)>(this, PC_COPY_RESOURCE)(this, dst, src);
      }
      Because place_outside_buffer allocates p with 0x1_0000 alignment (real.rs:1522),
      buffer_delta is 0 for every outside buffer, so copy_resource_x always takes the early
      return before reaching copy_buffer_region_x, executing CopyResource against an unmapped
      reserved resource. Calling real::use_buffer(dst); real::use_buffer(src); at the top of
      copy_resource_x fixes whole-buffer copies.
    • Likewise, pc_location (list_x.rs:4226, buffer footprints in CopyTextureRegion),
      clear_uav (list_x.rs:4417, ClearUnorderedAccessViewUint/Float — e.g. zeroing light/tile
      counters before compute), resolve_query_data_x (list_x.rs:4553), and console_list::close
      (console_list.rs:814-868, 889-916) never call use_buffer / outside_buffers_in_use; and
      VA-based command-list methods (FillMemoryWith32/64/128BitValueX, CopyMemoryToMemoryX,
      Write32/64BitValue*X, SetPredicationBufferX) resolve through real::uma_window_buffer /
      real::uma_va_of, which neither translate outside_buffer_address(va) nor call
      sparse::use_range.
  4. outside_buffers_in_use (bind.rs:1052-1064) skips entire < 64-slot tables near the end of
    a committed region and ignores buffer V#s at slot >= 64 (or directly indexed heaps).

    • if !crate::gpu::shader::readable(table, slot * 64) { continue; } skips slots 0..N too
      whenever a valid smaller table sits within 2 KiB of an uncommitted page boundary (checking
      readable(table + slot * k, 16) per slot or clamping to the readable span avoids dropping
      small tables). And any bindless buffer V# indexed at slot >= 64 (or via
      CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED with no Param::Table) never triggers use_range unless
      descriptor creation (dev_create_srv_x / dev_create_uav_x / #70 / #71 / dev_create_cbv_x)
      marks or maps outside buffers when a view of them is created.

Checked with cargo check --workspace --tests (x86_64-pc-windows-gnu) on main (8b957bec) +
321ada6a, plus a pure-CPU rustc --test reproduction of bvh_words(0x4_8000_0000, true) ->
0x0480_0000; no GPU, Wine or Windows run.

AI use: Antigravity (Gemini 4 Carbon High) traced the call graph and ran the host reproduction;
independently verified by Gemini 4 Hydrogen XHigh.

@relativespace2K

Copy link
Copy Markdown

Tested - retail title on native Windows AMD RDNA2, PR head 321ada6adef2953aeb0f49720b7f929fee1693a9 (stacked on #2798 1b11d3d54f2380d9a680192a8214246b97fc6ee8) on main b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7

Tool: OpenCode with DeepSeek V4.1 Flash 1017

  • AMD Radeon RX 6800 XT (16338 MiB), driver 32.0.21045.29003; Ryzen 5 5600, 31.9 GB;
    Windows 11 IoT Enterprise LTSC 26100; release build; DXC 1.9.2602.17.
  • cargo test --release -p xcl --lib -- outside_buffer table_addresses root_addresses_in_outside --test-threads=4:
    4 passed, 0 failed, 0 ignored, 0 skipped, 1338 filtered out.
  • Game: retail title 1.0.2.1, two 600 s runs, XCL_NETWORK=0 XCL_ACTIVITY=1 XCL_FRAME_DUMP=1 XCL_RUN_SECONDS=600, no other XCL_* variables; warm shader/pipeline caches.
run presents peak commit last present empty V# sparse driver compiles
main 1,903 38,002 MB 138.1 s 1 7,445 MB 104 / 1,057 s
PR 1,742 45,965 MB 132.4 s 0 8,017 MB 102 / 2,844 s

The buffer view ... not in UMA - empty V# warning disappears at this head (1 -> 0), and the
sparse windows grow by 572 MB (7,445 -> 8,017 MB on the console-code line), matching the ~580 MB
of outside buffers this PR describes: this title does use the path. The loading stall itself is
unchanged (presentation stops around 132 s; last frame 1,700 against 1,820 on main), so there
is no world or FPS comparison in this window.

The 45,965 MB peak is late and transient: it happens at 527 s, after the stall, while 87 driver
compiles finish (2,653 s of compile time after 140 s); commit is 33,794 MB at 595 s. It is not
growth of the sparse windows. The compile-time comparison is weak because the PR ran second
(40 DXIL misses against 102 on main). No crash, no error, 0 failed pipelines, 0 DXIL failures;
40 mesh refusals on both trees.

Not tested: world/FPS (never reached), NVIDIA/Intel GPUs, full workspace, debug build.

AI use: OpenCode with DeepSeek V4.1 Flash 1017 ran the tests, read the logs and wrote this comment; the figures and warning counts were checked against the run logs.

@gefydev

gefydev commented Nov 27, 2026

Copy link
Copy Markdown
Member

I tested #2799 on top of #2798 with a GTX 1650 (4 GiB) on the retail Series X title used in the #2357 tests. I applied both published patches through 321ada6a to main 2c717a04 without edits and ran main, PR, PR, main. All four runs used equivalent cache seeds, XCL_TEXTURE_LEVEL_PAGES=1, XCL_PREPARE=0, and XCL_FRAME_DUMP=300. I pressed Enter at 120 s of wall time after confirming the profile selector in each run. All four showed the loading artwork.

Run DXGI local near Enter + 30 s (MiB) First OOM (s after Enter) Peak texture-page pools (MiB) Nonblack framebuffer readbacks after Enter
Main 1 5952 53.477, command-list Close 3456 3/5
#2799 1 5385 62.639, CreateHeap (64 MiB) 4352 2/4
#2799 2 5386 60.757, CreateHeap (64 MiB) 4352 3/4
Main 2 5952 73.759, CreateHeap (64 MiB) 3776 3/7

At the common cut, all four runs had 3392 MiB in texture-page pools and 896 MiB in sparse pools. The PR reduced DXGI local usage by 566–567 MiB. An external, read-only snapshot of XCL's sparse bookkeeping found 128 deferred GPU-only buffers with 566.94 MiB of tile-aligned capacity. All 128 were still waiting for their first mapping near Enter + 30 s and just before each PR run's first OOM.

Both PR runs showed the early and later loading artwork in direct framebuffer readbacks. The temporary black frames were also present on main, and the artwork returned in all four runs. The PR runs' first OOM times fell between the two main results. Both PR runs reached 4352 MiB in texture-page pools and 6604 MiB peak DXGI local usage. All four runs ended during loading, before gameplay.

@CharlyRien

Copy link
Copy Markdown
Contributor

We hit the case this PR describes on a retail title running on a recent main. Giving the affected buffers real memory fixes our "skinned characters draw nothing" defect, but giving it to all of them makes the title crash. Details below.

Stack. main 7a649b0e, plus 28 local commits that are not upstream yet (texture alias copies, depth/stencil twins, diagnostics). None of them touch CreatePlacedResourceX for buffers, place_at_title_address or buffer_view. On top of that:

Switches: XCL_HEAP_WINDOWS=1 XCL_UMA_WINDOWS=16 XCL_ALIAS_COPY=1 XCL_PLACE_RETIRE=0 XCL_VIEW_REACH_MB=36 XCL_PREPARE=0 XCL_TWO_PASS_MB=2048 XCL_DEPTH_UAV_TWIN=1. RTX 3090, driver 616.56, Windows 11.

The case is real.

  • Without the port, main writes 128 empty buffer views at load (127 SRVs and 1 UAV). Every one is a buffer created with CreatePlacedResourceX outside every memory window, with its CPU pages reserved but not committed. There are 128 such buffers, 53 distinct sizes from 60 B to 64 MB, about 580 MB in total.
  • Two of them, 50 MB and 25 MB, hold the vertex positions read by the title's meshlet cull for skinned meshes. The cull reads them through view-heap indices in its root constants, so it reads zeros, culls everything, and the characters' bodies are never drawn.

Results with the port

  • Port limited to those 2 buffers (a local size filter): the skinned characters render again, with no crash. Some defects remain on the bodies, still under investigation.
  • All 128 buffers given memory: the title crashes on the CPU 110 to 150 s in. This happened in every run that gave memory to the problem buffers (6 runs), each at a different fault site in the title's own code, on objects in its heap.
    • The crash comes shortly after the title's GPU work on these buffers starts producing data. In one run, 65 of the buffers had their first use in the 1.9 s before the fault.
    • It is not the act of mapping: in the other two runs nearly every buffer had its memory by about 25 s, and the crash still came 100+ s later.
    • It happens with and without the extra use trigger described below, and also after fixing a self-deadlock / use-after-free in use_range (references dropped while the sparse state is held).
    • Bisecting by size (local filter) names one buffer. With 68 of them given memory (the 2 position buffers + half of the rest), the title does not crash. With the same set plus one 64 MB buffer (one per run), it crashes; a run with all 127 buffers except that one is pending.
    • That buffer has no view in a console descriptor heap. Its first use, via a D3D12.X: GPU-only buffers placed outside the memory windows live in them #2799 trigger, comes on the thread that starts the title's first DispatchX with thread dimensions, and 2.2-3.7 s before every fault.
    • Taking that buffer out is not enough on its own: with all 127 other buffers given memory, the title still crashes (123 s). Several buffers are involved.
    • We checked the obvious explanations on a run with all 128 buffers given memory. At every first use, the title had no committed CPU pages over the buffer's original address range, and no CPU page there was committed or written after placement (checked every 2 s). Reused tiles were cleared before use. The title still crashed (141 s).
    • So the content is not stale CPU data or uninitialised memory. The title's CPU appears to consume what the GPU now really produces in these buffers, through a path we have not found yet. Left empty, they read zeros and that GPU work hands the CPU nothing.
    • A capture of one frame with all 128 buffers given memory shows why. The title's GPU-driven compute programs reach the 64 MB buffer both through root descriptors, which the PR rewrites to the new address, and through 64-bit addresses packed into their root constants, which nothing rewrote: 969 dispatches of 3 pipelines in one frame. Those programs read through one address and write with unbounded float min/max atomics through another, so with half the paths real and half reading zeros they computed wrong target addresses. The fault registers held float values.
    • Rewriting the root-constant addresses too (a local opt-in) moves the failure later: about 163 s instead of 110-150 s. It also changes it from a memory fault on corrupted heap objects into an explicit breakpoint in the title's own code. All rewrites matched those three pipelines' pointer slots, and sampling the memory those programs point at found no stored copies of the buffers' original addresses. The title still stops, so some path to these buffers remains that we have not found.

About the PR itself

  • It no longer applies to main. It is based on b49be183, and sparse.rs has changed a great deal since then: placement now goes through place_buffer_in, with a placement lock and a generation check. Cherry-picking D3D12.X: a placed sparse buffer can wait for its tiles until first use #2798 conflicts across the whole file.
  • sparse_alloc fills window 0 first. Today's tree has sparse_alloc_above, which keeps window 0 free for the title's 32-bit memory.
  • The first-use triggers (root addresses, the first 64 table slots, copies, ExecuteIndirect) never see a buffer that a program reaches only through view-heap indices, which is how the cull above reads its positions. Without another trigger those buffers stay without memory and still read zeros. Our port therefore treats making a buffer view (and a CBV) in a console heap as a use, behind an opt-in switch.

For now we keep the port limited to the two position buffers, which fixes the characters. We can share it as a reference for a rebase, together with the follow-up fixes, the size filter and the per-run logs. Giving every outside buffer memory is not safe on this title yet.

AI use: found and written with Claude Code (Claude Opus 5.5), checked and posted by me.

@Eterst

Eterst commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

@CharlyRien thanks for the write-up above. We see what may be the same thing on another machine, and would like to try your limited port.

Our stack: main b94adbe4 + #3089 (with the same LISTS adaptation you describe) + #3442 + #2385, without #2798 / #2799. The settings:

  • XCL_DEVICE_TYPE=lockhart XCL_DEPTH_UAV_TWIN=1 XCL_CS_PSO_WAIT_MS=250 XCL_GFX_PSO_WAIT_MS=250
  • XCL_TEXTURE_MAX=512, so the world fits a 12 GB card (RTX 4070 SUPER, driver 621.40, Windows 10 19045).

What we see: the world loads and renders, then within about 40–500 s of its first frame the title stops. In three runs it was a CPU access violation in the title's own code, each time at a different site:

  • +0x2294954, read at 0xc4;
  • +0x503cfb7, read at 0x10;
  • +0x4e735ed, read at 0xc8.

Each time the pointer the title read through was null, read from an object whose first qword (its vtable) was 0. These objects are in the coherent window at 0xb00000000. With XCL_UMA_DRIVER=0 the title still crashed, earlier and at a fourth site: +0x258c436, reading through a garbage pointer, with the base again in that window. In another run it was a GPU hang (DXGI_ERROR_DEVICE_HUNG). Video memory was under the budget in all four. This matches your description: "each at a different fault site in the title's own code, on objects in its heap". We have not confirmed yet that the 128 outside buffers are involved here; we are looking at the fault sites now.

Could you share the port you mention? That is the hand port of #2798 + #2799, limited by size to the two vertex-position buffers, with your follow-ups: the use_range fix, and a view in a console heap counting as a use. A branch or a patch is fine. We would run it on the same stack and report back here with the crash count and what the bodies look like, on NVIDIA Ada (wave32).

AI use: Claude Code (Claude Opus 5.5) analysed the runs and drafted this comment.

@CharlyRien

Copy link
Copy Markdown
Contributor

Here is our targeted port of #2798 + #2799 (MacieGx), for you to test.

Base: main 91244db (note: not your b94adbe + #3089 + #3442 + #2385 stack; it may need a rebase or a cherry-pick onto it).
Commits, in order (9): #2798 port, #2799 port, "buffer-view use of an outside buffer is an unsafe call", lazy-placement first-use/release fix, "outside buffers take their addresses above window 0", "XCL_OUTSIDE_VIEW_USE=1 counts root addresses in the windows and CBVs as uses", two logging commits, and XCL_OUTSIDE_ONLY_BYTES.

Env that worked for us on the retail title:
XCL_OUTSIDE_VIEW_USE=1 XCL_OUTSIDE_ONLY_BYTES=0x3200000,0x1900000
On our stack it brought the characters' bodies back. It is targeted on purpose: placing all 128 buffers outside the windows crashed the title on our side, through pointers held in root constants. Only buffers of those two sizes are placed.

Not tested: this branch on its own (we run it inside a larger stack), and your GPU (RTX 4070 SUPER). It compiles on current main (cargo check only).

Branch: https://github.com/CharlyRien/xcl/tree/pr/outside-buffers-targeted (head 5777a84).

AI use: found and written with Claude Code (Claude Opus 5.5), checked and posted by me.

@CharlyRien

Copy link
Copy Markdown
Contributor

@MacieGx this and #2798 now conflict with main. On the retail title (RTX 3090) they brought the characters' bodies back for us, in a targeted form: only the two GPU-only buffers of 0x3200000 and 0x1900000 bytes are placed outside the windows (XCL_OUTSIDE_VIEW_USE=1 XCL_OUTSIDE_ONLY_BYTES=0x3200000,0x1900000). Placing all 128 crashed the title, through pointers it keeps in root constants (my note above). That port is rebased onto current main: https://github.com/CharlyRien/xcl/tree/pr/outside-buffers-targeted (9 commits: your two, then our fixes from the review of the port, the lazy first use / release fix, addresses above window 0, root addresses and CBVs counted as uses, logs, and the size filter).

Would you rebase #2798 / #2799 onto current main, or take what you find useful from that branch? I can post a test report on the new head.

AI use: found and written with Claude Code (Claude Opus 5.5), checked and posted by me.

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Triage (#1607) – head 321ada6

Stacked on #2798, and #2801 is stacked on top of it; only commit 321ada6 belongs here. Not a duplicate of #637, which mirrors VB/IB views of buffers that have CPU pages; this PR takes only ranges with no committed pages (has_cpu_pages). Nothing on main places such buffers in the sparse windows. bind_abi now takes the OUTSIDE_BUFFERS mutex for every root address outside the windows, and reads up to 64 V#s per bound table while a lazy buffer is pending, both while recording. Only the first 64 slots of each table are scanned, so a V# further in reaches the GPU before use_range maps it. The PR conflicts with main's restructured sparse.rs.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants