XGameRuntime: QueryInterface(IUnknown) on XCL's GDK objects gives one identity #1583

Open
Gruzzberry wants to merge 1 commit from upstream-pr/1593 into main
Gruzzberry commented 2026-11-24 18:03:05 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Gruzzberry on 2026-11-24T18:03:05Z.


The objects QueryApiImpl hands out have QueryInterface / AddRef / Release as their first three vtable slots, so they are COM objects. COM requires QueryInterface(IID_IUnknown) to succeed and to return the same pointer from every interface of the object, since that is how a caller compares identity. query_interface only accepted the class id, the vtable's own interface ids and, on the main vtable, ids the GDK table does not know, so on a non-main vtable (for example XUser's gamertag interface) it was refused with E_NOINTERFACE. IUnknown now answers with the class's main object from every vtable, so two vtables of one object compare equal.

What is in it

  • crates/xcl/src/hle/xgameruntime/api.rs: IID_IUNKNOWN in query_interface returns the class's main object (own(&clsid, &IID_IUNKNOWN), this if the object is not in the table); test query_interface_answers_iunknown_with_one_identity (main and gamertag vtables return the same pointer, an unknown id on the non-main vtable is still refused).

Tested

  • RTX 4070 (NVIDIA, wave32), i7-13700K, Windows 11 26200, rustc 1.100.0 stable, debug tests / release smoke
  • New test on main (9e3831e) with only the test added: FAILED (E_NOINTERFACE for IUnknown); with the one-line "answer with this" variant: FAILED (the two vtables return different pointers); with the fix: ok
  • cargo test --workspace -- --test-threads=4: 777 passed, 0 failed, 41 ignored
  • SKIPPED: gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64, gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64, heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows
  • cargo clippy -p xcl --all-targets: no new warnings in the changed lines

