GPU: rebind compute view-mark root descriptors after depth-twin conversion #2153

Merged
fuzeofficlal merged 1 commit from upstream-pr/2155 into main 2026-11-25 21:54:59 +00:00
fuzeofficlal commented 2026-11-25 06:24:59 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T06:24:59Z.


Problem

State::bind (crates/victory-gpu/src/draw.rs) binds p.marks (VIEW_MARKS root SRV and VIEW_WRITES root UAV) before iterating over p.stages. When a compute shader's descriptor table references a 16-bit depth texture whose writable twin was written earlier, State::tables transitions the texture via Twin::copy, whose compute converter() replaces the command list's compute root signature and sets need_rebind.

The subsequent if list.take_rebind() block restores SetComputeRootSignature(&p.root) and SetPipelineState(&p.pso) (invalidating all previously bound compute root parameters per D3D12 rules), while only per-stage root arguments are bound below it — leaving VIEW_MARKS and VIEW_WRITES unbound for the dispatch.

Changes

  • Rebind SetComputeRootShaderResourceView and SetComputeRootUnorderedAccessView for p.marks immediately after SetComputeRootSignature(&p.root) inside if list.take_rebind().
  • Add draw::tests::compute_view_marks_rebind_after_depth_twin_conversion: writes a 16-bit depth twin (format = 118), binds a view_marks = true compute HostPipeline reading that depth SRV (triggering Twin::copy and take_rebind) and writing page 1 of a tracked Shadow buffer, verifying zero D3D12 Debug Layer errors and copy_back_marks writeback across RTX 5090, AMD Radeon Graphics, and D3D12 WARP.
<!-- greyfinch-sync:Marvisak/VIctory:issue:6598596081 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2155). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T06:24:59Z. --- ### Problem `State::bind` (`crates/victory-gpu/src/draw.rs`) binds `p.marks` (`VIEW_MARKS` root SRV and `VIEW_WRITES` root UAV) before iterating over `p.stages`. When a compute shader's descriptor table references a 16-bit depth texture whose writable twin was written earlier, `State::tables` transitions the texture via `Twin::copy`, whose compute `converter()` replaces the command list's compute root signature and sets `need_rebind`. The subsequent `if list.take_rebind()` block restores `SetComputeRootSignature(&p.root)` and `SetPipelineState(&p.pso)` (invalidating all previously bound compute root parameters per D3D12 rules), while only per-stage root arguments are bound below it — leaving `VIEW_MARKS` and `VIEW_WRITES` unbound for the dispatch. ### Changes - Rebind `SetComputeRootShaderResourceView` and `SetComputeRootUnorderedAccessView` for `p.marks` immediately after `SetComputeRootSignature(&p.root)` inside `if list.take_rebind()`. - Add `draw::tests::compute_view_marks_rebind_after_depth_twin_conversion`: writes a 16-bit depth twin (`format = 118`), binds a `view_marks = true` compute `HostPipeline` reading that depth SRV (triggering `Twin::copy` and `take_rebind`) and writing page `1` of a tracked `Shadow` buffer, verifying zero D3D12 Debug Layer errors and `copy_back_marks` writeback across RTX 5090, AMD Radeon Graphics, and D3D12 WARP.
catminou4 commented 2026-11-25 07:02:57 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T06:33:10Z.

Review: COMMENTED


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

Compute view-mark root descriptors rebound after depth-twist — descriptor rebind fix for a specific transform path; narrow but plausible.

<!-- greyfinch-sync:Marvisak/VIctory:review:6052890387 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2155#pullrequestreview-6052890387). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T06:33:10Z. **Review:** COMMENTED --- Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff. Compute view-mark root descriptors rebound after depth-twist — descriptor rebind fix for a specific transform path; narrow but plausible.
DenRakEiw commented 2026-11-25 12:03:06 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T11:53:24Z.

Review: APPROVED


