Skip to content

D3D12.X: a title buffer may run on into the next sparse window - #3176

Open
Pipodi wants to merge 1 commit into
xcl-dev:mainfrom
Pipodi:nvdev-buffer-next-window
Open

Pipodi wants to merge 1 commit into
xcl-dev:mainfrom
Pipodi:nvdev-buffer-next-window

Conversation

@Pipodi

@Pipodi Pipodi commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

A buffer that a title places with CreatePlacedResourceX can run past the end of one sparse window and into the next. One did in a title run on a tree from before #2886, which keeps a reservation of one window or less inside a single window: 0x546000 bytes at 0x5fffd0000, going from sparse window 1 into window 2. This has not been reproduced on 54225f5, where sparse_reserve still places across windows when no single window has room. title_buffer_window returned None as soon as a buffer passed the end of its window. So place_at_title_address gave up, the buffer fell back to a committed DEFAULT buffer, and every view of it was an empty V#.

The console gives CreatePlacedResourceX a plain GPU virtual address. XCL's 4 GiB windows have no console counterpart. A title reservation can already straddle sparse windows (sparse_reserve falls back to placing across windows), and sparse::place_buffer checks the windows of both ends and maps the tiles of each. So a buffer whose windows k..=last are all sparse is now accepted. A run into a window that is not sparse (a view, committed or empty window) is still refused.

What is in it

  • crates/xcl/src/hle/d3d12x/real.rs: title_buffer_window accepts a buffer over a sparse window's end when every window it reaches is sparse.
  • Same file: new test gpu_view_tests::a_buffer_may_run_on_into_the_next_sparse_window. Without the fix it fails (left None, right Some((1, true))). The existing assertion "across a sparse window's end" now expects Some((0, true)) instead of None.

Tested

  • NVIDIA GeForce RTX 4090 (driver 621.40), Intel Core i9-13900K, Windows 11 26H2 (10.0.26300.9711), rustc 1.100.0. Tests are debug builds, the smoke runs are release builds.
  • Each run was made on this PR's head 20fd55c and on its base, nvidia-dev 54225f5.
  • cargo test -p xcl --lib --no-fail-fast -- --test-threads=2: the test binary aborted with exit code 0x7C10003 on both trees, after 1385 ok on this PR and 1384 on the base. This abort is already reported on nvidia-dev in [OFFICIAL] Merge queue: which PRs can be merged next, and how to claim a merge check #3041 (comment). The 393 tests that had not run were then run one at a time (--exact <name> --test-threads=1): 390 passed, 3 ignored, 0 failed, on both trees.
  • lib totals: this PR 1775 passed, 4 failed, 28 ignored; base 1774 passed, 4 failed, 28 ignored. The difference is the new test.
  • The same 4 tests fail on both trees: title_textures::tests::placed_title_textures_share_vram_and_preserve_pixels, stream_recheck_keeps_the_whole_upload_baseline_over_partial_uploads, stream_recheck_partial_upload_without_an_entry_queues_a_whole_upload, stream_recheck_schedule_catches_late_writes_and_resets_milestones.
  • cargo test --workspace with --test-threads=4; the other test binaries kept running after the lib aborted (exact cargo flags not recorded). All test binaries other than the lib: 132 passed, 0 failed, 20 ignored, on both trees.
  • SKIPPED, the same on both trees: 26 in the lib (mostly no wave64, plus three f16/f32 forms refused for gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426, no heap windows and a driver-cache test that needs Developer Mode), and 1 outside it (heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows).