Regression run (retail title 1.0.2.1, 60 s; first block main b7aa9f3, second this PR's head, which is on 9e3831e)

xcl-smoke v1
commit: b7aa9f3bd212088e0d927439284dc5ed325ce3c7
gpu: NVIDIA GeForce RTX 4070
title: 404998dc
seconds: 60
exit: 0x0
frames shown: 1648 (PresentX 1648)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16974 MB
xcl-smoke v1
commit: f326446781d6336721899335af750aad4acb40c2
gpu: NVIDIA GeForce RTX 4070
title: 404998dc
seconds: 60
exit: 0x0
frames shown: 1648 (PresentX 1648)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 17003 MB

Not tested

  • AMD / wave64 GPUs, Linux / Wine
  • No title is known to query IUnknown on these objects; the smoke run only shows nothing regressed

AI use

  • Claude Code with Claude Sonnet 5.5 found, wrote and tested it; the user reviews and opens it.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:5477620753 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1593). Originally posted by [Gruzzberry](https://github.com/Gruzzberry) on 2026-11-24T18:03:05Z. --- The objects `QueryApiImpl` hands out have QueryInterface / AddRef / Release as their first three vtable slots, so they are COM objects. COM requires `QueryInterface(IID_IUnknown)` to succeed and to return the same pointer from every interface of the object, since that is how a caller compares identity. `query_interface` only accepted the class id, the vtable's own interface ids and, on the main vtable, ids the GDK table does not know, so on a non-main vtable (for example XUser's gamertag interface) it was refused with `E_NOINTERFACE`. IUnknown now answers with the class's main object from every vtable, so two vtables of one object compare equal. **What is in it** - `crates/xcl/src/hle/xgameruntime/api.rs`: `IID_IUNKNOWN` in `query_interface` returns the class's main object (`own(&clsid, &IID_IUNKNOWN)`, `this` if the object is not in the table); test `query_interface_answers_iunknown_with_one_identity` (main and gamertag vtables return the same pointer, an unknown id on the non-main vtable is still refused). **Tested** - RTX 4070 (NVIDIA, wave32), i7-13700K, Windows 11 26200, rustc 1.100.0 stable, debug tests / release smoke - New test on `main` (9e3831e) with only the test added: FAILED (`E_NOINTERFACE` for IUnknown); with the one-line "answer with `this`" variant: FAILED (the two vtables return different pointers); with the fix: ok - `cargo test --workspace -- --test-threads=4`: 777 passed, 0 failed, 41 ignored - SKIPPED: `gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64`, `gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64`, `heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows` - `cargo clippy -p xcl --all-targets`: no new warnings in the changed lines **Regression run** (retail title 1.0.2.1, 60 s; first block `main` b7aa9f3, second this PR's head, which is on 9e3831e) ``` xcl-smoke v1 commit: b7aa9f3bd212088e0d927439284dc5ed325ce3c7 gpu: NVIDIA GeForce RTX 4070 title: 404998dc seconds: 60 exit: 0x0 frames shown: 1648 (PresentX 1648) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 16974 MB ``` ``` xcl-smoke v1 commit: f326446781d6336721899335af750aad4acb40c2 gpu: NVIDIA GeForce RTX 4070 title: 404998dc seconds: 60 exit: 0x0 frames shown: 1648 (PresentX 1648) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 17003 MB ``` **Not tested** - AMD / wave64 GPUs, Linux / Wine - No title is known to query IUnknown on these objects; the smoke run only shows nothing regressed **AI use** - Claude Code with Claude Sonnet 5.5 found, wrote and tested it; the user reviews and opens it. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
futurepro62 commented 2026-11-24 19:07:48 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T18:54:37Z.


Full-suite run, since this PR has no test report yet. Tested exact head f326446 (on its base 9e3831e).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form: 776 passed, 0 failed, 41 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • The new tests ran and passed: query_interface_answers_iunknown_with_one_identity.
  • Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4: 777 passed, 0 failed, 41 ignored. SKIPPED: heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • heap_window_out_of_memory_falls_back_to_the_switch_form was skipped with --skip. It fails on main 9e3831e too, not because of this PR: under XCL_REQUIRE_GPU=mesh, runner::skip_test turns every skip except "no wave64" into a failure, including this test's opt-in "no heap windows" skip (XCL_HEAP_WINDOWS unset). Reported as #1651.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
<!-- greyfinch-sync:ivall/xcl:comment:7141322492 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1593#issuecomment-7141322492). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-24T18:54:37Z. --- Full-suite run, since this PR has no test report yet. Tested exact head `f326446` (on its base `9e3831e`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed. - `cargo build --workspace`, then `XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form`: **776 passed, 0 failed, 41 ignored**. SKIPPED (no wave64): `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`. - The new tests ran and passed: `query_interface_answers_iunknown_with_one_identity`. - Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, `XCL_ADAPTER=radeon`), `cargo test --workspace -- --test-threads=4`: **777 passed, 0 failed, 41 ignored**. SKIPPED: `heap_window_out_of_memory_falls_back_to_the_switch_form` (no heap windows). - `heap_window_out_of_memory_falls_back_to_the_switch_form` was skipped with `--skip`. It fails on main `9e3831e` too, not because of this PR: under `XCL_REQUIRE_GPU=mesh`, `runner::skip_test` turns every skip except "no wave64" into a failure, including this test's opt-in "no heap windows" skip (`XCL_HEAP_WINDOWS` unset). Reported as #1651. **Not tested** - a release build, a game (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
DavidM1911 commented 2026-11-24 21:09:20 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T20:12:11Z.


Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~22 ignored. (Intermittent single-test flake under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified main.)

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7143184521 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1593#issuecomment-7143184521). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T20:12:11Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~22 ignored. (Intermittent single-test flake under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified `main`.) Thanks!
throny commented 2026-11-25 03:05:58 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-11-25T03:01:37Z.


Two contributors checked independently and found that #1610 #1615 solves the same problem (for #1488) in a different way: #1607, group D57. You may want to compare them with the other author and agree on one, or say in the PR why both are needed.

This is a hint from the community triage in #1607, not a maintainer decision.

AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.

<!-- greyfinch-sync:ivall/xcl:comment:7151516448 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1593#issuecomment-7151516448). Originally posted by [throny](https://github.com/throny) on 2026-11-25T03:01:37Z. --- <!-- xcl-1607-hint:D57 --> Two contributors checked independently and found that #1610 #1615 solves the same problem (for #1488) in a different way: #1607, group D57. You may want to compare them with the other author and agree on one, or say in the PR why both are needed. This is a hint from the community triage in #1607, not a maintainer decision. AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.
JJAutoCompare commented 2026-11-25 06:05:41 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-25T05:09:01Z.


XCL PR #1593 — focused Windows verification

Tested head f326446781d6336721899335af750aad4acb40c2. The detached worktree was clean before and after the run. The PR changes only crates/xcl/src/hle/xgameruntime/api.rs.

Tested

  • STOR-WINLAB, AMD Ryzen 7 3800X and Intel Arc A770 (driver 32.0.101.9175), Windows 11 Enterprise Evaluation x64 (10.0.26200.9974). DXC 1.9.2609.5 verified with dxc.exe --version. Rust 1.100.0 (0ef1bc386, x86_64-pc-windows-msvc). Unoptimized profiles with debug info and incremental compilation disabled.
  • cargo build --workspace succeeded. cargo test --workspace --no-run succeeded and produced 19 test executables.
  • cargo test -p xcl --lib xgameruntime -- --nocapture with XCL_ADAPTER=NONE_CPU_ONLY reported 74 passed, 0 failed, 0 ignored, and 675 filtered out. The log (pr1593-focused.log) contains 0 lines beginning with SKIPPED . The 74 includes two tests that returned early because the system XGameRuntime DLL and a default Windows audio endpoint were absent.
  • The new query_interface_answers_iunknown_with_one_identity test passed. It obtained distinct XUser main and gamertag interface pointers, checked that querying IID_IUnknown through either returned S_OK and the main object pointer, and checked that an unsupported IID on the gamertag interface returned E_NOINTERFACE with a null output.

Not tested

Only focused XGameRuntime tests and full workspace compilation were run. The full GPU workspace suite and retail-title smoke runs were omitted. The PC-runtime thunk path and Windows default-audio endpoint assertions were skipped as described above.

AI use

T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high) ran the build and verification. Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr1593-focused.log and published.