Verified against origin/main (940d32f) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP:

  • Rebinding compute view-mark root descriptors after depth-twin conversion cleanly keeps compute shaders seeing the right root descriptors.
  • cargo test -p victory-gpu draw::tests: 6/6 passed on RTX 5090, 6/6 passed on WARP (including compute_view_marks_rebind_after_depth_twin_conversion).
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: 0 warnings.
  • cargo xtask policy: 183 files ok.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6057108653 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2155#pullrequestreview-6057108653). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-25T11:53:24Z. **Review:** APPROVED --- Verified against `origin/main` (`940d32f`) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP: - Rebinding compute view-mark root descriptors after depth-twin conversion cleanly keeps compute shaders seeing the right root descriptors. - `cargo test -p victory-gpu draw::tests`: 6/6 passed on RTX 5090, 6/6 passed on WARP (including `compute_view_marks_rebind_after_depth_twin_conversion`). - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: 0 warnings. - `cargo xtask policy`: 183 files ok. AI-assisted (Gemini 4 Neon).
Marvisak commented 2026-11-25 12:03:47 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T11:26:09Z.


Automated triage for the maintainers.

Merge candidate.

The bug is real. On main, State::bind (crates/victory-gpu/src/draw.rs) binds the p.marks root SRV and UAV before the per-stage loop. When self.tables makes a depth texture readable via Twin::copy, the twin's compute converter swaps the root signature. The list.take_rebind() branch then calls SetComputeRootSignature(&p.root) again, which clears every root argument bound before it, and only the per-stage arguments are rebound below. So a compute dispatch that marks its view writes ran with VIEW_MARKS/VIEW_WRITES unbound. The fix keeps the mark addresses from the first bind and sets them again right after SetComputeRootSignature in that branch. The graphics path doesn't need it, because there the root signature is not reset.

The new test compute_view_marks_rebind_after_depth_twin_conversion covers the real path:

  • It writes a 16-bit depth twin and binds a view_marks compute pipeline that reads it, checking through twin::COPIES that the conversion ran.
  • It checks there are no debug-layer errors and that the value written to page 1 of a tracked buffer comes back through copy_back_marks.

The test is long, but every part of it is needed to reach this branch. Shader::for_test is test-only. CI is passing (check), and the PR merges cleanly.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7161043195 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2155#issuecomment-7161043195). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T11:26:09Z. --- <!-- victory-triage v1 head=c2cc905f689b8a80ed9cd34ebee1ce752aa7d0e5 verdict=merge-candidate at=2026-11-25T11:26:08Z --> Automated triage for the maintainers. **Merge candidate.** The bug is real. On `main`, `State::bind` (`crates/victory-gpu/src/draw.rs`) binds the `p.marks` root SRV and UAV before the per-stage loop. When `self.tables` makes a depth texture readable via `Twin::copy`, the twin's compute converter swaps the root signature. The `list.take_rebind()` branch then calls `SetComputeRootSignature(&p.root)` again, which clears every root argument bound before it, and only the per-stage arguments are rebound below. So a compute dispatch that marks its view writes ran with `VIEW_MARKS`/`VIEW_WRITES` unbound. The fix keeps the mark addresses from the first bind and sets them again right after `SetComputeRootSignature` in that branch. The graphics path doesn't need it, because there the root signature is not reset. The new test `compute_view_marks_rebind_after_depth_twin_conversion` covers the real path: - It writes a 16-bit depth twin and binds a `view_marks` compute pipeline that reads it, checking through `twin::COPIES` that the conversion ran. - It checks there are no debug-layer errors and that the value written to page 1 of a tracked buffer comes back through `copy_back_marks`. The test is long, but every part of it is needed to reach this branch. `Shader::for_test` is test-only. CI is passing (`check`), and the PR merges cleanly. --- _Generated by [Claude Code](https://claude.ai/code)_
upstream-sync closed this pull request 2026-11-25 22:03:28 +00:00
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!2153
No description provided.