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 /docs/d3d12_command_objects.md | |
| 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 'docs/d3d12_command_objects.md')
| -rw-r--r-- | docs/d3d12_command_objects.md | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/docs/d3d12_command_objects.md b/docs/d3d12_command_objects.md index 8dd9fcadb..0345af80e 100644 --- a/docs/d3d12_command_objects.md +++ b/docs/d3d12_command_objects.md | |||
| @@ -470,6 +470,46 @@ Xbox slots differ, a generic forward-to-PC thunk calls the wrong method. The cur | |||
| 470 | (`runtime/shims/d3d12_xs_device.h:1-18`) forwards every unshadowed slot in PC order and logs | 470 | (`runtime/shims/d3d12_xs_device.h:1-18`) forwards every unshadowed slot in PC order and logs |
| 471 | first calls; a wrong slot would therefore be visible as a misnamed call, not a silent success. | 471 | first calls; a wrong slot would therefore be visible as a misnamed call, not a silent success. |
| 472 | 472 | ||
| 473 | Queues and fences are wrapped the same way. | ||
| 474 | |||
| 475 | - **What is wrapped.** Device slots 8 (`CreateCommandQueue`), 75 (`CreateCommandQueue1`), 36 | ||
| 476 | (`CreateFence`) and 32 (`OpenSharedHandle`, when it opens a fence) return queue and fence proxies. Each | ||
| 477 | proxy forwards the public chain in PC order: 19 queue slots, and 11 or 12 fence slots, in SDK 10.0.26100. | ||
| 478 | - **Logging.** Each slot logs its first call. `--trace-d3d12` records every call except `AddRef`/`Release`, | ||
| 479 | as `XboxID3D12CommandQueue::Signal called` or `XboxID3D12Fence::Slot40 unsupported` (the README's trace | ||
| 480 | grammar); on the Vulkan device the layer's own record of the same call follows it. An interface the real | ||
| 481 | object implements but the proxy does not model is logged once and refused. | ||
| 482 | - **The refused tail.** A slot past the public chain, up to the end of the proxy's own table (128 queue and | ||
| 483 | 64 fence slots, every one a thunk), logs its first four argument words once and returns `E_NOTIMPL`. | ||
| 484 | - **The guard region.** Each table sits at the end of the first page of a 64 KiB reservation, and the rest | ||
| 485 | of that reservation is never committed. A slot past the table therefore faults on the vtable read itself, | ||
| 486 | inside the reservation, and a vectored handler logs the slot before the fault goes on. A vtable read that | ||
| 487 | lands beyond the reservation is not caught. | ||
| 488 | - **Unwrapping.** Wherever a device or queue method hands a heap, queue or fence object to the real | ||
| 489 | runtime, the proxy passes the real object instead: queue `Signal`/`Wait` (14/15), and device `CreateSharedHandle` (31), `MakeResident` | ||
| 490 | and `Evict` (34/35), `SetEventOnMultipleFenceCompletion` (45), `SetResidencyPriority` (46) and | ||
| 491 | `EnqueueMakeResident` (50). | ||
| 492 | - **QueryInterface.** It answers only the modelled interfaces, so no real object reaches the title. | ||
| 493 | - **What is not covered.** Command lists are not wrapped yet: `ExecuteCommandLists` passes the lists through, | ||
| 494 | and a heap proxy given to a list's `SetDescriptorHeaps` reaches the real list unchanged. The command-list | ||
| 495 | proxy of §3.5a adds the unwrap at both places. | ||
| 496 | |||
| 497 | Which of this is measured: the slot numbers and signatures are the SDK's (public). That the console | ||
| 498 | keeps the public queue and fence slots, and device slots 8/32/36/75, is an assumption the package cannot | ||
| 499 | test, as above. The proxies make a wrong assumption visible in the log; they do not prove it right. | ||
| 500 | `queue_proxy_test` checks all of this with no game files, on the host runtime (WARP and a hardware | ||
| 501 | adapter) and on the Vulkan device; `OpenSharedHandle` of a shared fence only on the host runtime, since the | ||
| 502 | Vulkan device does not share fences (the test prints "not checked" there). Each error case runs in its own | ||
| 503 | process and is compared with the real object's HRESULT. The test also includes a console-style client: it makes a heap through slot 14 (handle in | ||
| 504 | RAX) and buffers through slot 76 (layout word 0x1). It then copies through the queue proxy, finishes through | ||
| 505 | the fence proxy, reads the data back, and makes residency calls that carry the heap, queue and fence proxies. | ||
| 506 | `device_proxy_test` gets its queue and fence through the registered `D3D12XboxCreateDevice` shim. | ||
| 507 | |||
| 508 | The package-gated `bvh_builder_test` and `fsr_dispatch_test` stay at `SKIP (no package)` without | ||
| 509 | `LEONIDA_GAME_DIR`, and they would not cover these paths if they ran. Neither creates a queue or a fence: | ||
| 510 | the BVH builder's constructor calls device slots only, and `fsr_dispatch_test` records into a logging list it | ||
| 511 | never executes. Neither DLL calls the device slots the proxies change (§3.5, §3.5a). | ||
| 512 | |||
| 473 | The same caveat applies to **return conventions**: the public AMD64 COM convention (HRESULT in | 513 | The same caveat applies to **return conventions**: the public AMD64 COM convention (HRESULT in |
| 474 | EAX, `void` methods, out-parameters through pointers, `GetDesc` returning a 16-byte struct by | 514 | EAX, `void` methods, out-parameters through pointers, `GetDesc` returning a 16-byte struct by |
| 475 | value) is what the runtime implements. No Xbox-specific convention on a queue, list, fence or | 515 | value) is what the runtime implements. No Xbox-specific convention on a queue, list, fence or |
| @@ -532,7 +572,9 @@ than invent slots. | |||
| 532 | device slots 8/9/12/36, then queue slots 10/14/15, fence slots 8/9/10, and every slot beyond | 572 | device slots 8/9/12/36, then queue slots 10/14/15, fence slots 8/9/10, and every slot beyond |
| 533 | the public chain. The first `PresentX` call and the queue vtable tail are the only way to | 573 | the public chain. The first `PresentX` call and the queue vtable tail are the only way to |
| 534 | recover the present surface; a DXGI import would make the DXGI path the first | 574 | recover the present surface; a DXGI import would make the DXGI path the first |
| 535 | implementation instead ([d3d12_vulkan.md §8.2 Q6](d3d12_vulkan.md)). | 575 | implementation instead ([d3d12_vulkan.md §8.2 Q6](d3d12_vulkan.md)). The counters exist: device, |
| 576 | queue and fence proxies count every slot, and the queue and fence tails are logged with their | ||
| 577 | first argument words (§5.2). | ||
| 536 | 578 | ||
| 537 | Do not fill the unknown slots with guesses. A wrong slot is worse than a clean refusal; the | 579 | Do not fill the unknown slots with guesses. A wrong slot is worse than a clean refusal; the |
| 538 | existing device proxy already follows that rule (`runtime/shims/d3d12_xs_device.h:16-18`). | 580 | existing device proxy already follows that rule (`runtime/shims/d3d12_xs_device.h:16-18`). |