<!-- greyfinch-sync:ivall/xcl:comment:7153495564 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1593#issuecomment-7153495564). Originally posted by [JJAutoCompare](https://github.com/JJAutoCompare) on 2026-11-25T05:09:01Z. --- # XCL PR #1593 — focused Windows verification Tested head `f326446781d6336721899335af750aad4acb40c2`. The detached worktree was clean before and after the run. The PR changes only `crates/xcl/src/hle/xgameruntime/api.rs`. **Tested** - STOR-WINLAB, AMD Ryzen 7 3800X and Intel Arc A770 (driver 32.0.101.9175), Windows 11 Enterprise Evaluation x64 (10.0.26200.9974). DXC 1.9.2609.5 verified with `dxc.exe --version`. Rust 1.100.0 (0ef1bc386, x86_64-pc-windows-msvc). Unoptimized profiles with debug info and incremental compilation disabled. - `cargo build --workspace` succeeded. `cargo test --workspace --no-run` succeeded and produced 19 test executables. - `cargo test -p xcl --lib xgameruntime -- --nocapture` with `XCL_ADAPTER=NONE_CPU_ONLY` reported 74 passed, 0 failed, 0 ignored, and 675 filtered out. The log (`pr1593-focused.log`) contains 0 lines beginning with `SKIPPED `. The 74 includes two tests that returned early because the system XGameRuntime DLL and a default Windows audio endpoint were absent. - The new `query_interface_answers_iunknown_with_one_identity` test passed. It obtained distinct XUser main and gamertag interface pointers, checked that querying `IID_IUnknown` through either returned `S_OK` and the main object pointer, and checked that an unsupported IID on the gamertag interface returned `E_NOINTERFACE` with a null output. **Not tested** Only focused XGameRuntime tests and full workspace compilation were run. The full GPU workspace suite and retail-title smoke runs were omitted. The PC-runtime thunk path and Windows default-audio endpoint assertions were skipped as described above. **AI use** T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high) ran the build and verification. Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against `pr1593-focused.log` and published.
Gruzzberry commented 2026-11-25 10:10:32 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Gruzzberry on 2026-11-25T09:31:43Z.


