diff --git a/docs/d3d12_command_objects.md b/docs/d3d12_command_objects.md index 8dd9fcadb9..3a8c1435a3 100644 --- a/docs/d3d12_command_objects.md +++ b/docs/d3d12_command_objects.md @@ -254,21 +254,28 @@ batched paths. Disassembling the exported bodies and the functions they call directly gives these calls through the object received in the command-list parameter: -| RVA | Vtable offset | Public slot if PC order | Observed arguments | Confidence | -|---:|---:|---:|---|---| -| `0x2171e` | `+0xd0` | 26 `ResourceBarrier` | `NumBarriers=1`, `&{Type=2 (UAV), Flags=0, pResource=null}` | **Measured**: the shape is a global UAV barrier; slot 26 is the SDK `ResourceBarrier` | -| `0x1d9cb` | `+0x70` | 14 `Dispatch` | `(1, 1, 1)` | **Measured**: exact `Dispatch` shape | -| `0x1d85e` | `+0xc8` | 25 `SetPipelineState` | `RCX=list`; RDX is not re-set at the call site | Inferred: offset and object match; the pipeline argument is not proven | -| `0x1d7f4` | `+0x108` | 33 `SetComputeRoot32BitConstant` | root index, value and offset registers | Inferred | -| `0x1d8b9`, `0x1d956` | `+0x138` | 39 `SetComputeRootShaderResourceView` | `(root=3, value, …)` | Inferred | -| `0x1d8f9` | `+0x168` | 45 `SOSetTargets` | `NumBuffers=0` (a no-op), resource in R8 | Inferred; `NumBuffers=0` means the view pointer is not read | -| `0x1da02` | `+0x490` | **none** | `(1, &{0, 1, pointer, …})` | **Measured offset**; method identity **Open** | +The console list is not in PC order past slot 26 (section 3.5a), so the method column reads each call in the +console order, from the arguments at the call and from the inline write it falls back from (section 3.5a, last +paragraph). Every call below except the two barriers is the fallback branch of an inline write of the same values. + +| RVA | Vtable offset | Console slot → PC method | Observed arguments | Confidence | +|---:|---:|---|---|---| +| `0x2171e` | `+0xd0` | 26 → 26 `ResourceBarrier` | `NumBarriers=1`, `&{Type=2 (UAV), Flags=0, pResource=null}` | **Measured**: the shape is a global UAV barrier; slot 26 is the SDK `ResourceBarrier` | +| `0x1d9cb` | `+0x70` | 14 → 14 `Dispatch` | `(1, 1, 1)` | **Measured**: exact `Dispatch` shape | +| `0x1d85e` | `+0xc8` | 25 → 25 `SetPipelineState` | `RCX=list`, `RDX=[rdi+8]`: loaded at `0x1d7fa` and not changed before the call; the inline branch (`0x1d822`–`0x1d850`) copies 28 bytes from that object's `+0x10` | **Measured**: RDX is the pipeline the inline branch reads | +| `0x1d7f4` | `+0x108` | 33 → 29 `SetComputeRootSignature` | one argument, `RDX=[rcx]`: the pointer stored next to the pipeline (`[rdi]`; the pipeline is `[rdi+8]`) | **Measured** shape; agrees with slot 33 in section 3.5a | +| `0x1d8b9` | `+0x138` | 39 → 35 `SetComputeRoot32BitConstants` | `(3, 1, &value, offset)`: `EDX=3`, `R8D=EDX-2=1`, `R9=rsp+0x30`, fifth argument `EDI` | **Measured**: four arguments with a count and a source pointer; a root SRV takes two | +| `0x1d956` | `+0x138` | 39 → 35 `SetComputeRoot32BitConstants` | `(3, count, source, offset)`: `R8D=EDI` (the count of the inline copy loop above it), `R9=RSI` | **Measured** | +| `0x1d8f9` | `+0x168` | 45 → 41 `SetComputeRootUnorderedAccessView` | `(0, VA)`: `EDX=0`, `R8=RBP`; the inline branch writes a header word and the same 64-bit `RBP` (12 bytes) | **Measured**: a root index and a 64-bit address | +| `0x1da02` | `+0x490` | 146 → GCL7 80 `Barrier` | `(1, &group)`, group `{Type=0, NumBarriers=1, pGlobalBarriers}`; the barrier is the 16 bytes at RVA `0xcdf60`: `{0x80, 0x80, 0x10, 0x10}` | **Measured**: the public `Barrier(UINT32, const D3D12_BARRIER_GROUP*)` shape with public enum values | The `+0x490` call is after the `Dispatch(1,1,1)` at `0x1d9cb`, in the per-descriptor path. It is -**beyond the last public GCL8 slot**: slot 81 is `0x288`, so `0x490` is 65 slots past the end of -the public chain. It is either an appended console command-list method or a method of an internal -class that the helper receives through the command-list parameter; the evidence below favours the -second reading. Its arguments are not a public D3D12 method shape. +**beyond the last public GCL8 slot** (slot 81 is `0x288`), but its arguments are the public enhanced-barrier +call: one `D3D12_BARRIER_GROUP` of type `D3D12_BARRIER_TYPE_GLOBAL` (0) holding one `D3D12_GLOBAL_BARRIER` with +`SyncBefore = SyncAfter = D3D12_BARRIER_SYNC_COMPUTE_SHADING` (`0x80`) and +`AccessBefore = AccessAfter = D3D12_BARRIER_ACCESS_UNORDERED_ACCESS` (`0x10`), values as in SDK 10.0.26100 +`d3d12.h`. On the PC that method is GCL7 slot 80; on the console list it is slot 146. A second call site with the +same constant is `0xd7b4` (section 3.3a). The same two inner functions (`0x1d540` and `0x1d7c0`) contain the `+0x70`, `+0xc8`, `+0x108`, `+0x138`, `+0x168` and `+0x490` calls; the outer batched function contains the `+0xd0` barrier. @@ -277,12 +284,45 @@ The exported `CopyRaytracingAccelerationStructure` (ordinal 5) and the rehydrate internal functions using objects cached in the builder (`[this+0x10]` and `[this+8]`). Their signatures still require GCL4/GCL8 objects, but those bodies do not measure command-list slots. +### 3.3a Other builder call sites past the PC order + +The rest of `.text` has further calls through the list pointer. Each name below rests on the call shape; "inline" +means the call is the fallback of an inline write of the same values. + +| RVA | Vtable offset | Console slot → PC method | Observed arguments | Confidence | +|---:|---:|---|---|---| +| `0x1a1e9` | `+0x128` | 37 → 33 `SetComputeRoot32BitConstant` | `(2, value, 0)`: `EDX=R9D+2`, `R9D=0` (inline: header + one dword) | **Measured** shape | +| `0x14e81` | `+0x138` | 39 → 35 `SetComputeRoot32BitConstants` | `(0, 19, rsp+0xc0, 0)` (inline: header + 19 dwords) | **Measured** shape | +| `0x14e11` | `+0x158` | 43 → 39 `SetComputeRootShaderResourceView` | `(3, VA)`: `EDX=3`, `R8=R13` (inline: header + the 64-bit `R13`) | **Measured** shape | +| `0x1a3b0` | `+0x168` | 45 → 41 `SetComputeRootUnorderedAccessView` | `(0, VA)` (inline: header + a 64-bit value) | **Measured** shape | +| `0x20ed6` | `+0x4a0` | 148 → none | `(list, count * 40, 16)` returns a pointer; on null the DLL prints `D3D12 XDXR Error: Failed to allocate upload buffer` and throws `E_FAIL` | **Measured**: an upload allocator `(size, alignment)` | +| `0x20f99` | `+0x158` | 43 → 39 `SetComputeRootShaderResourceView` | `(0, p)`, `p` the pointer slot 148 returned at `0x20ed6`, unchanged | **Measured**: the CPU pointer is used as the GPU address | +| `0x149ba` | `+0x280` | 80 → none | `(x, 1, 1, 0x8020)`: `EDX=EDI`, `R8D=R9D=1`, fifth argument `0x8020` (inline: a five-dword packet) | Inferred: a `Dispatch` with one extra word | +| `0xd6de` | `+0x238` | 71 → none | `(&label, counter, 0 or 0x1000, 0)`: the counter at `[rbx+0x9c]` is incremented first; `0x1000` on the last item of a batch | Inferred: a GPU write of a 32-bit value to memory | +| `0xd679` | `+0x248` | 73 → none | `(&label, 3, reference, 0xffffffff, 0)` | Inferred: a GPU wait until the masked value compares (function 3) with the reference | +| `0xd7b4` | `+0x490` | 146 → GCL7 80 `Barrier` | the same global UAV barrier as `0x1da02` | **Measured** | + +So the compute root-binding group keeps its PC order four slots later (33, 37, 39, 43 and 45 here; 35 and 41 in +section 3.5a), and the console list has methods well past the PC tail: 71, 73, 80, 146 and 148 here, 141 in the +FSR DLL. + +Slot 148 matters beyond the builder: the address it returns is written by the CPU and passed unchanged to the GPU +as a root SRV address, so console upload memory has the same address for the CPU and the GPU. A replacement must +return memory whose CPU pointer is also a valid GPU address (for this layer: inside the arena of +[d3d12_vulkan.md §3.3](d3d12_vulkan.md)). + +The function at `0xd580` uses the 71/73 pair instead of the slot-146 barrier when the byte at RVA `0xd773c` is set. +That byte is one of seven bools at `0xd7738`–`0xd773e` in zero-initialised `.bss`. The only accesses to them in +`.text` are about 50 RIP-relative reads (`cmp`, `movzx`); there is no write and no export that points there. So in +the shipping DLL the label path is unreachable unless something writes that byte through a computed pointer, and +the barrier path is the one that runs. + ### 3.4 The object is wider than the public vtable The inner function at `0x1d7c0` receives the command-list pointer in RDX, copies it to RBX (`0x1d7da`–`0x1d7dd`), and then does more than call public methods: -- writes 16 bytes at `[rbx+0x544]` (`0x1d803`); +- writes 32 bytes at `[rbx+0x544]` (`0x1d803`, `0x1d810`: the pipeline object's `+0x10`..`+0x2f`); - writes a byte at `[rbx+0x140]` (`0x1d841`, `0x1d884`); - reads `[rbx+0x350]` (`0x1d877`) and `[rbx+0x344]` (`0x1d8c9`); - maintains a pointer at `[rbx+0x18]` against limits at `[rbx+0x30]` (`0x1d818`, `0x1d871`); @@ -291,14 +331,14 @@ The inner function at `0x1d7c0` receives the command-list pointer in RDX, copies A client that knows only the public COM interface cannot legally read or write those fields. The helper is therefore compiled against a **wider contract** than the public vtable: either the Xbox command-list object is an internal class whose layout first-party code may use, or the game -passes a builder-specific object that also implements the interface. The byte offsets are facts; -the field meanings and the method at `+0x490` are **Open**. +passes a builder-specific object that also implements the interface. Section 3.5a explains most of the fields +(the inline command buffer), and section 3.3 identifies `+0x490` as `Barrier` at console slot 146. This is the most important compatibility finding on this page. A replacement command list that implements only the public GCL7/GCL8 vtable is **not** safe to hand to `XboxBvhBuilder`'s build path. (Section 3.5a shows it is not safe for console-compiled callers' public calls either: the console list order differs from the PC order past slot 26.) The helper will touch fields the public -object does not define and call `+0x490`, which a public-only vtable does not have. +object does not define and call `+0x490` (console slot 146, `Barrier`), which a public-only vtable does not have. ### 3.5a The FSR DLL as a second device client @@ -339,7 +379,7 @@ shape and the shift around them, but the shape alone does not single the method | 25 (`+0xc8`) | 25 | `SetPipelineState` | `(pipeline)` at `0x59a0` | | 26 (`+0xd0`) | 26 | `ResourceBarrier` | run: `(1, barriers)`; the BVH builder's `+0xd0` | | 32 (`+0x100`) | **28** | `SetDescriptorHeaps` | run: `(1, &heap)`, the heap a device-proxy descriptor heap | -| 33 (`+0x108`) | **29** | `SetComputeRootSignature` (inferred) | one pointer argument, the first call at `0x59a0` (null in the run, where pipeline creation had failed) | +| 33 (`+0x108`) | **29** | `SetComputeRootSignature` | one pointer argument, the first call at `0x59a0` (null in the run, where pipeline creation had failed); in the BVH builder the pointer stored next to the pipeline (section 3.3) | | 35 (`+0x118`) | **31** | `SetComputeRootDescriptorTable` | `(index, heap GPU start + offset)` at `0x59a0` | | 41 (`+0x148`) | **37** | `SetComputeRootConstantBufferView` (inferred) | `(index, 64-bit GPU VA from the constant allocator)` at `0x6738`; the root SRV/UAV setters take the same shape | | 53 (`+0x1a8`) | **49** | `ClearUnorderedAccessViewUint` | run: `(GPU handle, CPU handle, resource, …)` | @@ -349,8 +389,8 @@ shape and the shift around them, but the shape alone does not single the method So the console list has four more methods than the PC list between `ResourceBarrier` (26) and `SetDescriptorHeaps` (console 32), and two fewer between `ClearUnorderedAccessViewUint` (console 53) and `ExecuteIndirect` (console 61). -Mapping the console list as "PC plus a constant" is wrong. The BVH builder's `+0x490` (slot 146) is also past the -end of the PC list, like 141. +Mapping the console list as "PC plus a constant" is wrong. The BVH builder adds 37, 39, 43 and 45 (the rest of the ++4 root group) and the console-only 71, 73, 80, 146 (`Barrier`) and 148 (sections 3.3 and 3.3a). **The list object is wider than its vtable, and this is what that width is for.** Before a root-argument or dispatch call the DLL checks a write cursor at `+0x18` against a limit (`+0x30` for root arguments, `+0x28` for a dispatch). While there is room, @@ -434,7 +474,7 @@ Even taking both projects at face value, the following remain **Open**: `CreateFence`; - the Xbox queue vtable beyond the public chain (`PresentX`, `SuspendX`, `ResumeX`); - the `PresentX` signature, plane struct, resource/view arrays and swapchain parameters; -- the command-list extension slots (only `0x490` is measured here, without a name); +- the command-list extension slots other than the ones sections 3.3a and 3.5a measured (71, 73, 80, 85, 141, 146, 148); - the DMA list type's real numeric value and the compute/copy console list IIDs; - any Xbox-specific return convention on these interfaces. @@ -485,8 +525,7 @@ command object. | `CreateCommandQueueX` | No slot or parameter layout; only the UMD message and an inferred shape. | | `SuspendX` / `ResumeX` | No slot or signature. | | Xbox queue/list/fence/allocator slot deviations | No runtime binary and no game executable; the package has no queue, fence or allocator client, and its only command-list client is the BVH builder. | -| Command-list method at `+0x490` | Offset measured; identity, signature and whether it is an appended COM method or an internal class method are unknown. | -| Builder's internal field layout (`+0x18`, `+0x30`, `+0x140`, `+0x344`, `+0x350`, `+0x544`) | No header or symbol; the helper's writes prove the contract is wider than the public vtable, but not what the fields mean. | +| Builder's list field `+0x350` | Read once (`0x1d877`) and not explained by the inline buffer of section 3.5a, which covers `+0x18`, `+0x28`, `+0x30`, `+0x140`, `+0x141`, `+0x344` and `+0x544`. | | DMA list use/value | The IID is prior art; type 6 is derived; no shipped module uses it. | ### 5.4 GCL8 (resolved in PR #164) @@ -495,8 +534,8 @@ The shipped builder's rehydrate exports name `ID3D12GraphicsCommandList8`, and `OMSetFrontAndBackStencilRef` is public GCL8 at slot 81. **PR #164 adds the public GCL8 interface** to `runtime/shims/d3d12_com.cpp`: it records the front/back values, resets them in `Reset`, answers `IID_ID3D12GraphicsCommandList8`, and registers the `d3d12_gcl8` CTest (9/9). The values are recorded -but not applied because this layer still has no pipeline/draw path. It does **not** close the -builder's `+0x490` gap, but a GCL8 pointer is now served instead of refused. +but not applied because this layer still has no pipeline/draw path. The builder's `+0x490` call is the +enhanced-barrier `Barrier` at console slot 146 (section 3.3), which a console-order list routes to GCL7 slot 80. ## 6. Return conventions @@ -516,18 +555,18 @@ return has been measured. The executable is absent, so the next step should use the one shipped client that exists rather than invent slots. -1. **Trace the builder's command-list calls with a logging proxy.** Create a test-only command +1. **Confirm sections 3.3 and 3.3a with a logging proxy.** Create a test-only command list whose public GCL6/GCL8 vtable logs `(slot, raw arguments)` and whose tail is a page of logged unknown slots. Pass it to `XboxBvhBuilder::BuildRaytracingAccelerationStructureBatched2X` with a minimal non-empty descriptor. The `+0xd0` barrier and `+0x70` dispatch should be observed first; the `+0x490` - call will be recorded with its raw arguments. This turns `0x490` from an offset into a - call shape and tests the "wider than the public vtable" hypothesis without a GPU. If the + call should arrive with one global UAV barrier group (section 3.3), and slot 148 should be + asked for `count * 40` bytes. Keep the cursor at its limit so every call reaches the vtable. If the builder validates its inputs before reaching the dispatch, use a descriptor shaped like the one its own `GetRaytracingAccelerationStructurePrebuildInfo` accepts (prior art measured a 3,000-vertex triangle geometry; the prebuild answer is 204,800 bytes / 128,704 scratch). 2. **GCL8 is now implemented** in PR #164 (public slot 81, recorded/reset, CTest 9/9); the - remaining builder gap is the `+0x490` method. + builder's `+0x490` is `Barrier` (section 3.3), and its slot 148 needs an upload allocator (section 3.3a). 3. **When the executable appears, trace the four creation calls first.** Per-slot counters on device slots 8/9/12/36, then queue slots 10/14/15, fence slots 8/9/10, and every slot beyond the public chain. The first `PresentX` call and the queue vtable tail are the only way to @@ -567,7 +606,10 @@ the SDK; the console GUIDs are attributed to SCARAB in - Builder call sites: Capstone 5.0.7 x86-64 disassembly of the 12 exported functions and the functions they call directly; RVAs are PE relative virtual addresses. The `0xd0` call is in the batched entry (`0x216a0`, site `0x2171e`); the `0x490` call is in the - per-descriptor function reached from it (`0x1d7c0`, site `0x1da02`). + per-descriptor function reached from it (`0x1d7c0`, site `0x1da02`). Section 3.3a: the + `call [reg+disp]` sites in the rest of `.text` whose object register holds the list pointer, + each read with the argument registers set before it and the inline write it falls back from; + the barrier constant is the 16 bytes at RVA `0xcdf60` (file offset from the section table). - Public slots: parse the `MIDL_INTERFACE`/`virtual` declarations in `d3d12.h`; the counts in section 2 include the seven `IUnknown`+`ID3D12Object` slots. Cross-check selected values with `python tools/d3d12_xs_surface.py --check --sdk` (116 slots, 83 standard GUIDs) and diff --git a/docs/d3d12_vulkan.md b/docs/d3d12_vulkan.md index 4dc091c3ef..8d77b668ab 100644 --- a/docs/d3d12_vulkan.md +++ b/docs/d3d12_vulkan.md @@ -1999,7 +1999,7 @@ Xodus is LGPL-2.1 and is cited only for its coverage number, not as a code sourc | # | Question | How to resolve | |---|---|---| | 1 | The device entry point is now named `D3D12XboxCreateDevice(adapter, params, riid, out)`. What do its 24-word params and flag bits mean? | Public documentation and the executable's call sites. Log the words and accept any flag bits; do not treat a wrong params layout as fatal until the fields are understood. | -| 2 | Which Xbox device/heap/queue/command-list slots differ? Prior art measured device slots 62 and 76 and descriptor-heap slots 9/10; slot 14 is the public `CreateDescriptorHeap`, with only the returned heap's start-handle return wrapped. **Partly measured** with the FSR DLL ([d3d12_command_objects.md §3.5a](d3d12_command_objects.md)): device slots 14, 15, 16, 18, 19, 27, 38, 62 and 76 at their expected shapes (24 in the code, not called), slot 67 a console-only pipeline call; command-list slots 14, 15, 25 and 26 at their PC positions, then shifted (+4 from `SetDescriptorHeaps` at 32, +2 at `ExecuteIndirect` at 61), with console-only methods at 85 and 141. Presentation, queue and fence slots remain unknown. | Trace every `QueryInterface` and every method slot with per-slot hit counters. A wrong slot shows as an immediate crash or wrong argument; compare against the SDK vtable. | +| 2 | Which Xbox device/heap/queue/command-list slots differ? Prior art measured device slots 62 and 76 and descriptor-heap slots 9/10; slot 14 is the public `CreateDescriptorHeap`, with only the returned heap's start-handle return wrapped. **Partly measured** with the FSR DLL ([d3d12_command_objects.md §3.5a](d3d12_command_objects.md)): device slots 14, 15, 16, 18, 19, 27, 38, 62 and 76 at their expected shapes (24 in the code, not called), slot 67 a console-only pipeline call; command-list slots 14, 15, 25 and 26 at their PC positions, then shifted (+4 from `SetDescriptorHeaps` at 32, +2 at `ExecuteIndirect` at 61), with console-only methods at 85 and 141. The BVH builder's call sites add the rest of the +4 root group (37, 39, 43, 45) and console slots 71, 73, 80, 146 (the GCL7 `Barrier`) and 148 (an upload allocator whose pointer is also the GPU address) ([d3d12_command_objects.md §3.3, §3.3a](d3d12_command_objects.md)). Presentation, queue and fence slots remain unknown. | Trace every `QueryInterface` and every method slot with per-slot hit counters. A wrong slot shows as an immediate crash or wrong argument; compare against the SDK vtable. | | 3 | How does the console map a root signature to `s0..s31` (order, per-stage visibility, spills above 32 dwords, static samplers, direct-heap base)? | Dump the game's root-signature blobs with the host deserializer; mask the `0x03000000` flag byte on a copy first; match against the per-shader user-SGPR read sets. If a signature exceeds 32 dwords, reverse the spill pointer from the shader. | | 4 | Are Xbox descriptor bytes GFX10 T#/S#, and what are the heap increments? Does the game use `Create*View` or build descriptors itself? | Dump a shader-visible heap after the first `CreateShaderResourceView` and after the first draw; compare the bytes the shader loads with the T# parser. The start-handle return ABI is known (RAX); the increment values still need measuring. | | 5 | What is the buffer/descriptor/code VA range, and what arena capacity is needed? | Log every `GetGPUVirtualAddress` and every descriptor base; track the high-water mark. Choose a capacity; grow at a frame boundary if needed. |