Copies at their place: their destination back to COMMON (#350) #425

Closed
github-bot wants to merge 1 commit from github-bot/gh-425 into a-publier AGit
Owner

@⁠MamaLeVrai on GitHub · 2026-11-27 00:57 UTC · original
MamaLeVrai:copy-dest-root-srv → a-publier · +177 −2 · 1 files · 1 commits · closed without merging

Fixes #350.

What

HostList::place_copy (host/place.rs, copies at their place, VICTORY_COPIES_IN_PLACE on by default) copied into the destination's host copy and followed it only with wait_for_all. That is a global barrier, or an aliasing + UAV barrier, so the buffer stayed promoted to COPY_DEST. That is a write state, and nothing can promote it again for the rest of the ExecuteCommandLists call. Readers after it then used the buffer in an invalid state:

  • the compare list of host copies "on the card": place_copy declares the range with gpu_writes, the compare binds it with SetComputeRootShaderResourceView(1, r.shadow.buffer…) (host.rs ~4729), and it goes to the queue in the same ExecuteCommandLists call after the runs. This is the issue's exact message: "COPY_DEST (promoted from COMMON state) … title buffer … on the card … invalid for use as a root shader resource";
  • a draw's root SRV later in the same list, with VICTORY_ROOT_SRV_DIRECT=1 (by default root SRVs are one-view tables, which the layer does not check).

Also, where source and destination are the same host copy, it was promoted to COPY_SOURCE and then written as COPY_DEST.

Change: after the copy, to.buffer goes COPY_DEST -> COMMON, then wait_for_all. In the same-buffer case, from.buffer goes COPY_SOURCE -> COMMON before it is copied into. That is how card_steps::record and the upcheck helpers already leave host copies, "as the submission's lists expect them".

Refreshes in a prelude list (the issue's second candidate) are not involved. Preludes only touch textures, and the card sync list goes in an ExecuteCommandLists call of its own.

Test

host::place::tests::copies_in_place_leave_their_buffers_to_root_views, ignored. It wants a diagnostics build, VICTORY_D3D12_DEBUG=1, and a process of its own. It listens with ID3D12InfoQueue1::RegisterMessageCallback, because the host's own submission empties the message queue. It runs 4 cases (copy then root SRV, copy then compare, same-buffer copy, and so on) for a 256 KiB host copy in PC memory and an 8 MiB one on the card, then executes.

VICTORY_D3D12_DEBUG=1 cargo test --release -p victory-gpu --features diagnostics --lib -- --ignored --exact host::place::tests::copies_in_place_leave_their_buffers_to_root_views, on an RX 6950 XT:

  • without the fix (place.rs as on a-publier, only the test added): 7 of the 8 cases get messages (1, 1, 1, 0 in PC memory; 2, 2, 1, 1 on the card), and the test fails;
  • with it: 0 messages in all 8, and the compare ran (1 or 2 passes) in each card case.

cargo test --release -p victory-gpu --lib, twice before and after: 396 passed, 0 failed, 34 / 35 ignored (the new ignored test).

Not covered

  • A placed copy into a buffer that something read earlier in the same list (a direct root view, a vertex or index buffer, an indirect argument, another copy's source) is still invalid, as before. Fixing that needs per-list state tracking for host copies, which only exists for textures.
  • The source of a copy between two host copies is left promoted to COPY_SOURCE, as is place_source's. Taking it back to COMMON would be wrong if an earlier read in the list had already combined that state.
  • Not run in the game. On AMD the global barrier probably made the copy's bytes visible anyway, so this may change nothing on screen. It does clear the debug layer's view for finding real errors.

AI-assisted (Claude Code); no game data.

🤖 Generated with Claude Code

**@⁠MamaLeVrai** on GitHub · 2026-11-27 00:57 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/425) `MamaLeVrai:copy-dest-root-srv` → `a-publier` · +177 −2 · 1 files · 1 commits · closed without merging Fixes #350. ## What `HostList::place_copy` (`host/place.rs`, copies at their place, `VICTORY_COPIES_IN_PLACE` on by default) copied into the destination's host copy and followed it only with `wait_for_all`. That is a global barrier, or an aliasing + UAV barrier, so the buffer stayed promoted to `COPY_DEST`. That is a write state, and nothing can promote it again for the rest of the `ExecuteCommandLists` call. Readers after it then used the buffer in an invalid state: - the compare list of host copies "on the card": `place_copy` declares the range with `gpu_writes`, the compare binds it with `SetComputeRootShaderResourceView(1, r.shadow.buffer…)` (host.rs ~4729), and it goes to the queue in the same `ExecuteCommandLists` call after the runs. This is the issue's exact message: "COPY_DEST (promoted from COMMON state) … title buffer … on the card … invalid for use as a root shader resource"; - a draw's root SRV later in the same list, with `VICTORY_ROOT_SRV_DIRECT=1` (by default root SRVs are one-view tables, which the layer does not check). Also, where source and destination are the same host copy, it was promoted to `COPY_SOURCE` and then written as `COPY_DEST`. **Change:** after the copy, `to.buffer` goes `COPY_DEST -> COMMON`, then `wait_for_all`. In the same-buffer case, `from.buffer` goes `COPY_SOURCE -> COMMON` before it is copied into. That is how `card_steps::record` and the upcheck helpers already leave host copies, "as the submission's lists expect them". Refreshes in a prelude list (the issue's second candidate) are not involved. Preludes only touch textures, and the card sync list goes in an `ExecuteCommandLists` call of its own. ## Test `host::place::tests::copies_in_place_leave_their_buffers_to_root_views`, ignored. It wants a diagnostics build, `VICTORY_D3D12_DEBUG=1`, and a process of its own. It listens with `ID3D12InfoQueue1::RegisterMessageCallback`, because the host's own submission empties the message queue. It runs 4 cases (copy then root SRV, copy then compare, same-buffer copy, and so on) for a 256 KiB host copy in PC memory and an 8 MiB one on the card, then executes. `VICTORY_D3D12_DEBUG=1 cargo test --release -p victory-gpu --features diagnostics --lib -- --ignored --exact host::place::tests::copies_in_place_leave_their_buffers_to_root_views`, on an RX 6950 XT: - without the fix (place.rs as on `a-publier`, only the test added): 7 of the 8 cases get messages (1, 1, 1, 0 in PC memory; 2, 2, 1, 1 on the card), and the test fails; - with it: 0 messages in all 8, and the compare ran (1 or 2 passes) in each card case. `cargo test --release -p victory-gpu --lib`, twice before and after: 396 passed, 0 failed, 34 / 35 ignored (the new ignored test). ## Not covered - A placed copy into a buffer that something read earlier in the same list (a direct root view, a vertex or index buffer, an indirect argument, another copy's source) is still invalid, as before. Fixing that needs per-list state tracking for host copies, which only exists for textures. - The source of a copy between two host copies is left promoted to `COPY_SOURCE`, as is `place_source`'s. Taking it back to COMMON would be wrong if an earlier read in the list had already combined that state. - Not run in the game. On AMD the global barrier probably made the copy's bytes visible anyway, so this may change nothing on screen. It does clear the debug layer's view for finding real errors. AI-assisted (Claude Code); no game data. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
HostList::place_copy left the destination host copy promoted to
COPY_DEST. A write promotion is final for the rest of the
ExecuteCommandLists call, so a later root SRV of the same list
(VICTORY_ROOT_SRV_DIRECT=1 draws) and the card compare list that follows
the runs in the same call (it reads the declared ranges, which include
the copy's, as a root SRV) were refused by the debug layer (id 538,
"COPY_DEST (promoted from COMMON state) ... invalid for use as a root
shader resource"). The destination now goes back to COMMON after the
copy; within one host copy, the source side goes back to COMMON before
it is copied into.

Test (ignored; diagnostics build, VICTORY_D3D12_DEBUG=1):
host::place::tests::copies_in_place_leave_their_buffers_to_root_views.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 00:59:47 +00:00
Author
Owner

@⁠copilot-pull-request-reviewer[bot] on GitHub · 2026-11-27 00:57 UTC · original · reviewed

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.

**@⁠copilot-pull-request-reviewer[bot]** on GitHub · 2026-11-27 00:57 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/425#pullrequestreview-6082114237) · **reviewed** 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.
github-bot closed this pull request 2026-11-27 02:16:13 +00:00
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-27 01:37 UTC · original

Closing in favor of #424, which fixes the same thing and also tracks buffer states per list. It passes this PR's debug-layer test with 0 messages in all 8 cases (details on #424).

AI-assisted (Claude Code); no game data.

**@⁠MamaLeVrai** on GitHub · 2026-11-27 01:37 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/425#issuecomment-7207445003) Closing in favor of #424, which fixes the same thing and also tracks buffer states per list. It passes this PR's debug-layer test with 0 messages in all 8 cases (details on #424). AI-assisted (Claude Code); no game data.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.