GPU: flush queued segments before evaluating memory and fence waits #3139
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T09:57:26Z.
Problem
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)Imported from Marvisak/VIctory. Originally posted by smaxxey on 2026-11-26T10:13:17Z.
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.
Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T12:11:58Z.
Review: APPROVED
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.