GPU: flush buffered segment piece before evaluating queue memory waits #2611
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!2611
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2611/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?
@fuzeofficlal on GitHub · 2026-11-25 16:46 UTC · original
fuzeofficlal:fix/gpu-hold-flush-piece-before-wait→main· +41 −0 · 1 files · 1 commits · closed without mergingSummary
In
crates/victory-gpu/src/hold.rs,Held::pumpbatches consecutive ready segments on a queue intopieceand evaluates the next segment'sValueWaits againstw.readbefore flushingpiece.Because
piecehas not run yet (including its bottom-of-pipe writes), evaluating waits against pre-piecememory causes two ordering bugs:pieceoverwrites a word (for example7 -> 8) and the next segment on the same queue waits for== 7, the wait reads the stale7and passes immediately in the same piece instead of blocking.piecewrites the value (8) that the next segment waits for (>= 8), the wait reads the stale value, blocks on the first check, and falsely records a wait inPumped::waited.Changes
crates/victory-gpu/src/hold.rs:Held::pump, flushpiece((w.run)(*queue, std::mem::take(&mut piece)); done.pieces += 1;) before evaluating a segment'swaitswhen!waits.is_empty() && !piece.is_empty(). Consecutive wait-free segments (waits.is_empty()) continue batching into a single piece.a_wait_for_the_value_overwritten_by_its_queue_stays_heldanda_wait_for_its_queues_write_holds_on_the_first_check.Verification
cargo test -p victory-gpu --lib hold::tests— 12/12 pass.cargo clippy -p victory-gpu --all-targets -- -D warningsand--features diagnostics— pass (0 warnings).cargo xtask policy— pass (184 files ok).@oni-swr on GitHub · 2026-11-25 17:15 UTC · original
WARP verification of
922b89bmerged cleanly ontoorigin/main13f91ca(detached checkout).Environment: Windows 11. No physical GPU device was created:
VICTORY_D3D12_WARP=1,VICTORY_WARP=1,cargo -j 4, separateCARGO_TARGET_DIR.Commands and results:
cargo clippy -j 4 -p victory-gpu --features diagnostics --all-targets: clean.cargo test -j 4 -p victory-gpu --features diagnostics --lib: 200 passed, 0 failed, 1 ignored (origin/main: 198 passed). Both newhold::tests pass.hold::).Review notes:
hold.rspump): textually clean and complementary; together 204 passed, 0 failed, 1 ignored. #2611 also covers wait-bearing segments that follow a segment without a read-back, which #2608 does not.Worldchange, see my #2608 comment.)runcall only happens when a segment has waits and the buffered piece is non-empty.memory::a_submission_that_missed_leaves_the_copies_at_oncefailed in roughly 4 of 20 full runs on bothorigin/mainand the merged PRs, andframe::waits_end_on_ticks_and_count_framesfailed once onorigin/main.Not tested: physical GPU, or a retail title.
Independent review and WARP verification by Claude Code (Claude Sonnet 5.5), an AI. No game files, dumps or retail data were used.
@kotekompotek on GitHub · 2026-11-25 17:50 UTC · original
Reviewed: running the buffered piece before evaluating the next segment's waits is correct — a queue's own earlier writes must be visible to its later waits (both tests pin the two sides: wait-for-own-write passes on first check, wait-for-overwritten-value stays held). Complements #2608 (post-submission writes) and #2605 (unreadable memory). CI green.
@Machad3x on GitHub · 2026-11-25 18:26 UTC · original
Setup: RTX 3080 Ti (driver 621.24), Windows 11, a local stack of open PRs merged with main
67e8ae1.Applied cleanly on that stack, together with #2601, #2598, #2576, #2626. One 10-minute game run reached gameplay with no device removal. These five PRs were not tested one by one, so nothing in that run is attributed to this PR alone.
Written with Claude Code; tested locally.
@Marvisak on GitHub · 2026-11-25 23:21 UTC · original
Automated triage for the maintainers.
The change in
Held::pump(crates/victory-gpu/src/hold.rs) runs the buffered piece before evaluating any segment that has waits, so a wait sees the memory its own queue's earlier segments wrote. The code does what it says and the two tests cover it, but it changes queue ordering behaviour without stated evidence: on hardware, a memory wait after a bottom-of-pipe write on the same queue is not automatically ordered after that write lands, so whether the wait ina_wait_for_the_value_overwritten_by_its_queue_stays_heldshould block is exactly what needs a reference (public RDNA2/PM4 documentation, D3D12 queue-ordering docs, or the title's own use that depends on it). It also has a cost: every wait-bearing segment that follows buffered work now forces a separate run-to-completion submission where before the segments were batched, and the second test only changes thewaiteddiagnostic. Please add the evidence and say which title pattern it fixes; a narrower flush (only when a wait would otherwise pass) would also reduce the extra submissions. CI:checkpassing.Generated by Claude Code
@fuzeofficlal on GitHub · 2026-11-25 23:24 UTC · original
Good point on both the hardware EOP-write vs CP-wait ordering (a bottom-of-pipe
RELEASE_MEMwrite on the same queue isn't automatically ordered ahead of a subsequentWAIT_REG_MEM) and the extra submission cost.Since there's no confirmed title pattern depending on blocking an already-satisfied wait behind an unsubmitted same-queue segment, and
Held::pumpalready flushespieceand re-checks when a wait isn't yet satisfied, I'll close this rather than adding unnecessary submission splits. Thanks for the review!Pull request closed