Debug layer: a card-side title buffer is read as a root SRV while still promoted to COPY_DEST (id 538) #350

Open
opened 2026-11-27 00:58:12 +00:00 by github-bot · 2 comments
Owner

@⁠MamaLeVrai on GitHub · 2026-11-26 21:32 UTC · original

What

With the D3D12 debug layer on (VICTORY_D3D12_DEBUG=1, diag build of a-publier cd8dfc0, default scripts\play.ps1 settings), the layer reports this error four times in the first minute of a run (three at 20:55:42 and one at 20:55:51, id 538, severity 1):

D3D12: ID3D12CommandQueue1::ExecuteCommandLists: Using SetComputeRootShaderResourceView on Command List (...:'Unnamed ID3D12GraphicsCommandList Object'): Resource state (0x400: D3D12_RESOURCE_STATE_COPY_DEST) (promoted from COMMON state) of resource (...:'title buffer 0xe30690000+0xa7df00 on the card') (subresource: 0) is invalid for use as a root shader resource. Expected State Bits (all): 0x40: D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE, Assumed Actual State: 0x400: D3D12_RESOURCE_STATE_COPY_DEST, Missing State: 0x40: D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE.

So a copy into a card-side host copy of a title buffer promoted it to COPY_DEST, and a later compute root SRV read it in the same list, or in a later list of the same ExecuteCommandLists, with no transition in between. A promoted write state does not decay until the call ends.

Where it may come from (not pinned down)

Two places record such copies with no transition of the destination afterwards. I have not found out which one this run hit:

  • HostList::place_copy (host/place.rs, copies at their place, VICTORY_COPIES_IN_PLACE on by default): CopyBufferRegion(&to.buffer, ...) is followed only by wait_for_all (a global barrier, or an aliasing + UAV barrier). Neither moves to.buffer out of COPY_DEST. Then to.gpu_writes(...), and the rest of the list may bind it as a root view.
  • Refreshes recorded in a prelude: outside VICTORY_GPU_TIMING, a submission's preludes and runs go to the queue in one ExecuteCommandLists(group) (host.rs, the groups = [(&lists[..], ())] path). So a prelude's promotion to COPY_DEST is still in force when the run's root SRV uses the buffer.

A transition COPY_DEST -> COMMON of the destination after such copies would let the later root view promote again. Doing that only where the buffer was not already in a read state in that list needs the list's state tracking, so I have not made a PR.

Relevance

On AMD the global barrier probably makes the copy's bytes visible anyway, so this may not change what the shaders read. In this run it is also not what lost the device: the loss (0x887A0007, nothing of ours on the card, #329) came 3.6 s after the last of these errors, and the layer reported nothing else at the loss but Kernel memory failure (id 834). I am filing it because it is a real spec violation the layer can see, and it gets in the way of finding real errors with the layer.

Host: RX 6950 XT (RDNA 2), driver 32.0.21045.29003, Windows 11 build 26300.

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

**@⁠MamaLeVrai** on GitHub · 2026-11-26 21:32 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/issues/350) ## What With the D3D12 debug layer on (`VICTORY_D3D12_DEBUG=1`, diag build of `a-publier` `cd8dfc0`, default `scripts\play.ps1` settings), the layer reports this error four times in the first minute of a run (three at 20:55:42 and one at 20:55:51, id 538, severity 1): ``` D3D12: ID3D12CommandQueue1::ExecuteCommandLists: Using SetComputeRootShaderResourceView on Command List (...:'Unnamed ID3D12GraphicsCommandList Object'): Resource state (0x400: D3D12_RESOURCE_STATE_COPY_DEST) (promoted from COMMON state) of resource (...:'title buffer 0xe30690000+0xa7df00 on the card') (subresource: 0) is invalid for use as a root shader resource. Expected State Bits (all): 0x40: D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE, Assumed Actual State: 0x400: D3D12_RESOURCE_STATE_COPY_DEST, Missing State: 0x40: D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE. ``` So a copy into a card-side host copy of a title buffer promoted it to `COPY_DEST`, and a later compute root SRV read it in the same list, or in a later list of the same `ExecuteCommandLists`, with no transition in between. A promoted write state does not decay until the call ends. ## Where it may come from (not pinned down) Two places record such copies with no transition of the destination afterwards. I have not found out which one this run hit: - `HostList::place_copy` (`host/place.rs`, copies at their place, `VICTORY_COPIES_IN_PLACE` on by default): `CopyBufferRegion(&to.buffer, ...)` is followed only by `wait_for_all` (a global barrier, or an aliasing + UAV barrier). Neither moves `to.buffer` out of `COPY_DEST`. Then `to.gpu_writes(...)`, and the rest of the list may bind it as a root view. - Refreshes recorded in a prelude: outside `VICTORY_GPU_TIMING`, a submission's preludes and runs go to the queue in one `ExecuteCommandLists(group)` (`host.rs`, the `groups = [(&lists[..], ())]` path). So a prelude's promotion to `COPY_DEST` is still in force when the run's root SRV uses the buffer. A transition `COPY_DEST -> COMMON` of the destination after such copies would let the later root view promote again. Doing that only where the buffer was not already in a read state in that list needs the list's state tracking, so I have not made a PR. ## Relevance On AMD the global barrier probably makes the copy's bytes visible anyway, so this may not change what the shaders read. In this run it is also **not** what lost the device: the loss (`0x887A0007`, nothing of ours on the card, #329) came 3.6 s after the last of these errors, and the layer reported nothing else at the loss but `Kernel memory failure` (id 834). I am filing it because it is a real spec violation the layer can see, and it gets in the way of finding real errors with the layer. Host: RX 6950 XT (RDNA 2), driver 32.0.21045.29003, Windows 11 build 26300. AI-assisted (Claude Code); no game data.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 00:58:12 +00:00
Author
Owner

