GPU: one tracker for the states of title buffer copies #367
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!367
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/367/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@MrEvilGamer on GitHub · 2026-11-24 02:39 UTC · original
MrEvilGamer:pr-buffer-state→main· +73 −17 · 3 files · 1 commits · closed without merging## 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
@MrEvilGamer on GitHub · 2026-11-24 02:54 UTC · original
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.
@r4tedx on GitHub · 2026-11-24 03:11 UTC · original
Review note. Built on
main(d2a4bae),cargo test -p victory-gpupasses on an RTX 5070 (no debug layer on this machine, so state errors would not show here). This does the same job as #334 and the two conflict inhost.rsandindirect.rs, so only one can go in.The same case I noted on #334 applies here: within one command a write can lose to a read.
bindhandles tables before root views; for a dispatch that writes a host copy through a table UAV and reads the same copy through a root SRV,gpu_writesmoves it to UNORDERED_ACCESS and the root view'srefreshthen moves it back to a read state, so the dispatch writes it while it is in a read state and no barrier separates those writes from the next vertex or index read.One difference from #334: here
refreshalways transitions to read, so every UAV use becomes READ then UAV, one extra barrier per use. With thousands of draws per frame that is worth measuring.From synthetic tests and reading only; I have no copy of the title.
Pull request closed