GPU: track D3D12 shadow-buffer states (#1670) #1690

Open
Elensito wants to merge 1 commit from upstream-pr/1691 into main
Elensito commented 2026-11-24 20:47:13 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Elensito on 2026-11-24T20:47:13Z.


What changed

  • Track shadow-buffer resource states across host command-list submissions.
  • Emit transitions for shader views, vertex/index buffers, and indirect arguments, combining compatible read-only states.
  • Add synthetic regression coverage for UAV-to-read transitions across submissions without game data.

Fixes #1670

Validation

  • cargo test -p victory-gpu
  • cargo xtask policy
  • VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --features diagnostics shadow::tests::buffer_states_follow_submission_order_and_combine_reads -- --nocapture

The reported RTX 5080 case could not be reproduced on that hardware locally.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6591088770 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1691). Originally posted by [Elensito](https://github.com/Elensito) on 2026-11-24T20:47:13Z. --- ## What changed - Track shadow-buffer resource states across host command-list submissions. - Emit transitions for shader views, vertex/index buffers, and indirect arguments, combining compatible read-only states. - Add synthetic regression coverage for UAV-to-read transitions across submissions without game data. Fixes #1670 ## Validation - `cargo test -p victory-gpu` - `cargo xtask policy` - `VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --features diagnostics shadow::tests::buffer_states_follow_submission_order_and_combine_reads -- --nocapture` The reported RTX 5080 case could not be reproduced on that hardware locally.
DenRakEiw commented 2026-11-24 21:03:13 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-24T20:57:02Z.

Review: APPROVED


Verified locally merged onto origin/main (Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC):

  • cargo test -p victory-gpu — 51 passed, 0 failed (1 ignored) on both RTX 5090 hardware and VICTORY_D3D12_WARP=1 (including buffer_states_follow_submission_order_and_combine_reads)
  • cargo clippy -p victory-gpu --all-targets — 0 warnings
  • cargo xtask policy — ok

Clean D3D12 shadow-buffer state tracking across submission order and combined read states. Looks good.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6047273440 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1691#pullrequestreview-6047273440). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-24T20:57:02Z. **Review:** APPROVED --- Verified locally merged onto `origin/main` (Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC): - `cargo test -p victory-gpu` — 51 passed, 0 failed (1 ignored) on both RTX 5090 hardware and `VICTORY_D3D12_WARP=1` (including `buffer_states_follow_submission_order_and_combine_reads`) - `cargo clippy -p victory-gpu --all-targets` — 0 warnings - `cargo xtask policy` — ok Clean D3D12 shadow-buffer state tracking across submission order and combined read states. Looks good. AI-assisted (Gemini 4 Neon).
catminou4 commented 2026-11-24 22:01:57 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T21:42:13Z.

Review: COMMENTED


Static review only: Windows-only code (D3D12/windows_sys/Win32) — nothing compiles or runs on macOS; source review of the diff.

D3D12 shadow-buffer states are tracked per submission order: buffer_state() queries the resource state, done() records completion against the shadow, and buffer_states_follow_submission_order_and_combine_reads tests ordering + read combining on a real device. This is the foundation for correct barrier elision on copied buffers — please make sure the Windows hardware test ran, since state tracking bugs show up as device removal or corruption, not test failures on macOS (which cannot run any of this).

<!-- greyfinch-sync:Marvisak/VIctory:review:6047875075 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1691#pullrequestreview-6047875075). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T21:42:13Z. **Review:** COMMENTED --- Static review only: Windows-only code (D3D12/windows_sys/Win32) — nothing compiles or runs on macOS; source review of the diff. D3D12 shadow-buffer states are tracked per submission order: buffer_state() queries the resource state, done() records completion against the shadow, and buffer_states_follow_submission_order_and_combine_reads tests ordering + read combining on a real device. This is the foundation for correct barrier elision on copied buffers — please make sure the Windows hardware test ran, since state tracking bugs show up as device removal or corruption, not test failures on macOS (which cannot run any of this).
Headache3318 commented 2026-11-25 02:05:47 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Headache3318 on 2026-11-25T01:09:01Z.


Independent second-read at head 667e7dc9a4.

This is a massive architectural simplification despite the modest title: 132 files changed, +2,270 / -37,366 lines. Several internal crates and features are removed (memory.rs page-table approach, bindless.rs, pipelines.rs, shaderpack.rs, publish.rs, many diagnostic features, HostList::id breadcrumb matching, range.rs).

What the PR adds: buffer state tracking on shadow buffers via HostList::buffer_state() and Shadow::state (AtomicU32), combining consecutive read states (VERTEX | SRV) and resetting on writes (UAV), mirroring the existing texture state model. New test validates the tracking.

Correctness concerns: three shadow.gpu_writes(list, address, len) calls are removed, so root UAV write-backs are no longer copied back to title memory — shader writes through root UAVs will be lost. The update_busy path that copied title writes under GPU write ranges is gone, which could cause stale constants to reach the GPU. Off-element buffer views (for_view) and keep_writes are removed.

Recommendation: The new buffer state tracking itself is clean and well-tested, consistent with the existing texture state model. But the scope is dramatically larger than the title suggests, and several correctness paths are gone. These removals should be documented as intentional simplifications with a note on what breaks. The removed test coverage should be restored or replaced. A commit message explaining why these features are being removed would help reviewers understand the rationale.

Arch Linux, kernel 7.3.5-arch1-1, zero-CPU read, AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7149255918 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1691#issuecomment-7149255918). Originally posted by [Headache3318](https://github.com/Headache3318) on 2026-11-25T01:09:01Z. --- Independent second-read at head 667e7dc9a4fd47f372b4ada77bda450c8d73587f. This is a massive architectural simplification despite the modest title: 132 files changed, +2,270 / -37,366 lines. Several internal crates and features are removed (memory.rs page-table approach, bindless.rs, pipelines.rs, shaderpack.rs, publish.rs, many diagnostic features, HostList::id breadcrumb matching, range.rs). **What the PR adds:** buffer state tracking on shadow buffers via `HostList::buffer_state()` and `Shadow::state` (AtomicU32), combining consecutive read states (VERTEX | SRV) and resetting on writes (UAV), mirroring the existing texture state model. New test validates the tracking. **Correctness concerns:** three `shadow.gpu_writes(list, address, len)` calls are removed, so root UAV write-backs are no longer copied back to title memory — shader writes through root UAVs will be lost. The `update_busy` path that copied title writes under GPU write ranges is gone, which could cause stale constants to reach the GPU. Off-element buffer views (`for_view`) and `keep_writes` are removed. **Recommendation:** The new buffer state tracking itself is clean and well-tested, consistent with the existing texture state model. But the scope is dramatically larger than the title suggests, and several correctness paths are gone. These removals should be documented as intentional simplifications with a note on what breaks. The removed test coverage should be restored or replaced. A commit message explaining why these features are being removed would help reviewers understand the rationale. Arch Linux, kernel 7.3.5-arch1-1, zero-CPU read, AI-assisted.
Marvisak commented 2026-11-25 02:06:12 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:34:30Z.


Automated triage for the maintainers.

Needs rebase. This pull request conflicts with main (conflicting: crates/victory-gpu/src/draw.rs, crates/victory-gpu/src/host.rs, crates/victory-gpu/src/indirect.rs, crates/victory-gpu/src/shadow.rs). It will be reviewed once it is rebased onto the current main.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7149704556 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1691#issuecomment-7149704556). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T01:34:30Z. --- <!-- victory-triage v1 head=667e7dc9a4fd47f372b4ada77bda450c8d73587f verdict=needs-rebase at=2026-11-25T01:34:30Z --> Automated triage for the maintainers. **Needs rebase.** This pull request conflicts with `main` (conflicting: `crates/victory-gpu/src/draw.rs`, `crates/victory-gpu/src/host.rs`, `crates/victory-gpu/src/indirect.rs`, `crates/victory-gpu/src/shadow.rs`). It will be reviewed once it is rebased onto the current `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
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/1691:upstream-pr/1691'
git switch 'upstream-pr/1691'

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/1691'
git switch 'upstream-pr/1691'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1691'
git switch 'upstream-pr/1691'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1691'
git switch 'main'
git merge --squash 'upstream-pr/1691'
git switch 'main'
git merge --ff-only 'upstream-pr/1691'
git switch 'main'
git merge 'upstream-pr/1691'
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!1690
No description provided.