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

Closed
Thomas73737 wants to merge 1 commit from upstream-pr/1502 into main
Thomas73737 commented 2026-11-24 18:33:48 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Thomas73737 on 2026-11-24T18:33:48Z.


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.
<!-- greyfinch-sync:Marvisak/VIctory:issue:6588753967 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1502). Originally posted by [Thomas73737](https://github.com/Thomas73737) on 2026-11-24T18:33:48Z. --- ## 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.
Ryanarcx2 commented 2026-11-24 21:03:41 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Ryanarcx2 on 2026-11-24T20:49:00Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7144094613 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1502#issuecomment-7144094613). Originally posted by [Ryanarcx2](https://github.com/Ryanarcx2) on 2026-11-24T20:49:00Z. --- 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.
upstream-sync closed this pull request 2026-11-25 01:06:45 +00:00
Marvisak commented 2026-11-25 01:08:14 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:41:41Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148779037 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1502#issuecomment-7148779037). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:41:41Z. --- 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

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