GPU: copy title writes under ranges a submission's shaders write #1322

Manually merged
github merged 1 commit from gh-pr/1322/head into gh-pr/1322/base 2026-11-26 04:27:29 +00:00
Owner

@⁠KevinPratap on GitHub · 2026-11-24 17:24 UTC · original
KevinPratap:fix/shadow-busy-title-writes → main · +76 −1 · 1 files · 1 commits · merged 2026-11-25 00:23 UTC

Problem

Shadow::update copies only the gaps around pending ranges: ranges that lists earlier in the same submission declared as written by shaders. The world binds unordered-access views of its whole 174 MB heap, so once one is declared, nothing the title writes anywhere in that heap reaches the host copy for the rest of the submission.

Constants the title writes into that heap are then read stale. Seen on an RTX 4050 Laptop (32-lane waves): a depth-downsample compute dispatch read its sizes (1024, 512, 2560, 1440 in title memory) as zeros from the host copy. 1/0 made its loop bounds about 4 billion, and the GPU ran until the device was removed as hung (DRED: the list stopped in that dispatch; the bytes were read from both sides when the device was removed).

Fix

A submission waits for the one before it (ExecuteCommandLists, then a fence wait), so when a submission refreshes, none of its own shaders have run. Under a pending range, the pages the title wrote are now copied as they are anywhere else (update_busy). The same bytes go into the snapshot writing took, so copy_back does not take them for a shader's write and does not undo the title's later writes with them.

Verified

  • New test shadow::tests::title_writes_under_a_busy_range_are_copied (write-watched memory, synthetic data): fails on main (shadow.update(...) > 0 is false, the constant never reaches the copy) and passes with this change. It also checks that a shader's byte still goes back and that a title write made after the refresh is not undone.
  • cargo test -p victory-gpu --release --lib: 52 passed, 1 ignored; cargo clippy -p victory-gpu --all-targets: no new warnings.
  • In the game, on an integration branch of open PRs (RTX 4050, diagnostics build, VICTORY_D3D12_DRED=1): the submission holding that dispatch completes instead of removing the device. The device is still removed later at other dispatches on that card; those are separate.

Only crates/victory-gpu/src/shadow.rs changes.

AI-assisted.

🤖 Generated with Claude Code

