GPU: the DRED report reads only the breadcrumb history that is there #3266

Open
davesousa wants to merge 1 commit from upstream-pr/3268 into main
davesousa commented 2026-11-26 15:10:57 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by davesousa on 2026-11-26T15:10:57Z.


With VICTORY_D3D12_DRED, Host::removal_data makes a slice of BreadcrumbCount ops over each unfinished node's pCommandHistory and walks all of it. On an RTX 3070 Ti (driver 621.40, Windows 11 26200) one removal's report crashed VIctory instead: 0xc0000005 reading op 15,360 of a node's history, exactly 60 KiB in, where the memory was reserved but not committed. So that removal's report was lost. It was 1 of 3 DRED removals I have, in a VICTORY_GPU_TIMING=1 run (#2703 + #2841 on my NVIDIA stack). The other reports on this card read histories of 17,030 to 19,268 ops without trouble, so the history is not capped at 15,360; in that one, the runtime's count ran past the history it had committed.

This PR:

  • reads the history through the kernel (read, as the title-memory copies do), page by page, up to the first page that cannot be read;
  • names the op at the stop only when it is in that part, and adds but only its first N commands can be read when the history is cut short;
  • lists the commands in flight only when the stop is inside the readable part (the marker notes still pair up, since the readable part is the list's first commands).

Test: host::breadcrumbs::a_history_shorter_than_its_count_is_read_as_far_as_it_is_there makes a two-page reservation with only the first page committed, and a count of two pages. With the old read (from_raw_parts over the count) put back, the test process dies with 0xc0000005 STATUS_ACCESS_VIOLATION; with this PR it passes.

Checks on the RTX 3070 Ti: both clippy commands and cargo xtask policy pass. cargo test --workspace --locked --no-fail-fast gives the same results as main on this card (two victory-gpu view-heap-cap failures, dynamic_slots_are_held_until_released and lists_share_a_table_and_copies_keep_their_views, and the victory-shader crash of #2571), plus the new test passing.

Not tested: a real removal with a cut-short history. That needs a GPU fault, and ID3D12Device5::RemoveDevice waits until the GPU is idle, so afterwards DRED lists no unfinished nodes (checked on this card). So there is no forced-removal test here.

Claimed on #1633. AI-assisted (Claude Code).

🤖 Generated with Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:issue:5512528887 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3268). Originally posted by [davesousa](https://github.com/davesousa) on 2026-11-26T15:10:57Z. --- With `VICTORY_D3D12_DRED`, `Host::removal_data` makes a slice of `BreadcrumbCount` ops over each unfinished node's `pCommandHistory` and walks all of it. On an RTX 3070 Ti (driver 621.40, Windows 11 26200) one removal's report crashed VIctory instead: `0xc0000005` reading op 15,360 of a node's history, exactly 60 KiB in, where the memory was reserved but not committed. So that removal's report was lost. It was 1 of 3 DRED removals I have, in a `VICTORY_GPU_TIMING=1` run (#2703 + #2841 on my NVIDIA stack). The other reports on this card read histories of 17,030 to 19,268 ops without trouble, so the history is not capped at 15,360; in that one, the runtime's count ran past the history it had committed. This PR: - reads the history through the kernel (`read`, as the title-memory copies do), page by page, up to the first page that cannot be read; - names the op at the stop only when it is in that part, and adds `but only its first N commands can be read` when the history is cut short; - lists the commands in flight only when the stop is inside the readable part (the marker notes still pair up, since the readable part is the list's first commands). Test: `host::breadcrumbs::a_history_shorter_than_its_count_is_read_as_far_as_it_is_there` makes a two-page reservation with only the first page committed, and a count of two pages. With the old read (`from_raw_parts` over the count) put back, the test process dies with `0xc0000005 STATUS_ACCESS_VIOLATION`; with this PR it passes. Checks on the RTX 3070 Ti: both clippy commands and `cargo xtask policy` pass. `cargo test --workspace --locked --no-fail-fast` gives the same results as `main` on this card (two `victory-gpu` view-heap-cap failures, `dynamic_slots_are_held_until_released` and `lists_share_a_table_and_copies_keep_their_views`, and the `victory-shader` crash of #2571), plus the new test passing. Not tested: a real removal with a cut-short history. That needs a GPU fault, and `ID3D12Device5::RemoveDevice` waits until the GPU is idle, so afterwards DRED lists no unfinished nodes (checked on this card). So there is no forced-removal test here. Claimed on #1633. AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Dukestar69 commented 2026-11-26 15:28:57 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T15:28:57Z.

Review: APPROVED


Reviewed the diff and verified locally on Windows 11 x64:

  • Reading DRED breadcrumb history page-by-page via ReadProcessMemory (readable_history) and bounds-checking done < history.len() in stopped_at / in_flight cleanly prevents access violations when BreadcrumbCount runs past committed pages.
  • cargo test -p victory-gpu --lib host::breadcrumbs:: -- --test-threads=1: 1 passed, 0 failed (a_history_shorter_than_its_count_is_read_as_far_as_it_is_there).
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo clippy -p victory-gpu --features diagnostics --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6076768935 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3268#pullrequestreview-6076768935). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T15:28:57Z. **Review:** APPROVED --- Reviewed the diff and verified locally on Windows 11 x64: - Reading DRED breadcrumb history page-by-page via `ReadProcessMemory` (`readable_history`) and bounds-checking `done < history.len()` in `stopped_at` / `in_flight` cleanly prevents access violations when `BreadcrumbCount` runs past committed pages. - `cargo test -p victory-gpu --lib host::breadcrumbs:: -- --test-threads=1`: 1 passed, 0 failed (`a_history_shorter_than_its_count_is_read_as_far_as_it_is_there`). - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean. - `cargo clippy -p victory-gpu --features diagnostics --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
oni-swr commented 2026-11-26 16:10:00 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-26T16:10:00Z.


WARP verification report (test report only, no code changes)

  • PR head: 7cbb83ec
  • main: 63bcca43 (control); WARP software adapter forced with VICTORY_WARP=1 VICTORY_D3D12_WARP=1, --features diagnostics, d3d10warp.dll 10.0.26100.9818; dxil.dll 1.8.2502.11 (Windows Kit 10.0.26100.0, via VICTORY_DXIL).
  • Each new/changed test run in its own process (--exact), -j 4, synthetic tests only, no game data. Command: cargo test -p victory-gpu --lib --features diagnostics -j 4 -- --exact <test>.
  • New test host::breadcrumbs::a_history_shorter_than_its_count_is_read_as_far_as_it_is_there: passes on the PR (1 passed).
  • Control on main: the test needs readable_history and stopped_at from this PR, so I added the test to main with two shims that keep main's behaviour (read the runtime's whole count unchecked, index the history at done). The test crashes on main with STATUS_ACCESS_VIOLATION (0xc0000005) reading the uncommitted page, i.e. the fault the PR describes. That is a main-plus-shim control, not unmodified main.
  • victory-gpu lib suite: PR 247 passed, 0 failed, 1 ignored; main 246 passed, 0 failed, 1 ignored. No failures on either.
  • Not tested: physical GPU. The test exercises memory reads only, not a real device-removed report.

AI-assisted: verification by Claude Code (Claude Sonnet 5.5)

<!-- greyfinch-sync:Marvisak/VIctory:comment:7197271139 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3268#issuecomment-7197271139). Originally posted by [oni-swr](https://github.com/oni-swr) on 2026-11-26T16:10:00Z. --- WARP verification report (test report only, no code changes) - PR head: `7cbb83ec` - main: `63bcca43` (control); WARP software adapter forced with `VICTORY_WARP=1 VICTORY_D3D12_WARP=1`, `--features diagnostics`, d3d10warp.dll 10.0.26100.9818; dxil.dll 1.8.2502.11 (Windows Kit 10.0.26100.0, via `VICTORY_DXIL`). - Each new/changed test run in its own process (`--exact`), `-j 4`, synthetic tests only, no game data. Command: `cargo test -p victory-gpu --lib --features diagnostics -j 4 -- --exact <test>`. - New test `host::breadcrumbs::a_history_shorter_than_its_count_is_read_as_far_as_it_is_there`: **passes on the PR** (1 passed). - Control on main: the test needs `readable_history` and `stopped_at` from this PR, so I added the test to main with two shims that keep main's behaviour (read the runtime's whole count unchecked, index the history at `done`). The test **crashes on main** with `STATUS_ACCESS_VIOLATION` (0xc0000005) reading the uncommitted page, i.e. the fault the PR describes. That is a main-plus-shim control, not unmodified main. - `victory-gpu` lib suite: PR 247 passed, 0 failed, 1 ignored; main 246 passed, 0 failed, 1 ignored. No failures on either. - Not tested: physical GPU. The test exercises memory reads only, not a real device-removed report. AI-assisted: verification by Claude Code (Claude Sonnet 5.5)
futurepro62 commented 2026-11-26 23:25:19 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-26T23:25:19Z.


NVIDIA full-suite run, to go with the reports above by Dukestar69, oni-swr, since none of them names a GPU run. Tested exact head 7cbb83e (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_history_shorter_than_its_count_is_read_as_far_as_it_is_there.
  • --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.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7205527565 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3268#issuecomment-7205527565). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-26T23:25:19Z. --- NVIDIA full-suite run, to go with the reports above by Dukestar69, oni-swr, since none of them names a GPU run. Tested exact head `7cbb83e` (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_history_shorter_than_its_count_is_read_as_far_as_it_is_there`. - `--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.
fuzeofficlal commented 2026-11-26 23:50:27 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T23:50:27Z.

Review: APPROVED


Looks good — cleanly prevents DRED breadcrumb reporting from faulting when BreadcrumbCount runs past the committed pages of pCommandHistory.

Checked crates/victory-gpu/src/host.rs:1548-1580, host.rs:3798-3829, and in_flight (host.rs:3836-3859):

  • readable_history reads pCommandHistory page-by-page through read (ReadProcessMemory) instead of forming a raw slice over BreadcrumbCount, keeping the valid readable prefix without faulting.
  • stopped_at safely uses .get(done as usize) and notes truncation whenever history.len() < count as usize.
  • Guarding in_flight with done > 0 && (done as usize) < history.len() keeps all slices inside in_flight in bounds, and the explicit else if done == 0 avoids misreporting pipelines when a list stopped past the readable prefix.
  • (Non-blocking note: returning early via if !readable { return; } before allocating piece in readable_history — and optionally checking history.is_aligned() — would avoid wasted per-page allocations if a corrupted node ever reports a very large BreadcrumbCount.)

Verification (7cbb83ec):

  • cargo xtask policy and cargo clippy -p victory-gpu (default and --features diagnostics, --tests -- -D warnings): passed.
  • host::breadcrumbs::a_history_shorter_than_its_count_is_read_as_far_as_it_is_there: passed on both hardware GPU and WARP.
  • Synthetic Windows virtual-memory probe covering count == 0, a non-page-aligned 4-byte-aligned pointer straddling committed/uncommitted pages (exact 3 trailing ops read), a pointer starting directly on PAGE_NOACCESS (0 ops, done == 0 handled), boundary done == history.len() (op unknown, in_flight skipped), and a 1,048,576-op count on an unreadable page (2.00 ms, no fault): all passed.
<!-- greyfinch-sync:Marvisak/VIctory:review:6081685743 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3268#pullrequestreview-6081685743). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T23:50:27Z. **Review:** APPROVED --- Looks good — cleanly prevents DRED breadcrumb reporting from faulting when `BreadcrumbCount` runs past the committed pages of `pCommandHistory`. Checked `crates/victory-gpu/src/host.rs:1548-1580`, `host.rs:3798-3829`, and `in_flight` (`host.rs:3836-3859`): - `readable_history` reads `pCommandHistory` page-by-page through `read` (`ReadProcessMemory`) instead of forming a raw slice over `BreadcrumbCount`, keeping the valid readable prefix without faulting. - `stopped_at` safely uses `.get(done as usize)` and notes truncation whenever `history.len() < count as usize`. - Guarding `in_flight` with `done > 0 && (done as usize) < history.len()` keeps all slices inside `in_flight` in bounds, and the explicit `else if done == 0` avoids misreporting pipelines when a list stopped past the readable prefix. - (Non-blocking note: returning early via `if !readable { return; }` before allocating `piece` in `readable_history` — and optionally checking `history.is_aligned()` — would avoid wasted per-page allocations if a corrupted node ever reports a very large `BreadcrumbCount`.) Verification (`7cbb83ec`): - `cargo xtask policy` and `cargo clippy -p victory-gpu` (default and `--features diagnostics`, `--tests -- -D warnings`): passed. - `host::breadcrumbs::a_history_shorter_than_its_count_is_read_as_far_as_it_is_there`: passed on both hardware GPU and WARP. - Synthetic Windows virtual-memory probe covering `count == 0`, a non-page-aligned 4-byte-aligned pointer straddling committed/uncommitted pages (exact 3 trailing ops read), a pointer starting directly on `PAGE_NOACCESS` (`0` ops, `done == 0` handled), boundary `done == history.len()` (`op unknown`, `in_flight` skipped), and a `1,048,576`-op count on an unreadable page (`2.00 ms`, no fault): all passed.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3268:upstream-pr/3268'
git switch 'upstream-pr/3268'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3268'
git switch 'upstream-pr/3268'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3268'
git switch 'upstream-pr/3268'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3268'
git switch 'main'
git merge --squash 'upstream-pr/3268'
git switch 'main'
git merge --ff-only 'upstream-pr/3268'
git switch 'main'
git merge 'upstream-pr/3268'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!3266
No description provided.