GPU: indirect argument buffers back to the common state after execution #1506

Closed
Bladureau wants to merge 1 commit from upstream-pr/1507 into main
Bladureau commented 2026-11-24 18:36:39 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Bladureau on 2026-11-24T18:36:39Z.


What

indirect::done now moves the argument buffer from INDIRECT_ARGUMENT to
COMMON, not to UNORDERED_ACCESS.

Why

Title buffers' host copies are created in COMMON (host.rs) and rely on
implicit promotion and decay: nothing else in the crate transitions them.
The indirect path is the exception. After ExecuteIndirect, done() left
the buffer explicitly in UNORDERED_ACCESS for the rest of the list, so it
could no longer be promoted. The same title buffer also holds vertex data, so
a later IASetVertexBuffers in that list found it in a state that does not
allow vertex reads. With the debug layer on:

D3D12 ERROR: ID3D12CommandQueue1::ExecuteCommandLists: Using IASetVertexBuffers
on Command List (...): Resource state (0x8: D3D12_RESOURCE_STATE_UNORDERED_ACCESS)
of resource (...:'title buffer 0x1c9b0000+0xae00000') (subresource: 0) is invalid
for use as a vertex buffer. [id=538]

Back in COMMON, the list's later uses promote the buffer again, as they do
everywhere else.

Results

These are diagnostics builds on an RTX 4060 Laptop, with VICTORY_D3D12_DEBUG=1
and VICTORY_D3D12_DRED=1, through the first mission's intro:

Run This change id=538 (IASetVertexBuffers) id=527 (barrier before-state)
1 no 125 137
2 yes 0 99
3 (control, warm cache) no 18 31

All of these errors are on the same buffer, so the counts follow how long
each run lasted.

What this does not fix

  • The id=527 errors remain. indirect::bound still assumes the buffer is
    in UNORDERED_ACCESS before its UNORDERED_ACCESS → INDIRECT_ARGUMENT
    transition. If the list has already promoted the buffer to a read state
    (vertex data), that before-state is wrong. Fixing it needs per-list state
    tracking for buffers, like HostList::transition does for textures. I left
    that out of this PR.
  • The world's GPU hang on this machine is not fixed. The control run
    shows this change is not what triggers it: the hang comes at a different
    point each run, with or without the change. See the NVIDIA test report, #1508.

Testing

  • cargo test -p victory-gpu: 50 passed, 1 ignored
  • cargo clippy -p victory-gpu --all-targets: clean
  • Live runs as in the table above

