GPU: reject the device-removal fence sentinel before reaping #249
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Belobug--VIctory-Belobug-AMD!249
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-249"
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?
@loyodea on GitHub · 2026-11-26 12:40 UTC · original
loyodea:victory-device-removal-context→main· +101 −9 · 1 files · 2 commits · openRelated to #98. D3D12 reports UINT64_MAX from GetCompletedValue when a device is removed. Treat that value as removal before retiring asynchronous work, copying back resources, or reporting completion. Preserve pending command lists for the existing failure reporter and release the submission and queue locks before diagnostics.
Tested
4f62c2afailed the same write-watch assertion.The test does not induce real device removal. Arc B580 runtime behavior and the cause of #98 remain unverified. #232 edits the same async completion logic and will require rebasing whichever PR lands second. Codex helped implement and test this patch.
@gut0to on GitHub · 2026-11-26 16:23 UTC · original · reviewed
AI-assisted review. I inspected the fence-removal handling and its unit test statically; I did not run tests or a GPU/game build. This review suggests one focused test seam for the failure path.
@ -1137,2 +1147,3 @@fn reap_completed(&self) -> Result<(), DeviceRemoved> {// SAFETY: a plain fence query.let completed = unsafe { self.fence.GetCompletedValue() };let completed = completed_fence_value(unsafe { self.fence.GetCompletedValue() })?;@gut0to on GitHub · 2026-11-26 16:23 UTC · original
AI-assisted review; I did not run tests. Could the sentinel test exercise the
reap_completeddecision through an injectable completed-value seam, and assert a pending submission remains queued and is not marked finished? The current test proves only that the conversion helper recognizesu64::MAX; it would not catch a caller bypassing that helper or retiring in-flight work before reporting device removal.@ -1137,2 +1147,3 @@fn reap_completed(&self) -> Result<(), DeviceRemoved> {// SAFETY: a plain fence query.let completed = unsafe { self.fence.GetCompletedValue() };let completed = completed_fence_value(unsafe { self.fence.GetCompletedValue() })?;@loyodea on GitHub · 2026-11-26 18:53 UTC · original
Agreed. The current test covers sentinel conversion in isolation. Injecting
u64::MAXat the fence read used by the reaper would let a test checkDeviceRemoved, verify that the pending submission and its list stay queued, and confirm that neither the deferred write nor the finished-fence value changes.@adrianmjim on GitHub · 2026-11-26 21:43 UTC · original
Tested on Windows 11 26300 with an RX 7900 XT (driver 32.0.32029.2010) and with WARP. Head
9bc5f30, base4f62c2a.On the test seam asked for in the review: a real device removal can test this without a seam. I wrote a local-only test (not committed) that does the following:
Hostfrom a WARP device or from the 7900 XT (Host::from_device).InFlightentry at fence 7 (finish: None).ID3D12Device5::RemoveDevice.wait_fence(7)orexecute(&[]).on_failureis set to a function that panics, and the call is wrapped incatch_unwind.The results are the same on WARP and on the 7900 XT:
RemoveDevice,fence.GetCompletedValue()returnsu64::MAX, as reported on #214.wait_fence(7): returns with no report. The entry is reaped andFINISHED_FENCEgoes to 7.execute(&[]): the entry is reaped too. The run then fails withdevice removed after a submission of 0 lists.device removed while waiting for asynchronous submissions. The entry stays inin_flightandFINISHED_FENCEdoes not move.Notes if this goes into the PR:
ON_FAILUREis a process-wideOnceLockandFINISHED_FENCEis global. On base, when both cases run in one process, the secondwait_fence(7)returns early becauseFINISHED_FENCEis already 7. Run the test alone (--exact), or use fence values that no other test reaches.fail()reads the removal reason from the globalhost(), not from the test's host. So in the test, the message has nodevice removed:part.Coverage:
reap_completedhas two callers,wait_fenceanddrain_in_flight_locked. The PR handles both.wait_in_flight,present,present_over,HostList::reset,HostList::dropand the timeline waits all go throughwait_fence.Test suite (
cargo test -p victory-gpu --lib, base and PR runs alternated, other heavy jobs running on the machine):--features diagnosticswithVICTORY_D3D12_WARP=1: 41 runs on each side. The new unit test passed in every PR run.page_mappings_run_after_a_queues_wait) failed once, on the PR side only.host refused the depth bounds pipeline) and then crashed. Run 30 had one depth bounds failure. None of these came back in the next 11 PR runs. The changed code does not run in test builds, because async submission is off undercfg(test).cargo clippy -p victory-gpu --lib --testsgives the same warnings on base and PR.Not tested: a real hang or page fault, DRED output with real pending lists, the game, an Arc B580.
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.