**@⁠KevinPratap** on GitHub · 2026-11-24 17:24 UTC · [original](https://github.com/Marvisak/VIctory/pull/1322) `KevinPratap:fix/shadow-busy-title-writes` → `main` · +76 −1 · 1 files · 1 commits · merged 2026-11-25 00:23 UTC ## Problem `Shadow::update` copies only the gaps around `pending` ranges: ranges that lists earlier in the same submission declared as written by shaders. The world binds unordered-access views of its whole 174 MB heap, so once one is declared, nothing the title writes anywhere in that heap reaches the host copy for the rest of the submission. Constants the title writes into that heap are then read stale. Seen on an RTX 4050 Laptop (32-lane waves): a depth-downsample compute dispatch read its sizes (1024, 512, 2560, 1440 in title memory) as zeros from the host copy. 1/0 made its loop bounds about 4 billion, and the GPU ran until the device was removed as hung (DRED: the list stopped in that dispatch; the bytes were read from both sides when the device was removed). ## Fix A submission waits for the one before it (`ExecuteCommandLists`, then a fence wait), so when a submission refreshes, none of its own shaders have run. Under a pending range, the pages the title wrote are now copied as they are anywhere else (`update_busy`). The same bytes go into the snapshot `writing` took, so `copy_back` does not take them for a shader's write and does not undo the title's later writes with them. ## Verified - New test `shadow::tests::title_writes_under_a_busy_range_are_copied` (write-watched memory, synthetic data): fails on `main` (`shadow.update(...) > 0` is false, the constant never reaches the copy) and passes with this change. It also checks that a shader's byte still goes back and that a title write made after the refresh is not undone. - `cargo test -p victory-gpu --release --lib`: 52 passed, 1 ignored; `cargo clippy -p victory-gpu --all-targets`: no new warnings. - In the game, on an integration branch of open PRs (RTX 4050, diagnostics build, `VICTORY_D3D12_DRED=1`): the submission holding that dispatch completes instead of removing the device. The device is still removed later at other dispatches on that card; those are separate. Only `crates/victory-gpu/src/shadow.rs` changes. AI-assisted. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Shadow::update skipped the ranges an earlier list of the same submission declared as written by shaders, so the title's writes there (constants, sizes) stayed stale in the copy for the whole submission; on an RTX 4050 Laptop a dispatch read its sizes as zeros and looped until the device was removed. A submission waits for the one before it, so none of its shaders has run when it refreshes: update_busy copies the pages the title wrote there since they were taken (Tracked::take), and puts the same bytes into the snapshot writing() took, so copy_back neither takes them for the GPU's nor puts them back over a later title write.

Test: title_writes_under_a_busy_range_are_copied fails on main and passes with this.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:27:28 +00:00
github manually merged commit ed0dbfd170 into gh-pr/1322/base 2026-11-26 04:27:29 +00:00
Author
Owner

@⁠crosettiremi on GitHub · 2026-11-24 17:34 UTC · original · edited 2026-11-24 17:44 UTC

Your depth-downsample investigation led to a reproducible neighboring-byte problem in XCL's sparse memory path. The mechanisms differ: XCL records a hash per 64-byte line. A four-byte GPU counter readback used to record the whole line as synchronized, including a CPU-written constant at byte 24 that had never been uploaded. The next dirty scan returned an empty list.

In an isolated local XCL patch, a partial readback updates the hash only if that line was clean beforehand. The native D3D12 regression now queues the expected 64-byte upload. A second fixture covers a readback spanning a dirty first line, a full line and a clean trailing line. The sparse test module passed 17 tests, with one timing test ignored. This verifies the lost-upload mechanism in XCL; the identity of its stalled game dispatch is still open.

Retail follow-up with only this XCL readback fix added to the previously tested integration build: Player1 input arrived at 47.017 s, assets streamed, and the last positive present sample was 228.288 s. The last captured frame remained dark. No device removal logged; the guest ended with an access violation writing zero at RVA 0x23cf683 after the 258 s sample. The last translated-pipeline counters had 22,659 skipped dispatches. Those counters do not identify the missing producer or a depth-downsample shader. One run on each build, with different account-selection timing.

**@⁠crosettiremi** on GitHub · 2026-11-24 17:34 UTC · [original](https://github.com/Marvisak/VIctory/pull/1322#issuecomment-7139406773) · edited 2026-11-24 17:44 UTC Your depth-downsample investigation led to a reproducible neighboring-byte problem in XCL's sparse memory path. The mechanisms differ: XCL records a hash per 64-byte line. A four-byte GPU counter readback used to record the whole line as synchronized, including a CPU-written constant at byte 24 that had never been uploaded. The next dirty scan returned an empty list. In an isolated local XCL patch, a partial readback updates the hash only if that line was clean beforehand. The native D3D12 regression now queues the expected 64-byte upload. A second fixture covers a readback spanning a dirty first line, a full line and a clean trailing line. The sparse test module passed 17 tests, with one timing test ignored. This verifies the lost-upload mechanism in XCL; the identity of its stalled game dispatch is still open. Retail follow-up with only this XCL readback fix added to the previously tested integration build: Player1 input arrived at 47.017 s, assets streamed, and the last positive present sample was 228.288 s. The last captured frame remained dark. No device removal logged; the guest ended with an access violation writing zero at RVA 0x23cf683 after the 258 s sample. The last translated-pipeline counters had 22,659 skipped dispatches. Those counters do not identify the missing producer or a depth-downsample shader. One run on each build, with different account-selection timing.
Author
Owner

@⁠aycow on GitHub · 2026-11-24 18:13 UTC · original

Thanks @⁠KevinPratap for the exact repro and patch. I verified the corresponding stale-constant failure on exact #185 and #387, including when the CPU update lands after command recording. Their synchronous branches now defer baseline snapshots until CPU refreshes complete (f173d36 and 709647f). The fixed variants preserve both the real GPU write and an independent later CPU write on AMD, NVIDIA and WARP with full GBV. #595 has a distinct lifetime issue because an earlier native submission may still be active during the refresh. The synthetic passes do not yet attribute the title material failure.

**@⁠aycow** on GitHub · 2026-11-24 18:13 UTC · [original](https://github.com/Marvisak/VIctory/pull/1322#issuecomment-7140337883) Thanks @⁠KevinPratap for the exact repro and patch. I verified the corresponding stale-constant failure on exact #185 and #387, including when the CPU update lands after command recording. Their synchronous branches now defer baseline snapshots until CPU refreshes complete (f173d36 and 709647f). The fixed variants preserve both the real GPU write and an independent later CPU write on AMD, NVIDIA and WARP with full GBV. #595 has a distinct lifetime issue because an earlier native submission may still be active during the refresh. The synthetic passes do not yet attribute the title material failure.
Author
Owner

@⁠KevinPratap on GitHub · 2026-11-24 22:32 UTC · original

Rebased onto today's main (70564ae0), which rewrote shadow.rs around Tracked and snapshot segments. The bug is still there: update skips the pending ranges entirely. The fix is now update_busy: under a pending range it copies the pages Tracked::take reports, and writes the same bytes into the snapshot segments writing took.

  • The new test shadow::tests::title_writes_under_a_busy_range_are_copied uses the tracked pool, like the existing shadow test. It fails on main ("the title's write is copied") and passes with this.
  • cargo clippy -p victory-gpu --all-targets -- -D warnings is clean.
  • cargo test -p victory-gpu --lib: the 3 failures are also there on main, on an RTX 4050 Laptop (dynamic_slots_are_held_until_released, a_texture_written_in_one_format_reads_in_another_through_a_placed_view, lists_share_a_table_and_copies_keep_their_views).

AI-assisted.

**@⁠KevinPratap** on GitHub · 2026-11-24 22:32 UTC · [original](https://github.com/Marvisak/VIctory/pull/1322#issuecomment-7146353607) Rebased onto today's `main` (70564ae0), which rewrote `shadow.rs` around `Tracked` and snapshot segments. The bug is still there: `update` skips the pending ranges entirely. The fix is now `update_busy`: under a pending range it copies the pages `Tracked::take` reports, and writes the same bytes into the snapshot segments `writing` took. - The new test `shadow::tests::title_writes_under_a_busy_range_are_copied` uses the tracked pool, like the existing shadow test. It fails on `main` ("the title's write is copied") and passes with this. - `cargo clippy -p victory-gpu --all-targets -- -D warnings` is clean. - `cargo test -p victory-gpu --lib`: the 3 failures are also there on `main`, on an RTX 4050 Laptop (`dynamic_slots_are_held_until_released`, `a_texture_written_in_one_format_reads_in_another_through_a_placed_view`, `lists_share_a_table_and_copies_keep_their_views`). AI-assisted.
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!1322
No description provided.