GPU: GetDevice and the DXGI device hand out the device at every level #249

Manually merged
github merged 1 commit from gh-pr/249/head into gh-pr/249/base 2026-11-26 03:56:35 +00:00
Owner

@⁠Maraco91 on GitHub · 2026-11-24 01:48 UTC · original
Maraco91:gpu/get-device-newer-levels → main · +54 −4 · 3 files · 1 commits · merged 2026-11-24 07:58 UTC

What

The device answers QueryInterface for ID3D12Device and for its newer levels, ID3D12Device1 to 8 and 11 (device::is_device; Grand Theft Auto VI creates it as ID3D12Device11). Two other ways to reach the device knew only the first interface:

  • object::parent_device: ID3D12DeviceChild::GetDevice, slot 0x38 of every device child (fences, queues, lists, heaps, resources, pipelines, ..);
  • dxgi::device_query: QueryInterface on the DXGI device, which "also answers for the D3D12 device".

Asked for the device by any newer level, both returned E_NOINTERFACE and a null pointer:

ID3D12Device11* device;
fence->GetDevice(IID_PPV_ARGS(&device));   // E_NOINTERFACE, device == nullptr

That is the interface the title itself holds, so code that goes from an object back to its device asks with exactly that id; callers rarely check this result, since on the host it cannot fail for an interface the device has.

Both now use the device's own test. is_device becomes pub(crate); nothing else changes.

I have not seen the title or its middleware make this call (I have no game files); it would show in the log as unknown interface on a device child.

Tested

Windows 11 Pro 10.0.26200, NVIDIA RTX 3080 Ti (driver 32.0.16.1656), rustc 1.98.1 (x86_64-pc-windows-msvc), no game data.

Two new unit tests in device.rs:

  • the_hosts_children_hand_out_newer_device_levels (Windows, needs a host device; I checked it did not take its no-GPU early return here): the reference. On the host device, a fence's GetDevice for ID3D12Device5 succeeds. Passes on main and with the fix.
  • the_device_is_found_at_every_level_through_others (no GPU): for ID3D12Device and each of the nine newer ids, a fence's GetDevice and the DXGI device's QueryInterface return S_OK and the device. Control: asking the fence's GetDevice for an interface the device is not (the fence's own id) still returns E_NOINTERFACE and nulls the pointer.

Results:

  • main (d2a4bae) + the tests only: cargo test -p victory-gpu --lib device::tests: the second test fails at the first newer id (ID3D12Device1): left: -2147467262 (E_NOINTERFACE), right: 0.
  • with the fix: cargo test -p victory-gpu --lib: 45 passed, 0 failed, 1 ignored.
  • cargo clippy -p victory-gpu --tests: nothing in the three files. rustfmt --check on them: clean.
  • cargo xtask policy: 151 files ok.
  • Trial merges (git merge-tree) with #153 and #32, which change object.rs: clean.

Not tested: a title run.

AI-assisted (Claude Code); the tests above were run on the machine described.

🤖 Generated with Claude Code

