Shader tests: reject device loss before dispatch readback #1248

Open
JiyouProt wants to merge 1 commit from upstream-pr/1251 into main
JiyouProt commented 2026-11-26 02:27:48 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by JiyouProt on 2026-11-26T02:27:48Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:issue:6618184878 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1251). Originally posted by [JiyouProt](https://github.com/JiyouProt) on 2026-11-26T02:27:48Z. --- `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.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1251:upstream-pr/1251'
git switch 'upstream-pr/1251'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1251'
git switch 'upstream-pr/1251'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1251'
git switch 'upstream-pr/1251'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1251'
git switch 'main'
git merge --squash 'upstream-pr/1251'
git switch 'main'
git merge --ff-only 'upstream-pr/1251'
git switch 'main'
git merge 'upstream-pr/1251'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
fxceless/victory-fork!1248
No description provided.