diff options
| author | AREA52 Agent <area52@localhost> | 2026-11-22 20:04:57 +0100 |
|---|---|---|
| committer | AREA52 Agent <area52@localhost> | 2026-11-22 20:04:57 +0100 |
| commit | 98de7444991993df83c2f3c53eba9432b12a3eae (patch) | |
| tree | e63108e8b1eb5ea92ddb0975580c1333a24fe2b3 /docs/d3d12_command_objects.md | |
| parent | 162821017ea3c286c8bec860f3ff94f037912061 (diff) | |
d3d12_command_objects: document the geometry-descriptor validation and the batched-build slot map corrections (D3D-293)
Extends section 7 with the CPU-side geometry descriptor validation that gates
BuildRaytracingAccelerationStructureBatched2X before the first list-vtable call
(the step the D3D-293 dynamic logging proxy stopped at), integrates the static
iced-x86 cross-check results: undocumented slot 90 (+0x2d0) as the worker's first
list call, the +0xd0 barrier being bss-gated (never fired in the shipping DLL),
the +0x490 global UAV barrier group, and slot 148 (count * 40) upload allocation.
Fixes D3D-293.
Diffstat (limited to 'docs/d3d12_command_objects.md')
| -rw-r--r-- | docs/d3d12_command_objects.md | 94 |
1 files changed, 86 insertions, 8 deletions
diff --git a/docs/d3d12_command_objects.md b/docs/d3d12_command_objects.md index 56e1fd5cd..c39bee547 100644 --- a/docs/d3d12_command_objects.md +++ b/docs/d3d12_command_objects.md | |||
| @@ -260,7 +260,7 @@ paragraph). Every call below except the two barriers is the fallback branch of a | |||
| 260 | 260 | ||
| 261 | | RVA | Vtable offset | Console slot → PC method | Observed arguments | Confidence | | 261 | | RVA | Vtable offset | Console slot → PC method | Observed arguments | Confidence | |
| 262 | |---:|---:|---|---|---| | 262 | |---:|---:|---|---|---| |
| 263 | | `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` | | 263 | | `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`; the site is gated (section 3.3b), so the call never fires in the shipping DLL | |
| 264 | | `0x1d9cb` | `+0x70` | 14 → 14 `Dispatch` | `(1, 1, 1)` | **Measured**: exact `Dispatch` shape | | 264 | | `0x1d9cb` | `+0x70` | 14 → 14 `Dispatch` | `(1, 1, 1)` | **Measured**: exact `Dispatch` shape | |
| 265 | | `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 | | 265 | | `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 | |
| 266 | | `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 | | 266 | | `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 | |
| @@ -324,6 +324,71 @@ That byte is one of seven bools at `0xd7738`–`0xd773e` in zero-initialised `.b | |||
| 324 | the shipping DLL the label path is unreachable unless something writes that byte through a computed pointer, and | 324 | the shipping DLL the label path is unreachable unless something writes that byte through a computed pointer, and |
| 325 | the barrier path is the one that runs. | 325 | the barrier path is the one that runs. |
| 326 | 326 | ||
| 327 | ### 3.3b The batched build validates the geometry descriptors on the CPU first | ||
| 328 | |||
| 329 | A logging-proxy harness (section 7, item 1) never reached the first list-vtable call: both runs of the | ||
| 330 | batched export faulted at RVA `0x142d3`, before the object received in the command-list parameter was | ||
| 331 | touched once. The reason is a CPU-side validation of the build items that the section 7 descriptor | ||
| 332 | guidance did not cover. The batched entry (`0x216a0`) reaches it through `0xe6a0` (call at `0x216dc`), | ||
| 333 | the packet processor `0xcc00` (call at `0xe781`) and a per-record validator at `0x14270` (call at | ||
| 334 | `0xce18`; a second call site exists at `0x11c25`). The processor walks the batched descriptor's 80-byte | ||
| 335 | build items (item `i` at descriptor `+ i*0x50`) and routes each by the dword at its `+0x08` — the | ||
| 336 | pointer's `+0x00` at the validator: kind 1 reaches the validator, kind 0 goes through `0xc820`/`0xc780` | ||
| 337 | instead, other values take an error path (`0xd52f`). The validator reads, from the pointer it receives | ||
| 338 | (all **measured** in the static disassembly): | ||
| 339 | |||
| 340 | | Offset | Field | Check | | ||
| 341 | |---:|---|---| | ||
| 342 | | `+0x08` | descriptor count | loop bound | | ||
| 343 | | `+0x0c` | elements layout (`D3D12_ELEMENTS_LAYOUT`) | 0 = inline array of 0x38-byte records, 1 = array of pointers to records; other values print `D3D12 XDXR Error: Unexpected value for D3D12_ELEMENTS_LAYOUT` and throw `E_INVALIDARG` | | ||
| 344 | | `+0x10` | descriptor base | mode 0: record `i` at `base + i*0x38`; mode 1: record `i` at `[base + i*8]` | | ||
| 345 | | record `+0x00` | geometry type (`D3D12_RAYTRACING_GEOMETRY_TYPE`) | 0 = triangles, 1 = AABBs; others print `D3D12 XDXR Error: Unrecognized D3D12_RAYTRACING_GEOMETRY_TYPE` and throw `E_INVALIDARG` | | ||
| 346 | | record `+0x08` | AABB count (type 1) | accumulated | | ||
| 347 | | record `+0x10` | index format (type 0) | at most `0x39` and in the bitset `0x0220040000000000` — `DXGI_FORMAT_R32_UINT` (42), `DXGI_FORMAT_R16_TYPELESS` (53), `DXGI_FORMAT_R16_UINT` (57); others print `D3D12 XDXR Error: Unsupported index buffer format provided` and throw `E_NOTIMPL` | | ||
| 348 | | record `+0x18` | index count (type 0, format ≠ 0) | exact multiple of 3; otherwise prints `D3D12 XDXR Error: Triangle index count must be a multiple of 3 when an index buffer is provided` and throws `E_INVALIDARG` | | ||
| 349 | | record `+0x1c` | vertex count (type 0, format = 0) | checked instead of the index count, also an exact multiple of 3; otherwise prints `D3D12 XDXR Error: Triangle vertex count must be a multiple of 3 when no index buffer is provided` and throws `E_INVALIDARG` | | ||
| 350 | |||
| 351 | The fault that stopped the dynamic runs is the base dereference itself: at `0x142d3` (`mov ecx,[rdx]`, | ||
| 352 | `rdx = base + i*0x38` in the inline mode) the record's type word is read with a CPU load, so a descriptor | ||
| 353 | whose base is a GPU address that is not CPU-readable faults there. For a replacement runtime this is a | ||
| 354 | measured host-side contract: the geometry descriptors must be backed by CPU-readable memory, not only by | ||
| 355 | the GPU arena. The validator returns the summed primitive count (the triangle counts ÷ 3 plus the AABB | ||
| 356 | counts), which the packet processor stores (`0xce1d`). It reads nothing past record `+0x1f`; what the | ||
| 357 | `+0x20..+0x37` tail of a record is used for is open — the dynamic runs stopped at the first record read. | ||
| 358 | |||
| 359 | The same static pass settles what the first list calls would have been, and finds that three of the sites | ||
| 360 | section 3.3 and 3.3a list or miss are gated by the zero-initialised bytes of section 3.3a, so in the | ||
| 361 | shipping DLL they never run: | ||
| 362 | |||
| 363 | - The `+0xd0` `ResourceBarrier` at `0x2171e` (section 3.3) needs a non-zero item count (`0x216e1`) and the | ||
| 364 | byte at `0xd773c` (`0x216e9`). Its shape stays as measured; in the shipping DLL the call never fires. | ||
| 365 | - Slot 90 (`+0x2d0`, call at `0xe836`) is new — it is not in the section 3.3a tail list. Its shape is | ||
| 366 | `(list, p, 0, last)`: `RDX = [item+0x28] + [item+0x54]*4`, where `item` is one 160-byte element of the | ||
| 367 | processor's output array, selected through the dword array beside it, `R9 = 1` on the last iteration, | ||
| 368 | and the element's dword at `+0x9c` is cleared first. The loop is behind the same `0xd773c` byte | ||
| 369 | (`0xe7d0`) and the count check, so it does not run in the shipping DLL either. | ||
| 370 | - The direct slot-146 barrier at `0xea99` is behind the adjacent byte `0xd773b` (`0xea41`, after the | ||
| 371 | per-item callback reports true); the wrapper calls at `0xebbb`, `0xec79`, `0xed37` and `0xee17` are not | ||
| 372 | gated by these bytes, and each ends in the measured slot-146 global UAV barrier (section 3.3a). | ||
| 373 | |||
| 374 | The path also reads one byte past the seven bools of section 3.3a: `0xd773f` at `0xce3f` and `0x11c35`. | ||
| 375 | A linear sweep of `.text` finds no writes to `0xd7738`–`0xd773f` (only `cmp`/`movzx` reads; the two `lea` | ||
| 376 | sites take the address of `0xd7740`, one past the last byte), so the read-only range is eight bytes. | ||
| 377 | |||
| 378 | With the gated sites removed, the shipping-DLL order for one item is (measured with a postbuild-info | ||
| 379 | type of 2, which routes to the `0x1d7c0` worker): the validation above → slot 146 four times through | ||
| 380 | the `0xd580` wrapper → the upload function `0x20ea0` (called at `0xee85`; a second site at `0xf0f9`): | ||
| 381 | slot 148 for `count * 40` bytes at alignment 16 (`0x20ed6`; the size is | ||
| 382 | `lea edx,[rsi+rsi*4]; shl edx,3`), root signature (33), pipeline (25, or its inline write), the | ||
| 383 | slot-148 pointer as root SRV (43, or inline), the count as a 32-bit root constant (37), and | ||
| 384 | `Dispatch((count+31)/32, 1, 1)` (`0x21054`, or its inline four-word packet) — then the per-entry | ||
| 385 | worker `0x1d7c0` (called at `0x217d0`) whose sequence section 3.3 lists, ending in the slot-146 | ||
| 386 | barrier at `0x1da02`. Postbuild-info types 0 and 3 route to the mirrored worker `0x1d540` (called at | ||
| 387 | `0x217e2`). Slot 148 is therefore asked before the per-entry dispatch, and the first dispatch on the | ||
| 388 | path is the upload function's own — the two refinements to section 7's prediction. The `+0x490` barrier | ||
| 389 | arguments (one global UAV group `{0x80, 0x80, 0x10, 0x10}`) and slot 148's `count * 40`/16 are confirmed | ||
| 390 | by both passes (D3D-293's static disassembly and this section's independent iced-x86 re-check). | ||
| 391 | |||
| 327 | ### 3.4 The object is wider than the public vtable | 392 | ### 3.4 The object is wider than the public vtable |
| 328 | 393 | ||
| 329 | The inner function at `0x1d7c0` receives the command-list pointer in RDX, copies it to RBX | 394 | The inner function at `0x1d7c0` receives the command-list pointer in RDX, copies it to RBX |
| @@ -692,16 +757,22 @@ return has been measured. | |||
| 692 | The executable is absent, so the next step should use the one shipped client that exists rather | 757 | The executable is absent, so the next step should use the one shipped client that exists rather |
| 693 | than invent slots. | 758 | than invent slots. |
| 694 | 759 | ||
| 695 | 1. **Confirm sections 3.3 and 3.3a with a logging proxy.** Create a test-only command | 760 | 1. **Confirm sections 3.3, 3.3a and 3.3b with a logging proxy.** Create a test-only command |
| 696 | list whose public GCL6/GCL8 vtable logs `(slot, raw arguments)` and whose tail is a page of | 761 | list whose public GCL6/GCL8 vtable logs `(slot, raw arguments)` and whose tail is a page of |
| 697 | logged unknown slots. Pass it to | 762 | logged unknown slots. Pass it to |
| 698 | `XboxBvhBuilder::BuildRaytracingAccelerationStructureBatched2X` with a minimal non-empty | 763 | `XboxBvhBuilder::BuildRaytracingAccelerationStructureBatched2X` with a minimal non-empty |
| 699 | descriptor. The `+0xd0` barrier and `+0x70` dispatch should be observed first; the `+0x490` | 764 | descriptor. The proxy ran twice; both runs stopped one step short, at the CPU-side geometry |
| 700 | call should arrive with one global UAV barrier group (section 3.3), and slot 148 should be | 765 | validation of section 3.3b (fault at `0x142d3`), before the first list call. The static pass |
| 701 | asked for `count * 40` bytes. Keep the cursor at its limit so every call reaches the vtable. If the | 766 | settled what the first calls will be: not the `+0xd0` barrier — it is gated and never fires |
| 702 | builder validates its inputs before reaching the dispatch, use a descriptor shaped like the | 767 | in the shipping DLL — but the wrapper's slot-146 barriers, then the upload function's slot |
| 703 | one its own `GetRaytracingAccelerationStructurePrebuildInfo` accepts (prior art measured a | 768 | 148 for `count * 40` bytes and its own `Dispatch((count+31)/32, 1, 1)`, and only then the |
| 704 | 3,000-vertex triangle geometry; the prebuild answer is 204,800 bytes / 128,704 scratch). | 769 | per-entry `Dispatch(1,1,1)` of section 3.3; the other new slot, 90, is gated too |
| 770 | (section 3.3b). Keep the cursor at its limit so every call reaches the vtable, and back the | ||
| 771 | geometry descriptors with CPU-readable memory holding valid 0x38-byte records per section 3.3b | ||
| 772 | (type 0, index format 0, vertex count a multiple of 3 — prior art measured a 3,000-vertex | ||
| 773 | triangle geometry; the prebuild answer is 204,800 bytes / 128,704 scratch). A descriptor shaped | ||
| 774 | like the one `GetRaytracingAccelerationStructurePrebuildInfo` accepts is not enough by itself, | ||
| 775 | because the validation reads the records with CPU loads. | ||
| 705 | 2. **GCL8 is now implemented** in PR #164 (public slot 81, recorded/reset, CTest 9/9); the | 776 | 2. **GCL8 is now implemented** in PR #164 (public slot 81, recorded/reset, CTest 9/9); the |
| 706 | builder's `+0x490` is `Barrier` (section 3.3), and its slot 148 needs an upload allocator (section 3.3a). | 777 | builder's `+0x490` is `Barrier` (section 3.3), and its slot 148 needs an upload allocator (section 3.3a). |
| 707 | 3. **When the executable appears, trace the four creation calls first.** Per-slot counters on | 778 | 3. **When the executable appears, trace the four creation calls first.** Per-slot counters on |
| @@ -749,6 +820,13 @@ the SDK; the console GUIDs are attributed to SCARAB in | |||
| 749 | `call [reg+disp]` sites in the rest of `.text` whose object register holds the list pointer, | 820 | `call [reg+disp]` sites in the rest of `.text` whose object register holds the list pointer, |
| 750 | each read with the argument registers set before it and the inline write it falls back from; | 821 | each read with the argument registers set before it and the inline write it falls back from; |
| 751 | the barrier constant is the 16 bytes at RVA `0xcdf60` (file offset from the section table). | 822 | the barrier constant is the 16 bytes at RVA `0xcdf60` (file offset from the section table). |
| 823 | - Section 3.3b and the gated sites: a second, independent disassembly pass (iced-x86, run for the | ||
| 824 | D3D-293 measurement) of the batched entry, the validation chain (`0xe6a0`, `0xcc00`, `0x14270`), | ||
| 825 | the upload function `0x20ea0` and the wrapper call sites; the dynamic side is D3D-293's | ||
| 826 | logging-proxy harness, whose two runs faulted at `0x142d3` before the first list call. The | ||
| 827 | quoted validation messages are the DLL's own wide strings at the `.rdata` addresses the throw | ||
| 828 | paths load. The gate-byte sentence is a linear sweep of `.text` collecting memory operands | ||
| 829 | targeting `0xd7738`–`0xd773f`. | ||
| 752 | - Public slots: parse the `MIDL_INTERFACE`/`virtual` declarations in `d3d12.h`; the counts in | 830 | - Public slots: parse the `MIDL_INTERFACE`/`virtual` declarations in `d3d12.h`; the counts in |
| 753 | section 2 include the seven `IUnknown`+`ID3D12Object` slots. Cross-check selected values with | 831 | section 2 include the seven `IUnknown`+`ID3D12Object` slots. Cross-check selected values with |
| 754 | `python tools/d3d12_xs_surface.py --check --sdk` (116 slots, 83 standard GUIDs) and | 832 | `python tools/d3d12_xs_surface.py --check --sdk` (116 slots, 83 standard GUIDs) and |