**@⁠Maraco91** on GitHub · 2026-11-24 01:48 UTC · [original](https://github.com/Marvisak/VIctory/pull/249) `Maraco91:gpu/get-device-newer-levels` → `main` · +54 −4 · 3 files · 1 commits · merged 2026-11-24 07:58 UTC ## What The device answers `QueryInterface` for `ID3D12Device` and for its newer levels, `ID3D12Device1` to `8` and `11` (`device::is_device`; Grand Theft Auto VI creates it as `ID3D12Device11`). Two other ways to reach the device knew only the first interface: - `object::parent_device`: `ID3D12DeviceChild::GetDevice`, slot 0x38 of every device child (fences, queues, lists, heaps, resources, pipelines, ..); - `dxgi::device_query`: `QueryInterface` on the DXGI device, which "also answers for the D3D12 device". Asked for the device by any newer level, both returned `E_NOINTERFACE` and a null pointer: ```c ID3D12Device11* device; fence->GetDevice(IID_PPV_ARGS(&device)); // E_NOINTERFACE, device == nullptr ``` That is the interface the title itself holds, so code that goes from an object back to its device asks with exactly that id; callers rarely check this result, since on the host it cannot fail for an interface the device has. Both now use the device's own test. `is_device` becomes `pub(crate)`; nothing else changes. I have not seen the title or its middleware make this call (I have no game files); it would show in the log as `unknown interface` on a device child. ## Tested Windows 11 Pro 10.0.26200, NVIDIA RTX 3080 Ti (driver 32.0.16.1656), rustc 1.98.1 (`x86_64-pc-windows-msvc`), no game data. Two new unit tests in `device.rs`: - `the_hosts_children_hand_out_newer_device_levels` (Windows, needs a host device; I checked it did not take its no-GPU early return here): the reference. On the host device, a fence's `GetDevice` for `ID3D12Device5` succeeds. Passes on `main` and with the fix. - `the_device_is_found_at_every_level_through_others` (no GPU): for `ID3D12Device` and each of the nine newer ids, a fence's `GetDevice` and the DXGI device's `QueryInterface` return `S_OK` and the device. Control: asking the fence's `GetDevice` for an interface the device is not (the fence's own id) still returns `E_NOINTERFACE` and nulls the pointer. Results: - `main` (d2a4bae) + the tests only: `cargo test -p victory-gpu --lib device::tests`: the second test **fails** at the first newer id (`ID3D12Device1`): `left: -2147467262` (`E_NOINTERFACE`), `right: 0`. - with the fix: `cargo test -p victory-gpu --lib`: **45 passed, 0 failed, 1 ignored**. - `cargo clippy -p victory-gpu --tests`: nothing in the three files. `rustfmt --check` on them: clean. - `cargo xtask policy`: 151 files ok. - Trial merges (`git merge-tree`) with #153 and #32, which change `object.rs`: clean. Not tested: a title run. AI-assisted (Claude Code); the tests above were run on the machine described. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The device answers QueryInterface for ID3D12Device and for its newer
levels (Grand Theft Auto VI creates it as ID3D12Device11). A device
child's GetDevice and the DXGI device's QueryInterface knew only the
first: asked for the device by the interface the title holds, they
answered E_NOINTERFACE with a null pointer.

Both now ask the device's own test (is_device).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:56:34 +00:00
github manually merged commit 717f322c3c into gh-pr/249/base 2026-11-26 03:56:35 +00:00
Author
Owner

@⁠jeremygold02 on GitHub · 2026-11-24 05:38 UTC · original

Tested current PR head 717f322c3ced51ea6f4baae4790a83efa2b2e184.

  • cargo test --locked -p victory-gpu --lib the_device -- --test-threads=1: 2 passed, 44 filtered out. The new the_device_is_found_at_every_level_through_others test asks a fence's GetDevice and the DXGI device's QueryInterface for the base device IID and every newer device level, checks that both return the same device, and verifies an unsupported fence IID returns E_NOINTERFACE with a null output. The existing device-creation test passed in the same target (interface test).
  • cargo test --locked -p victory-gpu --lib the_hosts_children_hand_out_newer_device_levels -- --test-threads=1: 1 passed. This Windows-only smoke test creates a host fence and asks for ID3D12Device5; it returns early when no host D3D12 device is available (host test).

The synthetic interface test verifies the COM-style lookup paths; the host check is conditional, and neither test runs a game or title.

**@⁠jeremygold02** on GitHub · 2026-11-24 05:38 UTC · [original](https://github.com/Marvisak/VIctory/pull/249#issuecomment-7123136938) Tested current PR head `717f322c3ced51ea6f4baae4790a83efa2b2e184`. - `cargo test --locked -p victory-gpu --lib the_device -- --test-threads=1`: 2 passed, 44 filtered out. The new `the_device_is_found_at_every_level_through_others` test asks a fence's `GetDevice` and the DXGI device's `QueryInterface` for the base device IID and every newer device level, checks that both return the same device, and verifies an unsupported fence IID returns `E_NOINTERFACE` with a null output. The existing device-creation test passed in the same target ([interface test](https://github.com/Marvisak/VIctory/blob/717f322c3ced51ea6f4baae4790a83efa2b2e184/crates/victory-gpu/src/device.rs#L449-L476)). - `cargo test --locked -p victory-gpu --lib the_hosts_children_hand_out_newer_device_levels -- --test-threads=1`: 1 passed. This Windows-only smoke test creates a host fence and asks for `ID3D12Device5`; it returns early when no host D3D12 device is available ([host test](https://github.com/Marvisak/VIctory/blob/717f322c3ced51ea6f4baae4790a83efa2b2e184/crates/victory-gpu/src/device.rs#L478-L495)). The synthetic interface test verifies the COM-style lookup paths; the host check is conditional, and neither test runs a game or title.
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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!249
No description provided.