Repository navigation
GPU: confirm the host fence before copying results back - #2899
andrewpozdnakov7-jpg wants to merge 1 commit into
Conversation
kotekompotek
left a comment
There was a problem hiding this comment.
Robust fence handling: SetEventOnCompletion failure or a non-WAIT_OBJECT_0 wake now falls back to polling GetCompletedValue rather than hanging or proceeding early — and the loop re-checks the actual submitted value, so a stale event signal can't pass the wait. Copy-back correctness preserved. LGTM.
fuzeofficlal
left a comment
There was a problem hiding this comment.
Verified head fde6a926 cleanly merged onto origin/main (63bcca43) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + D3D12 WARP + VICTORY_D3D12_DEBUG=1).
Code & Safety Review
- Signaling the host fence and failing immediately on
Signalerror rather than proceeding to copy-back closes a real data-race window, and confirmingGetCompletedValue() >= valueinwait_for_fence_valuebeforeStep::GpuWrite/copy_back_marks/defer_afterensures spurious or stale auto-reset event wakeups cannot allow premature reads. - No deadlock / device-removal hang:
Host::executeserializesself.eventunderself.submitted; onDXGI_ERROR_DEVICE_REMOVED, D3D12 guaranteesGetCompletedValue()returnsu64::MAX(>= *submitted), so the loop exits immediately into theremoveddiagnostic path instead of hanging.
Local Verification (VICTORY_D3D12_DEBUG=1)
- RTX 5090:
host::tests31/32 (including newsubmission_wait_confirms_fence_after_an_early_event; the 1 failure is the pre-existingdynamic_slots_are_held_until_releasedNVIDIA 1M view cap baseline),draw::tests20/20,queue::tests5/5,hold::tests10/10. - WARP:
host::tests32/32,draw::tests20/20,queue::tests5/5,hold::tests10/10. cargo clippy --locked -p victory-gpu --all-targets -- -D warnings(default and--features diagnostics) &cargo xtask policy(191 files ok): clean.
Looks clean and ready to merge.
|
Automated triage for the maintainers. Merge candidate. The synchronous wait in CI: passing. Generated by Claude Code |
Dukestar69
left a comment
There was a problem hiding this comment.
Tested locally merged onto origin/main (63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP):
- Diff review:
wait_for_fence_valueconfirmsfence.GetCompletedValue() >= valuein a loop (falling back to polling ifSetEventOnCompletionorWaitForSingleObjectfails), preventing premature result read-backs after spurious/early event wakes while preserving device-removed handling. cargo test -p victory-gpu submission_wait_confirms_fence_after_an_early_event -- --test-threads=1(RTX 5090 & WARP): 1 passed, 0 failed on both.cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Change
The synchronous host submission path uses a shared auto-reset event. A previous notification can wake a later wait while that submission's fence value is still pending. The old path also continued on an event-registration error or a failed Win32 wait. The work that copies GPU data back to guest memory relies on confirmed completion.
Check the completed value after the event wakes. Continue waiting on the registered event if an earlier signal woke it. If registration or the native wait fails, poll the fence at 1 ms intervals. A failed queue signal or the device-removed value goes through the submission failure path before copy-back. This is the standalone fence change suggested in the closing note on #2158.
Verification
The WARP test gives a private D3D12 queue a fence signal behind a closed gate and supplies an already-signalled auto-reset event. On
842b0cb76f8f5fa9289bd779783c51ec24d75302, the test extracts the existing wait without changing its decision. It returned the still-pending value0in six runs. Withfde6a92694cd5b61891e17ca4100a526384a6e4f, the same test stays blocked and sees1after the gate opens in all six runs.Full native WARP GPU suite passed with 247 tests and one ignored under each D3D12 debug setting, and again with GPU timing enabled. Strict GPU Clippy in both configurations and asset policy passed. The paired test uses synthetic data and exercises the early wake. Device removal was not induced.
Coordination · Win32 event wait · D3D12 fence completion
Please retain the Git author if cherry-picking the fix or test. If folding this change into another commit, please retain
Co-authored-by: andrewpozdnakov7-jpg <andrewpozdnakov7-jpg@users.noreply.github.com>.AI-assisted with Codex.