🤖 Generated with Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:issue:6588805425 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1507). Originally posted by [Bladureau](https://github.com/Bladureau) on 2026-11-24T18:36:39Z. --- ## What `indirect::done` now moves the argument buffer from `INDIRECT_ARGUMENT` to `COMMON`, not to `UNORDERED_ACCESS`. ## Why Title buffers' host copies are created in `COMMON` (`host.rs`) and rely on implicit promotion and decay: nothing else in the crate transitions them. The indirect path is the exception. After `ExecuteIndirect`, `done()` left the buffer explicitly in `UNORDERED_ACCESS` for the rest of the list, so it could no longer be promoted. The same title buffer also holds vertex data, so a later `IASetVertexBuffers` in that list found it in a state that does not allow vertex reads. With the debug layer on: ``` D3D12 ERROR: ID3D12CommandQueue1::ExecuteCommandLists: Using IASetVertexBuffers on Command List (...): Resource state (0x8: D3D12_RESOURCE_STATE_UNORDERED_ACCESS) of resource (...:'title buffer 0x1c9b0000+0xae00000') (subresource: 0) is invalid for use as a vertex buffer. [id=538] ``` Back in `COMMON`, the list's later uses promote the buffer again, as they do everywhere else. ## Results These are diagnostics builds on an RTX 4060 Laptop, with `VICTORY_D3D12_DEBUG=1` and `VICTORY_D3D12_DRED=1`, through the first mission's intro: | Run | This change | id=538 (`IASetVertexBuffers`) | id=527 (barrier before-state) | |-----|-------------|-------------------------------|-------------------------------| | 1 | no | 125 | 137 | | 2 | yes | **0** | 99 | | 3 (control, warm cache) | no | 18 | 31 | All of these errors are on the same buffer, so the counts follow how long each run lasted. ## What this does not fix * **The id=527 errors remain.** `indirect::bound` still assumes the buffer is in `UNORDERED_ACCESS` before its `UNORDERED_ACCESS → INDIRECT_ARGUMENT` transition. If the list has already promoted the buffer to a read state (vertex data), that before-state is wrong. Fixing it needs per-list state tracking for buffers, like `HostList::transition` does for textures. I left that out of this PR. * **The world's GPU hang on this machine is not fixed.** The control run shows this change is not what triggers it: the hang comes at a different point each run, with or without the change. See the NVIDIA test report, #1508. ## Testing * `cargo test -p victory-gpu`: 50 passed, 1 ignored * `cargo clippy -p victory-gpu --all-targets`: clean * Live runs as in the table above 🤖 Generated with [Claude Code](https://claude.com/claude-code)
copilot-pull-request-reviewer[bot commented 2026-11-24 19:03:45 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-24T18:36:51Z.

Review: COMMENTED


Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

<!-- greyfinch-sync:Marvisak/VIctory:review:6045162174 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1507#pullrequestreview-6045162174). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/copilot-pull-request-reviewer%5Bbot%5D) on 2026-11-24T18:36:51Z. **Review:** COMMENTED --- Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
Bladureau commented 2026-11-24 19:04:26 +00:00 (Migrated from github.com)

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


Follow-up: #1527 fixes the id=527 errors that this PR leaves (indirect::bound's before-state). It is stacked on this branch.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7141171646 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1507#issuecomment-7141171646). Originally posted by [Bladureau](https://github.com/Bladureau) on 2026-11-24T18:48:09Z. --- Follow-up: #1527 fixes the id=527 errors that this PR leaves (`indirect::bound`'s before-state). It is stacked on this branch.
upstream-sync closed this pull request 2026-11-24 20:02:22 +00:00
mercuryVM commented 2026-11-24 20:02:22 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T19:46:04Z.

Review: APPROVED


Tested f77bd04 on Windows 11, RTX 5070, MSVC: builds, cargo test --workspace --no-fail-fast 612 passed, 0 failed (on our fork main).

  • This is right. Title buffers' host copies live in COMMON and rely on promotion. done leaving the buffer explicitly in UNORDERED_ACCESS meant a later IASetVertexBuffers or SRV read of the same buffer in that list found it in a state that state promotion can't move out of.
  • A second ExecuteIndirect in the same list still works. bound runs its clamp dispatch through a root UAV on that buffer before its explicit UNORDERED_ACCESS → INDIRECT_ARGUMENT barrier, and that dispatch promotes the buffer from COMMON to UNORDERED_ACCESS.
  • Nit: there's no test. A list with an indirect draw followed by a vertex-buffer use of the same buffer, run with VICTORY_D3D12_DEBUG=1, would have caught the old state error.

Merged into our fork's main.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:review:6046195666 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1507#pullrequestreview-6046195666). Originally posted by [mercuryVM](https://github.com/mercuryVM) on 2026-11-24T19:46:04Z. **Review:** APPROVED --- Tested f77bd04 on Windows 11, RTX 5070, MSVC: builds, `cargo test --workspace --no-fail-fast` 612 passed, 0 failed (on our fork main). - This is right. Title buffers' host copies live in `COMMON` and rely on promotion. `done` leaving the buffer explicitly in `UNORDERED_ACCESS` meant a later `IASetVertexBuffers` or SRV read of the same buffer in that list found it in a state that state promotion can't move out of. - A second `ExecuteIndirect` in the same list still works. `bound` runs its clamp dispatch through a root UAV on that buffer before its explicit `UNORDERED_ACCESS → INDIRECT_ARGUMENT` barrier, and that dispatch promotes the buffer from `COMMON` to `UNORDERED_ACCESS`. - Nit: there's no test. A list with an indirect draw followed by a vertex-buffer use of the same buffer, run with `VICTORY_D3D12_DEBUG=1`, would have caught the old state error. Merged into our fork's main. AI-assisted (Claude Code).
Bladureau commented 2026-11-24 20:03:23 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Bladureau on 2026-11-24T19:58:19Z.


Closing in favour of #334, which fixes the same debug-layer errors (ids 527 and 538) more completely: it also tracks shader writes and table views, and has a debug-layer test. On this RTX 4060 Laptop, #334 with #578 gives 0 of each in the title: https://github.com/Marvisak/VIctory/pull/334#issuecomment-7142860514

<!-- greyfinch-sync:Marvisak/VIctory:comment:7142861433 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1507#issuecomment-7142861433). Originally posted by [Bladureau](https://github.com/Bladureau) on 2026-11-24T19:58:19Z. --- Closing in favour of #334, which fixes the same debug-layer errors (ids 527 and 538) more completely: it also tracks shader writes and table views, and has a debug-layer test. On this RTX 4060 Laptop, #334 with #578 gives 0 of each in the title: https://github.com/Marvisak/VIctory/pull/334#issuecomment-7142860514

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