GPU: a buffer view left null for lack of a host copy is made again after each submission #3529

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

@⁠Luislariosss on GitHub · 2026-11-27 14:33 UTC · original
Luislariosss:feat/buffer-view-retry → main · +258 −8 · 5 files · 2 commits · open

A buffer SRV or UAV whose host copy did not exist when the title first wrote its record is left null today, and the shader that reads it reads zero with no miss ever counted — the record is never revisited, so the null stays for as long as the title keeps it. descriptor::make_read has handled exactly this for texture views since it landed; this extends the same contract to buffer views.

A view left null for lack of a copy is now noted (descriptor::make_refused) and retried once at the end of every submission (Host::execute), where shadow::find creates the copy of the registered buffer (or a loose window for unregistered memory) and the view is remade from the same record. The regression test drives a refused view end to end: null and noted after a failed make, made after the submission's retry.

Notes for review:

  • A record that can never be copied (unregistered memory that never becomes a buffer) is retried at the end of every submission while it stays; the per-handle cost is a mirror that fails fast, but a backoff like the staging one could bound it if thousands of such records ever showed up.
  • remake returns "done" when mirror returns None (the record is no longer a view of ours); if a reviewer sees a transient mirror failure mode other than that, the note should be cleared there.

The first commit adds the instrumentation this was diagnosed with: large declared buffers logged at INFO (register), the distinct missed pages per frame next to the per-list sums, and the page-table rewrite line stays at DEBUG. On a run where the world's GPU-driven reads miss ~46k unique pages a frame, that instrumentation is what showed which addresses never gain a copy.

**@⁠Luislariosss** on GitHub · 2026-11-27 14:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/3529) `Luislariosss:feat/buffer-view-retry` → `main` · +258 −8 · 5 files · 2 commits · open A buffer SRV or UAV whose host copy did not exist when the title first wrote its record is left null today, and the shader that reads it reads zero with no miss ever counted — the record is never revisited, so the null stays for as long as the title keeps it. `descriptor::make_read` has handled exactly this for texture views since it landed; this extends the same contract to buffer views. A view left null for lack of a copy is now noted (`descriptor::make_refused`) and retried once at the end of every submission (`Host::execute`), where `shadow::find` creates the copy of the registered buffer (or a loose window for unregistered memory) and the view is remade from the same record. The regression test drives a refused view end to end: null and noted after a failed make, made after the submission's retry. Notes for review: - A record that can never be copied (unregistered memory that never becomes a buffer) is retried at the end of every submission while it stays; the per-handle cost is a `mirror` that fails fast, but a backoff like the staging one could bound it if thousands of such records ever showed up. - `remake` returns "done" when `mirror` returns `None` (the record is no longer a view of ours); if a reviewer sees a transient `mirror` failure mode other than that, the note should be cleared there. The first commit adds the instrumentation this was diagnosed with: large declared buffers logged at INFO (`register`), the distinct missed pages per frame next to the per-list sums, and the page-table rewrite line stays at DEBUG. On a run where the world's GPU-driven reads miss ~46k unique pages a frame, that instrumentation is what showed which addresses never gain a copy.
The world reads gigabytes a frame at addresses no view names; the page
table's misses say so, but not whether the working set is dense or has a
hot subset, nor whether a large buffer the shaders read is one the title
declared (a copy find can make) or memory with no resource (XMEM).

- shadow: a title buffer of 16 MiB or more logs "title buffer declared"
  when registered, with the "large buffer copied to the host" line of find
  telling registered buffers never read through views from XMEM.
- memory: the page-table rewrite ("title memory page table") logs at INFO.
- memory: the frame line carries missed_pages_unique next to the per-list
  sum of missed pages: distinct 64 KiB pages a frame.

No behaviour change: logs and a diagnostic count only.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 14:37:29 +00:00
Author
Owner

@⁠oni-swr on GitHub · 2026-11-27 15:06 UTC · original

Independent CPU/WARP verification of #3529 (no physical GPU, no game files)

