upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/docs/d3d12_command_objects.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/d3d12_command_objects.md')
-rw-r--r--docs/d3d12_command_objects.md55
1 files changed, 53 insertions, 2 deletions
diff --git a/docs/d3d12_command_objects.md b/docs/d3d12_command_objects.md
index 1aef12206..eea693c70 100644
--- a/docs/d3d12_command_objects.md
+++ b/docs/d3d12_command_objects.md
@@ -136,8 +136,41 @@ following each `0x40`/`0x48`/`0x60`/`0x120` call back to its receiver.
136 136
137So the four slots' callers are in the game executable, which the package does not contain (the 137So the four slots' callers are in the game executable, which the package does not contain (the
138same blocker as RT-5). Confidence for slots 8, 9, 12 and 36 stays **Open**: the table in §2.1 is 138same blocker as RT-5). Confidence for slots 8, 9, 12 and 36 stays **Open**: the table in §2.1 is
139still the SDK baseline. Once the executable is available, `tools/d3d12_iid_scan.py` run on it 139still the SDK baseline.
140shows whether it carries these IIDs, and its call sites through them give the slots. 140
141**Measured on the retail executable** (`python -I tools/d3d12_iid_scan.py`, 80 SDK IIDs read from
142the Windows SDK 10.0.26100 `d3d12.h`): the image carries 13 of them, and it carries the whole
143queue/allocator/list/fence set except the two base/second-generation names:
144
145| IID | In the executable |
146|---|---|
147| `ID3D12CommandQueue` | present |
148| `ID3D12CommandAllocator` | present |
149| `ID3D12GraphicsCommandList` | present (one slot-73 site; startup lists use the console IID below) |
150| `ID3D12Fence` | present |
151| `ID3D12CommandList` (base) | absent |
152| `ID3D12Fence1` | absent |
153
154The other carried IIDs are `ID3D12CommandSignature`, `ID3D12DescriptorHeap`, `ID3D12Device11`,
155`ID3D12PipelineState`, `ID3D12QueryHeap`, `ID3D12Resource`, `ID3D12RootSignature`,
156`ID3D12StateObject` and `ID3D12StateObjectProperties`; the image imports only
157`D3D12ConfigureVirtualMemoryX`, `D3D12SerializeVersionedRootSignature` and
158`D3D12XboxCreateDevice` from `d3d12_xs.dll`. `ID3D12Device11`
159(`{5405C344-D457-444E-B4DD-2366E45AEE39}`, `d3d12.h:24502,35748`, `.rdata` `0x1461E0638`) is the
160`riid` the executable passes to `D3D12XboxCreateDevice` (`0x14247856C` → `0x1424785B7`), which is
161why both `d3d12_iid_scan.py` and `is_device_iid` in `runtime/shims/d3d12_xs_device.cpp` recognise
162it during [retail_boot_chain.md](retail_boot_chain.md).
163
164A carried IID is necessary but not sufficient: it says the binary can ask for the interface, not
165where it does. The slots stay **Open** until a call site is followed.
166
167One console command-list IID is outside `d3d12.h`, so the scan cannot see it, and a proxy has to
168answer it rather than forward it to the PC device: `{C3827890-4024-474C-98CF-645B51DC4874}`
169(`.rdata` `0x1461E0668`), passed to Xbox device slot 73 (`CreateCommandListX`) in renderer startup
170at `0x142478B56` → `0x142478B71` ([retail_boot_chain.md](retail_boot_chain.md) §3.3,
171[#523](https://github.com/ubiquitarianism/leonida/issues/523)); the carried
172`IID_ID3D12GraphicsCommandList` (`0x1461ECFA0`) is passed to slot 73 at a separate site
173(`0x1417F6D1D` → `0x1417F6D34`).
141 174
142### 2.2 Queue, allocator and fence 175### 2.2 Queue, allocator and fence
143 176
@@ -565,6 +598,10 @@ shape and the shift around them, but the shape alone does not single the method
565| 55 (`+0x1b8`) | **51** | `DiscardResource` | `(resource, null)` at `0x6dcb`, after the pending barriers are flushed through slot 26 | 598| 55 (`+0x1b8`) | **51** | `DiscardResource` | `(resource, null)` at `0x6dcb`, after the pending barriers are flushed through slot 26 |
566| 59 (`+0x1d8`) | — | console only (shape) | four calls, two shapes: `(1, blob, size)` at `0x6b5a` and `0x6d53`, the blob a run of qwords whose first is `0xf3080 \| (qword count & 0x7f)`; and `(0, &qword, 8)` with the qword 1 at `0x6e52` and `0x6eb8`, only when a profiling bit of the context is set (`0x6e2a`). The first argument is set as a byte (`mov dl, 1` / `xor edx, edx`). It looks like one slot for both ends of a GPU event; no public method takes a bool first. With 55 at +4 and 61 at +2, the two slots the console lacks are among 56–60 | 599| 59 (`+0x1d8`) | — | console only (shape) | four calls, two shapes: `(1, blob, size)` at `0x6b5a` and `0x6d53`, the blob a run of qwords whose first is `0xf3080 \| (qword count & 0x7f)`; and `(0, &qword, 8)` with the qword 1 at `0x6e52` and `0x6eb8`, only when a profiling bit of the context is set (`0x6e2a`). The first argument is set as a byte (`mov dl, 1` / `xor edx, edx`). It looks like one slot for both ends of a GPU event; no public method takes a bool first. With 55 at +4 and 61 at +2, the two slots the console lacks are among 56–60 |
567| 61 (`+0x1e8`) | **59** | `ExecuteIndirect` | `(signature, 1, argument buffer, offset, null, 0)` at `0x59a0` | 600| 61 (`+0x1e8`) | **59** | `ExecuteIndirect` | `(signature, 1, argument buffer, offset, null, 0)` at `0x59a0` |
601| 71 (`+0x238`) | — | console only | `Write32BitValueBottomOfPipeX(address, u32 value, flush, flags)`: the 32-bit value, written into the title's memory once the list's work has run (the list values, [d3d12_xs_console_abi.md §5.5](d3d12_xs_console_abi.md)) |
602| 72 (`+0x240`) | — | console only | `Write64BitValueBottomOfPipeX(address, u64 value, flush, flags)`: the 64-bit value; flags 1 ask for a GPU timestamp and 2 for a system timestamp instead of the value the call carried |
603| 73 (`+0x248`) | — | console only | `Wait32BitValueX`: a wait on the 32-bit value; the list values hold the queue until it compares true or times out (§5.5 there) |
604| 74 (`+0x250`) | — | console only | `Wait64BitValueX`: the same on the 64-bit value |
568| 85 (`+0x2a8`) | — | `CopyTextureRegion` shape (inferred) | run: `(stack pointer, 0, 0)`, twice per dispatch. Statically six arguments, `(&dst, 0, 0, 0, &src, null)`: the public `CopyTextureRegion` (PC 16) with two `D3D12_TEXTURE_COPY_LOCATION`s, not one pointer. At `0x7147` dst is `{texture, SUBRESOURCE_INDEX, 0}` and src `{buffer, PLACED_FOOTPRINT, footprint}`, the footprint from device slot 38 (`GetCopyableFootprints`, `0x708b`); at `0x7191` both are subresource 0 (texture to texture). The caller also clears the next stack argument (`0x70e7`); whether the method takes a seventh is open, as is what console slot 16 is | 605| 85 (`+0x2a8`) | — | `CopyTextureRegion` shape (inferred) | run: `(stack pointer, 0, 0)`, twice per dispatch. Statically six arguments, `(&dst, 0, 0, 0, &src, null)`: the public `CopyTextureRegion` (PC 16) with two `D3D12_TEXTURE_COPY_LOCATION`s, not one pointer. At `0x7147` dst is `{texture, SUBRESOURCE_INDEX, 0}` and src `{buffer, PLACED_FOOTPRINT, footprint}`, the footprint from device slot 38 (`GetCopyableFootprints`, `0x708b`); at `0x7191` both are subresource 0 (texture to texture). The caller also clears the next stack argument (`0x70e7`); whether the method takes a seventh is open, as is what console slot 16 is |
569| 141 (`+0x468`) | — | console only | `(2, GPU VA, size, n)` at `0x65f8`: binds a buffer the DLL names `FFX_XBox_ComputeScratch`; `n` is the bound pipeline's scratch value from pipeline slot 11 (see above) | 606| 141 (`+0x468`) | — | console only | `(2, GPU VA, size, n)` at `0x65f8`: binds a buffer the DLL names `FFX_XBox_ComputeScratch`; `n` is the bound pipeline's scratch value from pipeline slot 11 (see above) |
570 607
@@ -573,6 +610,20 @@ So the console list has four more methods than the PC list between `ResourceBarr
573Mapping the console list as "PC plus a constant" is wrong. The BVH builder adds 37, 39, 43 and 45 (the rest of the 610Mapping the console list as "PC plus a constant" is wrong. The BVH builder adds 37, 39, 43 and 45 (the rest of the
574+4 root group) and the console-only 71, 73, 80, 146 (`Barrier`) and 148 (sections 3.3 and 3.3a). 611+4 root group) and the console-only 71, 73, 80, 146 (`Barrier`) and 148 (sections 3.3 and 3.3a).
575 612
613**The two value-write slots.** Slots 71 and 72 are the console's value writes and 73 and 74 the waits that go with
614them. The slot numbers are measured, not read: the retail title's own trace calls slot 71 with a title address and
615a value, slot 72 with a title address and the flags word and slot 74 with a wait's arguments, and the value writes
616are at 71/72 rather than at 69/70; and `XboxBvhBuilder.dll` reads a 32-bit value write at `+0x238` (slot 71) and a masked wait at `+0x248`
617(slot 73). The call shapes are xcl's (crates/xcl/src/hle/d3d12x/list_x.rs, GPL-2.0) and the deferred
618bottom-of-pipe write model is VIctory's (crates/victory-gpu/src/list.rs, GPL-3.0): the write is not a GPU command,
619it is a CPU write into the title's memory, made after the submission that recorded it has run. Both projects are
620cited for facts and for the model only, no code copied. The runtime has two writers for them, one per list: the list
621values (`runtime/shims/d3d12_xs_list_values.h`, on by default) for the lists they track, with the waits of slots 73
622and 74; and the GPU-label path (`runtime/src/vulkan_gpu_labels.h`, `LEONIDA_GPU_LABELS=1`) for the others. Both
623land a write whose address is a GPU address arena offset in the arena, never at that number in host memory, and one
624on a page of xmem's that the title's view keeps `PAGE_NOACCESS` through xmem's own mapping of the physical page
625(`runtime/src/value_write_sink.h`).
626
576**The list object is wider than its vtable, and this is what that width is for.** Before a root-argument or dispatch 627**The list object is wider than its vtable, and this is what that width is for.** Before a root-argument or dispatch
577call the DLL checks a write cursor at `+0x18` against a limit (`+0x30` for root arguments, `+0x28` for a dispatch). While there is room, 628call the DLL checks a write cursor at `+0x18` against a limit (`+0x30` for root arguments, `+0x28` for a dispatch). While there is room,
578it writes the command into that buffer itself instead of calling: a root argument is a header word from the 629it writes the command into that buffer itself instead of calling: a root argument is a header word from the