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

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

@⁠fuzeofficlal on GitHub · 2026-11-25 06:24 UTC · original
fuzeofficlal:fix/gpu-rebind-compute-view-marks → main · +212 −2 · 2 files · 1 commits · merged 2026-11-25 21:54 UTC

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.
**@⁠fuzeofficlal** on GitHub · 2026-11-25 06:24 UTC · [original](https://github.com/Marvisak/VIctory/pull/2155) `fuzeofficlal:fix/gpu-rebind-compute-view-marks` → `main` · +212 −2 · 2 files · 1 commits · merged 2026-11-25 21:54 UTC ### 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.
State::bind sets the view-mark table SRV and written-pages bitmap UAV root descriptors before iterating over pipeline stages. When a compute shader reads a 16-bit depth texture whose writable twin is newer, State::tables transitions the texture through Twin::copy's compute converter, replacing the command list's compute root signature and setting need_rebind.

The subsequent take_rebind block restored SetComputeRootSignature(&p.root) and SetPipelineState(&p.pso), invalidating all previously bound compute root parameters while only per-stage root arguments were set afterward, leaving VIEW_MARKS and VIEW_WRITES unbound for the dispatch.

Rebind the compute view-mark SRV and UAV root descriptors immediately after restoring the compute root signature on rebind.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:56:26 +00:00
github manually merged commit c2cc905f68 into gh-pr/2155/base 2026-11-26 04:56:27 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 11:26 UTC · original

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

**@⁠Marvisak** on GitHub · 2026-11-25 11:26 UTC · [original](https://github.com/Marvisak/VIctory/pull/2155#issuecomment-7161043195) <!-- 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)_
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!2155
No description provided.