Skip to content

Shaders: bound the test host fence waits so a wedged device fails instead of hanging - #3143

Open
Mdemets wants to merge 1 commit into
Marvisak:mainfrom
Mdemets:contrib/fence-waits
Open

Mdemets wants to merge 1 commit into
Marvisak:mainfrom
Mdemets:contrib/fence-waits

Conversation

@Mdemets

@Mdemets Mdemets commented Nov 26, 2026

Copy link
Copy Markdown

Three command-recording paths in the test host spin on GetCompletedValue() with yield_now() and no deadline. A device that neither signals the fence nor reports itself removed wedges the test binary forever — the same shape as the world hang in #71 (a submission that never finishes and ends in a TDR), just observed from the suite instead of a title run.

What changes

  • one wait_for_fence helper, poll every 2 ms, returns the device-removed reason exactly as the old loops did;
  • after 120 s without a signal it returns a named error saying no fence signal arrived and the device is not removed;
  • VICTORY_WAIT_SECS raises the deadline for a deliberately long run;
  • all three call sites now share it, so behaviour cannot drift between them.

Verification

cargo check -p victory-shader --lib clean on 63bcca4.

From the test fleet's branch (c5eb934), where it stopped a wedged A5000 from hanging the suite for the rest of the night.

…tead of hanging

Three command-recording paths spun on `GetCompletedValue()` with `yield_now()` and no
deadline. A device that neither signals the fence nor reports itself removed wedged the
test binary forever, which is the shape of the world hang in JMAN730#71.

`wait_for_fence` polls every 2 ms, returns the device-removed reason as before, and fails
after 120 s with a named error. `VICTORY_WAIT_SECS` raises the deadline for deliberately
long runs.

From the test fleet's branch (c5eb934).

@Dukestar69 Dukestar69 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified on RTX 5090 against origin/main (63bcca4):

  • cargo test -p victory-shader --lib emit::host:: -- --test-threads=1: passed (parallel_warp_pipelines_and_draws).
  • cargo clippy -p victory-shader --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Cleanly bounds test-host fence waits so a wedged device fails fast with an error instead of hanging CI/test runs.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

@steven-seagull27

steven-seagull27 commented Nov 26, 2026 •

Copy link
Copy Markdown

@Mdemets I tested the new wait helper on native Windows with an RTX 5080 (621.40) and built-in WARP. With a one-second deadline, both adapters accepted an immediate queue signal and a delayed fence signal. A healthy unsignaled fence returned the named timeout after 1,000–1,002 ms. Each case ran twice per adapter in a fresh process.

I found one case where the helper returns success before readback should proceed. In a separate process with no GPU work queued I called ID3D12Device5::RemoveDevice on the test process’s device. On both adapters the fence returned UINT64_MAX and the removal reason was 0x887A0005 (DXGI_ERROR_DEVICE_REMOVED), yet wait_for_fence returned Ok(()) on all four runs at 8cd3a449. The current >= 1 check accepts the removal value before reading the removal reason. D3D12 fence return values

The attached change checks the removal reason after reading the fence and rejects the sentinel. All four removal runs returned an error with the patch. Healthy signals and timeouts still behaved as expected. I also switched the deadline comparison to elapsed time. With the largest accepted u64 timeout, the original helper panicked adding the duration to Instant even on an already completed fence. The same fence returned immediately with the patch. The included regression creates private fences on a healthy device. Fix and regression test

git fetch https://github.com/steven-seagull27/VIctory.git codex/pr3143-fence-completion
git cherry-pick fe4446a418985c18a4f4913f96eddb8ce80c7b39
cargo test --locked -p victory-shader --lib emit::host::tests::fence_wait_rejects_the_removed_value -- --exact --nocapture

I also tested this with the latest shared-queue revision, 076c0e7e on #3093. The two PRs conflict at all three readback waits. The optional merge keeps one signal on the shared queue and uses the bounded wait for the requested fence value. Both adapters passed immediate and delayed signals, a wait for value 2 starting at 1, timeout, device removal, and the maximum timeout override. The hardware shared-queue test and existing WARP draw test also passed twice each. Tested integration branch

AI-assisted patch and tests using synthetic D3D12 work on Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants