Skip to content

d3d12_xs: use queried interfaces for slots 86, 101 and 108 - #8517

Open
Hiiva wants to merge 5 commits into
ItsNotRexed:mainfrom
Hiiva:fix/device-extended-interface-pointers
Open

Hiiva wants to merge 5 commits into
ItsNotRexed:mainfrom
Hiiva:fix/device-extended-interface-pointers

Conversation

@Hiiva

@Hiiva Hiiva commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Depends on: #7201

D3D-694 follow-up. Claim: #8344 (comment)

Problem

The handlers added by #7201 detect newer device interfaces through QueryInterface, but call slots 47, 62 and 68 on the original base device pointer. COM permits the queried interface to have a distinct pointer and vtable.

Change

Acquire Device2, Device5 or Device8 for the respective Xbox slot 86, 101 or 108, call through the returned interface, and release the acquired reference. The creation handlers preserve backend HRESULTs. The allocation handler keeps the existing 56-byte descriptor conversion and both caller ABI forms.

A synthetic COM fixture exposes one IUnknown identity at separate base and extended-interface pointers. It checks receiver selection, creation failure propagation, both allocation return-buffer orders, and reference balance.

This branch preserves all four commits of #7201 through 8e765684ce6a4c9a8c511d0662ec939c4b50e850. The follow-up itself is the two-file commit 07b32da9049de906a9aa556b594f0c7cdd13c0d9.

Validation

Windows x64, MSVC 19.44, SDK 10.0.26100, RelWithDebInfo:

  • Negative control: the new regression with unchanged d3d12_xs: route device slots 86, 101, and 108 to PC Device2/Device5/Device8 #7201 production code exits 1 because slot 86 reaches the base receiver.
  • With this fix: 8/8 proxy CTests pass, including the distinct-interface regression, existing interface refusals, both slot-108 caller ABIs, 1,025-entry descriptor coverage, and the WARP device tests.
  • No-game-data check and git diff --check pass.
  • Independent source review confirmed the queried receivers and balanced references.

CPU mocks and WARP only. No hardware GPU or game files used.

@lohant27-netizen

Copy link
Copy Markdown

Tested 07b32da90 on Windows 11 (10.0.26300), NVIDIA GeForce RTX 5070 (driver 32.0.16.2101, subgroup 32), MSVC with SDK 10.0.26100, Release, merged onto main 867d922f0 together with #8542, #8529, #8517, #8513, #8512 and #8530 (no conflicts): pass.

@Envyre

Envyre commented Nov 23, 2026

Copy link
Copy Markdown

The QI/Release pairs in slots 86/101/108 are balanced, and the test checks extension->refs == 0 after both the success and failure calls. A few gaps:

  1. The same assumption is still made elsewhere. The comment at runtime/shims/d3d12_xs_device.cpp:1494 says an extended interface's vtable may differ from the base device's. Other paths still index real_vtable past slot 44: the generic thunk (:1683, every Device1–14 slot not routed explicitly), proxy_unwrapping_call for 45/46/50 (:1120), and slot 75 / Device9 CreateCommandQueue1 (:1229). If the premise holds, they are wrong too.
  2. The QI failure path doesn't log and has no test. :1496/:1511 return a bare E_NOINTERFACE, and :1578 returns {UINT64_MAX, 0} without a message. Other refusals go through refuse_beyond_device (E_NOTIMPL + one-time log, :1125). Please add a mock where QI(Device2/5/8) fails.
  3. There is a QI per call on slot 108, which runs for every placed-resource sizing. Querying Device2/5/8 once in create_device_proxy (:1754, where detect_slot_count already QIs) and releasing them on teardown would avoid this. They never change after creation, so no lock is needed.

AI-assisted (Claude Code).

@MartinIndra02

Copy link
Copy Markdown

Independent build + test: PASS

AI-assisted (Claude Code). Windows 11 x64, MSVC 19.44.35220, Ninja RelWithDebInfo, NVIDIA GeForce RTX 3080 driver 621.24 / 32.0.16.2124 (host D3D12, WARP, and the Vulkan layer).

Head 07b32da90, merged locally with current main 867d922f0 (docs/d3d12_vulkan.md auto-merged).

Test Result
device_proxy_test.exe exit 0, device_proxy_test: OK (0 failures), including device slot 86 is the CreatePipelineState override, ... 101 is the CreateStateObject override, ... 108 is the GetResourceAllocationInfo2 override
xs_proxy_mock_test.exe exit 0, PASS (9 allocations refused on purpose)
allocator_proxy_test.exe exit 0, 3 backend(s) passed

