GPU: every object answers for IUnknown #270

Merged
Maraco91 merged 1 commit from upstream-pr/270 into main 2026-11-25 00:19:22 +00:00
Maraco91 commented 2026-11-24 01:56:07 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Maraco91 on 2026-11-24T01:56:07Z.


What

QueryInterface(IID_IUnknown) fails on every graphics object: the device, the DXGI objects, fences, queues, lists, allocators, heaps, resources, pipelines, root signatures.

Each object's query matches the id against its own list (FENCE_IIDS, QUEUE_IIDS, ..) through object::is, and no list holds IUnknown (00000000-0000-0000-c000-000000000046). So the answer is E_NOINTERFACE and a null pointer, with an unknown interface warning. The same goes for every other call that hands out an object by interface id (creation, GetDevice, GetParent).

COM requires every object to answer for it, and code relies on that: to compare two interface pointers for identity (QueryInterface(IID_IUnknown) on both, as ComPtr/CComPtr comparisons do), to hold an object as a plain reference, or to hand it to an API that takes any object.

object::is now also matches IUnknown; every caller listed above goes through it, and all of them answer with the object that was asked (or, for GetDevice/GetParent, with the object they name), which is right for IUnknown too. The DXGI device answers with the D3D12 device, as it already does for the device's own id: one pointer whichever of the object's interfaces is asked, which is what identity comparisons need.

I have not seen the title or its middleware ask (I have no game files); it would show in the log as unknown interface with the id above.

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. The test needs no GPU.

New unit test every_object_answers_for_iunknown in object.rs: QueryInterface for IUnknown through slot 0 of the device, of a fence, and of the DXGI device returns S_OK; the device and the fence answer with themselves, the DXGI device with the device. Control: an id no object has still gets E_NOINTERFACE and a nulled pointer from the fence.

  • main (d2a4bae) + the test and the constant only: cargo test -p victory-gpu --lib every_object_answers fails at the device: left: (-2147467262, 0x0) (E_NOINTERFACE, null).
  • with the fix: cargo test -p victory-gpu --lib: 44 passed, 0 failed, 1 ignored; cargo test -p victory-hle --lib: 86 passed, 0 failed (it drives these objects through d3d12x).
  • cargo clippy -p victory-gpu --tests: nothing in object.rs. rustfmt --check object.rs: clean.
  • cargo xtask policy: 151 files ok.
  • Trial merges (git merge-tree) with #32, #153 and #249, which change object.rs: all clean.

Not tested: a title run.

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

