GPU: GetDeviceRemovedReason reports the host device's state instead of E_NOTIMPL #928

Merged
BastienRodz merged 1 commit from upstream-pr/928 into main 2026-11-25 00:24:05 +00:00
BastienRodz commented 2026-11-24 14:17:23 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by BastienRodz on 2026-11-24T14:17:23Z.


What's wrong

Microsoft's ID3D12Device::GetDeviceRemovedReason reference (https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12device-getdeviceremovedreason):

Gets the reason that the device was removed, or S_OK if the device isn't removed.

In crates/victory-gpu/src/device.rs (FUNCTIONS), the PC-order device table wires slot 36 (0x120, CreateFence, line 380) and slot 38 (0x130, GetCopyableFootprints, line 381), leaving slot 37 (0x128, GetDeviceRemovedReason) on object::missing (crates/victory-gpu/src/object.rs:282-292), which logs method not implemented once and returns E_NOTIMPL.

Calling slot 0x128 on a fresh device:

  • Expected: S_OK (0x00000000)
  • Actual: E_NOTIMPL (0x80004001)

Impact

A title that checks FAILED(device->GetDeviceRemovedReason()) treats E_NOTIMPL as a lost device and enters device-loss recovery on a healthy device. No tester log so far shows slot=0x128, so Grand Theft Auto VI apparently does not call it.

What the fix does

Add removed_reason in crates/victory-gpu/src/device.rs and wire it at slot 37 (0x128): query host.device.GetDeviceRemovedReason() when a host device exists, returning S_OK on Ok (or when there is no host device) and the error's HRESULT (e.code().0) otherwise. Add a unit test verifying slot 0x128 returns S_OK on a healthy device.

Tests

a_healthy_device_reports_no_removal calls slot 0x128 on the device and expects S_OK.

  • On main: it fails with left: -2147467263 (0x80004001, E_NOTIMPL), right: 0.
  • With the fix, on GitHub's windows-latest with the upstream CI's commands (clippy -D warnings with and without --all-features, then cargo test --workspace --locked), everything passes; victory-gpu 51 passed, 0 failed (https://github.com/BastienRodz/VIctory/actions/runs/45406532329). The runner has a host D3D12 device, so the call goes through the host's GetDeviceRemovedReason.

Not tested: a removed host device, where the host's reason is returned.

No game data used. AI-assisted: found with GPT-6.2 Astra, written with Gemini 4 Neon, reviewed and verified with Claude Code.

Fixes #900.

🤖 Generated with Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:issue:6583826903 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/928). Originally posted by [BastienRodz](https://github.com/BastienRodz) on 2026-11-24T14:17:23Z. --- ## What's wrong Microsoft's `ID3D12Device::GetDeviceRemovedReason` reference (<https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12device-getdeviceremovedreason>): > Gets the reason that the device was removed, or `S_OK` if the device isn't removed. In `crates/victory-gpu/src/device.rs` (`FUNCTIONS`), the PC-order device table wires slot 36 (`0x120`, `CreateFence`, line 380) and slot 38 (`0x130`, `GetCopyableFootprints`, line 381), leaving slot 37 (`0x128`, `GetDeviceRemovedReason`) on `object::missing` (`crates/victory-gpu/src/object.rs:282-292`), which logs `method not implemented` once and returns `E_NOTIMPL`. Calling slot `0x128` on a fresh device: - Expected: `S_OK` (`0x00000000`) - Actual: `E_NOTIMPL` (`0x80004001`) ## Impact A title that checks `FAILED(device->GetDeviceRemovedReason())` treats `E_NOTIMPL` as a lost device and enters device-loss recovery on a healthy device. No tester log so far shows `slot=0x128`, so Grand Theft Auto VI apparently does not call it. ## What the fix does Add `removed_reason` in `crates/victory-gpu/src/device.rs` and wire it at slot 37 (`0x128`): query `host.device.GetDeviceRemovedReason()` when a host device exists, returning `S_OK` on `Ok` (or when there is no host device) and the error's `HRESULT` (`e.code().0`) otherwise. Add a unit test verifying slot `0x128` returns `S_OK` on a healthy device. ## Tests `a_healthy_device_reports_no_removal` calls slot `0x128` on the device and expects `S_OK`. - **On `main`:** it fails with `left: -2147467263` (`0x80004001`, `E_NOTIMPL`), `right: 0`. - **With the fix,** on GitHub's `windows-latest` with the upstream CI's commands (clippy `-D warnings` with and without `--all-features`, then `cargo test --workspace --locked`), everything passes; `victory-gpu` 51 passed, 0 failed (https://github.com/BastienRodz/VIctory/actions/runs/45406532329). The runner has a host D3D12 device, so the call goes through the host's `GetDeviceRemovedReason`. **Not tested:** a removed host device, where the host's reason is returned. No game data used. AI-assisted: found with GPT-6.2 Astra, written with Gemini 4 Neon, reviewed and verified with Claude Code. Fixes #900. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
DenRakEiw commented 2026-11-24 15:03:22 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-24T14:21:18Z.

Review: APPROVED


Tested merged cleanly onto main (ffe310e) on Windows 11 x64 (Rust 1.98.1 MSVC) with NVIDIA GeForce RTX 5090 (Blackwell) and WARP (VICTORY_D3D12_WARP=1):

  • cargo test -p victory-gpu (RTX 5090): 51 passed, 0 failed, 1 ignored
  • VICTORY_D3D12_WARP=1 cargo test -p victory-gpu (WARP): 51 passed, 0 failed, 1 ignored
  • cargo clippy -p victory-gpu --all-targets: 0 warnings
  • cargo xtask policy: ok

Clean fix forwarding GetDeviceRemovedReason to the host D3D12 device. Approving.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6040908747 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/928#pullrequestreview-6040908747). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-24T14:21:18Z. **Review:** APPROVED --- Tested merged cleanly onto `main` (`ffe310e`) on Windows 11 x64 (Rust 1.98.1 MSVC) with **NVIDIA GeForce RTX 5090** (Blackwell) and **WARP** (`VICTORY_D3D12_WARP=1`): - `cargo test -p victory-gpu` (RTX 5090): **51 passed, 0 failed, 1 ignored** - `VICTORY_D3D12_WARP=1 cargo test -p victory-gpu` (WARP): **51 passed, 0 failed, 1 ignored** - `cargo clippy -p victory-gpu --all-targets`: **0 warnings** - `cargo xtask policy`: ok Clean fix forwarding `GetDeviceRemovedReason` to the host D3D12 device. Approving. AI-assisted (Gemini 4 Neon).
dcastell1 commented 2026-11-24 15:04:03 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by dcastell1 on 2026-11-24T14:28:34Z.


Verified on native Windows (no Wine): NVIDIA GeForce RTX 5090 (driver 621.24), Windows 11 10.0.26300, Rust 1.98.1, MSVC 14.44.35207, debug build. main@ffe310e baseline on this box: 342 passed, 0 failed, 6 ignored.

cargo test --workspace
343 passed; 0 failed; 6 ignored   (exit 0)

One more passing test than the baseline; GetDeviceRemovedReason reporting the host's reason is exercised and green.

Tree restored afterwards (full diff against a clean checkout); no game data, the tests are synthetic. AI-assisted (opencode): applied the patch to a built tree, ran cargo test --workspace, reverted it.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7134435868 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/928#issuecomment-7134435868). Originally posted by [dcastell1](https://github.com/dcastell1) on 2026-11-24T14:28:34Z. --- Verified on native Windows (no Wine): NVIDIA GeForce RTX 5090 (driver 621.24), Windows 11 10.0.26300, Rust 1.98.1, MSVC 14.44.35207, debug build. `main@ffe310e` baseline on this box: **342 passed, 0 failed, 6 ignored**. ``` cargo test --workspace 343 passed; 0 failed; 6 ignored (exit 0) ``` One more passing test than the baseline; `GetDeviceRemovedReason` reporting the host's reason is exercised and green. Tree restored afterwards (full diff against a clean checkout); no game data, the tests are synthetic. AI-assisted (opencode): applied the patch to a built tree, ran `cargo test --workspace`, reverted it.
Zipettte commented 2026-11-24 16:05:19 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Zipettte on 2026-11-24T15:40:56Z.


Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 033598b: cargo test -p victory-gpu passes, 51 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).

