Repository navigation
d3d12_xs: the device proxy answers IDXGIDevice1 (GetAdapter), step 3 of the GDKX boot sequence - #3538
Conversation
…of the GDKX boot sequence A GDKX title asks its device for IDXGIDevice1, then GetAdapter and EnumOutputs(0), to find the output it gives SetFrameIntervalX. The proxy refused the QueryInterface, and a PC ID3D12Device has no IDXGIDevice to forward to. The proxy now answers IDXGIObject, IDXGIDevice and IDXGIDevice1 as one COM object with the device (a second vtable pointer in the proxy, same reference count and QueryInterface). GetAdapter and GetParent return the adapter of the device behind it: the host DXGI adapter with the device's LUID on the host backend, the layer's own rt::dxgi adapter on the Vulkan device (set_device_outer installs that provider). dxgi_device_test walks it on WARP, the first hardware adapter and the Vulkan device. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
kacper-serewis
left a comment
There was a problem hiding this comment.
At 1b3a0d8 direct creation with IID_IDXGIDevice1 returns a secondary interface pointer. runtime/shims/d3d12_xs.cpp:180 passes it to outer/provider setup but d3d12_xs_device.cpp:1431 recognizes only the primary vtable. On Windows WARP a synthetic provider returning E_ABORT was skipped and GetAdapter instead returned S_OK with a host adapter. Resolve the primary proxy before installing identity/provider and add a direct-DXGI-IID creation regression. The ordinary device-to-DXGI query path passed identity, reference-count and LUID checks. Vulkan path inspected in source. AI-assisted CPU/WARP validation.
…ntity and the layer's adapter create_device_proxy returns the proxy's DXGI pointer when the title asks for IDXGIDevice1. D3D12XboxCreateDevice passed that pointer to set_device_outer, so the Vulkan device's outer identity was the DXGI pointer, and set_device_adapter_provider, which knew only the primary vtable, set nothing: GetAdapter then loaded the host's dxgi.dll and returned a host adapter. set_device_outer resolves the proxy first (device_proxy_primary), and set_device_adapter_provider takes either pointer, returns whether it set the provider and says so on stderr when it did not. dxgi_device_test creates the device as IDXGIDevice1 on WARP, a hardware adapter and the Vulkan device. Found by @kacper-serewis in review. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
@kacper-serewis thank you, you are right, and it was a real hole: with Fixed in 974da13:
Full |
kacper-serewis
left a comment
There was a problem hiding this comment.
The provider blocker is resolved at 974da13. The same WARP reproducer now returns provider E_ABORT with a cleared output, and focused identity/reference-count checks passed. One regression-test fixture needs correction: runtime/test/dxgi_device_test.cpp:230 passes the address of a four-byte int to helpers reading a pointer-sized vtable field. On x64 that reads past the fixture. Use a pointer-sized null field, e.g. void* not_a_proxy = nullptr, passing its address. CPU/WARP-only re-review; no hardware or Vulkan run. AI-assisted.
The helpers read a vtable pointer (8 bytes) from the object they are given; the fixture was a 4-byte int, so they read past it. Found in review. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
@kacper-serewis right again, thank you: |
kacper-serewis
left a comment
There was a problem hiding this comment.
D3D-386 at 3d48c4a. The pointer-sized fixture resolves the last finding. Windows x64 WARP direct IDXGIDevice1 creation, canonical device identity via QI and child fence, provider E_ABORT and cleared adapter, and reset to the matching WARP LUID all passed. No hardware or Vulkan run in this recheck. AI-assisted.
|
Tested 3d48c4a on RTX 4070 Ti SUPER (driver 617.42, Windows 11, MSVC 14.42): pass. A second NVIDIA GPU and driver for the "other GPUs" the description leaves open; the reviews above were WARP-only.
Built with cl.exe at /W4 /permissive-, no warnings. Not run: the full ctest and AI-assisted. |
|
Wine and Proton check: Setup: CachyOS Linux, Ryzen 7 7700X iGPU (RDNA2, RADV, Mesa 26.3.1). Cross-built with clang-cl and xwin (RelWithDebInfo). I tested the merge with main that GitHub builds (
The PR adds no new failure under either Wine or Proton. No game files. AI-assisted (Claude-Opus). |
Claim: #3232 (comment) (carried over to #3381: #3381 (comment))
The problem
docs/d3d12_vulkan.md§4.5 lists the GDKX boot sequence from the public samples. Step 3 is "QI the device forIDXGIDevice1,GetAdapter,EnumOutputs(0)", and the output it finds is the first argument ofSetFrameIntervalX. The device a title gets fromD3D12XboxCreateDevicerefuses that QueryInterface: the proxy answers onlyIUnknown,ID3D12Objectand theID3D12Devicechain (runtime/shims/d3d12_xs_device.cpp,is_device_iid), and nothing inruntime/shimsimplementsIDXGIDevice::GetAdapter. A GDKX-style title stops there, before any frame event orPresentX.Forwarding is not an option: a PC
ID3D12Devicehas noIDXGIDevice(the new test checks that on the host runtime).The change
IDXGIObject,IDXGIDeviceandIDXGIDevice1as one COM object with the device: a second vtable pointer inside the proxy object, with the proxy's reference count and its QueryInterface, soIUnknownis the same pointer from both sides and QI leads back to the device proxy.IDXGIDevice2and later are refused (the samples ask forIDXGIDevice1).GetAdapterandGetParentreturn the adapter of the device behind the proxy.GetAdapterLuid(CreateDXGIFactory1+EnumAdapterByLuid, loaded from System32 on first use, so none of the 25 targets that compile this file gains a link dependency).rt::dxgiadapter, the onert::d3d12::create_dxgi_factoryenumerates.rt::d3d12::set_device_outerinstalls that provider, so every place that puts the proxy over the Vulkan device gets it and a title on that backend never receives a host DXGI object from this call.SetMaximumFrameLatency/GetMaximumFrameLatencyandSetGPUThreadPriority/GetGPUThreadPrioritykeep and return their value with the documented ranges; nothing acts on them.CreateSurfaceandQueryResourceResidencylog once and returnE_NOTIMPL. Private data goes to the device's own (ID3D12Objecthas the same three methods).IDXGIDevice1directly (a title may pass that IID toD3D12XboxCreateDevice): what comes back is the proxy's DXGI pointer.set_device_outerresolves the proxy from it before it sets the identity and the provider, andset_device_adapter_provideraccepts either pointer, returns whether it set anything and says so on stderr when it did not. (Second commit, 974da13: the first one left the Vulkan device with the host's adapter on this path. Found by @kacper-serewis.)docs/d3d12_vulkan.md§4.5 gets one bullet in the layer plan.Assumptions, stated in the code and the doc: the 14 slots are the public
dxgi.horder (not measured on the console, like the queue's and the fence's public slots), and the HRESULTs for null arguments and the refused methods are this layer's choice, not measured.Not in this PR:
EnumOutputson the layer's adapter (D3D-313, #2976; until it lands the Vulkan backend answersDXGI_ERROR_NOT_FOUNDthere, as onmain), the swapchain (D3D-2, #3259), D3D-296, and the frame events themselves.Tests
Windows 11, MSVC 14.44 (VS 2022), the CMake and Ninja that Visual Studio ships (3.31.6), SDK 10.0.26100, RelWithDebInfo, NVIDIA RTX 4090 (driver 621.14). No game files.
dxgi_device_test(ctestdxgi_device), host WARP: QI for the three interfaces gives one pointer;IUnknownidentity with the device; QI back toID3D12Deviceis the proxy; reference counts;IDXGIDevice2refused;GetAdapterandGetParentgive an adapter whose LUID is the device's;EnumOutputs(0)isS_OKwith an output orDXGI_ERROR_NOT_FOUND; frame latency, thread priority, null arguments, private data shared with the device; the device's count is back where it startedEnumOutputs(0)gives an output)IDXGIAdapter4, its factory has exactly one adapter) and the layer's device is released by its last referenceEnumOutputs(0)isDXGI_ERROR_NOT_FOUNDuntil #2976)IDXGIDevice1directly, on the three backends: the returned pointer is not the proxy; QI back toID3D12Devicegives the proxy; the count is 1 before and after; a fence'sGetDevicegives the proxy; the adapter has the device's LUID, and on the Vulkan device it is the layer's own (noIDXGIAdapter4, one adapter in its factory); a provider set through the DXGI pointer is the oneGetAdapterasks (E_ABORTcomes back, the output stays null); a non-proxy is refuseddxgi_device_testfails at the first QueryInterfaceset_device_outerwithout resolving the proxy (the defect of the first commit)dxgi_device_testfails on the Vulkan device at the "layer's own adapter" checkctest(142 tests) at 974da13winhttp_offline, the known flake onmain(TEST-721); it passed 3 of 3 when rerun alone and this change does not touch it. 8 skip (package- or feature-gated);gameinputis disabled (no SDL3)python -I tests/test_docs_links.py,test_docs_list_items.py,test_docs_repo_paths.py,test_docs_design_rows.pyNot tested: Wine (the host half is skipped there, as in
allocator_proxy_test), other GPUs, and a title's own call sequence (there is no executable).AI-assisted (Claude Code).
🤖 Generated with Claude Code