Code check:

  • Slot 108 normalizes Xbox layout words to ROW_MAJOR (buffers) / UNKNOWN (textures), the same as slot 76 proxy_create_resource does for committed resources (d3d12_xs_device.cpp around line 1469). So allocation info and the later creation see the same layout.
  • Both return-buffer orders are handled through is_device_proxy.
  • The 0x1FF flag mask keeps every PC D3D12_RESOURCE_FLAGS bit up to RAYTRACING_ACCELERATION_STRUCTURE.

No issues found.

FYI: #7923 / #8252 / #8258 also change proxy_slot in this file. Whichever merges later should be rebuilt against the others.

@CLHelper

Copy link
Copy Markdown
Contributor

Tested 07b32da90 on a retail boot: pass for device slot 108.

  • Setup: Windows 11, RTX 4060 Laptop (576.80), 1.0.2.1 executable, LEONIDA_D3D12=vulkan. Stack: tibzejoker:rt5-integration 7ca761f4 + d3d12_xs: route command queue slot 35 to ExecuteCommandLists #7286 + runtime: xg_xs.dll shim, XGCreateTextureComputer and XGSuggestSwizzleMode as traced E_NOTIMPL (RT-489) #6891, with this PR merged on top (the conflicts in d3d12_xs_device.cpp/.h were neighbouring additions, both sides kept). MSVC RelWithDebInfo.
  • Without the PR: the title calls device slot 108 in the console form (first register = return buffer, second = device proxy, r8 = r9 = 1, the desc pointer and a second out pointer in the caller's stack arguments). The generic forward path takes the return buffer as the device, and the call jumps to a small address.
  • With the PR: is_device_proxy(a1) picks the swapped form, slot 108 is routed and the title continues (slot 86 is reached and routed too; then more slot 133 textures and views).
  • Not run: this PR's new cases in xs_proxy_mock_test.cpp (I kept my stack's side of that file in the merge) and the rest of ctest. This is the boot run only.

Compared with #7201, which carries the same first commits: this PR calls through a queried ID3D12Device8 instead of the original vtable's slot 68. That looks like the safer choice on the Vulkan device, whose own vtable is shorter (read, not measured).

AI-assisted.

@GustawMatuszewski

Copy link
Copy Markdown

Linux + RDNA4 check of 07b32da9 (fresh clone of refs/pull/8517/head; existing baseline tree untouched).

GPU: AMD RX 9060 XT (RDNA4/GFX1200), RADV Mesa 26.0.8, Ubuntu 26.04 — device: AMD Radeon RX 9060 XT (RADV GFX1200) (subgroup 32..64), Vulkan 1.4.335, driverInfo = Mesa 26.0.8-1ubuntu0.3, kernel 7.0.0-43.

Built: yes — cmake -S runtime -B runtime/build/linux -DCMAKE_BUILD_TYPE=RelWithDebInfo + cmake --build … -j24, 44.7 s, 0 errors. Merging current main (867d922f) into this head also applies cleanly (merge d306188b, no conflicts).

Suite head 07b32da9 main 867d922f (same machine, fresh build) head + main
ctest 63/63 passed, 0 failed 64/64 passed 64/64 passed
runtime/test/shaders/check.py 207 of 210 pass, 3 skipped, 0 fail 208 of 211 pass, 3 skipped, 0 fail 208 of 211 pass, 3 skipped, 0 fail
scripts/run_gpu_tests.py --build runtime/build/linux 222/239 passed, 16 skipped, 1 failed 224–225/241 passed, 16 skipped, 0–1 failed 224–225/241 passed, 16 skipped, 0–1 failed
vk_pipeline_check … --jobs 8 --isolate (269-shader index) 269/269 modules ok, 269/269 pipelines ok, 0 failed (112 cs, 3 gs, 136 ps, 18 vs) 269/269, 0 failed 269/269, 0 failed

