victory-gpu: leave host copies of title memory in the common state (debug layer: 704 + 37 state errors -> 0) #2660
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!2660
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2660/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?
@pes7 on GitHub · 2026-11-25 17:42 UTC · original
pes7:perf/buffer-states→main· +27 −38 · 3 files · 2 commits · closed without mergingThe first world frames move a host copy of title memory into a state it is never in, and leave it there. The debug layer says so about 40 times a minute.
A host copy of title memory (
crate::shadow) is made inD3D12_RESOURCE_STATE_COMMONand normally never moved: every use a copy has - unordered access, vertex and index buffers, indirect arguments, constant data - is served by the host's implicit promotion out of the common state. One place did move one: the indirect clamp.Those are the only transitions of a buffer in the crate, and both name a state the copy was not in. The title's own argument passes write the arguments through a descriptor, with no transition of ours, so the copy is still common when the first barrier claims it was in unordered access:
and the second barrier leaves the copy in unordered access for good, so the next draw that binds the same memory as a vertex buffer is invalid:
The same memory is read as arguments and then as vertices in these frames, which is why the two go together.
Measured with the debug layer on the title (diagnostics build,
VICTORY_D3D12_DEBUG=1, warm caches), counting its messages:The run after the change went further than the one before it - it reached the world frames, 5-20 fps, instead of stopping in the menu - and still had no state mismatch of either kind.
What stays is the UAV barrier, which is the ordering the clamp needs (it must read what the title's argument passes wrote). The transitions go, and so does
done(): there is nothing to put back.cargo test --workspace --locked, both clippy configurations with-D warnings,cargo xtask policy.The title asks for 1 245 184 descriptor slots, more than the 1 000 000 a host heap holds, and it walks them in increasing order. "Log when the high-water mark moves" is therefore one line per distinct slot: 199 846 of the first 200 000 lines of a run, ~8 000 a second, on the thread recording the frame. That was the whole of the first frame's stall: before 310 932 lines in the run, first frame 21 433 ms after 231 lines in the run, first frame 33 ms Same build, same warm caches (926 MB pipeline library, 1 347 MB shader cache), same 150 s window. What the line said - that slots above the host heap's count are not mirrored - is what the one line now says. The underlying problem is not this change: 245 184 title slots can never be mirrored because they exceed the tier-2 heap limit, which needs either several host heaps with the index arithmetic adjusted or the views above 1 M placed elsewhere. That is why the first world frames get null views. cargo test --workspace --locked; both clippy configurations with -D warnings; cargo xtask policy.A host copy of title memory (crate::shadow) is made in the common resource state and normally never moved: unordered access, vertex and index buffers, indirect arguments and constant data all come from the host's implicit promotion out of that state. The indirect clamp was the one place that moved one, and it moved it to a state it was never in: l.ResourceBarrier(&[uav_barrier(), transition(buffer, UNORDERED_ACCESS, INDIRECT_ARGUMENT)]); ... l.ResourceBarrier(&[transition(buffer, INDIRECT_ARGUMENT, UNORDERED_ACCESS)]); The title writes the arguments it hands over through a descriptor, with no transition of ours, so the copy is still common when the first barrier claims it was in unordered access (the debug layer's "Before state (UNORDERED_ACCESS) ... does not match with the state (COMMON)"), and the pair's second half left it in unordered access for good, where the next draw that binds the same memory as a vertex buffer is invalid ("state is invalid for use as a vertex buffer", ~40 a minute in the first world frames). The debug layer, on the title, diagnostics build with VICTORY_D3D12_DEBUG, warm caches: id=527 "Before state ... does not match" 704 -> 0 id=538 vertex buffer in unordered access 37 -> 0 and the run after the change went further than the one before it (it reached the world frames instead of stopping in the menu) with no state mismatch of either kind. The UAV barrier stays: it is the ordering the clamp needs, and it is what the clamp's tests check. cargo test --workspace --locked; both clippy configurations with -D warnings; cargo xtask policy.@pes7 on GitHub · 2026-11-25 17:43 UTC · original
Superseded by
315cea1on main ("barriers start from the states resources are in: prelude order, the clamp's own buffer"), which fixes the same thing better: the clamp no longer writes the copy of the title's memory at all - it reads the title's records through a root view and writes the clamped ones into an argument buffer of the list's own, and only that one is transitioned. Title buffers' copies are then never transitioned, which is what this PR's one change (dropping the clamp's transitions anddone) set out to do.For the record, the debug-layer counts I measured on the way, since they agree with the ones in that commit: on the title with
VICTORY_D3D12_DEBUG=1and warm caches,mainbefore any of this reported id=527 ("Before state ... does not match") 704 times and id=538 (vertex buffer in UNORDERED_ACCESS) 37 times; with only the clamp's transitions dropped they were 0 and 0, in a run that went further (it reached the world frames instead of stopping in the menu).Closing rather than rebasing: main's version is strictly better, and tests for it are in that commit.
Pull request closed