GPU: flush queued segments before evaluating memory and fence waits #3141
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!3141
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3141"
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-26 09:57 UTC · original
fuzeofficlal:fix/gpu-hold-flush-before-wait→main· +183 −0 · 2 files · 1 commits · openProblem
In
crates/victory-gpu/src/hold.rs,Held::pumpaccumulates consecutive ready segments on a queue intopieceand flushespiecevia(w.run)before executingItem::Signal, as its comment notes (A Signal or Wait keeps its place: the piece before it runs first). However, neitherItem::Segment(with non-emptyValueWaits) norItem::FenceWaitflushedpiecebefore testing their wait condition.Because an earlier segment on the same queue can modify the waited memory (via
Write32/64BitValueBottomOfPipeX, shader writebacks, or direct writes tofence::gpu_address), evaluating waits against pre-segment memory causes two ordering bugs:Write64BitValueBottomOfPipeX(flag, 0)), then waits for another queue to set it back (Wait64BitValueX(flag == 1)),list::waitsplits the list into two segments.Held::pumpqueues segment 0 inpieceand immediately checks segment 1's wait against stale memory (flag == 1), erroneously passes, and submits both segments together before the peer queue runs. The same happens if a segment rewrites a fence's memory before anItem::FenceWait.fresh = false), and records a false stall inPumped::waited.Fix
Flush any pending
pieceon the current queue before evaluating non-emptyValueWaits onItem::Segmentand before evaluatingItem::FenceWait. Consecutive wait-free segments (waits.is_empty()) are unaffected and continue to batch into a single host submission.Verification
Added four regression tests (all four confirmed failing on
main63bcca43before the fix and passing after):hold::tests::a_wait_runs_the_work_before_it_firsthold::tests::a_wait_for_an_earlier_segment_on_the_same_queue_does_not_stallhold::tests::a_fence_wait_runs_the_work_before_it_firstqueue::tests::in_list_wait_sees_bottom_of_pipe_writes_before_it(end-to-end guest command list usingWrite64BitValueBottomOfPipeX+Wait64BitValueX+ExecuteCommandLists, verified on both hardware D3D12 andVICTORY_D3D12_WARP=1)Full checks passed:
hold::tests(13/13),queue::tests(6/6), andresource::tests::a_list_waiting_for_another_queues_write_reads_what_it_wroteon both native D3D12 andVICTORY_D3D12_WARP=1cargo clippy --workspace --all-targets --locked -- -D warningsand--all-features(0 warnings)rustfmt --edition 2024 --check(0 diffs on all modified/added lines)cargo test -p xtask --locked policy::tests::repository_passes_policy(asset policy: 191 files ok)@smaxxey on GitHub · 2026-11-26 10:13 UTC · original
Ran this on an RTX 4060 Laptop GPU (Ada, 8 GB, driver 32.0.16.1742), Windows 11 26300, Rust 1.98.1. No game files. Head
469d7a6merged locally ontomain63bcca4.cargo test -p victory-gpu --lib --locked -- --test-threads=1: the threehold::testscases andqueue::tests::in_list_wait_sees_bottom_of_pipe_writes_before_iton the hardware device.cargo test -p victory-gpu --lib --locked: 233 passed, 2 failed, same asmain63bcca4on this card: only the two NVIDIA failures of #1835 (descriptor::host::tests::dynamic_slots_are_held_until_released,memory::tests::lists_share_a_table_and_copies_keep_their_views), nothing new.Tested with Claude Code's help.
@Dukestar69 on GitHub · 2026-11-26 12:11 UTC · original · approved these changes
Verified on RTX 5090 against
origin/main(63bcca4):cargo test -p victory-gpu --lib queue:: -- --test-threads=1: 6/6 passed (includingin_list_wait_sees_bottom_of_pipe_writes_before_it).cargo test -p victory-gpu --lib hold:: -- --test-threads=1: passed.cargo test -p victory-gpu --lib fence:: -- --test-threads=1: 2/2 passed;draw::: 20/20 passed.cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Cleanly flushes queued segments before evaluating in-list memory and fence waits.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.