Shader: check device removal before FMad readback #2450
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!2450
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2450"
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?
@Damokles2 on GitHub · 2026-11-25 13:48 UTC · original
Damokles2:fix-shader-fmad-device-removal→main· +82 −11 · 1 files · 1 commits · openProblem
fuses_fmad()checks for device removal inside its fence polling loop. D3D12 documents thatGetCompletedValue()returnsUINT64_MAXafter removal. That value satisfies the loop's completion condition, so execution can reach readback without establishing that the GPU copy completed. Fence contract · Readback mapping contractFix
Check
GetDeviceRemovedReason()immediately after the fence wait and before readback. The change preserves existing error conversion, polling behavior, resource lifetimes, FMad classification, and adapter initialization policy. A small private helper lets CPU-only tests exercise the same wait-to-readback decision used by the production probe. Device removal status contractRegression and validation
The test-only baseline had three passing tests and one expected failure in
immediate_removal_skips_readback. Readback was invoked once when zero calls were expected.The patched Windows-MSVC run validated
de9a0315887daf72fb4edf7a7d6dc6673ec32cf6.dxbctests — 2 passed, 0 failed.git diff --check— passed.The single fork-only run passed on its first attempt and took 3 minutes 36 seconds on the runner. Windows-MSVC validation
The regression uses simulated fence and device-status responses. Native D3D12 device removal, GPU execution, and full workspace runtime coverage were outside its scope. The guard handles removal observed at the end of the wait. Device removal can still occur after the status check.
References and coordination
AI-assisted development disclosure — OpenAI Codex assisted with investigation, implementation, regression testing, CI validation, and preparation of this PR.
@kotekompotek on GitHub · 2026-11-25 14:16 UTC · original
Correct:
GetCompletedValuereturnsu64::MAXon a removed device, which satisfied the< 1wait and letMaprun on dead readback — the FMad verdict then read garbage or failed as its own error, hiding the removal. The post-wait status check closes it. Extractingread_fmad_after_waitmakes all four paths unit-testable without a device; the test matrix covers MAX-immediate, mid-poll removal, and both healthy outcomes.@Marvisak on GitHub · 2026-11-25 15:58 UTC · original
Automated triage for the maintainers.
Merge candidate, low priority. In
crates/victory-shader/src/emit/host.rsfuses_fmad, a device removed by the time the fence reads complete (it then reportsu64::MAX, which ends the wait) now returns the "device removed" error instead of mapping the readback; the wait-then-readback order is moved into a small helper with CPU-only tests. The only caller,crates/victory-gpu/src/host.rsat adapter setup, uses the result just to pick a log line, so the visible effect is a correct message in that case. CI: passing.Generated by Claude Code
@fuzeofficlal on GitHub · 2026-11-26 00:55 UTC · original
Code review and RTX 5090 + WARP + DXIL verification at head
de9a0315887dmerged cleanly ontomain(63bcca43c6a0):crates/victory-shader/src/emit/host.rs:720-751):read_fmad_after_waitand checkingdevice_status()(GetDeviceRemovedReason()) after the fence wait completes and beforereadback.Map(...)cleanly closes the D3D12 device-removal window whereID3D12Fence::GetCompletedValue()returnsu64::MAX, breaks the wait loop, and would otherwise read zeros from the readback buffer and misclassify FMAD support.#2922(emit/host.rs:691-694sampler heap binding): ~25 lines apart, zero merge conflict and complementary.dxil.dll10.0.26100.0,VICTORY_D3D12_DEBUG=1, Rust 1.98.1):cargo xtask policy:191 files ok;cargo clippy -p victory-shader --all-targets -- -D warnings(default +--all-features): 0 warningsemit::host emit::tests emit::lower::tests: 55/55 passed on both RTX 5090 and WARPemit::semantics_tests::hosts_that_do_not_fuse_are_named: passed (WARP = Ok(false), RTX 5090 hardware fuses FMad =true).LGTM.
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.