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.md71
1 files changed, 63 insertions, 8 deletions
diff --git a/docs/d3d12_command_objects.md b/docs/d3d12_command_objects.md
index 0c94f58c7..5a214e325 100644
--- a/docs/d3d12_command_objects.md
+++ b/docs/d3d12_command_objects.md
@@ -270,6 +270,41 @@ shipped modules, not a claim that the game never queries for them.
270The `GraphicsCommandList` ASCII string occurs 30 times in `XboxBvhBuilder.dll` (type/debug 270The `GraphicsCommandList` ASCII string occurs 30 times in `XboxBvhBuilder.dll` (type/debug
271names); `PresentX` does not occur in any of the 16 DLLs. 271names); `PresentX` does not occur in any of the 16 DLLs.
272 272
273
274### 3.2a No shipped module passes an unknown GUID at a call site
275
276Section 3.2's byte scan can only recognise *known* IIDs; a console-only GUID (the four list IIDs of
277[`d3d12_xs_surface.md §4`](d3d12_xs_surface.md)) would scan as anonymous data. The call-site scan closes
278that hole: `tools/d3d12_guid_sites.py` enumerates every 16-byte constant a module's code can name —
279RIP-relative `lea` targets in data sections, absolute pointers stored in data, two adjacent
280`movabs` immediates that inline a GUID without a constant pool, and `mov reg, [rip+...]` loads
281through import slots (a GUID imported as data) — and reports which are GUID-shaped. Over all 16
282modules of the 1.0.2.1 package:
283
284| Binary | GUID-shaped constants the code references |
285|---|---|
286| `XboxBvhBuilder.dll` | 2: `IID_ID3D12RootSignature`, `IID_ID3D12PipelineState` (the same pair as §3.2) |
287| `amd_fidelityfx_upscaler_xbox.dll` | 8: the §3.2 set, nothing else |
288| `amd_fidelityfx_loader_xbox.dll` | 0 |
289| the other 13 modules | 0–44 GUIDs each (six have none); where present they are HTTP, WinRT and CRT interfaces — none of these modules imports `d3d12_xs.dll`, so none can call D3D12 at all |
290
291No module loads a GUID through an import slot, and no `movabs` pair inlines one. As a control, the
292upscaler's single `IID_ID3D12Device` reference (rva `0x482f0`) is the IID of a real slot-0
293`QueryInterface` call (`(this, &IID, &out)`, decompiled at rva `0xde66`). So the only
294interfaces any shipped module can name at a `QueryInterface` or a creation call are the ten it
295already uses; a console compute/copy list IID cannot appear in the package, statically, in any
296form. The same scan looks for code-referenced static `D3D12_COMMAND_QUEUE_DESC` windows
297`{Type, Priority, Flags, NodeMask}`: 10 windows in 3 modules survive the shape filter, every one with
298`Type` 1 — a PC enum value — and all of them offset tables read by stride arithmetic, not queue
299descriptions (checked by decompiling the referencing function of the upscaler's six). None has a
300value past `VIDEO_DECODE` (4), so the DMA type's numeric value has no static source in the package
301either.
302
303Reproduce: `python -I tools/d3d12_guid_sites.py <package>/*.dll --known
304IID_ID3D12ConsDmaCommandList=30bc77b9-8379-4b25-95de-b8588c42275d` (prints GUID values and counts
305only). The four list IIDs and the DMA type remain reachable only through the running title, as
306[`d3d12_xs_surface.md §4`](d3d12_xs_surface.md) already requires for the IIDs.
307
273### 3.3 The BVH builder's command-list call sites 308### 3.3 The BVH builder's command-list call sites
274 309
275The exported `BuildRaytracingAccelerationStructure` (ordinal 3, RVA `0x21610`) copies the input 310The exported `BuildRaytracingAccelerationStructure` (ordinal 3, RVA `0x21610`) copies the input
@@ -466,9 +501,16 @@ vtable pointer of a public object.
466 at `+0x18`, a copy of the kind-6 program at `+0x28` with its exact size at `+0x30`, and kind 7 at `+0x38` 501 at `+0x18`, a copy of the kind-6 program at `+0x28` with its exact size at `+0x30`, and kind 7 at `+0x38`
467 ([fspx.md](fspx.md)). The proxy maps the console desc to `D3D12_COMPUTE_PIPELINE_STATE_DESC` and routes it to 502 ([fspx.md](fspx.md)). The proxy maps the console desc to `D3D12_COMPUTE_PIPELINE_STATE_DESC` and routes it to
468 `CreateComputePipelineState` (PC slot 11). On a PC device that call fails (`E_FAIL`) because the code is not a PC 503 `CreateComputePipelineState` (PC slot 11). On a PC device that call fails (`E_FAIL`) because the code is not a PC
469 shader, so the DLL falls back to slot 62; its message for that failure calls the fallback "NewBE". The Vulkan 504 shader, so the DLL falls back to slot 62; its message for that failure calls the fallback "NewBE". With kind 0 in
470 device takes the bare kind-6 program and finds its translated module by `fspx_code_sha256` ([fspx.md](fspx.md), 505 the description (always, from this DLL) the proxy passes all four pairs on as one `FSPX` payload, checking each pair
471 "Build and run-time lookup"), for the programs the build translated. 506 before reading it. The Vulkan device then finds the translated module by `fspx_code_sha256` and `fspx_state_sha256`
507 ([fspx.md](fspx.md), "Build and run-time lookup"), for the programs the build translated.
508 - **The layout is pinned from the DLL's code:** its FSPX reader (`0x1a20`), the same loop inline for a container,
509 and the copy into the description. The kind 0 and kind 6 of one call come from the same payload. With the
510 reader run on all 29 programs, every translated program resolves to its own entry ([fspx.md](fspx.md), "How
511 the table was pinned").
512 - **A failed call is logged with its number** (`slot 67 call N failed`). The DLL creates its pipelines one after
513 another, so a miss is not necessarily the first call's.
472- **Slot 62** (call at `0x5825`) takes the measured `(D3D12_COMPUTE_PIPELINE_STATE_DESC*, 0, 0, riid, out)`. The PC 514- **Slot 62** (call at `0x5825`) takes the measured `(D3D12_COMPUTE_PIPELINE_STATE_DESC*, 0, 0, riid, out)`. The PC
473 runtime refuses the DLL's code (`E_FAIL`): it is not a PC shader. The DLL's pipeline function then returns 515 runtime refuses the DLL's code (`E_FAIL`): it is not a PC shader. The DLL's pipeline function then returns
474 `0x8000000d` (`0x4b85`), but the dispatch goes on, records the null pipeline and faults (`0x65ff`), which is where a 516 `0x8000000d` (`0x4b85`), but the dispatch goes on, records the null pipeline and faults (`0x65ff`), which is where a
@@ -482,9 +524,20 @@ vtable pointer of a public object.
482 the largest value (`+0x10f8`). Before a dispatch whose pipeline has a non-zero value (`0x64d3`; zero skips the 524 the largest value (`+0x10f8`). Before a dispatch whose pipeline has a non-zero value (`0x64d3`; zero skips the
483 binding), the DLL creates the scratch buffer once, `largest * 0xd0` bytes rounded up to 64 KiB, through device 525 binding), the DLL creates the scratch buffer once, `largest * 0xd0` bytes rounded up to 64 KiB, through device
484 slot 27 in state `UNORDERED_ACCESS` (`0x65ab`), names it `FFX_XBox_ComputeScratch`, and binds it with list slot 526 slot 27 in state `UNORDERED_ACCESS` (`0x65ab`), names it `FFX_XBox_ComputeScratch`, and binds it with list slot
485 141 `(2, GPU VA, buffer size, this pipeline's value)` (`0x65f8`). Measured: the calls and the arithmetic. Open: 527 141 `(2, GPU VA, buffer size, this pipeline's value)` (`0x65f8`). Measured: the calls and the arithmetic.
486 what the slot-11 object is, the unit of its dword (the factor 1024 suggests KiB), the meaning of `0xd0`, and 528 - **Failure and zero (measured, `0x585c` to `0x58b1`).** The value at `+0x44` is set to 0 before the call. A failed
487 of the leading `2`. 529 HRESULT or a null `obj` skips to the function's success return with the value still 0, so pipeline creation does
530 not depend on slot 11. At dispatch a value of 0 skips both the scratch buffer and list slot 141 (`0x64d6`).
531 - **The object (measured shape, hypothesis about its type).** Slot 3 is called with no arguments and its result is
532 read as a pointer to the dword; slot 2 releases it. That is the shape of `ID3DBlob::GetBufferPointer` and
533 `Release`.
534 - **No per-program size (measured on the 29 programs).** `COMPUTE_PGM_RSRC2.SCRATCH_EN` is clear in all 29, no
535 program has a `scratch_*` or `flat_scratch` instruction, and kind-0 words 0, 1 and 2 are each one value across
536 all 29.
537 - **Implemented.** The Vulkan device's pipeline answers slot 11 with a blob holding 0; console slots 9 and 10
538 return `E_NOTIMPL`. A translated module keeps its private data in SPIR-V, not in a console scratch buffer.
539 - **Open.** What the console returns there for these programs, the unit of the dword (the factor 1024 suggests
540 KiB), the meaning of `0xd0`, and of the leading `2`.
488- The DLL's 29 shaders are `DXBC` containers with `SFI0`, `ISG1`, `OSG1`, `PSV0`, `RTS0`, `HASH` and `ACCC` parts 541- The DLL's 29 shaders are `DXBC` containers with `SFI0`, `ISG1`, `OSG1`, `PSV0`, `RTS0`, `HASH` and `ACCC` parts
489 and no `DXIL`. The `ACCC` payload starts with the tag `FSPX` in all 29; the game's own native shaders are `FSSM` 542 and no `DXIL`. The `ACCC` payload starts with the tag `FSPX` in all 29; the game's own native shaders are `FSSM`
490 inside `XBCH` ([design.md](design.md)). `FSPX` is a directory around an uncompressed RDNA2 program and its 543 inside `XBCH` ([design.md](design.md)). `FSPX` is a directory around an uncompressed RDNA2 program and its
@@ -664,7 +717,8 @@ Even taking both projects at face value, the following remain **Open**:
664- the Xbox queue vtable beyond the public chain (`PresentX`, `SuspendX`, `ResumeX`); 717- the Xbox queue vtable beyond the public chain (`PresentX`, `SuspendX`, `ResumeX`);
665- the `PresentX` signature, plane struct, resource/view arrays and swapchain parameters; 718- the `PresentX` signature, plane struct, resource/view arrays and swapchain parameters;
666- the command-list extension slots other than the ones sections 3.3a and 3.5a measured (71, 73, 80, 85, 141, 146, 148); 719- the command-list extension slots other than the ones sections 3.3a and 3.5a measured (71, 73, 80, 85, 141, 146, 148);
667- the DMA list type's real numeric value and the compute/copy console list IIDs; 720- the DMA list type's real numeric value and the compute/copy console list IIDs, which the package
721 itself cannot supply (§3.2a): they need the running title or a vendor runtime;
668- any Xbox-specific return convention on these interfaces. 722- any Xbox-specific return convention on these interfaces.
669 723
670## 5. What a runtime can do without the executable 724## 5. What a runtime can do without the executable
@@ -780,7 +834,8 @@ command object.
780| `SuspendX` / `ResumeX` | No slot or signature. | 834| `SuspendX` / `ResumeX` | No slot or signature. |
781| 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. | 835| 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. |
782| 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`. | 836| 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`. |
783| DMA list use/value | The IID is prior art; type 6 is derived; no shipped module uses it. | 837| DMA list use/value | The IID is prior art; type 6 is derived; no shipped module uses it, and no module can name any GUID at a call site beyond its known ten or holds a static queue description with a non-PC type (§3.2a). |
838| Compute/copy console list IIDs | Not exported (see #3520) and not present at any call site (§3.2a); only the running title can supply them. |
784 839
785### 5.4 GCL8 (resolved in PR #164) 840### 5.4 GCL8 (resolved in PR #164)
786 841