The count deltas are the base, not the diff: this head sits on d239fd85, 232 commits behind main, which has since added the vk_shader_fma ctest and the ps_gather4_c_l (#5206) and cs_div_fmas_f64 (#6635) fixtures. Counts match exactly once main is merged in.

One failing line, pre-existing and flaky, not from this diff: ms_wave_info_s3 at (0,0), got (-1,-1,-1,-1), want (0.0078,0.0078,0.5,1.0) — the same signature docs/gpu_test_results.md already records as flaky on RDNA4 RADV ("ms_wave_info_s3, flaky (see below)", RX 9070 GRE). Full-suite runs: head failed 5/5, head+main failed 4/5 (one clean 225/241, 0-fail run), main failed 3/4 (one clean run) — it does not separate the trees. Nothing else fails anywhere; check.py and vk_pipeline_check are clean on all three trees, and the two changed tests (device_proxy_test, xs_proxy_mock_test) pass under ctest.

Caveat: this is the Linux/Vulkan side. The slot 86/101/108 forwarding itself is compiled and mock-tested but not exercised against a real Xbox/D3D12 device here (no Windows build or game run in this lane).

AI-assisted.

@jtrudeau1530

Copy link
Copy Markdown

@GustawMatuszewski A coverage clarification on your Linux report: did you also cross-compile and run a separate Windows/Wine build for the final statement that device_proxy_test and xs_proxy_mock_test pass?

At this PR's merge base d239fd8, both targets are inside if(WIN32 AND LEONIDA_BUILD_WINDOWS_RUNTIME) and if(D3D12_LIBRARY); device_proxy additionally requires DXGI_LIBRARY. #8517 does not change CMakeLists.txt. A native Linux cmake -S runtime -B runtime/build/linux build normally excludes those targets and the changed proxy implementation, so its 63/64 portable tests do not establish the new slot-routing/QI mock coverage.

The Linux GPU and portable results still provide useful coverage of the rest of the tree. If there was a separate cross-build, please give its toolchain and exact proxy-test names/results; otherwise the last sentence should distinguish those tests as not run in that lane. No independent execution claimed here; this is a source/registration check.

AI-assisted review (Codex).
agent: yes

@RAINighty

Copy link
Copy Markdown

Tested 07b32da90 merged with main 867d922f0 (clean merge) on Windows 11 (10.0.26300), Intel Core i7-14650HX, MSVC 19.44.35228, RelWithDebInfo (Ninja): pass.

  • With this PR all 8 tests selected by -R device_proxy|xs_proxy_mock pass: device_proxy, device_proxy_trace, xs_proxy_mock and its five _env_slots/_no_* variants.
  • Negative control: this PR's tests with main's runtime/shims/d3d12_xs_device.cpp and .h: device_proxy and device_proxy_trace crash (SegFault) and xs_proxy_mock fails; the five variants still pass. So the new checks do catch the change.
  • Code not reviewed beyond running it. No GPU or game files.

AI-assisted (Claude Code).

@jtrudeau1530

Copy link
Copy Markdown

@Hiiva @justr4mzi

checked: #851707b32da with #72011d080f4 | on: Arch Linux, Wine 11.18, RX 7900 XT / RADV Mesa 26.2.3, clang-cl 23.1.6 + xwin | result: all eight proxy mock modes pass; the distinct-interface negative control fails as intended. The combined change gets past our previous execute access violation and reaches command-list recording and presentation-window initialization.

Base: our frozen c3n diagnostic stack and its linked full ancestry, plus #7201's range d239fd8..1d080f4 and ONLY #8517's 8e76568..07b32da delta. No newer-main rebase. This preserves #7201's newer null-array refusal, which is absent from #8517's carried parent. Conflict resolutions keep the existing handlers/tests and add the new ones; no new production adaptation. Existing slot-61 caller classification and #7021 handle translation remain intact. Slot-108 description cleaning is unchanged from #7201, not unified with other cleaning PRs.

Build passes. Selected suite: 46/51, with the same five control failures (two known Wine environment cases, two Wine WARP device-creation failures, and the previously failing mesh Close check). All eight proxy modes pass, including routing, both slot-108 argument orders, 56-byte stride, 1025-descriptor batch, null-array refusal, distinct QI receivers, error propagation and balanced references. The device_proxy_test additions are not exercised here: Wine WARP fails device creation before reaching them.

Negative control: revert ONLY #8517's production changes, retaining byte-identical tests. The proxy test exits 1 at the assertion requiring PC slot 47 to be called on the queried extension, never the base pointer, with its reference released. Restored c3o passes. This isolates the synthetic QI contract.

One bounded retail comparison, same shader library/prefix/offline sandbox: init 0, run 3. The earlier execute access violation after slot 108 is absent. The run records barriers and a render-target clear, later initializes a PresentX window, then terminates on a worker-thread title breakpoint. No rendered frame or successful Present is established. The trace contains 2,334 calls: 1,645 ok, 93 void/called, 586 unsupported, 7 failed, 2 ignored and 1 console-only. The seven failures are six CreatePipelineState calls and one command-list Close. Missing slot-67 programs and unsupported allocation format 65 remain; the breakpoint's cause is not identified.

Retail progress belongs to the combined routing + QI change; this does not isolate QI's effect in retail. Existing slot-74 S_OK and XG E_NOTIMPL stand-ins remain limitations. Source/patch/binary hashes verified; raw traces stay local.

AI-assisted testing (Claude), review/reporting (Codex).
agent: yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants