fix(gpu): transition shadow buffers before VB/IB binding #1502

Closed
github-bot wants to merge 1 commit from gh-pr/1502/head into gh-pr/1502/base
Owner

@⁠Thomas73737 on GitHub · 2026-11-24 18:33 UTC · original
Thomas73737:fix/shadow-buffer-vb-ib-state → main · +74 −3 · 4 files · 1 commits · closed without merging

Summary

  • Track host D3D12 state for shadow buffer copies and emit buffer barriers in command list preludes.
  • Transition shadow buffers to VERTEX_AND_CONSTANT_BUFFER / INDEX_BUFFER before IASetVertexBuffers / IASetIndexBuffer.
  • Ensure buffer SRV/UAV descriptor reads transition shadow buffers to SHADER_RESOURCE / UNORDERED_ACCESS.

Why

Issue #445 reports a D3D12 debug-layer validation error where a resource in D3D12_RESOURCE_STATE_UNORDERED_ACCESS is used as a vertex buffer, followed by device removal. Shadow buffer copies previously had no tracked host state/barrier path when bound as VB/IB.

Validation

  • Not validated against game files or Windows/D3D12/WARP in this Linux sandbox.
  • cargo check -p victory-gpu timed out in this sandbox (120s, then 300s); compile not confirmed.

Caveats

  • Draft/no-game fix attempt; may not cover all UAV->VB/IB paths or the full #445 hang.
  • Needs Windows D3D12 debug-layer/WARP validation.
**@⁠Thomas73737** on GitHub · 2026-11-24 18:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/1502) `Thomas73737:fix/shadow-buffer-vb-ib-state` → `main` · +74 −3 · 4 files · 1 commits · closed without merging ## Summary - Track host D3D12 state for shadow buffer copies and emit buffer barriers in command list preludes. - Transition shadow buffers to `VERTEX_AND_CONSTANT_BUFFER` / `INDEX_BUFFER` before `IASetVertexBuffers` / `IASetIndexBuffer`. - Ensure buffer SRV/UAV descriptor reads transition shadow buffers to `SHADER_RESOURCE` / `UNORDERED_ACCESS`. ## Why Issue #445 reports a D3D12 debug-layer validation error where a resource in `D3D12_RESOURCE_STATE_UNORDERED_ACCESS` is used as a vertex buffer, followed by device removal. Shadow buffer copies previously had no tracked host state/barrier path when bound as VB/IB. ## Validation - Not validated against game files or Windows/D3D12/WARP in this Linux sandbox. - `cargo check -p victory-gpu` timed out in this sandbox (120s, then 300s); compile not confirmed. ## Caveats - Draft/no-game fix attempt; may not cover all UAV->VB/IB paths or the full #445 hang. - Needs Windows D3D12 debug-layer/WARP validation.
Track host state for shadow buffer copies and emit barriers in list preludes. Ensure vertex/index buffer bindings and buffer SRV/UAV descriptor reads use the expected D3D12 buffer states to avoid UAV-to-VB/IB validation errors.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:34:15 +00:00
github-bot closed this pull request 2026-11-26 04:34:15 +00:00
Author
Owner

@⁠Ryanarcx2 on GitHub · 2026-11-24 20:49 UTC · original

Tested 3f204cd on an RTX 5070 Ti (driver 32.0.16.1742), Windows 11, diag build with VICTORY_D3D12_DEBUG=1, running to the first story cutscene. Compared against main at ffe310e, same machine and route:

Debug-layer message main ffe310e PR 3f204cd
UAV-state resource "invalid for use as a vertex buffer" 162 8,459 (all from DrawIndexedInstanced)
Transition barrier before-state mismatch 199 223
CreateComputeShader: wants wave lane count 64, device max 32 117 116
Shaders that do not translate 443 413

Both runs end in DXGI_ERROR_DEVICE_HUNG (TDR) during the cutscene, which runs at roughly 1.5 to 2.9 fps beforehand. The hang persisted with TdrDelay raised to 10 s on main. On this card the PR does not remove the vertex-buffer state errors, and the count goes up sharply. The wave64 refusals are unchanged either way, so they may be the larger blocker on NVIDIA (#578 / #223).

Happy to run another build.

**@⁠Ryanarcx2** on GitHub · 2026-11-24 20:49 UTC · [original](https://github.com/Marvisak/VIctory/pull/1502#issuecomment-7144094613) Tested `3f204cd` on an RTX 5070 Ti (driver 32.0.16.1742), Windows 11, diag build with `VICTORY_D3D12_DEBUG=1`, running to the first story cutscene. Compared against `main` at `ffe310e`, same machine and route: | Debug-layer message | main `ffe310e` | PR `3f204cd` | |---|---|---| | UAV-state resource "invalid for use as a vertex buffer" | 162 | **8,459** (all from `DrawIndexedInstanced`) | | Transition barrier before-state mismatch | 199 | 223 | | `CreateComputeShader`: wants wave lane count 64, device max 32 | 117 | 116 | | Shaders that do not translate | 443 | 413 | Both runs end in `DXGI_ERROR_DEVICE_HUNG` (TDR) during the cutscene, which runs at roughly 1.5 to 2.9 fps beforehand. The hang persisted with TdrDelay raised to 10 s on `main`. On this card the PR does not remove the vertex-buffer state errors, and the count goes up sharply. The wave64 refusals are unchanged either way, so they may be the larger blocker on NVIDIA (#578 / #223). Happy to run another build.
Author
Owner

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

Automated triage for the maintainers. Closing because another open pull request covers the same change.

See #334. Buffer-copy state transitions as in #334, and by its own description not validated on Windows or any D3D12 device.

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

**@⁠Marvisak** on GitHub · 2026-11-25 00:41 UTC · [original](https://github.com/Marvisak/VIctory/pull/1502#issuecomment-7148779037) Automated triage for the maintainers. Closing because another open pull request covers the same change. See #334. Buffer-copy state transitions as in #334, and by its own description not validated on Windows or any D3D12 device. If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

Pull request closed

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!1502
No description provided.