GPU: GetDeviceRemovedReason returns E_NOTIMPL on a healthy device #900

Closed
opened 2026-11-26 04:14:08 +00:00 by github-bot · 2 comments
Owner

@⁠BastienRodz on GitHub · 2026-11-24 13:46 UTC · original

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.

Fix

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.

The fix is ready on a branch of my fork, since PR creation is limited to collaborators: https://github.com/BastienRodz/VIctory/commits/gpu/device-removed-reason (one commit on main ffe310e, device.rs +20).

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.

**@⁠BastienRodz** on GitHub · 2026-11-24 13:46 UTC · [original](https://github.com/Marvisak/VIctory/issues/900) ## 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. ## Fix 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. The fix is ready on a branch of my fork, since PR creation is limited to collaborators: https://github.com/BastienRodz/VIctory/commits/gpu/device-removed-reason (one commit on `main` `ffe310e`, `device.rs` +20). ## 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:14:08 +00:00
Author
Owner

@⁠DaniiL35 on GitHub · 2026-11-24 13:48 UTC · original

Verified branch 033598b (on top of ffe310e):

D3D12 ABI Vtable Verification

Checked the ID3D12Device COM vtable layout:

  • Slot 36 (offset 0x120): CreateFence
  • Slot 37 (offset 0x128): GetDeviceRemovedReason
  • Slot 38 (offset 0x130): GetCopyableFootprints
  • Slot 39 (offset 0x138): CreateQueryHeap

In FUNCTIONS (crates/victory-gpu/src/device.rs), slot 37 was previously skipped, falling through to object::missing which returns E_NOTIMPL (0x80004001). Because FAILED(0x80004001) evaluates to true, any DirectX 12 middleware or title asserting device health via device->GetDeviceRemovedReason() would erroneously treat a healthy device as removed/crashed.

Code & Concurrency Inspection

  • removed_reason correctly queries host.device.GetDeviceRemovedReason() under #[cfg(windows)].
  • On success (or when running without a host device in unit tests), it returns S_OK (0x00000000).
  • On failure (actual host device removal or TDR), it propagates the underlying HRESULT (e.code().0).
  • Cross-platform: The #[cfg(windows)] check prevents compilation errors or warnings on headless / non-Windows builds, returning S_OK.

Tests & Policy

  • Unit test a_healthy_device_reports_no_removal exercises slot 0x128 directly via the function table and asserts S_OK.
  • Clean diff (+20 lines in device.rs). Pure synthetic unit test, no proprietary assets or SDK headers.
  • Passes cargo xtask policy.

Reviewed and verified. AI-assisted with Antigravity.

**@⁠DaniiL35** on GitHub · 2026-11-24 13:48 UTC · [original](https://github.com/Marvisak/VIctory/issues/900#issuecomment-7133360192) Verified branch `033598b` (on top of `ffe310e`): ### D3D12 ABI Vtable Verification Checked the `ID3D12Device` COM vtable layout: - Slot 36 (offset `0x120`): `CreateFence` - **Slot 37 (offset `0x128`)**: `GetDeviceRemovedReason` - Slot 38 (offset `0x130`): `GetCopyableFootprints` - Slot 39 (offset `0x138`): `CreateQueryHeap` In `FUNCTIONS` (`crates/victory-gpu/src/device.rs`), slot 37 was previously skipped, falling through to `object::missing` which returns `E_NOTIMPL` (`0x80004001`). Because `FAILED(0x80004001)` evaluates to true, any DirectX 12 middleware or title asserting device health via `device->GetDeviceRemovedReason()` would erroneously treat a healthy device as removed/crashed. ### Code & Concurrency Inspection - `removed_reason` correctly queries `host.device.GetDeviceRemovedReason()` under `#[cfg(windows)]`. - On success (or when running without a host device in unit tests), it returns `S_OK` (`0x00000000`). - On failure (actual host device removal or TDR), it propagates the underlying `HRESULT` (`e.code().0`). - Cross-platform: The `#[cfg(windows)]` check prevents compilation errors or warnings on headless / non-Windows builds, returning `S_OK`. ### Tests & Policy - Unit test `a_healthy_device_reports_no_removal` exercises slot `0x128` directly via the function table and asserts `S_OK`. - Clean diff (+20 lines in `device.rs`). Pure synthetic unit test, no proprietary assets or SDK headers. - Passes `cargo xtask policy`. Reviewed and verified. AI-assisted with Antigravity.
Author
Owner

@⁠MichaelSmithAI on GitHub · 2026-11-24 13:48 UTC · original

Independent Wine result on 033598b, RTX 4090 with vkd3d-proton 3.2. A test-only fixture queried the live host device, created the guest device and called slot 37 (0x128) through its vtable. Both calls reported success. The fixture logged after both assertions, confirming this run reached the live-device path. All eight focused device tests passed. This covers the healthy-device case. A removed-device HRESULT and a GTA VI call site remain unverified.

**@⁠MichaelSmithAI** on GitHub · 2026-11-24 13:48 UTC · [original](https://github.com/Marvisak/VIctory/issues/900#issuecomment-7133368355) Independent Wine result on 033598b, RTX 4090 with vkd3d-proton 3.2. A test-only fixture queried the live host device, created the guest device and called slot 37 (`0x128`) through its vtable. Both calls reported success. The fixture logged after both assertions, confirming this run reached the live-device path. All eight focused device tests passed. This covers the healthy-device case. A removed-device HRESULT and a GTA VI call site remain unverified.
This discussion has been locked. Commenting is limited to contributors.
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory#900
No description provided.