D3D12.X: answer IDXGIDevice3 and IDXGIDevice4 on console device shim #3384
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3384"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-29T11:49:53Z.
What is in it
IDXGIDeviceshim (crates/xcl/src/hle/d3d12x/dxgi_device.rs) to answerIDXGIDevice3andIDXGIDevice4inanswers()and expose their COM vtable slots:IDXGIDevice3::Trim(no-op on the PC D3D12 device wrapper).IDXGIDevice4::OfferResources1(validatesn > 0 && resources.is_null() -> E_INVALIDARG, returnsS_OK).IDXGIDevice4::ReclaimResources1(returnsS_OKwhenn == 0, validatesresources/resultspointers, fillsresults[..n]withDXGI_RECLAIM_RESOURCE_RESULT_OK(0), returnsS_OK).dxgi_device.rsmethods: clear*outwhenqireceives a nullriid, clear*outinget_parenton nullriidoradapter()failure, and guard zero-count slices inquery_resource_residencyandreclaim_resources.dxgi_device.rs(answers_dxgi_device_interfaces_up_to_4andwarp_dxgi_device3_and_4_com_methods) verifying failing-before/passing-afterIDXGIDevice3/IDXGIDevice4queries,Trim,OfferResources1,ReclaimResources1(populated, empty, and invalid-pointer cases), null-riid*outclearing, and COM identity round-trip back toID3D12Device.Tested
answers_dxgi_device_interfaces_up_to_4panicked onIDXGIDevice3;warp_dxgi_device3_and_4_com_methodsreturnedE_NOINTERFACE(0x80004002) onQueryInterface(IDXGIDevice3)).cargo test -p xcl --lib -j 4 -- hle::d3d12x::dxgi_device:: --nocapture): 2 passed, 0 failed, 0 ignored.cargo test --workspace -j 2 -- --test-threads=4 --skip test_title_runs_and_game_folder_is_untouched --skip uma_driver::tests::withXCL_DXC_DIRset to DXC 1.9 on RTX 5070 Ti): 41 test binaries, 2611 passed, 0 failed, 49 ignored, 9 filtered out.SKIPPEDbreakdown (26 total): 21no wave64(RTX 5070 Ti is wave32), 3refused(V_MUL_F16,V_PK_MUL_F16,V_CVT_F16_F32#1426semantics), 2no heap windows(XCL_HEAP_WINDOWS=1opt-in).Regression run
Not tested
IDXGIDevice3orIDXGIDevice4on the device; coverage ofTrim,OfferResources1, andReclaimResources1comes from the synthetic WARP COM test.test_title_runs_and_game_folder_is_untouched,uma_driver::tests::, wave64 GPU tests, andXCL_HEAP_WINDOWS=1opt-in unit tests were not run in the workspace suite.AI use
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T04:57:08Z.
merge-check
base:
d0832e614fhead:
ef25f34c22merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2892 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: read the whole diff (dxgi_device.rs, +138/-12). A console title asking the device for IDXGIDevice3 or IDXGIDevice4 now gets the shim instead of E_NOINTERFACE. Findings: (1) Not tested says no title asks for these interfaces, and nothing shows the console device exposes them, so the need isn't shown. (2) Unrelated hardening is bundled in: clearing
*outinqi/get_parent(~88-93, ~137-151) and zero-count guards (~182, ~222) that change nothing since the pointer was already checked for null; CONTRIBUTING puts that in its own PR. (3)OfferResources1(~241-246) doesn't check its priority or flags, which real DXGI rejects. (4) AI use names no tool or model; no what-and-why paragraph or issue link. Fine: the vtable layout is right (Trim at slot 17, OfferResources1 at 18, ReclaimResources1 at 19, 20 slots in all, matching DXGI), reference counts and the QI path back to the device are correct, a no-op Trim is fine for D3D12, ReclaimResources1 reports every resource as kept, and the test calls each new slot through thewindowscrate's IDXGIDevice4 vtable withskip_test.performance: 60 s smoke of a retail title, main
d0832e61vs this merge (8852640f): 1516 -> 1665 frames shown (109 %; last presents per 2 s: 60 60 60), peak commit 18133 -> 16915 MB, 0 device removals, 0 crashes.verdict: safe to merge (the unrelated hardening should be its own PR, and the description should say which title asks for IDXGIDevice3/4)
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5
AI-written and posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T02:44:32Z.
Code review location:
crates/xcl/src/hle/d3d12x/dxgi_device.rs; line 241offer_resources1/reclaim_resources1copy the IDXGIDevice2 versions with different validation, so the same input behaves differently by interface.OfferResources(1, NULL, prio)returns S_OK butOfferResources1(1, NULL, prio, 0)returns E_INVALIDARG, andReclaimResources(1, NULL, out)returns S_OK butReclaimResources1(1, NULL, out)returns E_INVALIDARG.OfferResources1also accepts undefined flag bits (e.g. 0xFFFF). One shared helper per pair, with offer_resources1 checkingflags & !DXGI_OFFER_RESOURCE_FLAG_ALLOW_DECOMMIT, would keep them consistent.Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T02:44:32Z.
Code review location:
crates/xcl/src/hle/d3d12x/dxgi_device.rs; line 256Not certain about this one:
reclaim_resources1returns E_POINTER when pResults is null, but the IDXGIDevice2reclaim_resourceshere accepts a null output, and as far as I know DXGI allows NULL when the caller will refill the resources anyway. A title callingReclaimResources1(n, resources, NULL)gets 0x80004003 instead of S_OK, and a FAILED() check may skip or stop. The new test asserts E_POINTER, which locks this in.Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T02:44:32Z.
Review: COMMENTED
Review of
ef25f34c: 3 finding(s). 2 are inline. These are on lines outside the diff:crates/xcl/src/hle/d3d12x/real.rs:4069:dev_qi_xcallsdxgi_device::createon every QueryInterface, so each IDXGIDevice/1/2/3/4 query returns a separate DxgiDevice with its own priority and latency state. Answering two more versions makes this easier to hit.device->QI(IDXGIDevice1)->SetMaximumFrameLatency(1)followed bydevice->QI(IDXGIDevice4)->GetMaximumFrameLatencyreturns 3 (a fresh object's default), and SetGPUThreadPriority / GetGPUThreadPriority split the same way. Caching one DxgiDevice per console device would fix it.These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.
Imported from ivall/xcl. Originally posted by stijn-boer on 2026-12-02T18:18:21Z.
merge-check
base:
817eb1fc9fhead:
ef25f34c22verdict: not yet: the focused WARP COM checks passed and the workspace and smoke exits reproduced on main. The AMD runtime path for the new DXGI interfaces was unverified.
Windows / AMD RDNA4 (native D3D12) — DXGI device interface checks on
ef25f34Clean merge onto
mainat817eb1f(merge commitfc5fc9d2d99575fdb0c1b0638a3966bc8de5df1b).git diff --checkwas clean.Setup
d3d12SDKLayers.dll, DXC 1.9.2609.5Tested
cargo build --workspacepassed.cargo test --workspace --no-fail-fast -- --test-threads=4 --show-outputexited 101 on both builds. The baseline table row is from a prior run of the same commit, machine, SDK, and command.SKIPPEDnoticesmainCounts are partial because two test processes aborted on each build.
main— none observed in the comparable results.dxgi_device::tests::yielded 2 passed, 0 failed, 0 ignored, 0 skip notices with--test-threads=1 --show-output --nocapture. The WARP test exercised interface queries through IDXGIDevice4, Trim, empty and populated resource arrays, and invalid reclaim and query pointers.uploads_start_from_each_subresources_statepassed.Shared failures and process aborts
fuzz_validate_and_gpu_1,fuzz_validate_and_gpu_3, andtwo_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobsreported failures on both builds.gpu_compute_e2etest processes exited with0xc0000409on both builds.Retail smoke
Ran
scripts/smoke.ps1 -Game <local folder> -Seconds 60 -Xcl <debug binary>withXCL_UMA_DRIVER=mixedfor title hash2c508222.main0xc00004090xc00004090xc0000409The first run's higher startup commit did not reproduce. These exits leave retail use of the new interfaces unverified.
Diff review
The WARP test confirmed QueryInterface routing and the return codes it directly invokes. OfferResources1 with a nonzero count and a null resource-array pointer is handled in the implementation. The test only calls OfferResources1 through the safe slice wrapper.
Not tested
Remaining workspace tests after the aborts, retail performance, the runtime's AMD call path for the new DXGI interfaces, and the raw OfferResources1 null-array call.
AI use
Codex (GPT-6) merged and built the PR, ran the tests, compared the results with
main, reviewed the diff, and drafted this report.Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-02T19:39:29Z.
Closing: speculative
IDXGIDevice3/4shim with no title requesting it and review findings on per-QI shim allocation andOfferResources1.Pull request closed