GPU: confirm the host fence before copying results back #2899

Open
github-bot wants to merge 1 commit from github-bot/gh-2899 into main AGit
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-25 23:25 UTC · original
andrewpozdnakov7-jpg:codex1/confirm-host-fence-completion → main · +98 −14 · 1 files · 1 commits · open

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 value 0 in six runs. With fde6a92694cd5b61891e17ca4100a526384a6e4f, the same test stays blocked and sees 1 after 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 <[email protected]>.

AI-assisted with Codex.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-25 23:25 UTC · [original](https://github.com/Marvisak/VIctory/pull/2899) `andrewpozdnakov7-jpg:codex1/confirm-host-fence-completion` → `main` · +98 −14 · 1 files · 1 commits · open ## 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 value `0` in six runs. With `fde6a92694cd5b61891e17ca4100a526384a6e4f`, the same test stays blocked and sees `1` after 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](https://git.gtahub.st/github/Marvisak--VIctory/issues/1633) · [Win32 event wait](https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-waitforsingleobject) · [D3D12 fence completion](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12fence-getcompletedvalue) 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 <[email protected]>`. AI-assisted with Codex.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:17:01 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-26 04:31 UTC · original

Automated triage for the maintainers.

Merge candidate. The synchronous wait in Host::submit (host.rs) becomes wait_for_fence_value, which re-checks GetCompletedValue after every wake, falls back to 1 ms polling if event registration or the wait fails, and stops on the device-removed value; a failed Signal goes through fail before any copy-back. This closes a real gap on main, where a failed SetEventOnCompletion let copy-back run before the GPU finished. The WARP test with a gated queue checks that the wait does not return early.

CI: passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-26 04:31 UTC · [original](https://github.com/Marvisak/VIctory/pull/2899#issuecomment-7182664733) <!-- victory-triage v1 head=fde6a92694cd5b61891e17ca4100a526384a6e4f verdict=merge-candidate at=2026-11-26T04:30:59Z --> Automated triage for the maintainers. **Merge candidate.** The synchronous wait in `Host::submit` (`host.rs`) becomes `wait_for_fence_value`, which re-checks `GetCompletedValue` after every wake, falls back to 1 ms polling if event registration or the wait fails, and stops on the device-removed value; a failed `Signal` goes through `fail` before any copy-back. This closes a real gap on main, where a failed `SetEventOnCompletion` let copy-back run before the GPU finished. The WARP test with a gated queue checks that the wait does not return early. CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2899/head:github-bot/gh-2899'
git switch 'github-bot/gh-2899'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2899'
git switch 'github-bot/gh-2899'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2899'
git switch 'github-bot/gh-2899'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2899'
git switch 'main'
git merge --squash 'github-bot/gh-2899'
git switch 'main'
git merge --ff-only 'github-bot/gh-2899'
git switch 'main'
git merge 'github-bot/gh-2899'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2899
No description provided.