Repository navigation
GPU: one tracker for the states of title buffer copies - #367
MrEvilGamer wants to merge 1 commit into
Conversation
A title buffer's host copy that a shader writes is promoted to the unordered access state, which does not decay back to the common state. Reading it later as vertex, index or constant data without a barrier is invalid (the debug layer reports it, and NVIDIA GPUs hang), and the indirect passes moved the same buffers with hard-coded before states that did not match what the list had left them in. Every change of state now goes through HostList::resource_state, which remembers the state the list left each buffer in, so a barrier always names it. Shadow::refresh and Shadow::gpu_writes request the read or the write state, the argument clamp and its `done` use the same call, and a list ends with the buffers it moved in the common state again. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Closing this as a duplicate of #334, which was opened first and finds the same cause: the host copies of title buffers are promoted to unordered access, never come back to the common state, and the indirect passes use fixed barrier states, so the debug layer reports a vertex buffer in the wrong state (ids 527 and 538) on NVIDIA. What I measured agrees with the results already reported on #334: with the tracker the state errors in the world went from 33 and 23 to 0, and the device is still removed (DXGI_ERROR_DEVICE_HUNG) about 100 to 140 s into the world, so the hang has another cause. Please review #334 rather than this one. |
|
Review note. Built on The same case I noted on #334 applies here: within one command a write can lose to a read. One difference from #334: here From synthetic tests and reading only; I have no copy of the title. |
What
A title buffer's host copy that a shader writes is promoted to the unordered access state, and that state does not decay back to the common state. Reading the copy later as vertex, index or constant data without a barrier is invalid. The debug layer reports it, and NVIDIA GPUs hang on it (see #199 and #264, which name
IASetVertexBufferswith a buffer inUNORDERED_ACCESS). Separately, the indirect passes (indirect::boundandindirect::done) moved the same buffers with hard-coded "before" states that did not match what the list had left them in.Every change of a copy's state now goes through one function,
HostList::resource_state, which remembers the state the list left each buffer in, so a barrier always names it:Shadow::refreshasks for the read state (BUFFER_READ: vertex and constant, index, both shader-resource stages, indirect argument), andShadow::gpu_writesasks for unordered access.indirect::boundandindirect::doneuse the same call instead of fixed transitions.buffers_to_common, run byclose), so the next list starts from a known state.Refs #199, #264. It does not close them (see "Not fixed").
Tested
Windows 11, NVIDIA GeForce RTX 4060 Ti, diagnostics build,
VICTORY_D3D12_DEBUG=1(D3D12 debug layer),VICTORY_INDIRECT=1, a retail 1.0.2.1 copy. Each run goes through the menus (scripted Enter presses) into the world.Debug layer errors in the world, one run each, on
d2a4baeand on the same commit with this change:d2a4baeResourceBarrier: before state does not match the state in the preceding barrierDrawIndexedInstanced: vertex buffer in the wrong stateThe other errors are unchanged by it: 622 (wave64 compute shaders on a 32-lane device, #189 and #192 cover that), 599 (two) and 645 (the descriptor heap cap). A first run with the change did not get past the menus, so I did not count it; the second reached the world 20 s in.
I also ran the same change on a larger local branch with #24 and #282 applied, where the counts were far higher before it (4,832 of id 527 and 9 of id 538) and zero after.
cargo test -p victory-gpu: 43 passed, 1 ignored.cargo clippy -p victory-gpu --all-targets, with and withoutdiagnostics: no warning names this code.cargo xtask policypasses on a clean checkout of the commit.cargo fmt --checkalready fails ond2a4baein files this change does not touch. The lines it adds are formatted.Not fixed
The device is still removed (
DXGI_ERROR_DEVICE_HUNG) about 100 to 140 s into the world, with and without this change. With the state errors gone, the debug layer reports nothing else before the removal, so the hang has another cause. The world is still black.I did not measure the cost. Each buffer a list uses adds one barrier at its first use and one when the list closes. Frame times in the world were 0.7 to 1.1 s both before and after, but that is not a benchmark.
Checklist
cargo fmt,cargo clippy --workspace --all-targetsandcargo test --workspacepass. (Only-p victory-gpuwas run;fmt --checkfails onmainalready.)cargo xtask policypasses. The change adds no game files or data taken from them.🤖 Generated with Claude Code