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

Closed
github-bot wants to merge 2 commits from gh-pr/1527/head into gh-pr/1527/base
Owner

@⁠Bladureau on GitHub · 2026-11-24 18:48 UTC · original
Bladureau:fix/indirect-args-tracked-reads → main · +248 −9 · 5 files · 2 commits · closed without merging

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

**@⁠Bladureau** on GitHub · 2026-11-24 18:48 UTC · [original](https://github.com/Marvisak/VIctory/pull/1527) `Bladureau:fix/indirect-args-tracked-reads` → `main` · +248 −9 · 5 files · 2 commits · closed without merging **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)
Title buffers' host copies live in the common state and rely on implicit
promotion and decay. indirect::done left the argument buffer in unordered
access for the rest of the list, so a later vertex read of the same title
buffer found it in a state that does not allow it (debug layer id=538).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
indirect::bound assumed its argument buffer was in unordered access. It is
a title buffer's host copy, so it is in the common state or in the read
states the list's own bindings promoted it to (vertex data, indices, root
views, counts), and the debug layer reported the wrong before-state
(id=527). Each list now notes those promotions (promotion.rs). The clamp
starts from them, the execution holds the buffer in generic read, since
its own bindings may read the same buffer, and the list ends with every
promoted buffer back in the common state for the next list of the
submission.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:35:16 +00:00
github-bot closed this pull request 2026-11-26 04:35:16 +00:00
Author
Owner

@⁠Bladureau on GitHub · 2026-11-24 19:58 UTC · original

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: #334

**@⁠Bladureau** on GitHub · 2026-11-24 19:58 UTC · [original](https://github.com/Marvisak/VIctory/pull/1527#issuecomment-7142862465) 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://git.gtahub.st/github/Marvisak--VIctory/pulls/334

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