🤖 Generated with Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:issue:6572839376 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/270). Originally posted by [Maraco91](https://github.com/Maraco91) on 2026-11-24T01:56:07Z. --- ## What `QueryInterface(IID_IUnknown)` fails on every graphics object: the device, the DXGI objects, fences, queues, lists, allocators, heaps, resources, pipelines, root signatures. Each object's query matches the id against its own list (`FENCE_IIDS`, `QUEUE_IIDS`, ..) through `object::is`, and no list holds `IUnknown` (`00000000-0000-0000-c000-000000000046`). So the answer is `E_NOINTERFACE` and a null pointer, with an `unknown interface` warning. The same goes for every other call that hands out an object by interface id (creation, `GetDevice`, `GetParent`). COM requires every object to answer for it, and code relies on that: to compare two interface pointers for identity (`QueryInterface(IID_IUnknown)` on both, as `ComPtr`/`CComPtr` comparisons do), to hold an object as a plain reference, or to hand it to an API that takes any object. `object::is` now also matches `IUnknown`; every caller listed above goes through it, and all of them answer with the object that was asked (or, for `GetDevice`/`GetParent`, with the object they name), which is right for `IUnknown` too. The DXGI device answers with the D3D12 device, as it already does for the device's own id: one pointer whichever of the object's interfaces is asked, which is what identity comparisons need. I have not seen the title or its middleware ask (I have no game files); it would show in the log as `unknown interface` with the id above. ## 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. The test needs no GPU. New unit test `every_object_answers_for_iunknown` in `object.rs`: `QueryInterface` for `IUnknown` through slot 0 of the device, of a fence, and of the DXGI device returns `S_OK`; the device and the fence answer with themselves, the DXGI device with the device. Control: an id no object has still gets `E_NOINTERFACE` and a nulled pointer from the fence. - `main` (d2a4bae) + the test and the constant only: `cargo test -p victory-gpu --lib every_object_answers` **fails** at the device: `left: (-2147467262, 0x0)` (`E_NOINTERFACE`, null). - with the fix: `cargo test -p victory-gpu --lib`: **44 passed, 0 failed, 1 ignored**; `cargo test -p victory-hle --lib`: **86 passed, 0 failed** (it drives these objects through `d3d12x`). - `cargo clippy -p victory-gpu --tests`: nothing in `object.rs`. `rustfmt --check object.rs`: clean. - `cargo xtask policy`: 151 files ok. - Trial merges (`git merge-tree`) with #32, #153 and #249, which change `object.rs`: all 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)
jeremygold02 commented 2026-11-24 06:55:37 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by jeremygold02 on 2026-11-24T04:05:05Z.


Tested this open PR at head 92f2c60c8159e34a47570aa81f3d25624cc6db5c (still current when refreshed before posting).

cargo test --locked -p victory-gpu --lib every_object_answers_for_iunknown passed object::tests::every_object_answers_for_iunknown. It checks IUnknown identity through the device, fence and DXGI-device interfaces, and confirms an unsupported IID still returns E_NOINTERFACE with a null output. The coverage is in object.rs. This is a unit test and does not require a GPU or title run.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7121691477 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/270#issuecomment-7121691477). Originally posted by [jeremygold02](https://github.com/jeremygold02) on 2026-11-24T04:05:05Z. --- Tested this open PR at head `92f2c60c8159e34a47570aa81f3d25624cc6db5c` (still current when refreshed before posting). `cargo test --locked -p victory-gpu --lib every_object_answers_for_iunknown` passed `object::tests::every_object_answers_for_iunknown`. It checks `IUnknown` identity through the device, fence and DXGI-device interfaces, and confirms an unsupported IID still returns `E_NOINTERFACE` with a null output. The coverage is in [object.rs](https://github.com/Marvisak/VIctory/blob/92f2c60c8159e34a47570aa81f3d25624cc6db5c/crates/victory-gpu/src/object.rs). This is a unit test and does not require a GPU or title run.
mercuryVM commented 2026-11-24 08:36:03 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T08:36:03Z.

Review: APPROVED


Tested 92f2c60 on Windows 11, RTX 5070, MSVC: cargo test --workspace --no-fail-fast passes (265 passed, 0 failed), including every_object_answers_for_iunknown.

  • COM's rule is that every object answers IUnknown, with the same pointer whichever interface is asked. Putting IUNKNOWN into object::is covers every query path in one place.
  • I checked the identity part. The device's query_interface tries is_device(iid) first, so IUnknown returns the device. The DXGI device's device_query checks [device::IID] first, so its IUnknown also returns the D3D12 device. One pointer, as the test asserts.
  • Callers that use is for something other than a query (the creation paths in device.rs:92 and descriptor.rs:637) now accept IUnknown as a requested interface and hand back the object. That is also what native D3D12 does for CreateX(..., IID_IUnknown, ...).

No issues found.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:review:6036007928 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/270#pullrequestreview-6036007928). Originally posted by [mercuryVM](https://github.com/mercuryVM) on 2026-11-24T08:36:03Z. **Review:** APPROVED --- Tested 92f2c60 on Windows 11, RTX 5070, MSVC: `cargo test --workspace --no-fail-fast` passes (265 passed, 0 failed), including `every_object_answers_for_iunknown`. - COM's rule is that every object answers `IUnknown`, with the same pointer whichever interface is asked. Putting `IUNKNOWN` into `object::is` covers every query path in one place. - I checked the identity part. The device's `query_interface` tries `is_device(iid)` first, so `IUnknown` returns the device. The DXGI device's `device_query` checks `[device::IID]` first, so its `IUnknown` also returns the D3D12 device. One pointer, as the test asserts. - Callers that use `is` for something other than a query (the creation paths in `device.rs:92` and `descriptor.rs:637`) now accept `IUnknown` as a requested interface and hand back the object. That is also what native D3D12 does for `CreateX(..., IID_IUnknown, ...)`. No issues found. AI-assisted (Claude Code).
upstream-sync closed this pull request 2026-11-25 01:03:13 +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!270
No description provided.