Shader tests: reject device loss before dispatch readback #1251

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

@⁠JiyouProt on GitHub · 2026-11-26 02:27 UTC · original
JiyouProt:codex/shader-readback-device-loss → main · +84 −6 · 1 files · 1 commits · open

emit::host::Host::dispatch can reach readback after device removal: its removal check is inside while fence.GetCompletedValue() < 1, but D3D12 returns UINT64_MAX for a removed device. The loop therefore exits without checking that the device is still usable. Microsoft's fence contract

Check device status after the wait, before any output mapping, as the draw path already does. A small test-only helper keeps the dispatch and regression on the same path. Polling, resource lifetimes, shader lowering and runtime defaults are unchanged.

The regression first completes a normal queue-signalled fence, then removes an isolated child-process WARP device and checks a never-signalled fence. The original wait returned Ok(()) with its value at UINT64_MAX; the fixed wait returns the removal error. No physical adapter is removed. Older runtimes without ID3D12Device5 explicitly skip this native removal case.

Scope and related work

  • One file, test-host code only. No title data or protected binary is needed or added.
  • #964 fixes the analogous condition in the separate production copy queue. #694 reuses test queues and does not add this check; its patch was inspected.
  • Marvisak/VIctory#1734 also checks removal after waiting, within a broader event-wait/object-reuse optimization. This is a minimal correction for this fork's existing polling path with a native regression, without porting that optimization.

Validation

  • Windows 11 Pro 10.0.26300, Ryzen 7 5800X, 64 GB, RTX 3080 Ti 12 GB / NVIDIA 616.92, Microsoft WARP, DXIL validator 1.9.2609.5. Portable Rust/Clippy 1.100.0 GNU, LLVM-MinGW/LLD 23.1.6; hardware FMA enabled on this compatible CPU. This differs from the repository's pinned 1.98.1 MSVC toolchain.
  • Before the guard: the new native regression fails with removed is not completed: (). After: normal completion accepted and actual WARP removal rejected.
  • cargo test --locked -p victory-shader --lib --no-fail-fast -j 4 -- --test-threads=4 --nocapture, Debug and Release (--release): 218 passed, 0 failed, 3 ignored each. Main c74e173 Debug: 217 passed, 0 failed, 3 ignored.
  • Final commit c09c05e: shader library builds in Debug and Release; 20 further native regression runs pass, 10 in each configuration, with actual removal observed in every run.
  • Each full run also reports four compiler-unavailable skips and one refused WARP compute-pipeline case. Harness pass counts include those skips; they are not claimed as coverage. The new native removal test actually ran.
  • cargo clippy --locked -p victory-shader --all-targets -- -D warnings, default and --all-features: passed. Changed-file asset policy and git diff --check passed. Three existing formatting differences elsewhere in this file were left alone.

Limits
Shader-crate validation only; no full workspace, MSVC, AMD, physical-device-removal, D3D12 debug-layer or retail-title run. No FPS or gameplay fix claimed. Device removal can still occur after the final check; existing map errors continue to propagate.

AI-assisted: OpenAI Codex (GPT-6; exact model variant unavailable), investigation, implementation, native regression and validation. Publication authorized by the user.

**@⁠JiyouProt** on GitHub · 2026-11-26 02:27 UTC · [original](https://github.com/fxceless/victory-fork/pull/1251) `JiyouProt:codex/shader-readback-device-loss` → `main` · +84 −6 · 1 files · 1 commits · open `emit::host::Host::dispatch` can reach readback after device removal: its removal check is inside `while fence.GetCompletedValue() < 1`, but D3D12 returns `UINT64_MAX` for a removed device. The loop therefore exits without checking that the device is still usable. [Microsoft's fence contract](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12fence-getcompletedvalue) Check device status after the wait, before any output mapping, as the draw path already does. A small test-only helper keeps the dispatch and regression on the same path. Polling, resource lifetimes, shader lowering and runtime defaults are unchanged. The regression first completes a normal queue-signalled fence, then removes an isolated **child-process WARP device** and checks a never-signalled fence. The original wait returned `Ok(())` with its value at `UINT64_MAX`; the fixed wait returns the removal error. No physical adapter is removed. Older runtimes without `ID3D12Device5` explicitly skip this native removal case. **Scope and related work** - One file, test-host code only. No title data or protected binary is needed or added. - #964 fixes the analogous condition in the separate production copy queue. #694 reuses test queues and does not add this check; its patch was inspected. - [Marvisak/VIctory#1734](https://github.com/Marvisak/VIctory/pull/1734) also checks removal after waiting, within a broader event-wait/object-reuse optimization. This is a minimal correction for this fork's existing polling path with a native regression, without porting that optimization. **Validation** - Windows 11 Pro 10.0.26300, Ryzen 7 5800X, 64 GB, RTX 3080 Ti 12 GB / NVIDIA 616.92, Microsoft WARP, DXIL validator 1.9.2609.5. Portable Rust/Clippy 1.100.0 GNU, LLVM-MinGW/LLD 23.1.6; hardware FMA enabled on this compatible CPU. This differs from the repository's pinned 1.98.1 MSVC toolchain. - Before the guard: the new native regression fails with `removed is not completed: ()`. After: normal completion accepted and actual WARP removal rejected. - `cargo test --locked -p victory-shader --lib --no-fail-fast -j 4 -- --test-threads=4 --nocapture`, Debug and Release (`--release`): **218 passed, 0 failed, 3 ignored** each. Main `c74e173` Debug: **217 passed, 0 failed, 3 ignored**. - Final commit `c09c05e`: shader library builds in Debug and Release; **20 further native regression runs pass**, 10 in each configuration, with actual removal observed in every run. - Each full run also reports four compiler-unavailable skips and one refused WARP compute-pipeline case. Harness pass counts include those skips; they are not claimed as coverage. The new native removal test actually ran. - `cargo clippy --locked -p victory-shader --all-targets -- -D warnings`, default and `--all-features`: passed. Changed-file asset policy and `git diff --check` passed. Three existing formatting differences elsewhere in this file were left alone. **Limits** Shader-crate validation only; no full workspace, MSVC, AMD, physical-device-removal, D3D12 debug-layer or retail-title run. No FPS or gameplay fix claimed. Device removal can still occur after the final check; existing map errors continue to propagate. AI-assisted: OpenAI Codex (GPT-6; exact model variant unavailable), investigation, implementation, native regression and validation. Publication authorized by the user.
D3D12 signals removed-device fences with UINT64_MAX, bypassing the polling-loop removal check. Check device status once more before mapping dispatch outputs, as the draw path already does. Exercise both normal queue completion and the removal sentinel on a child process WARP device. No hardware device is removed.

Related: fxceless/victory-fork#964 (copy queue); Marvisak/VIctory#1734 (broader shader test-host optimization).

Assisted-by: OpenAI Codex (GPT-6; exact model variant unavailable)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:00:24 +00:00
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/1251/head:github-bot/gh-1251'
git switch 'github-bot/gh-1251'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1251'
git switch 'github-bot/gh-1251'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1251'
git switch 'github-bot/gh-1251'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1251'
git switch 'main'
git merge --squash 'github-bot/gh-1251'
git switch 'main'
git merge --ff-only 'github-bot/gh-1251'
git switch 'main'
git merge 'github-bot/gh-1251'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.