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

Open
github-bot wants to merge 2 commits from github-bot/gh-2799 into main AGit
Owner

@⁠MacieGx on GitHub · 2026-11-26 13:50 UTC · original
MacieGx:d3d12x/outside-buffers → main · +356 −10 · 5 files · 2 commits · open

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** on GitHub · 2026-11-26 13:50 UTC · [original](https://github.com/xcl-dev/xcl/pull/2799) `MacieGx:d3d12x/outside-buffers` → `main` · +356 −10 · 5 files · 2 commits · open 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](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]>
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 (#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 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 13:54:45 +00:00
Author
Owner

@⁠ettehn on GitHub · 2026-11-26 13:59 UTC · original

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.

**@⁠ettehn** on GitHub · 2026-11-26 13:59 UTC · [original](https://github.com/xcl-dev/xcl/pull/2799#issuecomment-7194111670) 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: ```text 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.
Author
Owner

@⁠Aniseto on GitHub · 2026-11-26 13:59 UTC · original

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.

**@⁠Aniseto** on GitHub · 2026-11-26 13:59 UTC · [original](https://github.com/xcl-dev/xcl/pull/2799#issuecomment-7194129273) 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.
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/2799/head:github-bot/gh-2799'
git switch 'github-bot/gh-2799'

Merge

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