Repository navigation
Runtime: Xbox-ABI proxies for the command queue and the fence (BUILD-231) - #1270
Conversation
|
I checked the public queue/fence chain against a pixel oracle on
Windows 11 build 26200, NVIDIA 616.92, AMD 26.10.1. These were standalone test processes using the public queue and fence methods. Guest-loader execution, the D3D-136 command-list proxy, and #908 presentation are outside this measurement. |
|
@Vonsek, thanks. This covers ground my own runs didn't. Two questions so others can reproduce it:
For the record: #1270 is still on AI-assisted reply (Claude Code). |
…231) Device slots 8 (CreateCommandQueue), 75 (CreateCommandQueue1), 36 (CreateFence) and 32 (OpenSharedHandle of a fence) now return queue and fence proxies. They forward the public chain in PC order (19 queue slots, 11 or 12 fence slots), refuse and log a slot past it up to the end of the proxy's table, and name a read past the table through a guard region and a vectored handler. Heap, queue and fence proxies are unwrapped wherever a device or queue method hands them to the real runtime: queue Signal/Wait, device slots 31/34/35/45/46/50. Arrays are copied without exceptions. QueryInterface answers only the modelled interfaces, and logs one the real object has but the proxy does not model. Outputs are cleared on failure as for slots 14/62/76. --trace-d3d12 records proxy calls in the README grammar. Every function a thunk hands its words to keeps them in the same positions, because a title passes only as many as the method takes. Tests: queue_proxy_test (host WARP, host hardware, Vulkan device; differential per-process error cases, guard faults, identity, threads, raw-slot client, child-runner self-test), xs_proxy_mock_test (older devices, fences without Fence1, OpenSharedHandle branches, allocation failures; three guard-setup fault modes), and device_proxy_test through the D3D12XboxCreateDevice shim. No game files. AI-assisted (Claude Code). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ist proxy Queue slot 10 ExecuteCommandLists hands the real queue the PC list behind each list proxy (UnwrappedArray: 16 inline, E_OUTOFMEMORY when a longer copy cannot be allocated), and proxy_real_object knows the list vtable. device_proxy_test and d3d12_vulkan_device_test execute the list proxy itself on the queue proxy.
74764c5 to
62593f4
Compare
Item: BUILD-231, claimed in #634 and tracked in the coordination issue.
Follow-up that builds on this: D3D-136, @quackottu's console-order command-list proxy. It adds the
ExecuteCommandListsunwrap in its own PR, as agreed in #1218.Related: #908 (PresentX). Its queue methods sit past the public chain, which is exactly the tail this proxy refuses and logs. This PR does not depend on #908, and #908 does not depend on this PR.
What
Until now,
D3D12XboxCreateDevicewrapped only the device and the slot-14 descriptor heaps. Queues and fences reached the title as bare PC or Vulkan-layer objects with the SDK vtable, so a console-only queue method past the PC chain jumped through whatever memory followed that vtable.What is wrapped. Device slots 8
CreateCommandQueue, 75CreateCommandQueue1(only withID3D12Device9), 36CreateFenceand 32OpenSharedHandle(when it opens a fence) return queue and fence proxies.Forwarding. The public chain is forwarded in PC order: 19 queue slots, and 11 or 12 fence slots depending on whether the real fence has
ID3D12Fence1(SDK 10.0.26100).The refused tail. A slot past the public chain, up to the end of the proxy's table (128 queue slots, 64 fence slots), logs its first four argument words once and returns
E_NOTIMPL. That is wherePresentX/SuspendX/ResumeXwill show up. Their slots are not guessed.Guard region. Each table sits at the end of the first page of a 64 KiB reservation whose remaining pages are never committed. A slot past the table therefore faults on the vtable read itself, and a vectored handler names the slot before the fault continues. If the reservation,
VirtualProtector the handler fails, that is logged, andcommand_object_tables_guarded()reports false wherever a fault past the table would no longer be named.Unwrapping. Wherever a device or queue method hands a heap, queue or fence object to the real runtime, the real object is passed:
Signal/Wait(14/15);CreateSharedHandle(31),MakeResident/Evict(34/35),SetEventOnMultipleFenceCompletion(45),SetResidencyPriority(46) andEnqueueMakeResident(50).Arrays are copied without exceptions: up to 16 entries inline, longer ones with
new (std::nothrow). An allocation failure returnsE_OUTOFMEMORY.Leonida's own code.
d3d12_com.cpplooks through the queue proxy wherever it needs the real queue (queue_uses_calibrated_timestamps,last_execute_result).COM identity. QueryInterface answers only the modelled interfaces. An interface the real object implements but the proxy does not model is logged once with its GUID and refused.
GetDevicereturns the device proxy. Each proxy holds its real object and the device proxy.Output pointers. A non-null output is cleared before any failure, following bc59ef4's convention for slots 14/62/76. With a null output, the device's own answer is returned (
S_FALSEfor a capability check).Logging and trace. First calls are logged per slot.
--trace-d3d12records proxy calls in the README grammar (XboxID3D12CommandQueue::Signal called,XboxID3D12Fence::Slot40 unsupported). Device slots 31/34/35/45/46/50/75 log "beyond the PC device vtable" once when the real device predates the interface, as the generic thunk does.Not covered. Command lists are still passed through
ExecuteCommandListsas they are, and a heap proxy given to a list'sSetDescriptorHeapsreaches the real list unchanged. D3D-136 closes both gaps.Why it is built this way
realat offset 8, per-slot counters, and QueryInterface restricted to modelled interfaces. A reviewer who knowsHeapProxyknows these too.docs/d3d12_command_objects.md§5.2), and the proxy makes a wrong assumption visible.d3d12_xs_device.cpp. The mock test hit exactly this in its own thunks in an optimized build, which is how the rule was found and written down.Tests
No game files and no Xbox DLLs anywhere.
queue_proxy_test(new) runs on host WARP, host D3D12 on the hardware adapter, and the Vulkan device. It covers:OpenSharedHandle;The child-process runner of the differential check drains the pipe while the child runs, so output of any size can't stall it. It keeps only the output tail, stops hung children at the time limit and reports crashes and failed starts. Its own self-test covers a normal exit, 8 MiB of output, hung children (silent, and after 256 KiB), a crash, a missing executable, and injected pipe and thread failures, all without leaking a handle.
xs_proxy_mock_test(new) runs over synthetic COM objects, with no D3D12 runtime and no GPU. It covers:ID3D12Device,Device1,Device3andDevice9;ID3D12Fence1;S_OKwith no object;OpenSharedHandlebranch, with refcounts;operator new.Three more CTest entries (
--fail-virtualalloc,--fail-virtualprotect,--fail-veh) patch the test's own import table so the guard-region setup fails.device_proxy_testgets a queue and a fence through the registeredD3D12XboxCreateDeviceshim and runs a GPU signal through them.Results, on
origin/main0d61c35, with this branch against the same commit without it:main0d61c35LEONIDA_VK_VALIDATION=1, implicit layers offd3d12_clear_test(#917)queue_proxy_test,device_proxy_test, mock test, 3 fault modes)/W4 /WX /analyze(d3d12_xs_device.cpp, both new tests)--trace-d3d12lines checked against the README grammardevice_proxy_test10/10,queue_proxy_test5/5The five new CTest entries are
queue_proxy,xs_proxy_mock, and the three mock fault modes.gameinputstays disabled without SDL3, as onmain.Coverage of
runtime/shims/d3d12_xs_device.cpp(whole file; clang-cl 23 source-based, all three test executables): 96.7 % of lines, 100 % of functions (98), 72.5 % of branches. In the new code, only two paths are not covered:XS_TRACE;VirtualFreeafter a failed commit inside a successful reservation.The rest of the uncovered lines are earlier device/heap proxy code (slot 62's extra words, slot 67, slot names).
Not tested:
E_NOTIMPL, soOpenSharedHandleis checked on the host runtime only. The test prints "not checked" on Vulkan.Hardware
Windows 11 (10.0.26200), NVIDIA GeForce RTX 4060 Ti 16 GB, driver 621.01, Vulkan SDK 1.4.363.1, MSVC 19.50 (VS 18 Build Tools), LLVM 23.1.6 (coverage and clangd only).
Generated with [Claude Code]