diff options
| author | AimLogin <4jt8mn8wjn@privaterelay.appleid.com> | 2026-11-22 10:25:02 +0100 |
|---|---|---|
| committer | AimLogin <4jt8mn8wjn@privaterelay.appleid.com> | 2026-11-22 11:08:53 +0100 |
| commit | 62593f47ca3bfd9f68261292c19567da9f117daa (patch) | |
| tree | 06b688e80f510792b168ebe8317abb29922168b4 /runtime/test/device_proxy_test.cpp | |
| parent | c0ac5fd6518b3ba9fa66765b8b07099990dadd74 (diff) | |
Runtime: Xbox-ABI proxies for the command queue and the fence (BUILD-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>
Diffstat (limited to 'runtime/test/device_proxy_test.cpp')
| -rw-r--r-- | runtime/test/device_proxy_test.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/runtime/test/device_proxy_test.cpp b/runtime/test/device_proxy_test.cpp index 91c8a67d4..343556abd 100644 --- a/runtime/test/device_proxy_test.cpp +++ b/runtime/test/device_proxy_test.cpp | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | // hidden return pointer in RDX, so slot 14 wraps it) | 7 | // hidden return pointer in RDX, so slot 14 wraps it) |
| 8 | // slot 62 CreateComputePipelineState | 8 | // slot 62 CreateComputePipelineState |
| 9 | // slot 76 resource creation with an Xbox layout word (0x101) | 9 | // slot 76 resource creation with an Xbox layout word (0x101) |
| 10 | // slot 8/36 CreateCommandQueue/CreateFence (return queue and fence proxies that run GPU work) | ||
| 10 | // Slot 9 on the device is CreateCommandAllocator on the PC vtable and must still forward, which proves the handle | 11 | // Slot 9 on the device is CreateCommandAllocator on the PC vtable and must still forward, which proves the handle |
| 11 | // getters were not wedged into the device slots. Console output also shows the proxy's first-call slot log. | 12 | // getters were not wedged into the device slots. Console output also shows the proxy's first-call slot log. |
| 12 | #include <windows.h> | 13 | #include <windows.h> |
| @@ -365,6 +366,34 @@ int main() { | |||
| 365 | check(FAILED(hr) && proxy_out == nullptr, "slot 76 nulls its output for a null description"); | 366 | check(FAILED(hr) && proxy_out == nullptr, "slot 76 nulls its output for a null description"); |
| 366 | } | 367 | } |
| 367 | 368 | ||
| 369 | // Slots 8 and 36 on the device the shim made: a title gets queue and fence proxies, and they run GPU work. | ||
| 370 | { | ||
| 371 | using CreateQueueFn = HRESULT(WINAPI*)(void*, const D3D12_COMMAND_QUEUE_DESC*, const IID*, void**); | ||
| 372 | using CreateFenceFn = HRESULT(WINAPI*)(void*, UINT64, D3D12_FENCE_FLAGS, const IID*, void**); | ||
| 373 | void** vtable = *reinterpret_cast<void***>(device.Get()); | ||
| 374 | const D3D12_COMMAND_QUEUE_DESC queue_desc{}; | ||
| 375 | const IID iid_queue = __uuidof(ID3D12CommandQueue); | ||
| 376 | const IID iid_fence = __uuidof(ID3D12Fence); | ||
| 377 | ComPtr<ID3D12CommandQueue> queue; | ||
| 378 | ComPtr<ID3D12Fence> fence; | ||
| 379 | hr = reinterpret_cast<CreateQueueFn>(vtable[8])(device.Get(), &queue_desc, &iid_queue, | ||
| 380 | reinterpret_cast<void**>(queue.GetAddressOf())); | ||
| 381 | check(SUCCEEDED(hr) && rt::d3d12_xs::is_queue_proxy(queue.Get()), "slot 8 returns a queue proxy"); | ||
| 382 | hr = reinterpret_cast<CreateFenceFn>(vtable[36])(device.Get(), 0, D3D12_FENCE_FLAG_NONE, &iid_fence, | ||
| 383 | reinterpret_cast<void**>(fence.GetAddressOf())); | ||
| 384 | check(SUCCEEDED(hr) && rt::d3d12_xs::is_fence_proxy(fence.Get()), "slot 36 returns a fence proxy"); | ||
| 385 | if (queue && fence) { | ||
| 386 | HANDLE event = CreateEventW(nullptr, FALSE, FALSE, nullptr); | ||
| 387 | check(event && SUCCEEDED(queue->Signal(fence.Get(), 1)) && | ||
| 388 | SUCCEEDED(fence->SetEventOnCompletion(1, event)) && WaitForSingleObject(event, 5000) == 0, | ||
| 389 | "the queue proxy signals the fence proxy on the GPU"); | ||
| 390 | if (event) CloseHandle(event); | ||
| 391 | ComPtr<ID3D12Device> owner; | ||
| 392 | check(SUCCEEDED(queue->GetDevice(IID_PPV_ARGS(owner.GetAddressOf()))) && owner.Get() == device.Get(), | ||
| 393 | "the queue proxy's GetDevice is the device the shim returned"); | ||
| 394 | } | ||
| 395 | } | ||
| 396 | |||
| 368 | // Hold a reference to the PC device so the final check can prove the proxy's Release balances its own. | 397 | // Hold a reference to the PC device so the final check can prove the proxy's Release balances its own. |
| 369 | if (real) real->AddRef(); | 398 | if (real) real->AddRef(); |
| 370 | // Drop every device child before the proxy so the PC device is not released first. | 399 | // Drop every device child before the proxy so the PC device is not released first. |