Environment: Windows 11 build 26200, WARP software adapter (VICTORY_WARP=1, VICTORY_D3D12_WARP=1), dxil.dll 1.8.2502.11 (Windows SDK 10.0.26100.0, x64), cargo -j 4, separate target dir.

SHAs: head 14dd3b8fd2ea19733b232177dc1904258a7f6875; merge base on main 63bcca43c6a00a758510398fa43096ce7e4f7df0 (unchanged since the claim; nobody else had posted a check on the PR or #1633 after 15:01Z). The PR touches only victory-gpu.

cargo test -p victory-gpu --lib passed failed ignored
base 63bcca4 231 0 1
head 14dd3b8 232 0 1 (two runs)

The new descriptor::host::tests::a_refused_buffer_view_is_noted_and_made_at_the_next_retry was also run on its own and passes. cargo clippy -p victory-gpu --all-targets -- -D warnings on head is clean. Caveat: the test returns early if host() is None; I did not separately confirm it took the WARP path rather than the early return.

Diff read: no blocking findings. Notes, most relevant first:

  1. make_refused_now holds the SHADER_HEAPS lock across remake -> mirror -> prepare -> shadow::find, which can allocate a whole title-buffer copy or a 4 MiB loose window. make_read deliberately does its expensive work outside that lock because title threads writing views wait on it (its comment cites 1-6 s a frame). Suggest collecting the noted handles under the lock and remaking after dropping it, or at least moving the find out.
  2. remake calls mirror(.., for_draw = true). If the noted record has since become a placed texture view (the title overwrote the slot, or the heap was freed and another sits at that range), later is false and the texture is made eagerly, bypassing the lazy path the placed-texture shortcut exists for. A buffer-only check before remaking would avoid it.
  3. Cost of never-copyable records: reading find, an address outside every registered buffer falls to loose(), which succeeds for any address, so a refusal should mostly mean the allocation failed or exact returned None. Each submission then repeats the failing allocation per noted record, under the lock from (1). The backoff the PR description mentions seems worth adding. I could not measure this without the title.
  4. Ordering: the retry runs after the lists have executed and before copy-back, so the submission that read the null view still reads zeros; the view is good for the next one, as described. A fresh copy cannot hold GPU writes, so running before copy-back looks benign. Records the title overwrote are cleaned at the next retry (made, or no longer a view).
  5. Nits: make_at (dynamic slots) discards the no-copy flag, so those are never retried. pause_refused / REFUSED are process-global, so the test relies on the pause flag to keep other tests' submissions away.

AI use: this check was done with Claude Code (Claude Sonnet 5.5).

**@⁠oni-swr** on GitHub · 2026-11-27 15:06 UTC · [original](https://github.com/Marvisak/VIctory/pull/3529#issuecomment-7221629226) **Independent CPU/WARP verification of #3529** (no physical GPU, no game files) **Environment:** Windows 11 build 26200, WARP software adapter (`VICTORY_WARP=1`, `VICTORY_D3D12_WARP=1`), dxil.dll 1.8.2502.11 (Windows SDK 10.0.26100.0, x64), cargo `-j 4`, separate target dir. **SHAs:** head `14dd3b8fd2ea19733b232177dc1904258a7f6875`; merge base on main `63bcca43c6a00a758510398fa43096ce7e4f7df0` (unchanged since the claim; nobody else had posted a check on the PR or #1633 after 15:01Z). The PR touches only `victory-gpu`. | `cargo test -p victory-gpu --lib` | passed | failed | ignored | |---|---|---|---| | base 63bcca4 | 231 | 0 | 1 | | head 14dd3b8 | 232 | 0 | 1 (two runs) | The new `descriptor::host::tests::a_refused_buffer_view_is_noted_and_made_at_the_next_retry` was also run on its own and passes. `cargo clippy -p victory-gpu --all-targets -- -D warnings` on head is clean. Caveat: the test returns early if `host()` is `None`; I did not separately confirm it took the WARP path rather than the early return. **Diff read: no blocking findings.** Notes, most relevant first: 1. `make_refused_now` holds the `SHADER_HEAPS` lock across `remake` -> `mirror` -> `prepare` -> `shadow::find`, which can allocate a whole title-buffer copy or a 4 MiB loose window. `make_read` deliberately does its expensive work outside that lock because title threads writing views wait on it (its comment cites 1-6 s a frame). Suggest collecting the noted handles under the lock and remaking after dropping it, or at least moving the `find` out. 2. `remake` calls `mirror(.., for_draw = true)`. If the noted record has since become a placed texture view (the title overwrote the slot, or the heap was freed and another sits at that range), `later` is false and the texture is made eagerly, bypassing the lazy path the placed-texture shortcut exists for. A buffer-only check before remaking would avoid it. 3. Cost of never-copyable records: reading `find`, an address outside every registered buffer falls to `loose()`, which succeeds for any address, so a refusal should mostly mean the allocation failed or `exact` returned `None`. Each submission then repeats the failing allocation per noted record, under the lock from (1). The backoff the PR description mentions seems worth adding. I could not measure this without the title. 4. Ordering: the retry runs after the lists have executed and before copy-back, so the submission that read the null view still reads zeros; the view is good for the next one, as described. A fresh copy cannot hold GPU writes, so running before copy-back looks benign. Records the title overwrote are cleaned at the next retry (made, or no longer a view). 5. Nits: `make_at` (dynamic slots) discards the no-copy flag, so those are never retried. `pause_refused` / `REFUSED` are process-global, so the test relies on the pause flag to keep other tests' submissions away. AI use: this check was done with Claude Code (Claude Sonnet 5.5).
Author
Owner

@⁠futurepro62 on GitHub · 2026-11-27 20:11 UTC · original

NVIDIA full-suite run, to go with the reports above by oni-swr, since none of them names a GPU run. Tested exact head 14dd3b8 (on its base 63bcca4).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), dxil.dll from Windows SDK 10.0.26100 (the loader's default), debug.
  • cargo build --workspace --locked, then cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 867 passed, 0 failed, 10 ignored.
  • The new tests ran and passed: a_refused_buffer_view_is_noted_and_made_at_the_next_retry.
  • --skip leaves out tests that fail on main 63bcca4 on this card too, not because of this PR: heap_direct_texture_reads_mark_their_heap_index ends the victory-shader test process with 0xc0000005 (#2571), so without the skip the rest of that crate never reports; dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views and the two stride_tests hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); gathers_at_a_level_match_the_hardware fails on lane 0 (#1744).

Not tested

  • AMD (the tests take the default adapter), a release build, the title (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
**@⁠futurepro62** on GitHub · 2026-11-27 20:11 UTC · [original](https://github.com/Marvisak/VIctory/pull/3529#issuecomment-7227255807) NVIDIA full-suite run, to go with the reports above by oni-swr, since none of them names a GPU run. Tested exact head `14dd3b8` (on its base `63bcca4`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), `dxil.dll` from Windows SDK 10.0.26100 (the loader's default), debug. - `cargo build --workspace --locked`, then `cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware`: **867 passed, 0 failed, 10 ignored**. - The new tests ran and passed: `a_refused_buffer_view_is_noted_and_made_at_the_next_retry`. - `--skip` leaves out tests that fail on main `63bcca4` on this card too, not because of this PR: `heap_direct_texture_reads_mark_their_heap_index` ends the `victory-shader` test process with `0xc0000005` (#2571), so without the skip the rest of that crate never reports; `dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views` and the two `stride_tests` hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); `gathers_at_a_level_match_the_hardware` fails on lane 0 (#1744). **Not tested** - AMD (the tests take the default adapter), a release build, the title (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
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/3529/head:github-bot/gh-3529'
git switch 'github-bot/gh-3529'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3529'
git switch 'github-bot/gh-3529'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3529'
git switch 'github-bot/gh-3529'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3529'
git switch 'main'
git merge --squash 'github-bot/gh-3529'
git switch 'main'
git merge --ff-only 'github-bot/gh-3529'
git switch 'main'
git merge 'github-bot/gh-3529'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!3529
No description provided.