Thanks for the triage hint. On the overlap with #1610 and #1615:

  • Order: this PR was opened at 18:03 UTC on 24 Nov; #1610 followed at 18:14 and #1615 at 18:15.
  • Scope: this PR only touches crates/xcl/src/hle/xgameruntime/api.rs. QueryInterface(IID_IUnknown) returns the class's main object from every vtable, so all of an object's interfaces report one identity, as COM requires. #1615 answers IID_IUnknown too. #1610 also changes sibling-interface QI and forwarding aliases, which this PR leaves alone.
  • Tests: it has three independent passing reports above (RTX 5070 Ti, RTX 3060 Ti, Arc A770).

I'm happy to go with whichever the maintainers prefer. If #1610's wider change is wanted, I can close this one, or rebase it to sit under #1610 as the identity part with its test.

AI use: drafted with Claude Code (Claude Opus 5.5) and posted by it at my request, after I reviewed it.

<!-- greyfinch-sync:ivall/xcl:comment:7158451542 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1593#issuecomment-7158451542). Originally posted by [Gruzzberry](https://github.com/Gruzzberry) on 2026-11-25T09:31:43Z. --- Thanks for the triage hint. On the overlap with #1610 and #1615: - **Order:** this PR was opened at 18:03 UTC on 24 Nov; #1610 followed at 18:14 and #1615 at 18:15. - **Scope:** this PR only touches `crates/xcl/src/hle/xgameruntime/api.rs`. `QueryInterface(IID_IUnknown)` returns the class's main object from every vtable, so all of an object's interfaces report one identity, as COM requires. #1615 answers `IID_IUnknown` too. #1610 also changes sibling-interface QI and forwarding aliases, which this PR leaves alone. - **Tests:** it has three independent passing reports above (RTX 5070 Ti, RTX 3060 Ti, Arc A770). I'm happy to go with whichever the maintainers prefer. If #1610's wider change is wanted, I can close this one, or rebase it to sit under #1610 as the identity part with its test. AI use: drafted with Claude Code (Claude Opus 5.5) and posted by it at my request, after I reviewed it.
github-actions[bot] commented 2026-11-29 20:44:27 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-29T20:44:27Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7262320298 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1593#issuecomment-7262320298). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-29T20:44:27Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
Foniass commented 2026-12-01 06:12:46 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T06:12:46Z.


Triage (#1607) – head f326446

Overlaps #1610 and #1615 (D57), which answer QueryInterface(IID_IUnknown) in the same function. #1610 gives the same answer (the class's main object, this outside the table) but also adds sibling-interface QI and changes forwarding aliases in QueryApiImpl. #1615 returns this, so two vtables of one object give two different IUnknown pointers, which breaks COM identity.
This PR is the earliest and smallest of the three and only does the IUnknown part. Main's query_interface still refuses IID_IUnknown on non-main vtables.
No problems found in the diff.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7302614961 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1593#issuecomment-7302614961). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T06:12:46Z. --- **Triage (#1607)** – head f326446 Overlaps #1610 and #1615 (D57), which answer QueryInterface(IID_IUnknown) in the same function. #1610 gives the same answer (the class's main object, `this` outside the table) but also adds sibling-interface QI and changes forwarding aliases in `QueryApiImpl`. #1615 returns `this`, so two vtables of one object give two different IUnknown pointers, which breaks COM identity. This PR is the earliest and smallest of the three and only does the IUnknown part. Main's `query_interface` still refuses IID_IUnknown on non-main vtables. No problems found in the diff. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
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/1593:upstream-pr/1593'
git switch 'upstream-pr/1593'

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/1593'
git switch 'upstream-pr/1593'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1593'
git switch 'upstream-pr/1593'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1593'
git switch 'main'
git merge --squash 'upstream-pr/1593'
git switch 'main'
git merge --ff-only 'upstream-pr/1593'
git switch 'main'
git merge 'upstream-pr/1593'
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
xcl-dev/xcl!1583
No description provided.