upleb.uk

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

summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorAndréLanD <andreviniciusmerlia@gmail.com>2026-11-25 18:28:15 -0300
committerGitHub <noreply@github.com>2026-11-25 18:28:15 -0300
commit5c6b60e8ad6db1ba8a042f67579f12f720efa673 (patch)
treea749c609446ae593b0708d548dcb130510b79902 /docs
parent36572941c5be9ba0824353925d9d7330fe213ea4 (diff)
parentb9ad785e5f6b39a15447c4a87648dffb1c264309 (diff)
Merge pull request #1117 from robot00f/docs/b3
docs(d3d12_xs_surface): slot 108 is an allocation-info query, not a GUID query (D3D12-SLOT108-QUERY)
Diffstat (limited to 'docs')
-rw-r--r--docs/d3d12_xs_surface.md125
1 files changed, 122 insertions, 3 deletions
diff --git a/docs/d3d12_xs_surface.md b/docs/d3d12_xs_surface.md
index 0cae107f7..460b50d29 100644
--- a/docs/d3d12_xs_surface.md
+++ b/docs/d3d12_xs_surface.md
@@ -450,6 +450,124 @@ before treating it as new. For `OMSetFrontAndBackStencilRef` the signature is id
450GCL8-compiled game calls it at the public slot; SCARAB's placement after GCL6 would land in the 450GCL8-compiled game calls it at the public slot; SCARAB's placement after GCL6 would land in the
451wrong slot. Leonida's public-chain command list already has it at GCL8. 451wrong slot. Leonida's public-chain command list already has it at GCL8.
452 452
453### 5.2 Arity and receiver of device slots 86, 101, 108, 132 and 133 (and offset `+0x418` / 131)
454
455These six offsets are called in the title's executable; five reach the device and `+0x418` (131)
456does not. `+0x2B0`, `+0x328`, `+0x360` and `+0x418`-`+0x428` are past every published interface,
457so they are console slots on whatever object the call is made on, and the receiver is not
458automatically the device: the console runtime repeats offsets across object vtables. The whole
459image has **243** indirect calls `call [reg+disp]` at these six offsets; most of them are *not* on
460the device, and a count that ignores the receiver overstates the device surface by an order of
461magnitude.
462
463The receiver is proven by a backward definition chain from the `call` that ends in a full-width load
464of the device pointer. The title keeps that pointer in a block of `.data` aliases
465(`0x1475DF000`-`0x1475DF048` and `0x148759D00`) that one constructor fills with the same value
466(`0x1424785D4`-`0x142478621` copies the qword at `0x1475DF048` into the other eleven). A site whose
467chain ends in one of those globals is a device site. A site whose chain ends in a *different*
468global, in an argument of unknown provenance or in the return of a helper is counted but not
469attributed.
470
471| Slot | Offset | Raw sites | Sites on the device | Receiver at those sites | Registers / stack at those sites | What the device sites support |
472|---:|---|---:|---:|---|---|---|
473| 86 | `+0x2B0` | 37 | **1** (`0x142479A87`) | `[0x1475DF000]` (alias of the device pointer) | `rcx`=device, `rdx`=&desc (first qword `0x2B0`), `r8`=&`IID_ID3D12PipelineState`, `r9`=&out | three-argument, `riid`-out PSO stream creation (`CreatePipelineState` in [d3d12_vulkan.md](d3d12_vulkan.md) §3.1) |
474| 101 | `+0x328` | 28 | **1** (`0x1424813EF`) | `[0x1475DF018]` (alias) | `rcx`=device, `rdx`=&desc (dword 0 = `3`, dword 4 = index, `+8` = pointer), `r8`=&`IID_ID3D12StateObject`, `r9`=&out | three-argument, `riid`-out state-object creation with a leading type word `3` (`CreateStateObject` in [d3d12_vulkan.md](d3d12_vulkan.md) §3.1) |
475| 108 | `+0x360` | 31 | **2** (`0x140ABFDA9`, `0x140ABFE07`) | vtable fetched from the device (`[0x1475DF030]` / `[0x1475DF035]`); `rdx` is the device itself: the slot returns a 16-byte struct, so the MSVC x64 ABI puts the hidden return buffer in `rcx` and `this` moves to `rdx` | `rcx`=&16-byte `D3D12_RESOURCE_ALLOCATION_INFO` return, `rdx`=device, `r8d`=1 (`visibleMask`), `r9d`=1 (`numResourceDescs`), `[rsp+0x20]`=&56-byte `D3D12_RESOURCE_DESC`, `[rsp+0x28]`=&24-byte scratch (`D3D12_RESOURCE_ALLOCATION_INFO1`-sized) | allocation-info query over one 56-byte resource description (4 KiB small-resource retry; routed as `GetResourceAllocationInfo2` in [d3d12_vulkan.md](d3d12_vulkan.md) §3.1) |
476| 131 | `+0x418` | 26 | **0** | - | - | the offset is called, but only on non-device receivers here; a device form is unproven |
477| 132 | `+0x420` | 47 | **1** (`0x1424745E4`) | `[0x1475DF048]` (the alias the copy loop reads) | `rcx`=device, `edx`=3 | single small enum/int argument |
478| 133 | `+0x428` | 74 | **5** (`0x14006DD85`, `0x14193DFF8`, `0x14193E2D4`, `0x141E8684C`, `0x1456F802B`) | `[0x1475DF048]` or `[0x148759D00]` | `rcx`=device, `rdx`=GPU VA, `r8`=&`D3D12_RESOURCE_DESC`, `r9d`=state (`6`, `0xFFFFFFFF` or a register), `[rsp+0x20]`=clear, `[rsp+0x28]`=&`IID_ID3D12Resource`, `[rsp+0x30]`=&out | six-argument placed-resource creation, stable across all five sites |
479
480Per slot:
481
482- **86.** The `riid` at `0x1461E06B8` is `765a30f3-f624-4c6f-a828-ace948622445`,
483 `IID_ID3D12PipelineState` (§3), so the device form creates a PSO: `(desc, riid, out)`, which
484 [d3d12_vulkan.md](d3d12_vulkan.md) §3.1 (`runtime/shims/d3d12_xs_device.cpp`) routes as
485 `CreatePipelineState` to PC slot 47 (`ID3D12Device2::CreatePipelineState`). The
486 descriptor's first qword is the slot number itself (`mov qword ptr [rdx], 0x2B0`), i.e. the
487 caller keeps a command record. A second caller reaches the pair 86/87 on *another* object: at
488 `0x14258FC20`-`0x14258FC56` it loads the vtable into `r8`, sets `edx`, branches on a byte and
489 calls `+0x2B8` or `+0x2B0` with that one argument, then tags the returned qword `4` or `3`. So
490 the recorder form is one argument and a returned value, and the device form is the three-argument
491 creation; do not generalise either to the other. A shim that only knows 86 will miss the 87
492 branch.
493- **101.** The `riid` at `0x1461E06D8` is `47016943-fca8-4594-93ea-af258b55346d`,
494 `IID_ID3D12StateObject` (SDK `d3d12.h:44486`, not in the 28-IID set of §3). The descriptor is
495 `{dword 3, dword index, pointer}`: `[rdx]` is the type word `3` (`D3D12_STATE_OBJECT_TYPE_RAYTRACING_PIPELINE`
496 or collection), `[rdx+4]` an index into the table the caller just filled (`0x142481350`-`0x1424813BD`)
497 and `[rdx+8]` a pointer (`rdi`). That is the DXR state-object side of the game, routed in
498 [d3d12_vulkan.md](d3d12_vulkan.md) §3.1 (`runtime/shims/d3d12_xs_device.cpp`) as
499 `CreateStateObject(desc, riid, out)` to PC slot 62 (`ID3D12Device5::CreateStateObject`).
500- **108.** No GUID is compared at either site. Both sit in one function, `0x140ABFAE0`-`0x140ABFE6C`
501 (reached through the thunk at `0x140ABFAD0`), which first computes the surface size and then makes
502 the one call twice at most. The 5th argument is a 56-byte `D3D12_RESOURCE_DESC`: the callee reads
503 `Dimension` at `+0`, `Alignment` at `+8`, `Width` at `+0x10`, `Height` at `+0x18`,
504 `DepthOrArraySize` at `+0x1C`, `Format` at `+0x20`, `Layout` at `+0x2C` and `Flags` at `+0x30`, and
505 writes back the 4-texel-aligned `Width`/`Height` for block-compressed formats
506 (`0x140ABFB2B`-`0x140ABFB40`). `Format` becomes bits per pixel through `0x144D9F3C0`, which indexes
507 the 128/96/64/32/16/8/4-bit table at `0x1461ED5B8`; dimension 4 (3D) with `Layout` 0 has `Layout`
508 set to the console word `0x105` (`0x140ABFD4B`-`0x140ABFD57`), dimension 3 (2D) takes the tile-shape
509 table, and a buffer is plain `Width × Height × Depth × bits`. When the whole surface is under
510 `0x80008` bits it writes `Alignment = 0x1000`, asks for that alignment, and if the returned alignment
511 is not `0x1000` clears `Alignment` to 0 and calls again (`0x140ABFDBF`-`0x140ABFE07`) — the retry the
512 SDK's small-resource sample does with `D3D12_SMALL_RESOURCE_PLACEMENT_ALIGNMENT` (4096,
513 `d3d12.h:1304`), and the 4 KiB small-texture alignment the host layer already answers
514 ([d3d12_vulkan.md](d3d12_vulkan.md) §4.2). The 16-byte return is `{SizeInBytes, Alignment}` and the
515 code traps unless the high dword of `SizeInBytes` is 0, so a returned size has to fit 32 bits
516 (`0x140ABFE15`).
517 That is the argument list, return placement and struct use of
518 `ID3D12Device4::GetResourceAllocationInfo1(visibleMask, numResourceDescs, pResourceDescs,
519 pResourceAllocationInfo1)` (`d3d12.h:12418-12422`), including a 24-byte
520 `D3D12_RESOURCE_ALLOCATION_INFO1` buffer as the 4th argument (`d3d12.h:2965-2970`);
521 [d3d12_vulkan.md](d3d12_vulkan.md) §3.1 (`runtime/shims/d3d12_xs_device.cpp`) serves it by
522 expanding the 56-byte `D3D12_RESOURCE_DESC` (normalising `0x105` and Xbox flag bits) and routing to
523 PC slot 68 (`ID3D12Device8::GetResourceAllocationInfo2`). **Measured**: the shape, the struct
524 offsets, `0x1000`/`0x105`, the retry and the assert. **Open**: the exact console wire method name
525 (`GetResourceAllocationInfo1` vs `GetResourceAllocationInfoX` / `2`) — no IID or symbol string is
526 present at the sites.
527- **131.** Twenty-six sites, none on the device. Two are on sub-objects reached through another
528 global (`0x1415A487D` indexes a table at `[rax+0x28]`), one at `0x14437CFED` follows slot 130
529 (`+0x410`) on the same receiver and reads the out dword it wrote, and the rest are on arguments
530 whose caller does not carry the device. The shape there is `(dword* out)` with a returned value
531 that a site compares (`0x141F9BE30`), plus a four-argument form
532 (`0xC280`, `0x20000`, `0`, `0xFFFFFFFFFF00` at `0x141560994`). It sits in the 0x400 block with
533 132/133, and both of those do have device sites, so a device form is plausible but not shown:
534 do not implement it on the strength of these sites.
535- **132.** The only device site passes `edx=3` and nothing else. Off the device the same offset is
536 a predicate taking one 32-bit constant (`2`, `3`, `0xFFF7E7A4`, `0xBD8817DB`) and returning in
537 `al` (`test al, al` at `0x14118ABB4`), which reads as a feature or capability query; that family's
538 receiver is not the device, so `3` cannot be read as a capability id for the device form yet.
539- **133.** All five device sites are identical: VA, a console `D3D12_RESOURCE_DESC` (Xbox `Flags`
540 bits above the PC ones), state, clear, `IID_ID3D12Resource`, out. That is the same shape and the
541 same `riid` the retail run logged (`retail_boot_chain.md` §3.4, "device slot 133 places a
542 resource at a virtual address"), measured independently here from the same `riid` constant at
543 `0x1463FA690` in three different sites, all `696442be-a72e-4059-bc79-5b5c98040fad`.
544 Static and run agree on six arguments and on the order. This is the strongest row of the six.
545 Off the device the same offset is a different shape - `this` only, returning an object, at
546 `0x14107D67F`; `this` + `0` at `0x143BF0C50` - so 133 on another receiver is not this method.
547
548The co-occurrence fits the block reading: 108 is called alongside 106/107/109/110/111 in
549`0x140504AB0`, 131 alongside 57 in `0x14123C630`/`0x14123CD70`, and 132 with 133 in
550`0x1403D2260`, `0x14060C420`, `0x14060CA50`, `0x141394800` and `0x141597B60`, always with the same
551argument (`rdx` = the struct that carries the size/VA). None of those receivers is proven to be
552the device, so the pairing says "one feature area", not "same arity" and not "device slot".
553
554What this does not say:
555
556- A raw site count is not a device count. The largest raw buckets are argument-provenance sites
557 (26 of 47 at 132, 40 of 74 at 133), many of them in wrapper code that re-dispatches on an
558 inherited or returned pointer. The same offset also carries a different arity off the device
559 (`0x14107D67F`, `0x143BF0C50` above), so an offset alone never names a method.
560- `rdx`, `r8` and `r9` at a site can be dead for the method; only the setup within the last few
561 instructions is listed. The arity above is the *caller's* setup, not a header.
562- No symbol string appears at any of the six call-site groups. On the device, 86, 101, 108 and
563 133 match the routes in [d3d12_vulkan.md](d3d12_vulkan.md) §3.1 and
564 [retail_boot_chain.md](retail_boot_chain.md) §3.4 (`CreatePipelineState`, `CreateStateObject`,
565 `GetResourceAllocationInfo2` and `CreatePlacedResourceX` in
566 `runtime/shims/d3d12_xs_device.cpp`). Offsets `+0x418` (131) and `+0x420` (132) remain unnamed
567 here, and 131 has no device receiver.
568- The proxy table must still be long enough: slot 133 is the highest slot the title reaches, so a
569 128-entry table faults (retail observation) and anything below 134 is a guess.
570
453## 6. Command lists and `CreateCommandList` 571## 6. Command lists and `CreateCommandList`
454 572
455The one measured console command-list rule, quoted from the UMD: 573The one measured console command-list rule, quoted from the UMD:
@@ -675,7 +793,7 @@ evidence.
675| Leonida unknown | Status after SCARAB (and §7.1) | What is actually new | 793| Leonida unknown | Status after SCARAB (and §7.1) | What is actually new |
676|---|---|---| 794|---|---|---|
677| #1 device entry point and 24-word params | **described** | The separate console device export exists at ordinal 13 and is named `D3D12ConsCreateDevice` internally / `D3D12XboxCreateDevice` publicly; the params struct is named `D3D12CONS_CREATE_DEVICE_PARAMETERS`. Public sources name 17 fields and their x64 offsets, plus two more field names; a 24-word block still has at least four words unaccounted (§7.1). | 795| #1 device entry point and 24-word params | **described** | The separate console device export exists at ordinal 13 and is named `D3D12ConsCreateDevice` internally / `D3D12XboxCreateDevice` publicly; the params struct is named `D3D12CONS_CREATE_DEVICE_PARAMETERS`. Public sources name 17 fields and their x64 offsets, plus two more field names; a 24-word block still has at least four words unaccounted (§7.1). |
678| #2 device/heap/queue/command-list slots | **partly measured** | SCARAB has no console slot map. Its appended-after-GCL6 model conflicts with the SDK's GCL8/GCL9 methods (§5.1). Public §7.1 gives the presentation slots (device 78-81, queue 30/32); the heap and command-list slot map is still unknown. Do not use SCARAB as a slot source. | 796| #2 device/heap/queue/command-list slots | **partly measured** | §5.2 measures the arity and receiver of device slots 86, 101, 108, 132 and 133 (86, 101, 108 and 133 match the routes in [d3d12_vulkan.md](d3d12_vulkan.md) §3.1 and [retail_boot_chain.md](retail_boot_chain.md) §3.4); offset `+0x418` (131) has no device receiver, so it stays open. SCARAB has no console slot map. Its appended-after-GCL6 model conflicts with the SDK's GCL8/GCL9 methods (§5.1). Public §7.1 gives the presentation slots (device 78-81, queue 30/32); the heap and command-list slot map is still unknown. Do not use SCARAB as a slot source. |
679| #3 root signature → `s0..s31` | **still unknown** | Only flag names (`D3D12CONS_ROOT_SIGNATURE_FLAG_FORCE_MEMORY_BASED_ABI`, `_RAYTRACING`); no mapping. Leonida's own register-based/spill facts already go further. | 797| #3 root signature → `s0..s31` | **still unknown** | Only flag names (`D3D12CONS_ROOT_SIGNATURE_FLAG_FORCE_MEMORY_BASED_ABI`, `_RAYTRACING`); no mapping. Leonida's own register-based/spill facts already go further. |
680| #4 descriptor bytes and increments | **still unknown** | No measured increment. `D3D12CONS_DESCRIPTOR_HEAP_TYPE_SAMPLER_UNBOUNDED` is a new name, not a size. | 798| #4 descriptor bytes and increments | **still unknown** | No measured increment. `D3D12CONS_DESCRIPTOR_HEAP_TYPE_SAMPLER_UNBOUNDED` is a new name, not a size. |
681| #5 VA range / arena capacity | **still unknown** | — | 799| #5 VA range / arena capacity | **still unknown** | — |
@@ -693,8 +811,9 @@ evidence.
693| free-function dispositions | **answered as a list** | 7 standard + 16 console-only; Leonida serves 4 today. | 811| free-function dispositions | **answered as a list** | 7 standard + 16 console-only; Leonida serves 4 today. |
694 812
695The honest summary: SCARAB closes the **export/IID contract** and the **DMA-list rule**, and gives 813The honest summary: SCARAB closes the **export/IID contract** and the **DMA-list rule**, and gives
696a **name-level map** of the extension surface. It does not close presentation, slots, struct 814a **name-level map** of the extension surface. It does not close presentation, the slot map,
697layouts, numeric flags or tiling. 815struct layouts, numeric flags or tiling; §5.2 adds five device slots to what the game itself
816answers (leaving offset `+0x418` / 131 open with 0 device sites).
698 817
699## 10. Claims that did not hold up 818## 10. Claims that did not hold up
700 819