@⁠ANDREANIADS on GitHub · 2026-11-26 21:43 UTC · original

I traced the two proposed paths at cd8dfc06. The card-shadow refresh that copies the title buffers submits its own command list at line 4618. The batched per-list preludes are built by HostList::prelude for texture uploads and texture transitions. This narrows where to trace the buffer named in the validation message. Shadow refresh and submission · Per-list prelude

HostList::place_copy is still a candidate. Its destination receives a buffer copy followed by wait_for_all. The same-shadow case also uses the original buffer as a source before writing it back through an intermediate. Logging the physical source/destination and command-list identity there, then at the next root SRV bind, would distinguish the paths before choosing a resource-specific transition. Placed copies

I ran a positive control on a physical RTX 3070: start in COMMON, copy four words, transition COPY_DEST → NON_PIXEL_SHADER_RESOURCE, then dispatch a compute shader with a root SRV and read back. All four words matched in both layouts: one direct command list, and two direct lists in a single ExecuteCommandLists call. The local debug-layer component is missing (0x887A002D), so the original ID 538 and in-game device loss remain unverified here. Tested with Codex.

dxgi-buffer-state-control.zip

**@⁠ANDREANIADS** on GitHub · 2026-11-26 21:43 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/issues/350#issuecomment-7204006509) I traced the two proposed paths at `cd8dfc06`. The card-shadow refresh that copies the title buffers submits its own command list at line 4618. The batched per-list preludes are built by `HostList::prelude` for texture uploads and texture transitions. This narrows where to trace the buffer named in the validation message. [Shadow refresh and submission](https://github.com/Belobug/VIctory-Belobug-AMD/blob/cd8dfc06/crates/victory-gpu/src/host.rs#L4518-L4619) · [Per-list prelude](https://github.com/Belobug/VIctory-Belobug-AMD/blob/cd8dfc06/crates/victory-gpu/src/host.rs#L6905) `HostList::place_copy` is still a candidate. Its destination receives a buffer copy followed by `wait_for_all`. The same-shadow case also uses the original buffer as a source before writing it back through an intermediate. Logging the physical source/destination and command-list identity there, then at the next root SRV bind, would distinguish the paths before choosing a resource-specific transition. [Placed copies](https://github.com/Belobug/VIctory-Belobug-AMD/blob/cd8dfc06/crates/victory-gpu/src/host/place.rs#L235-L287) I ran a positive control on a physical RTX 3070: start in COMMON, copy four words, transition `COPY_DEST → NON_PIXEL_SHADER_RESOURCE`, then dispatch a compute shader with a root SRV and read back. All four words matched in both layouts: one direct command list, and two direct lists in a single `ExecuteCommandLists` call. The local debug-layer component is missing (`0x887A002D`), so the original ID 538 and in-game device loss remain unverified here. Tested with Codex. [dxgi-buffer-state-control.zip](https://github.com/user-attachments/files/35484783/dxgi-buffer-state-control.zip)
Author
Owner

@⁠BE29ZZ on GitHub · 2026-11-27 00:53 UTC · original

Opened #424 to fix this.

It adds per-HostList direct buffer state tracking (crates/victory-gpu/src/host/buffers.rs) wired into place_copy / place_source, indirect clamps, draw direct buffer bindings, HostList::prelude cross-list handoffs, and plan.check:

  • Restores place_copy destination (COPY_DEST -> COMMON) and source buffers (including same-buffer COPY_SOURCE -> COPY_DEST -> COMMON) with exact pre-transition StateBefore when a buffer was already promoted earlier in the list or in an earlier list of the same ExecuteCommandLists batch.
  • Verified locally on Windows 11 x64 / RTX 3060 / Rust 1.98.1: both cargo clippy passes clean, cargo test -p victory-gpu --lib --locked -- --test-threads=1 (402 passed, 0 failed) including new unit and GPU tests, and cargo test -p xtask --locked (9 passed).
**@⁠BE29ZZ** on GitHub · 2026-11-27 00:53 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/issues/350#issuecomment-7206839941) Opened #424 to fix this. It adds per-`HostList` direct buffer state tracking (`crates/victory-gpu/src/host/buffers.rs`) wired into `place_copy` / `place_source`, `indirect` clamps, `draw` direct buffer bindings, `HostList::prelude` cross-list handoffs, and `plan.check`: - Restores `place_copy` destination (`COPY_DEST -> COMMON`) and source buffers (including same-buffer `COPY_SOURCE -> COPY_DEST -> COMMON`) with exact pre-transition `StateBefore` when a buffer was already promoted earlier in the list or in an earlier list of the same `ExecuteCommandLists` batch. - Verified locally on Windows 11 x64 / RTX 3060 / Rust 1.98.1: both `cargo clippy` passes clean, `cargo test -p victory-gpu --lib --locked -- --test-threads=1` (402 passed, 0 failed) including new unit and GPU tests, and `cargo test -p xtask --locked` (9 passed).
This discussion has been locked. Commenting is limited to contributors.
No description provided.