Tested with AI assistance (Claude).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7136434694 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/928#issuecomment-7136434694). Originally posted by [Zipettte](https://github.com/Zipettte) on 2026-11-24T15:40:56Z. --- Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 033598b: `cargo test -p victory-gpu` passes, 51 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed). _Tested with AI assistance (Claude)._
BastienRodz commented 2026-11-24 22:02:23 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by BastienRodz on 2026-11-24T21:50:08Z.


Rebased onto main 70564ae; the only conflicts were test blocks added on both sides at the end of the file. On windows-latest the run is red, but only on emit::synthetic_tests::gathers_at_a_level_match_the_hardware and permutes_read_the_lane_named_and_zero_from_lanes_left_out. main alone fails those two the same way, in its own CI (https://github.com/Marvisak/VIctory/actions/runs/45492970391) and on our fork (https://github.com/BastienRodz/VIctory/actions/runs/45494314536): the runner's adapter is a software one. This PR's own tests pass there. A fix for those two tests is on its way as a separate PR.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7145451041 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/928#issuecomment-7145451041). Originally posted by [BastienRodz](https://github.com/BastienRodz) on 2026-11-24T21:50:08Z. --- Rebased onto `main` `70564ae`; the only conflicts were test blocks added on both sides at the end of the file. On `windows-latest` the run is red, but only on `emit::synthetic_tests::gathers_at_a_level_match_the_hardware` and `permutes_read_the_lane_named_and_zero_from_lanes_left_out`. `main` alone fails those two the same way, in its own CI (https://github.com/Marvisak/VIctory/actions/runs/45492970391) and on our fork (https://github.com/BastienRodz/VIctory/actions/runs/45494314536): the runner's adapter is a software one. This PR's own tests pass there. A fix for those two tests is on its way as a separate PR.
BastienRodz commented 2026-11-24 22:02:28 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by BastienRodz on 2026-11-24T21:59:20Z.


The fix for those two main tests is #1752 (windows-latest green with it).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7145653149 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/928#issuecomment-7145653149). Originally posted by [BastienRodz](https://github.com/BastienRodz) on 2026-11-24T21:59:20Z. --- The fix for those two `main` tests is #1752 (`windows-latest` green with it).
upstream-sync closed this pull request 2026-11-25 01:04:56 +00:00
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
Marvisak/VIctory!928
No description provided.