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.md70
1 files changed, 68 insertions, 2 deletions
diff --git a/docs/d3d12_command_objects.md b/docs/d3d12_command_objects.md
index a064eb5bd..8dd9fcadb 100644
--- a/docs/d3d12_command_objects.md
+++ b/docs/d3d12_command_objects.md
@@ -295,10 +295,76 @@ passes a builder-specific object that also implements the interface. The byte of
295the field meanings and the method at `+0x490` are **Open**. 295the field meanings and the method at `+0x490` are **Open**.
296 296
297This is the most important compatibility finding on this page. A replacement command list that 297This is the most important compatibility finding on this page. A replacement command list that
298implements only the public GCL7/GCL8 vtable is safe for the game's own public calls, but it is 298implements only the public GCL7/GCL8 vtable is **not** safe to hand to `XboxBvhBuilder`'s build path. (Section 3.5a
299**not** safe to hand to `XboxBvhBuilder`'s build path. The helper will touch fields the public 299shows it is not safe for console-compiled callers' public calls either: the console list order differs from the PC
300order past slot 26.) The helper will touch fields the public
300object does not define and call `+0x490`, which a public-only vtable does not have. 301object does not define and call `+0x490`, which a public-only vtable does not have.
301 302
303### 3.5a The FSR DLL as a second device client
304
305`amd_fidelityfx_upscaler_xbox.dll` is a second shipped module compiled against the console device, the second
306measured client of the console **command list** after the BVH builder (section 3.3), and the first one run. It is run
307by `fsr_dispatch_test` with its measured Xbox backend
308descriptor ([d3d12_vulkan.md Appendix A.3](d3d12_vulkan.md)), on a PC device behind the Xbox-ABI proxy, and its
309command recorder (RVA `0x59a0`) was read with Ghidra 12.2 through REA. RVAs are from image base `0x180000000`. The
310run's command-list calls are the same 13, in the same order, on an RTX 2000 Ada (driver 597.06) and on WARP.
311
312**Device.** At context creation it calls slots 14, 15, 18, 19, 27, 38 and 76 and heap slot 9, all with the shapes the
313PC order and the measured overrides predict; slot 76 takes the seven `CreateCommittedResource` arguments. During
314`ffxDispatch` it adds 16 `CreateRootSignature` and heap slot 10 (the recorder also has a path that calls 24
315`CopyDescriptorsSimple`, not taken in this run), plus its two compute-pipeline paths:
316
317- **Slot 67** (call at `0x56d9`) is **not** the PC `CreateProtectedResourceSession1`: it takes `(desc, riid, out)`
318 with `IID_ID3D12PipelineState` and a console-only desc: the root signature at `+0x00`, two pointers into the DLL
319 with sizes (`0x1c` and `0x14` bytes here) at `+0x08`..`+0x20`, and a copy of a code blob at `+0x28` with its size
320 at `+0x30` (`0x1080` bytes here; most likely the shader's native code). The proxy used to forward it to the PC
321 method at the same index; it now refuses it (`E_NOTIMPL`). When it fails, the DLL takes slot 62.
322- **Slot 62** (call at `0x5825`) takes the measured `(D3D12_COMPUTE_PIPELINE_STATE_DESC*, 0, 0, riid, out)`. The PC
323 runtime refuses the DLL's code (`E_FAIL`): it is not a PC shader. The DLL's pipeline function then returns
324 `0x8000000d` (`0x4b85`), but the dispatch goes on, records the null pipeline and faults (`0x65ff`), which is where a
325 PC device stops.
326- The DLL's 29 shaders are `DXBC` containers with `SFI0`, `ISG1`, `OSG1`, `PSV0`, `RTS0`, `HASH` and `ACCC` parts
327 and no `DXIL`. The `ACCC` payload starts with the tag `FSPX` in all 29; the game's own native shaders are `FSSM`
328 inside `XBCH` ([design.md](design.md)). What `FSPX` holds, and whether the existing unpacker and translator can
329 take it, is open; running FSR needs that, not the executable.
330
331**Command list.** The console list is **not** the PC order past `ResourceBarrier`. Each row is backed by the
332argument shape at the call and, where marked "run", by the call seen in the run. Rows marked "inferred" fit the
333shape and the shift around them, but the shape alone does not single the method out:
334
335| Console slot (offset) | PC slot | Method | Evidence |
336|---|---|---|---|
337| 14 (`+0x70`) | 14 | `Dispatch` | the vtable path of the inline dispatch at `0x59a0`; the BVH builder's `Dispatch(1,1,1)` at `+0x70` |
338| 15 (`+0x78`) | 15 | `CopyBufferRegion` | run: `(resource, 0, resource, …)` |
339| 25 (`+0xc8`) | 25 | `SetPipelineState` | `(pipeline)` at `0x59a0` |
340| 26 (`+0xd0`) | 26 | `ResourceBarrier` | run: `(1, barriers)`; the BVH builder's `+0xd0` |
341| 32 (`+0x100`) | **28** | `SetDescriptorHeaps` | run: `(1, &heap)`, the heap a device-proxy descriptor heap |
342| 33 (`+0x108`) | **29** | `SetComputeRootSignature` (inferred) | one pointer argument, the first call at `0x59a0` (null in the run, where pipeline creation had failed) |
343| 35 (`+0x118`) | **31** | `SetComputeRootDescriptorTable` | `(index, heap GPU start + offset)` at `0x59a0` |
344| 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 |
345| 53 (`+0x1a8`) | **49** | `ClearUnorderedAccessViewUint` | run: `(GPU handle, CPU handle, resource, …)` |
346| 61 (`+0x1e8`) | **59** | `ExecuteIndirect` | `(signature, 1, argument buffer, offset, null, 0)` at `0x59a0` |
347| 85 (`+0x2a8`) | — | console only | run: `(stack pointer, 0, 0)`, twice per dispatch |
348| 141 (`+0x468`) | — | console only | `(2, GPU VA, size, n)` at `0x65f8`: binds a buffer the DLL names `FFX_XBox_ComputeScratch` |
349
350So the console list has four more methods than the PC list between `ResourceBarrier` (26) and `SetDescriptorHeaps`
351(console 32), and two fewer between `ClearUnorderedAccessViewUint` (console 53) and `ExecuteIndirect` (console 61).
352Mapping the console list as "PC plus a constant" is wrong. The BVH builder's `+0x490` (slot 146) is also past the
353end of the PC list, like 141.
354
355**The list object is wider than its vtable, and this is what that width is for.** Before a root-argument or dispatch
356call the DLL checks a write cursor at `+0x18` against a limit (`+0x30` for root arguments, `+0x28` for a dispatch). While there is room,
357it writes the command into that buffer itself instead of calling: a root argument is a header word from the
358per-root-parameter table at `+0x344` and then the value (32 bits for a descriptor table, 64 for the slot-41 GPU VA),
359a dispatch four words (`0x4002c400`, or `(flag | 0x1000ba00) << 2`, then x, y, z).
360It sets a flag byte at `+0x140`, stores a flag at `+0x141` from the
361pipeline, and copies 32 bytes of the pipeline object (from its `+0x10`) to `+0x544`. These are the fields
362section 3.4 measured in the BVH builder's helper without a meaning (`+0x18`, `+0x30`, `+0x140`, `+0x344`, `+0x544`).
363**With the cursor at the limit, every command goes through the vtable**: that is how `fsr_dispatch_test` records
364them, and it is the simplest contract for a layer that does not want to decode these packets. Whether the game's
365executable makes the same check before writing is unknown until it is available; it is compiled against the same
366console headers.
367
302### 3.5 What the package does not measure 368### 3.5 What the package does not measure
303 369
304There is no shipped client for `ID3D12CommandQueue`, `ID3D12Fence`, `ID3D12CommandAllocator`, 370There is no shipped client for `ID3D12CommandQueue`, `ID3D12Fence`, `ID3D12CommandAllocator`,