D3D12.X: a placed sparse buffer can wait for its tiles until first use #2798

Open
github-bot wants to merge 1 commit from github-bot/gh-2798 into main AGit
Owner

@⁠MacieGx on GitHub · 2026-11-26 13:50 UTC · original
MacieGx:sparse/lazy-placed-buffers → main · +145 −9 · 1 files · 1 commits · open

A placed sparse buffer can now be made without video memory and get its tiles when a list is about to use one of its addresses. This is preparation with no change in behaviour: nothing places a buffer lazily yet. The next PR uses it for the GPU-only buffers that the newer retail title places outside the memory windows; today those get an empty V#, so their light, ray and tile lists read as empty. Part of #505.

Why lazily: the title places 128 or more such buffers (about 580 MB) at start. In a lab tree that gave all of them video memory at once, the runs ran out of RAM before the world. Placed lazily, 108 buffers / 526 MB were in use 25 s into the world (573 of 578 MB by 365 s in a longer run).

#2539 (open) also changes sparse::place_buffer; whichever lands second rebases. #637 (open) mirrors views of buffers outside UMA from their CPU pages, which these GPU-only buffers do not have.

What is in it

  • crates/xcl/src/hle/d3d12x/sparse.rs:
    • place_buffer_when(.., lazy), with place_buffer = place_buffer_when(.., false) as before;
    • use_range(va, len) maps the waiting buffers in that range, and checks two atomics before it takes the state's lock;
    • State::back_buffer (the tile mapping place_buffer did inline), take_lazy, lazy_bounds;
    • forget_in drops a buffer released before its first use;
    • two tests.

Tested

  • NVIDIA GeForce RTX 5080 16 GB, driver 621.24, Windows 11 Pro 26200, Rust stable MSVC, debug.
  • cargo test -p xcl --lib -- hle::d3d12x::sparse --test-threads=4: 19 passed, 0 failed, 1 ignored (the two new tests among them), 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 1b11d3d: 1433 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.

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: 1b11d3d54f2380d9a680192a8214246b97fc6ee8
gpu: NVIDIA GeForce RTX 5080
title: 16b5e5d4
seconds: 60
exit: 0x0
frames shown: 1617 (PresentX 1617)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14966 MB

Not tested

  • The lazy path in a title: it has no caller in this PR. The lab tree's version of it, with its callers, ran in the newer retail title (runs R1 to O16).
  • AMD and Intel GPUs.

AI use

  • Claude Code with Claude Opus 5.5: ported the lab's lazy placement onto main's sparse state, 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** on GitHub · 2026-11-26 13:50 UTC · [original](https://github.com/xcl-dev/xcl/pull/2798) `MacieGx:sparse/lazy-placed-buffers` → `main` · +145 −9 · 1 files · 1 commits · open A placed sparse buffer can now be made without video memory and get its tiles when a list is about to use one of its addresses. This is preparation with no change in behaviour: nothing places a buffer lazily yet. The next PR uses it for the GPU-only buffers that the newer retail title places outside the memory windows; today those get an empty V#, so their light, ray and tile lists read as empty. Part of #505. Why lazily: the title places 128 or more such buffers (about 580 MB) at start. In a lab tree that gave all of them video memory at once, the runs ran out of RAM before the world. Placed lazily, 108 buffers / 526 MB were in use 25 s into the world (573 of 578 MB by 365 s in a longer run). #2539 (open) also changes `sparse::place_buffer`; whichever lands second rebases. #637 (open) mirrors views of buffers outside UMA from their CPU pages, which these GPU-only buffers do not have. **What is in it** - `crates/xcl/src/hle/d3d12x/sparse.rs`: - `place_buffer_when(.., lazy)`, with `place_buffer` = `place_buffer_when(.., false)` as before; - `use_range(va, len)` maps the waiting buffers in that range, and checks two atomics before it takes the state's lock; - `State::back_buffer` (the tile mapping `place_buffer` did inline), `take_lazy`, `lazy_bounds`; - `forget_in` drops a buffer released before its first use; - two tests. **Tested** - NVIDIA GeForce RTX 5080 16 GB, driver 621.24, Windows 11 Pro 26200, Rust stable MSVC, debug. - `cargo test -p xcl --lib -- hle::d3d12x::sparse --test-threads=4`: 19 passed, 0 failed, 1 ignored (the two new tests among them), 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 `1b11d3d`: 1433 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`. **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: 1b11d3d54f2380d9a680192a8214246b97fc6ee8 gpu: NVIDIA GeForce RTX 5080 title: 16b5e5d4 seconds: 60 exit: 0x0 frames shown: 1617 (PresentX 1617) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14966 MB ``` **Not tested** - The lazy path in a title: it has no caller in this PR. The lab tree's version of it, with its callers, ran in the newer retail title (runs R1 to O16). - AMD and Intel GPUs. **AI use** - Claude Code with Claude Opus 5.5: ported the lab's lazy placement onto `main`'s sparse state, 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](https://claude.com/claude-code)
Preparation for buffers a title places outside the memory windows
(#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 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 13:54:43 +00:00
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2798/head:github-bot/gh-2798'
git switch 'github-bot/gh-2798'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2798'
git switch 'github-bot/gh-2798'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2798'
git switch 'github-bot/gh-2798'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2798'
git switch 'main'
git merge --squash 'github-bot/gh-2798'
git switch 'main'
git merge --ff-only 'github-bot/gh-2798'
git switch 'main'
git merge 'github-bot/gh-2798'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.