Regression run
Both runs were made on the same retail title for 60 s with XCL_PREPARE=0 and the same scripted presses. The first block is from main b937fba (same title, 60 s, XCL_PREPARE=0, same presses, made the same day for #1448); the second is from nvidia-dev 54225f5, the base of this PR, for a like-for-like comparison; the third is this PR's head.

xcl-smoke v1
commit: b937fbab2964b2c142f5d13662b91b00f99b9848
gpu: NVIDIA GeForce RTX 4090
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1522 (PresentX 1522)
presents per 2 s (last 3): 60 60 61
device removals: 0
crashes: 0
peak commit: 20102 MB
xcl-smoke v1
commit: 54225f5884a94cd23b7aab3f703a7c975070aa77
gpu: NVIDIA GeForce RTX 4090
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1656 (PresentX 1656)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 17955 MB
xcl-smoke v1
commit: 20fd55ccf43a7b0a95d9f3a48d75cc06367eb678
gpu: NVIDIA GeForce RTX 4090
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1625 (PresentX 1625)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 17957 MB

Not tested

  • AMD and other GPUs.
  • Other titles' paths.
  • Whether the 60 s smoke reaches this code.
  • An earlier build of this change, on a tree from before Memory: keep single-window sparse_reserve allocations inside one window #2886, placed the straddling buffer (its views were no longer empty). That run later hit a GPU hang (an MMU fault at about 285 s). A repeat run of the same build did not hang, so it is not known whether the change caused the hang. That earlier build is not this head commit.
  • The main block comes from a tree 341 commits behind nvidia-dev; the like-for-like comparison is the nvidia-dev block.

AI use

  • Claude Code, Claude Opus 5.5: wrote the code, the test and this description.
  • Claude Sonnet 5.5 subagents: made the test and smoke runs, and reviewed the change.

CreatePlacedResourceX of a buffer at 0x5fffd0000 (0x546000 bytes) ran from
sparse window 1 into window 2. title_buffer_window returned None once the
buffer passed its window's end, so place_at_title_address gave up and the
buffer fell back to a committed DEFAULT buffer: every view of it was an
empty V#, found in a title run by tracing the placed buffers.

A title's reservations may straddle sparse windows (sparse_reserve), shaders
already carry across windows, and sparse::place_buffer checks the windows of
both ends and maps the tiles of each. So accept a buffer whose windows
k..=last are all sparse; a run into a window that is not sparse stays refused.

The test a_buffer_may_run_on_into_the_next_sparse_window failed without this
(left None, right Some((1, true))); the old assertion that expected None across
a sparse window's end now expects Some((0, true)).

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

Copy link
Copy Markdown
Contributor

On RTX 5070 12 GB / NVIDIA 616.92, I verified that a single placed buffer returns the expected bytes on both sides of the sparse window 1 → 2 boundary at head 20fd55ccf43a7b0a95d9f3a48d75cc06367eb678.

The native fixture used XCL's actual 4 GiB sparse windows, with the boundary at 0x600000000. I committed the adjacent 64 KiB CPU tiles and filled them with different deterministic patterns. The fixture placed three resources through the production place_at_title_address path, supplied the two tiles' dirty pages to sparse::before_execute, and copied bytes from the resulting D3D12 resources into fenced readback buffers.

Readback Expected bytes checked Mismatches
Single-window control, last tile of window 1 65,536 0
Single-window control, first tile of window 2 65,536 0
Straddling buffer, window 1 portion 65,408 0
Same buffer, window 2 portion 65,408 0

The crossing placement began 128 bytes into the first tile and ended 128 bytes before the end of the second. XCL recorded a 128-byte native buffer offset, which the readback used. Two fresh processes produced identical counts, with zero skips and a healthy device in both. This exercises normal sparse placement and data upload for a known address. It did not exercise automatic reservation under fragmentation, shader V# sampling, or the retail sequence mentioned in the description.

AI use: OpenAI Codex (GPT-6) prepared the test-only fixture, ran the native checks and wrote this report.

@throny

throny commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

merge-check claim
head: 20fd55c

@thehollowedone

thehollowedone commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

merge-check
base: 54225f5
head: 20fd55c
merge: clean
build: cargo build --offline --locked --workspace -> ok on the head
tests: cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4 --skip uma_driver::tests::a_refused_gpu_upload_segment_becomes_custom --skip uma_driver::tests::mixed_window_keeps_its_bytes_and_the_gpu_sees_every_segment --skip uma_driver::tests::failed_restore_stops_before_importing_an_unbacked_window --skip two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs -> head 1,906 passed, 1 failed, 48 ignored; base 1,905 passed, 1 failed, 48 ignored, across 40 binaries each. The same console_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk failed with DXIL not compiled yet on both. Both printed 26 SKIPPED notices (21 no wave64, 3 translation refusals, 2 no heap windows); these are not coverage. The extra head pass is this PR's new boundary test.
review: no finding in the one-file diff or its placement path. The head's sole parent is the current nvidia-dev commit. title_buffer_window checks the inclusive last byte and all crossed window kinds; the existing sparse::place_buffer maps tiles by their absolute addresses across windows. The new acceptance applies only when every crossed window is sparse. The independent native readback verifies the production placement's bytes on both sides of a boundary.
performance: the additional window-kind walk runs only when a buffer crosses its starting window. No frame-time or title placement rate was measured here; the author's paired 60 s smoke blocks are in the PR description.
verdict: safe to merge
hardware / tool and model: RTX 3080 Ti / 621.35, Ryzen 7 9800X3D, Windows 11 build 26300, rustc 1.99.1 MSVC, debug. Codex (GPT-6.2 Sol) reviewed the change and ran the build and paired suites; Codex (GPT-6.2 Astra) independently traced the sparse placement path.

Tested: On the clean head, cargo test --offline --locked -p xcl --lib gpu_view_tests -- --test-threads=1 passed 4/4, including the new boundary selection test; these are helper tests, not native readbacks. My first whole-suite attempt stopped advancing in two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs; I interrupted that incomplete run and excluded that test in both completed runs. The three uma_driver exclusions are documented branch-level fail-stop cases.

Not tested: a title run at this head, automatic cross-window reservation under fragmentation, shader reads from the resulting view, AMD/Intel, and the four excluded tests.

@throny

throny commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

merge-check
base: 54225f5 (nvidia-dev)
head: 20fd55c
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 (no --skip) on nvidia-dev 54225f5 + #3187 + this PR -> 1905 passed, 6 failed, 48 ignored, 27 SKIPPED lines. #3187 is in the tree because without it the lib test binary is terminated on this card; the same tree without this PR gave 1904 passed and the same 6 failures (placed_title_textures_share_vram_and_preserve_pixels, three stream_recheck_* tests, two vram::tests). So: one more test passes, nothing new fails.
review: no blocking finding; all hunks read. Before, a title buffer that ran past the end of its sparse window was refused and fell back to a committed buffer whose views were empty. Now it is accepted when the start window and every window up to the last one it touches are sparse; the end is computed with a checked add, a buffer over more than two windows works the same way, and a run into a view window, a committed window or no window is still refused. The placement code already checked the windows of both ends and maps tile by tile. Minor: the doc comment above the function still describes the old rule, and an older size sum a few lines on could still overflow for an absurd width (not new). Not verified: every other user of a placed buffer's range; the indirect-argument path refuses a range that crosses.
performance: none; no translator source.
verdict: safe to merge
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Triage (#1607) – head 20fd55c

No open or merged PR makes the same change (#2886, merged, keeps single-window sparse_reserve allocations inside one window; this lets a placed buffer span adjacent sparse windows).
title_buffer_window now accepts a buffer over a sparse window's end when every window it reaches is sparse; sparse::place_buffer checks both ends with window_index and maps tiles per address, so a multi-window buffer is handled there. The existing assertion is flipped and a new test covers the next-window and non-sparse cases. No problems found in the diff.
Recommendation: keep open.

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

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

merge-check
base: 493dbd3
head: 20fd55c
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2901 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: read the whole diff (+20/-2). title_buffer_window now accepts a buffer that runs past a sparse window's end when every window it reaches is sparse. Findings: (1) Anything bound by GPU address still stops at the window end. Each window is its own buffer on the PC. pc_va_in (list_x.rs ~5745) translates an address into window k's resource only, and view_bytes (~5755) says it outright: a view across a window's end runs into addresses nothing maps. Vertex and index buffers get clamped there, so the part in the next window reads as zeros. Root CBV / SRV / UAV and indirect arguments that cross go through the same translation (unverified each). Before this PR such a buffer fell back to a committed buffer, so this trades a slower whole buffer for one whose second part reads as zeros when bound by address. The flipped assertion hides that limit, and no test binds one by address. The MMU fault at 285 s the description mentions may be this (unverified). (2) The doc comment above title_buffer_window (real.rs ~1764-1767) still says buffers may not cross a window. (3) The PR is based on nvidia-dev 54225f5, far behind main, but merges cleanly. Its red CI test, kernelx::tests::an_address_keeps_the_page_the_title_mapped_there_last, frees a reservation and expects mapping there to fail, which a parallel test can race; it isn't touched here. Fine: the windows are adjacent with no gaps and share one write-watched reservation, place_buffer makes one reserved resource per buffer and maps tiles by absolute address, and Map, copies and resource-based views are right. The new test fails without the change. Since #2886 a buffer crosses windows only when no single window has room, so the smoke run doesn't reach it; no smoke run here.
performance: no smoke run (the default path doesn't reach this change); not measured.
verdict: not yet: a buffer that spans two sparse windows is still bound by GPU address into one window's resource (pc_va_in / view_bytes), so its part in the next window reads as zeros where main fell back to a committed buffer (finding 1); handle address-based bindings across the boundary, or keep the fallback for buffers that are bound by address
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5

AI-written and posted by Foniass without a human check of each point.

@github-actions github-actions Bot added area:d3d12 D3D12.X runtime, command lists, resources, sparse memory gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) labels Dec 1, 2026
@Pipodi Pipodi closed this Dec 1, 2026
@Pipodi Pipodi reopened this Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:d3d12 D3D12.X runtime, command lists, resources, sparse memory gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants