Shaders: bound synthetic test fence waits and retain unfinished submissions #3413
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!3413
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3413"
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?
@carlosmegino on GitHub · 2026-11-26 23:08 UTC · original
carlosmegino:codex/shader-dispatch-fence-timeout→main· +249 −26 · 1 files · 1 commits · openA synthetic shader test whose GPU submission never finishes currently spins indefinitely; a removed fence can also report
u64::MAXand be mistaken for success before readback. This adds a shared, cumulative 30-second fence wait to the test host'sdrawanddispatchpaths.Follow-up to @fuzeofficlal's non-blocking suggestion on #3180. Based on main
63bcca43c6a00a758510398fa43096ce7e4f7df0; head60771e1f65f6ff3df086435dbf8e635ced92a8de. #3180 is unchanged.Behavior and resource lifetime
u64::MAXare rejected before the fence value can count as completion. Readback is reached only after a successful wait.Instantis created outside the polling loop. Its elapsed time accumulates across polls and yields; the deadline is not restarted. The limit covers the fence wait afterSignal, not blocking inside a D3D12 API call.#[cfg(test)]helpers, call sites and regressions incrates/victory-shader/src/emit/host.rs. Runtime adapter initialization, shader translation and #3180's Wave64 fixtures are untouched.Relationship to #1734
Reviewed #1734 at
7d6cff93e0804f983f389686744fc304213853fd. Both PRs touch the draw/dispatch wait sites, so integration needs manual conflict resolution.#1734 targets performance: event-based waiting and reuse of command objects. Its 100 ms waits allow periodic device-status checks, but do not impose a total deadline. This PR targets robustness: a total deadline, explicit removed-fence detection, and lifetime protection when completion cannot be established. It keeps the existing yield-based polling and makes no performance claim.
When combining them, the pooled fence's expected timeline value must replace this branch's one-shot value of 1. A submitted batch that times out or fails must be quarantined from the pool without resetting or destroying it; retain its command objects, event and per-dispatch resources until completion is proven or the process exits. Simply clearing
Reused::recording, callingReset, or assigning*reused = Nonewould not preserve this guarantee for potentially active work. Pre-submission recording failures are a separate case, since that recording has not reached the GPU. The cached event must also remain valid while its fence registration can still signal it.This PR is independently based on main, not a combined implementation of #1734. No combined-tree execution is claimed.
Existing validation
Reused the recorded evidence for this commit; no redundant test reruns for the publication review:
cargo clippy --workspace --all-targets --locked -- -D warnings: passed.cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: passed.cargo xtask policy: 191 files OK, using this worktree's own maintenance build.cargo test -p victory-shader --locked --lib emit::host::tests:: -- --test-threads=1: 6 passed. Five new deterministic regressions cover success, the exact timeout boundary, removed-fence/device-status cases, and release/retention of submission objects; the existing concurrent WARP draw test also passes.cargo test -p victory-shader --locked --lib emit::memory_tests::root_views_read_their_copy_and_zeros_past_it -- --test-threads=1: 1 passed, exercising dispatch readback.git diff --check: passed. The full workspace test suite was not rerun for this change.Timeout/removal regressions inject status queries and a clock. They do not deliberately hang a GPU or remove a real device.
Pre-existing formatting differences
cargo fmt --all -- --checkwas run and fails on existing formatting in main (includingvictory-formats/src/texture.rs), so this is not claimed as a green check. The modified file was also compared with rustfmt output against the original main version: the same four existing formatting regions remain, with no new differences. They concern the GS bytecode pointer expression, the format alternatives and buffer patterns inview_strides, and theTypedUavmatch arm. New/changed code is rustfmt-formatted; unrelated formatting is preserved to keep the diff scoped.@AurumCarlos on GitHub · 2026-11-26 23:22 UTC · original · reviewed
This overlaps #3143 (Mdemets, still open: "bound the test host fence waits so a wedged device fails instead of hanging"), which changes the same file (
crates/victory-shader/src/emit/host.rs) for the same reason. The description doesn't mention it. Worth linking it and agreeing with Mdemets which one goes forward, or what this adds on top (the cumulative deadline and theu64::MAX/ device-removed check), so the maintainer doesn't get two versions of the same fix.@fuzeofficlal on GitHub · 2026-11-26 23:26 UTC · original · approved these changes
LGTM! Verified locally with
cargo xtask policy,cargo clippy --locked -p victory-shader --all-targets -- -D warnings,cargo clippy --locked -p victory-shader --all-features -- -D warnings, andVICTORY_D3D12_DEBUG=1runs ofemit::host::(6/6 passed) andemit::valu_tests::(35/35 passed) on both RTX 5090 (VICTORY_WARP=0) and WARP (VICTORY_WARP=1) with no formatting issues on the PR's changed lines.wait_for_fence(crates/victory-shader/src/emit/host.rs:68-100) checksGetDeviceRemovedReasonandcompleted == u64::MAXbefore treatingcompleted >= 1as completion and bounds waits withFENCE_TIMEOUT(30s).retain_until_complete/submit_and_wait(host.rs:107-154, 1328, 2074) cleanly retain the queue, allocator, command list, fence, readback buffers, heaps, UAVs, root signature, and PSO across bothdrawanddispatchfailure/unwind paths while releasing them normally on completion.(Minor non-blocking note for a follow-up: the existing
fuses_fmadprobe athost.rs:801outside#[cfg(test)]still submits before creating its fence and polls without a timeout oru64::MAXcheck, andSignalerrors could optionally queryGetDeviceRemovedReason.)@carlosmegino on GitHub · 2026-11-26 23:42 UTC · original
Thanks for highlighting #3143. I've reviewed both implementations and agree that we should consolidate the work rather than maintain competing fixes.
Following fuzeofficlal's approval, #3413 now has independent hardware and WARP validation for device-removal detection, cumulative timeouts and submission resource lifetime protection.
@Mdemets, I'm happy to collaborate on a combined implementation that preserves your configurable timeout, polling interval and coverage of all three submission paths, together with the safety guarantees and regression tests from #3413.
I've also noted @steven-seagull27's existing removal-sentinel/elapsed-time correction and shared-queue integration on #3143. We should account for that work, and the event/object-reuse proposals, when choosing a single integration path.
Let me know which approach you prefer.
@carlosmegino on GitHub · 2026-11-26 23:42 UTC · original
Thanks again for the thorough review and independent validation.
I agree that fuses_fmad deserves the same fence completion and resource lifetime guarantees. I'll coordinate with Mdemets regarding #3143 before extending the implementation, so we avoid further duplication.
Recorded follow-up work, pending that consolidation:
These are deferred follow-ups; no additional implementation is being opened in parallel.
@Dukestar69 on GitHub · 2026-11-27 01:27 UTC · original · approved these changes
LGTM — verified on Windows (RTX 5090 + WARP):
cargo test -p victory-shader --lib emit::host::tests::passed (6/6, including all 5 new fence-timeout and submission-retention tests)cargo test -p victory-shader --lib emit::crosslane_tests::passed (5/5) on RTX 5090 and underVICTORY_WARP=1cargo clippy -p victory-shader --all-targets -- -D warningsand--all-features --all-targets -- -D warningsboth passed with 0 warningscargo xtask policypassed (191 files ok)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.