GPU: indirect execution starts from the read states the list promoted #1526

Closed
Bladureau wants to merge 2 commits from upstream-pr/1527 into main
Bladureau commented 2026-11-24 18:48:00 +00:00 (Migrated from github.com)

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


This PR builds on #1507. Until #1507 is merged, its commit (f77bd04)
shows up here too. The only new commit in this PR is 2ae2e72.

What

The second half of the indirect path's state handling: the id=527 errors
that #1507 left.

indirect::bound assumed its argument buffer was in UNORDERED_ACCESS. That
buffer is a title buffer's host copy. It is in COMMON or in the read states
the list's own bindings promoted it to. When a draw had already read it as
vertex data, the debug layer reported the wrong before-state:

D3D12 ERROR: ID3D12CommandQueue1::ExecuteCommandLists: Using ResourceBarrier on
Command List (...): Before state (0x8: D3D12_RESOURCE_STATE_UNORDERED_ACCESS) of
resource (...:'title buffer 0x1c9b0000+0xae00000') (subresource: 0) specified by
transition barrier does not match with the current resource state
(0x1: D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER) (assumed at first use)
[id=527]

How

  • promotion.rs (new): each HostList notes the read states its own
    bindings promote title buffers to. Read states add up, as the host's do.
    The module is pure bookkeeping, unit-tested without a GPU.
  • Bindings that note a read (draw.rs):
    Binding Read state noted
    vertex buffers VERTEX_AND_CONSTANT_BUFFER
    index buffer INDEX_BUFFER
    root CBVs VERTEX_AND_CONSTANT_BUFFER
    root SRVs NON_PIXEL_SHADER_RESOURCE, or PIXEL_SHADER_RESOURCE for the pixel stage
    indirect count buffer INDIRECT_ARGUMENT
  • indirect::bound holds the buffer and starts from what the list
    promoted. From COMMON, the clamp's root UAV promotes it by itself, as
    before. From read states, an explicit transition to UNORDERED_ACCESS
    comes first.
  • During the execution, the buffer is held in GENERIC_READ instead of
    INDIRECT_ARGUMENT. The execution's own bindings (made after bound) can
    read the same title buffer as vertices, indices or root SRVs. done
    returns it to COMMON and releases it.
  • HostList::close returns every buffer the list promoted to COMMON.
    Decay only happens at the end of ExecuteCommandLists, and a submission
    holds many lists, so without this the next list of the submission could
    receive a buffer still in read states. Its clamp would then write a
    buffer it cannot promote to UNORDERED_ACCESS.

Limit: accesses through descriptor tables are not noted. The debug
layer does not track them either, without GPU-based validation.

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 id=527 id=538 Other errors
main 137 125 622, 599, 232
#1507 99 0 622, 599, 232
this PR 0 0 622, 599, 232

None of the other errors are state errors, and each was there before:

Error Cause
622 wave64 compute shaders on a wave32 GPU
599 one texture format that does not allow UAVs
232 the device removal itself

The new "a host list ends with a title buffer in an explicit state"
warning never fired.

This does not fix the world's GPU hang on this machine. It still comes
during the intro. #1508 has the measurements, which point at video memory
(8 GB).

Testing

  • cargo test -p victory-gpu: 53 passed, 1 ignored (3 new tests in
    promotion)
  • cargo clippy -p victory-gpu --all-targets, with and without
    --features diagnostics: clean
  • Live runs as in the table above

🤖 Generated with Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:issue:6588998562 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1527). Originally posted by [Bladureau](https://github.com/Bladureau) on 2026-11-24T18:48:00Z. --- **This PR builds on #1507.** Until #1507 is merged, its commit (`f77bd04`) shows up here too. The only new commit in this PR is `2ae2e72`. ## What The second half of the indirect path's state handling: the id=527 errors that #1507 left. `indirect::bound` assumed its argument buffer was in `UNORDERED_ACCESS`. That buffer is a title buffer's host copy. It is in `COMMON` or in the read states the list's own bindings promoted it to. When a draw had already read it as vertex data, the debug layer reported the wrong before-state: ``` D3D12 ERROR: ID3D12CommandQueue1::ExecuteCommandLists: Using ResourceBarrier on Command List (...): Before state (0x8: D3D12_RESOURCE_STATE_UNORDERED_ACCESS) of resource (...:'title buffer 0x1c9b0000+0xae00000') (subresource: 0) specified by transition barrier does not match with the current resource state (0x1: D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER) (assumed at first use) [id=527] ``` ## How * **`promotion.rs` (new):** each `HostList` notes the read states its own bindings promote title buffers to. Read states add up, as the host's do. The module is pure bookkeeping, unit-tested without a GPU. * **Bindings that note a read** (`draw.rs`): | Binding | Read state noted | |---|---| | vertex buffers | `VERTEX_AND_CONSTANT_BUFFER` | | index buffer | `INDEX_BUFFER` | | root CBVs | `VERTEX_AND_CONSTANT_BUFFER` | | root SRVs | `NON_PIXEL_SHADER_RESOURCE`, or `PIXEL_SHADER_RESOURCE` for the pixel stage | | indirect count buffer | `INDIRECT_ARGUMENT` | * **`indirect::bound`** holds the buffer and starts from what the list promoted. From `COMMON`, the clamp's root UAV promotes it by itself, as before. From read states, an explicit transition to `UNORDERED_ACCESS` comes first. * **During the execution, the buffer is held in `GENERIC_READ`** instead of `INDIRECT_ARGUMENT`. The execution's own bindings (made after `bound`) can read the same title buffer as vertices, indices or root SRVs. `done` returns it to `COMMON` and releases it. * **`HostList::close`** returns every buffer the list promoted to `COMMON`. Decay only happens at the end of `ExecuteCommandLists`, and a submission holds many lists, so without this the next list of the submission could receive a buffer still in read states. Its clamp would then write a buffer it cannot promote to `UNORDERED_ACCESS`. **Limit:** accesses through descriptor tables are not noted. The debug layer does not track them either, without GPU-based validation. ## 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 | id=527 | id=538 | Other errors | |---|---|---|---| | main | 137 | 125 | 622, 599, 232 | | #1507 | 99 | 0 | 622, 599, 232 | | **this PR** | **0** | **0** | 622, 599, 232 | None of the other errors are state errors, and each was there before: | Error | Cause | |---|---| | 622 | wave64 compute shaders on a wave32 GPU | | 599 | one texture format that does not allow UAVs | | 232 | the device removal itself | The new "a host list ends with a title buffer in an explicit state" warning never fired. **This does not fix the world's GPU hang on this machine.** It still comes during the intro. #1508 has the measurements, which point at video memory (8 GB). ## Testing * `cargo test -p victory-gpu`: 53 passed, 1 ignored (3 new tests in `promotion`) * `cargo clippy -p victory-gpu --all-targets`, with and without `--features diagnostics`: 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:52 +00:00 (Migrated from github.com)

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

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:6045316303 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1527#pullrequestreview-6045316303). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/copilot-pull-request-reviewer%5Bbot%5D) on 2026-11-24T18:48:10Z. **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.
upstream-sync closed this pull request 2026-11-24 20:02:26 +00:00
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:22Z.


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:7142862465 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1527#issuecomment-7142862465). Originally posted by [Bladureau](https://github.com/Bladureau) on 2026-11-24T19:58:22Z. --- 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!1526
No description provided.