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:
authorSuarezPM <SuarezPM@users.noreply.github.com>2026-11-22 11:23:56 -0300
committerSuarezPM <SuarezPM@users.noreply.github.com>2026-11-22 11:34:05 -0300
commit5ecb637a028ae604f4dbaa3b4e992a6db1378de0 (patch)
treeedfb5b87505723cbee43c92f3dce08cae1b20532 /docs
parentce5380a65e8ffcb9859618f7847c95408737ba33 (diff)
Docs: the embedded shader containers; the BVH builder's programs are console FSSM
The 52 containers in XboxBvhBuilder.dll carry an LLVM bitcode blob and an XDAT/XBCH record. The console record decompresses to FSSM: 52/52 unpack, 42 translate, 41 pass spirv-val with the existing translator. The 10 left need global_atomic_fmax/fmin, buffer_load_ushort and tbuffer_load_format_x (format 8), plus one OpSelectionMerge emission bug. Correct the DXIL-front-end premise in d3d12_vulkan.md (4.8, 7.1, 7.2, M6, Q7, Q20, A.2) and index the new note.
Diffstat (limited to 'docs')
-rw-r--r--docs/README.md1
-rw-r--r--docs/d3d12_vulkan.md92
-rw-r--r--docs/embedded_shaders.md125
3 files changed, 175 insertions, 43 deletions
diff --git a/docs/README.md b/docs/README.md
index 57b9540a3..7a56afe12 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -73,6 +73,7 @@ method, scope and caveats. No game data is included.
73| [buffer_bounds.md](buffer_bounds.md) | V# `OOB_SELECT` bounds measured natively: RDNA2 (gfx1036) follows Mesa's GFX11 column (729/732 cases), not GFX10; raw mode also counts `soffset`. | 73| [buffer_bounds.md](buffer_bounds.md) | V# `OOB_SELECT` bounds measured natively: RDNA2 (gfx1036) follows Mesa's GFX11 column (729/732 cases), not GFX10; raw mode also counts `soffset`. |
74| [fssm_crosscheck.md](fssm_crosscheck.md) | FSSM/RDNA2 facts cross-checked against SCARAB; code starts at `code_off + 0x28`. | 74| [fssm_crosscheck.md](fssm_crosscheck.md) | FSSM/RDNA2 facts cross-checked against SCARAB; code starts at `code_off + 0x28`. |
75| [fspx.md](fspx.md) | `FSPX`, the FidelityFX DLL's native compute programs (its shaders' `ACCC` part): directory as the DLL reads it, kind-0 dispatch state, the hash prologue, `gfx1030` for its `v_dot4` code; 13 of 29 translate with `tools/fspx_unpack.py`. | 75| [fspx.md](fspx.md) | `FSPX`, the FidelityFX DLL's native compute programs (its shaders' `ACCC` part): directory as the DLL reads it, kind-0 dispatch state, the hash prologue, `gfx1030` for its `v_dot4` code; 13 of 29 translate with `tools/fspx_unpack.py`. |
76| [embedded_shaders.md](embedded_shaders.md) | DXBC containers embedded in the package's DLLs: 52 in `XboxBvhBuilder.dll` (console `FSSM` via the `XDAT`/`XBCH` record; 41/52 pass `spirv-val` today) and 29 `ACCC`/`FSPX` in the FidelityFX upscaler; the scan/extract tool and the four rules still missing. |
76| [coder.md](coder.md) | The compressed mass in `story000_script.rpf`: entry framing (`align16(entry+8)` payload), the 32-value tag alphabet, deflate-shaped but proprietary, variable-length 7/8-bit LSB-first codes with no stored table, and the `n7 = 116..127` search that finishes it. | 77| [coder.md](coder.md) | The compressed mass in `story000_script.rpf`: entry framing (`align16(entry+8)` payload), the 32-value tag alphabet, deflate-shaped but proprietary, variable-length 7/8-bit LSB-first codes with no stored table, and the `n7 = 116..127` search that finishes it. |
77| [mission_logic.md](mission_logic.md) | Mission state tables: 0x20 record layout (band counter, byte offsets), the 64-byte pool element with world transforms, case-folding joaat keys, 53.5 % of states named, 113 state-set clusters covering 82.4 % of files. | 78| [mission_logic.md](mission_logic.md) | Mission state tables: 0x20 record layout (band counter, byte offsets), the 64-byte pool element with world transforms, case-folding joaat keys, 53.5 % of states named, 113 state-set clusters covering 82.4 % of files. |
78 79
diff --git a/docs/d3d12_vulkan.md b/docs/d3d12_vulkan.md
index e96dcae72..ca5ebf10d 100644
--- a/docs/d3d12_vulkan.md
+++ b/docs/d3d12_vulkan.md
@@ -1383,12 +1383,13 @@ The trace will enumerate them.
1383- `D3D12_FEATURE_LEVELS`: report the highest feature level the Vulkan device can satisfy (12_2 when mesh/RT 1383- `D3D12_FEATURE_LEVELS`: report the highest feature level the Vulkan device can satisfy (12_2 when mesh/RT
1384 features are present). 1384 features are present).
1385- `D3D12_FEATURE_SHADER_MODEL`: answer the shader model the layer can honour, not the driver's maximum. Nothing in 1385- `D3D12_FEATURE_SHADER_MODEL`: answer the shader model the layer can honour, not the driver's maximum. Nothing in
1386 the runtime compiles DXIL: the game's shaders arrive as SPIR-V from the offline translator, and the only DXIL path 1386 the runtime compiles DXIL: the game's shaders arrive as SPIR-V from the offline translator, and the BVH
1387 (the BVH builder) is lowered to standard DXIL, whose baseline is 6.0. A request above it is clamped down to 6.0, 1387 builder's container also carries a console FSSM program that the same translator handles. A request above 6.0 is
1388 a request for 5.1 is answered with 5.1 (D3D12's own baseline, which a caller asking for the minimum expects), and a 1388 clamped down to 6.0, a request for 5.1 is answered with 5.1 (D3D12's own baseline, which a caller asking for the
1389 value below 5.1 is refused with `E_INVALIDARG`. Measured against the host PC runtime (616.86) on an RTX 5070: 1389 minimum expects), and a value below 5.1 is refused with `E_INVALIDARG`. Measured against the host PC runtime
1390 5.1-6.8 echo the request, 6.9 clamps to 6.8, and `0` is `E_INVALIDARG`; `0x5f` crashed the host runtime, which the 1390 (616.86) on an RTX 5070: 5.1-6.8 echo the request, 6.9 clamps to 6.8, and `0` is `E_INVALIDARG`; `0x5f` crashed
1391 test records in a comment rather than repeating. WARP answers a 5.1 request the same way. 1391 the host runtime, which the test records in a comment rather than repeating. WARP answers a 5.1 request the same
1392 way.
1392- `D3D12_FEATURE_ROOT_SIGNATURE`: 1.1, the version the proxy can always produce. A 1.2 blob is rewritten as 1.1 when 1393- `D3D12_FEATURE_ROOT_SIGNATURE`: 1.1, the version the proxy can always produce. A 1.2 blob is rewritten as 1.1 when
1393 the host's serializer stops at 1.1 and nothing is lost (`d3d12_xs_rootsig.cpp`), and Windows 10's `d3d12.dll` stops 1394 the host's serializer stops at 1.1 and nothing is lost (`d3d12_xs_rootsig.cpp`), and Windows 10's `d3d12.dll` stops
1394 there, so 1.1 is what the game can rely on everywhere. A higher request is clamped down like the shader model, and 1395 there, so 1.1 is what the game can rely on everywhere. A higher request is clamped down like the shader model, and
@@ -2150,24 +2151,24 @@ own names use the `XDXR` prefix for Xbox's raytracing path:
2150 node format: node id = address >> 3 | type, box16/box32/triangle nodes, 256-byte base units. That is the format 2151 node format: node id = address >> 3 | type, box16/box32/triangle nodes, 256-byte base units. That is the format
2151 the runtime must produce for the game's compute traversal. 2152 the runtime must produce for the game's compute traversal.
2152 2153
2153**The builder's own shaders are a separate problem.** They are Xbox DXIL using `@xbox.*` intrinsics, not FSSM 2154**The builder's own shaders are console FSSM, not Xbox DXIL.** Each of the 52 containers carries an LLVM
2154RDNA2: prior art found 44 of the 53 call non-standard `@xbox.*` functions and fail the PC D3D12 shader compiler, 2155bitcode blob and an `XDAT`/`XBCH` record; the PC experiment below compiled the bitcode, but the console runtime
2155and 22 have been lowered to standard DXIL and accepted as pipelines on an RX 7800 XT. Thirty-one of the 53 use raw 2156executes the `XBCH` record. Measured from that record: 52/52 unpack to `FSSM`, 42 translate and 41 pass
215664-bit addresses (global load/store/atomic and `s_load`), so lowering also needs an address-to-resource mapping. 2157`spirv-val` with the same translator the game's 26,503 shaders use; the 10 left need `global_atomic_fmax`/`fmin`,
2157The existing FSSM translator does not cover these shaders, and their results are not yet checked against a 2158`buffer_load_ushort` and `tbuffer_load_format_x` with format 8, plus one `OpSelectionMerge` emission bug
2158reference. If the game uses the builder, the layer needs a DXIL path (or a substitute builder); this is on the 2159([embedded_shaders.md](embedded_shaders.md)). The raw 64-bit addresses are the corpus's existing raw-address path,
2159critical path for the RT effects, not a footnote. 2160not a separate lowering. Open: whether the game uses the builder at all (RT-5) and whether the translated
2161programs match a reference on a GPU.
2160 2162
2161The design choice follows from that: **build AMD-format BVH data, not a `VkAccelerationStructureKHR`, unless the 2163The design choice follows from that: **build AMD-format BVH data, not a `VkAccelerationStructureKHR`, unless the
2162shaders are changed to `OpTraceRayKHR`.** The game's 64 RT compute shaders traverse the nodes themselves; a 2164shaders are changed to `OpTraceRayKHR`.** The game's 64 RT compute shaders traverse the nodes themselves; a
2163Vulkan AS would be invisible to them. Two paths: 2165Vulkan AS would be invisible to them. Two paths:
2164 2166
21651. If `XboxBvhBuilder` does the build with its own compute dispatches (the likely case, given it ships as a DLL 21671. If `XboxBvhBuilder` does the build with its own compute dispatches (the likely case, given it ships as a DLL
2166 with a device and command lists), the layer must translate and run its Xbox DXIL compute shaders — it cannot 2168 with a device and command lists), the layer must translate and run its compute shaders. The console programs
2167 feed DXIL to Vulkan directly. Buffers, UAVs, descriptors, barriers and indirect dispatch are necessary but not 2169 are `FSSM` and 41 of the 52 already pass `spirv-val`; the ten above still need their four rules. Buffers,
2168 sufficient; the 53 builder shaders need the DXIL path described above, and the 31 raw-address shaders need a 2170 UAVs, descriptors, barriers and indirect dispatch are necessary but not sufficient. The standard
2169 VA-to-resource mapping. The standard `BuildRaytracingAccelerationStructure` calls may never reach our command 2171 `BuildRaytracingAccelerationStructure` calls may never reach our command list.
2170 list.
21712. If the game calls `ID3D12GraphicsCommandList4::BuildRaytracingAccelerationStructure`, the layer must implement 21722. If the game calls `ID3D12GraphicsCommandList4::BuildRaytracingAccelerationStructure`, the layer must implement
2172 it. Produce the AMD node layout in the arena, with the same geometry/instance rules the translator assumes, 2173 it. Produce the AMD node layout in the arena, with the same geometry/instance rules the translator assumes,
2173 and make `GetRaytracingAccelerationStructurePrebuildInfo` return sizes for that layout. 2174 and make `GetRaytracingAccelerationStructurePrebuildInfo` return sizes for that layout.
@@ -2420,7 +2421,7 @@ M0–M2 do not need the executable.
2420| **M3** | Depth/stencil, multiple render targets, resource barriers, render passes, occlusion queries, fences, 2–3 frames in flight; run the game's first frames | Real frame structure and the first game code | The game reaches its first rendered frame (loading screen/menu or whatever the executable does) or stops on a single unsupported call with a clean report. **Synthetic part met** by `d3d12_m3_frame_test`: through the proxy, D3D12 API only, six frames through a ring of three slots (three frames in flight; each slot has its own allocator, list, targets, depth buffer, query and fence, and a frame waits with `SetEventOnCompletion` + an event for the fence its slot signalled three frames earlier before reading back and recording the slot again). Pass 1 draws three rectangles from root constants with translator-output shaders (`vs_m3.asm`, `ps_m3.asm`, hand-written RDNA2) through `OMSetRenderTargets` into two render targets (R8G8B8A8_UNORM and R32_FLOAT) and a `D24_UNORM_S8_UINT` depth/stencil buffer (the layer substitutes D32_SFLOAT_S8_UINT on the Radeon; the RTX has it natively): depth LESS with write, stencil REPLACE with references 1 and 2, then a draw with no depth test whose stencil test is EQUAL; the far rectangle runs inside `BeginQuery`/`EndQuery(OCCLUSION)` and `ResolveQueryData` writes its sample count to a readback buffer. Resource barriers move the first target RENDER_TARGET → PIXEL_SHADER_RESOURCE\|COPY_SOURCE and the second to COPY_SOURCE (and back at the next frame, from resources created in those states). Pass 2 samples the first target through an SRV in a descriptor table (the M2 path) with `ps_m3_post.asm` into a third target. Every pixel of all three targets (the float one bit for bit) matches the CPU reference with error 0 in each of the six frames, and the occlusion count equals the exact visible area of the far rectangle in each frame (3555 samples over the six frames); validation (with synchronization validation) clean on the AMD Radeon 880M and the RTX 5070 Laptop. **Still open for M3:** render passes (`BeginRenderPass`, D3D-27) are not exercised, nor `BINARY_OCCLUSION`, occlusion during pipeline statistics (D3D-162), MSAA or depth/stencil copies and read-only DSV states in this test; the game's own first frames need the executable | 2421| **M3** | Depth/stencil, multiple render targets, resource barriers, render passes, occlusion queries, fences, 2–3 frames in flight; run the game's first frames | Real frame structure and the first game code | The game reaches its first rendered frame (loading screen/menu or whatever the executable does) or stops on a single unsupported call with a clean report. **Synthetic part met** by `d3d12_m3_frame_test`: through the proxy, D3D12 API only, six frames through a ring of three slots (three frames in flight; each slot has its own allocator, list, targets, depth buffer, query and fence, and a frame waits with `SetEventOnCompletion` + an event for the fence its slot signalled three frames earlier before reading back and recording the slot again). Pass 1 draws three rectangles from root constants with translator-output shaders (`vs_m3.asm`, `ps_m3.asm`, hand-written RDNA2) through `OMSetRenderTargets` into two render targets (R8G8B8A8_UNORM and R32_FLOAT) and a `D24_UNORM_S8_UINT` depth/stencil buffer (the layer substitutes D32_SFLOAT_S8_UINT on the Radeon; the RTX has it natively): depth LESS with write, stencil REPLACE with references 1 and 2, then a draw with no depth test whose stencil test is EQUAL; the far rectangle runs inside `BeginQuery`/`EndQuery(OCCLUSION)` and `ResolveQueryData` writes its sample count to a readback buffer. Resource barriers move the first target RENDER_TARGET → PIXEL_SHADER_RESOURCE\|COPY_SOURCE and the second to COPY_SOURCE (and back at the next frame, from resources created in those states). Pass 2 samples the first target through an SRV in a descriptor table (the M2 path) with `ps_m3_post.asm` into a third target. Every pixel of all three targets (the float one bit for bit) matches the CPU reference with error 0 in each of the six frames, and the occlusion count equals the exact visible area of the far rectangle in each frame (3555 samples over the six frames); validation (with synchronization validation) clean on the AMD Radeon 880M and the RTX 5070 Laptop. **Still open for M3:** render passes (`BeginRenderPass`, D3D-27) are not exercised, nor `BINARY_OCCLUSION`, occlusion during pipeline statistics (D3D-162), MSAA or depth/stencil copies and read-only DSV states in this test; the game's own first frames need the executable |
2421| **M4** | Compute PSOs, UAVs, storage images, indirect dispatch, copy queues, async streaming | Asset loading and GPU compute | The world's streaming path runs without device loss; compute results match a CPU/reference check | 2422| **M4** | Compute PSOs, UAVs, storage images, indirect dispatch, copy queues, async streaming | Asset loading and GPU compute | The world's streaming path runs without device loss; compute results match a CPU/reference check |
2422| **M5** | Mesh shaders, `ExecuteIndirect`, bindless-table pressure, multi-threaded command lists, pipeline cache | World rendering | A stable open-world frame at any frame rate; then profile and optimise | 2423| **M5** | Mesh shaders, `ExecuteIndirect`, bindless-table pressure, multi-threaded command lists, pipeline cache | World rendering | A stable open-world frame at any frame rate; then profile and optimise |
2423| **M6** | Ray tracing/XDXR: standard AS builds or the shipped `XboxBvhBuilder` compute path; BVH node format; Xbox DXIL path for the builder's 53 shaders (22 lowered so far) | RT shadows and any RT effects | RT output matches a reference; the builder's shaders run through the DXIL path or a substitute; no unknown XDXR call remains | 2424| **M6** | Ray tracing/XDXR: standard AS builds or the shipped `XboxBvhBuilder` compute path; BVH node format; the builder's 52 console `FSSM` programs (41 pass `spirv-val`, four rules left: [embedded_shaders.md](embedded_shaders.md)) | RT shadows and any RT effects | RT output matches a reference; the builder's shaders run through the `FSSM` translator or a substitute; no unknown XDXR call remains |
2424| **M7** | HDR, VRS, `PresentX` planes (2-plane HDR + GameDVR compose, `ImmediateThresholdPercent`), resize, alt-tab, `SuspendX`/`ResumeX`, frame pacing and `GetFrameStatisticsX` | Presentation polish | HDR and resize work on the target display; no validation errors over a long run. **Partly met:** `ImmediateThresholdPercent` (late frame flipped at once through `VK_KHR/EXT_swapchain_maintenance1` IMMEDIATE/FIFO_RELAXED, section 4.5; checked on the fake-clock decision and on the Vulkan present mode, 0 VUIDs in our runs with `LEONIDA_VK_VALIDATION=1` on two GPUs, no tearing observed on a display; the console's real semantics are unmeasured). `SuspendX`/`ResumeX`, frame pacing and a minimal `GetFrameStatisticsX` exist; HDR, VRS, plane compose, alt-tab are open | 2425| **M7** | HDR, VRS, `PresentX` planes (2-plane HDR + GameDVR compose, `ImmediateThresholdPercent`), resize, alt-tab, `SuspendX`/`ResumeX`, frame pacing and `GetFrameStatisticsX` | Presentation polish | HDR and resize work on the target display; no validation errors over a long run. **Partly met:** `ImmediateThresholdPercent` (late frame flipped at once through `VK_KHR/EXT_swapchain_maintenance1` IMMEDIATE/FIFO_RELAXED, section 4.5; checked on the fake-clock decision and on the Vulkan present mode, 0 VUIDs in our runs with `LEONIDA_VK_VALIDATION=1` on two GPUs, no tearing observed on a display; the console's real semantics are unmeasured). `SuspendX`/`ResumeX`, frame pacing and a minimal `GetFrameStatisticsX` exist; HDR, VRS, plane compose, alt-tab are open |
2425 2426
2426### 6.1 Minimum API set for the first frame 2427### 6.1 Minimum API set for the first frame
@@ -2474,7 +2475,7 @@ DLLs were executed against a PC D3D12 device through the Xbox-ABI proxy.
2474| Xbox root-signature descriptors carry flags `0x03000000`. The PC serializer rejects them with `E_INVALIDARG`; the proxy clears the high byte on a copy. The v1.0 `D3D12SerializeRootSignature` path keeps flags at +32, and `0x3000001` also fails on the PC runtime. | *Run* — [PLATFORM_SURFACE.md](https://github.com/realdody/americas-recomp/blob/xbox-series/docs/xbox/PLATFORM_SURFACE.md) | Narrows the root-signature reflection risk. Mask the high byte on a private copy; the meaning of the bits remains **Open**. See section 3.5. | 2475| Xbox root-signature descriptors carry flags `0x03000000`. The PC serializer rejects them with `E_INVALIDARG`; the proxy clears the high byte on a copy. The v1.0 `D3D12SerializeRootSignature` path keeps flags at +32, and `0x3000001` also fails on the PC runtime. | *Run* — [PLATFORM_SURFACE.md](https://github.com/realdody/americas-recomp/blob/xbox-series/docs/xbox/PLATFORM_SURFACE.md) | Narrows the root-signature reflection risk. Mask the high byte on a private copy; the meaning of the bits remains **Open**. See section 3.5. |
2475| The BVH builder's constructor creates 53 compute pipelines through device slot 62, called with a compute-PSO shape (a plain `D3D12_COMPUTE_PIPELINE_STATE_DESC`, two zero words, iid, out). On the PC interface the prior art forwards to, slot 62 is `CreateStateObject` (wrong arity), so the proxy overrides it. | *Run* — [PLATFORM_SURFACE.md](https://github.com/realdody/americas-recomp/blob/xbox-series/docs/xbox/PLATFORM_SURFACE.md) | Corrects the assumption that the whole device vtable is public order. Slot 62 must be compute-PSO creation for the builder, not a state object. Slots 1/15/18/19/27/38 did match the desktop order. | 2476| The BVH builder's constructor creates 53 compute pipelines through device slot 62, called with a compute-PSO shape (a plain `D3D12_COMPUTE_PIPELINE_STATE_DESC`, two zero words, iid, out). On the PC interface the prior art forwards to, slot 62 is `CreateStateObject` (wrong arity), so the proxy overrides it. | *Run* — [PLATFORM_SURFACE.md](https://github.com/realdody/americas-recomp/blob/xbox-series/docs/xbox/PLATFORM_SURFACE.md) | Corrects the assumption that the whole device vtable is public order. Slot 62 must be compute-PSO creation for the builder, not a state object. Slots 1/15/18/19/27/38 did match the desktop order. |
2476| A reusable `xbox_device_proxy.h` forwards every slot to a PC object, counts hits per slot and logs first calls with `XS_TRACE=1`; the observed device slots include 1, 14, 15, 16, 18, 19, 27, 38, 62 and 76. Their `xgr` stand-in covers 48 of 398 methods; Xodus (LGPL-2.1) covers 152 of 396 via IDL-generated stubs. | *Run* — [platform README](https://github.com/realdody/americas-recomp/blob/xbox-series/tools/xbox/platform/README.md), [PLATFORM_SURFACE.md](https://github.com/realdody/americas-recomp/blob/xbox-series/docs/xbox/PLATFORM_SURFACE.md) | Confirms the trace-first approach and shows the long tail. We adopt the *method* (per-slot counters, first-call logging), not the code. | 2477| A reusable `xbox_device_proxy.h` forwards every slot to a PC object, counts hits per slot and logs first calls with `XS_TRACE=1`; the observed device slots include 1, 14, 15, 16, 18, 19, 27, 38, 62 and 76. Their `xgr` stand-in covers 48 of 398 methods; Xodus (LGPL-2.1) covers 152 of 396 via IDL-generated stubs. | *Run* — [platform README](https://github.com/realdody/americas-recomp/blob/xbox-series/tools/xbox/platform/README.md), [PLATFORM_SURFACE.md](https://github.com/realdody/americas-recomp/blob/xbox-series/docs/xbox/PLATFORM_SURFACE.md) | Confirms the trace-first approach and shows the long tail. We adopt the *method* (per-slot counters, first-call logging), not the code. |
2477| The BVH builder's 53 compute shaders are Xbox DXIL with `@xbox.*` intrinsics; 44 of 53 fail the PC D3D12 shader compiler, 22 have been lowered to standard DXIL and accepted as pipelines, and 31 use raw 64-bit GPU addresses. | *Run* — [PLATFORM_SURFACE.md](https://github.com/realdody/americas-recomp/blob/xbox-series/docs/xbox/PLATFORM_SURFACE.md) | A separate translation path from the FSSM RDNA2 corpus. See section 4.8 and the paragraph below. | 2478| The BVH builder's 53 compute shaders are Xbox DXIL with `@xbox.*` intrinsics; 44 of 53 fail the PC D3D12 shader compiler, 22 have been lowered to standard DXIL and accepted as pipelines, and 31 use raw 64-bit GPU addresses. | *Run* — [PLATFORM_SURFACE.md](https://github.com/realdody/americas-recomp/blob/xbox-series/docs/xbox/PLATFORM_SURFACE.md) | A separate translation path from the FSSM RDNA2 corpus when measured on the **bitcode**. Measured later on the console `XBCH` record of the same containers: 52 programs, 41 pass `spirv-val` through the FSSM translator ([embedded_shaders.md](embedded_shaders.md)). |
2478 2479
2479### 7.1 What this confirms, corrects and narrows 2480### 7.1 What this confirms, corrects and narrows
2480 2481
@@ -2503,9 +2504,9 @@ DLLs were executed against a PC D3D12 device through the Xbox-ABI proxy.
2503 Xbox value and slot 76. 2504 Xbox value and slot 76.
2504- **Root signatures.** The `0x03000000` flags must be masked on a copy before the host serializer/deserializer. 2505- **Root signatures.** The `0x03000000` flags must be masked on a copy before the host serializer/deserializer.
2505 Our earlier "forward the blob to the host" was too simple; the PC serializer rejects the Xbox bits. 2506 Our earlier "forward the blob to the host" was too simple; the PC serializer rejects the Xbox bits.
2506- **BVH builder.** Its shaders are Xbox DXIL, not FSSM. "Run the builder's dispatches" therefore needs a DXIL 2507- **BVH builder.** Its console programs are `FSSM`; the bitcode in the same container is the representation the
2507 translation/lowering path plus an address-to-resource mapping for the raw-address shaders; the FSSM translator 2508 PC compiler consumed. "Run the builder's dispatches" therefore takes the same FSSM → SPIR-V path as the game,
2508 does not cover them. 2509 with four rules still missing ([embedded_shaders.md](embedded_shaders.md)).
2509 2510
2510**Narrows.** 2511**Narrows.**
2511 2512
@@ -2520,16 +2521,18 @@ DLLs were executed against a PC D3D12 device through the Xbox-ABI proxy.
2520- The `xgr` 48/398 and Xodus 152/396 coverage numbers show how large the long tail is. They do not change the 2521- The `xgr` 48/398 and Xodus 152/396 coverage numbers show how large the long tail is. They do not change the
2521 plan: implement what the game calls, in the order it calls it. 2522 plan: implement what the game calls, in the order it calls it.
2522 2523
2523### 7.2 The BVH builder's Xbox DXIL path 2524### 7.2 The BVH builder's shader path
2524 2525
2525The builder's 53 compute shaders are a second shader front end. They are Xbox DXIL with `@xbox.*` intrinsics that 2526The builder's 52 compute shaders are a second *corpus*, not a second shader front end. Each container carries an
2526map one-to-one to RDNA instructions (global load/store/atomic with 64-bit addresses, `s_load`, min/med/max, 2527LLVM bitcode blob and an `XDAT`/`XBCH` record; the bitcode is what the PC D3D12 compiler experiment consumed
2527bitfield insert, alignbyte, cndmask, packed f16 min/max and lane/wave operations). The standard PC DXIL compiler 2528(44 of 53 rejected, 22 lowered), while the console runtime executes the `XBCH` record. That record decompresses
2528rejects 44 of the 53; 22 have been lowered to standard DXIL and compile; the 31 that use raw 64-bit addresses also 2529to `FSSM`, the same container the game's own compute shaders use: 52/52 unpack, 42 translate and 41 pass
2529need a table mapping those addresses to resources. This is separate from the FSSM RDNA2 translator, which covers 2530`spirv-val` with `tools/rdna2spirv.py`. The 10 left stop at `global_atomic_fmax`/`fmin` (6 programs),
2530the game's 26,503 shaders. A port that uses `XboxBvhBuilder` needs both: FSSM → SPIR-V for the game, and an Xbox 2531`buffer_load_ushort` (3) and `tbuffer_load_format_x` with format 8 (1), plus the `FindTreelets` assembly error;
2531DXIL → standard DXIL → SPIR-V path (or a substitute builder) for the BVH helper. The prior art has compiled 2532[embedded_shaders.md](embedded_shaders.md) lists them. The raw 64-bit addresses are the translator's existing
2532lowered shaders but has no reference output yet, so correctness is unverified. 2533raw-address path, so no address-to-resource table is needed on top. A port that runs `XboxBvhBuilder` therefore
2534needs the FSSM translator plus four rules, not a DXIL front end (a substitute builder remains the alternative).
2535Correctness is still unverified on a GPU and the call sites need the executable (RT-5).
2533 2536
2534### 7.3 Licence 2537### 7.3 Licence
2535 2538
@@ -2552,7 +2555,7 @@ Xodus is LGPL-2.1 and is cited only for its coverage number, not as a code sourc
2552 absent executable. 2555 absent executable.
2553- The prior art's measured Xbox ABI (section 7): 6 Xbox-specific static imports across the 16 DLLs, 2556- The prior art's measured Xbox ABI (section 7): 6 Xbox-specific static imports across the 16 DLLs,
2554 `D3D12XboxCreateDevice`, device slots 62/76, descriptor-heap start handles in RAX, root-signature flags 2557 `D3D12XboxCreateDevice`, device slots 62/76, descriptor-heap start handles in RAX, root-signature flags
2555 `0x03000000`, and the BVH builder's Xbox DXIL shaders. 2558 `0x03000000`, and the BVH builder's container format (a DXIL bitcode blob plus the console `XBCH` record).
2556 2559
2557### 8.2 Unknown / open questions 2560### 8.2 Unknown / open questions
2558 2561
@@ -2564,7 +2567,7 @@ Xodus is LGPL-2.1 and is cited only for its coverage number, not as a code sourc
2564| 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. | 2567| 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. |
2565| 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. | 2568| 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. |
2566| 6 | Which swapchain/present path is used: DXGI, `PresentX`, or both? | **Partly answered from public samples (§4.5):** GDKX samples use `PresentX` + frame events and no DXGI swapchain (DXGI only for `IDXGIDevice1`→adapter→output). Hypothesis for the game, not observed: same. Still open: vtable slots, `D3D12XBOX_*` layouts, and whether the game also creates a swapchain. Check imports and the first present call. Implement the `PresentX` + frame-event presenter first; keep DXGI swapchain as fallback. | 2569| 6 | Which swapchain/present path is used: DXGI, `PresentX`, or both? | **Partly answered from public samples (§4.5):** GDKX samples use `PresentX` + frame events and no DXGI swapchain (DXGI only for `IDXGIDevice1`→adapter→output). Hypothesis for the game, not observed: same. Still open: vtable slots, `D3D12XBOX_*` layouts, and whether the game also creates a swapchain. Check imports and the first present call. Implement the `PresentX` + frame-event presenter first; keep DXGI swapchain as fallback. |
2567| 7 | Does the game build acceleration structures through the standard D3D12 calls or through `XboxBvhBuilder`'s own compute path? | Log `BuildRaytracingAccelerationStructure`, `CopyRaytracingAccelerationStructure`, `Emit...PostbuildInfo`, and the builder's command-list method calls on the first RT frame. The builder's 53 shaders are Xbox DXIL; 44/53 fail the PC compiler and 22 have been lowered. If the builder path is used, the layer needs a DXIL plan. | 2570| 7 | Does the game build acceleration structures through the standard D3D12 calls or through `XboxBvhBuilder`'s own compute path? | Log `BuildRaytracingAccelerationStructure`, `CopyRaytracingAccelerationStructure`, `Emit...PostbuildInfo`, and the builder's command-list method calls on the first RT frame. The builder's container carries a DXIL bitcode blob and a console `XBCH` record; the record is `FSSM` and 41 of 52 programs pass `spirv-val` ([embedded_shaders.md](embedded_shaders.md)). If the builder path is used, translate the `XBCH` record rather than the bitcode. |
2568| 8 | What are the layouts of `D3D12XBOX_XDXR_STREAM_DESC`, the batched build desc, and the offline statistics desc? | **Measured** from `XboxBvhBuilder.dll`'s reads ([xdxr.md](xdxr.md)): `BATCHED_DESC2` (`0x50`) and `XDXR_STREAM_DESC` (`0x10`) with every field's offset, and the stream records' offsets, types and defaults. Still open: the record names, and the offline statistics layout, which the DLL never writes (it rejects that postbuild type). | 2571| 8 | What are the layouts of `D3D12XBOX_XDXR_STREAM_DESC`, the batched build desc, and the offline statistics desc? | **Measured** from `XboxBvhBuilder.dll`'s reads ([xdxr.md](xdxr.md)): `BATCHED_DESC2` (`0x50`) and `XDXR_STREAM_DESC` (`0x10`) with every field's offset, and the stream records' offsets, types and defaults. Still open: the record names, and the offline statistics layout, which the DLL never writes (it rejects that postbuild type). |
2569| 9 | Xbox texture creation is device slot 76 with layout `0x101` (tiled) or `0x1` (row-major). What is the tiled data layout, and does the game upload console-tiled or DCC data? | Trace slot 76, `CopyTextureRegion` and the resource descs. If the game uploads console-tiled data, add a detile step or a matching layout. | 2572| 9 | Xbox texture creation is device slot 76 with layout `0x101` (tiled) or `0x1` (row-major). What is the tiled data layout, and does the game upload console-tiled or DCC data? | Trace slot 76, `CopyTextureRegion` and the resource descs. If the game uploads console-tiled data, add a detile step or a matching layout. |
2570| 11 | What should `CheckFeatureSupport` answer for UMA, resource binding tier, mesh tier, RT tier? | **Implemented** (D3D-11). Reports truthful host architecture (discrete desktop GPU: non-UMA), ResourceBindingTier 3 (descriptor indexing / bindless support), 48-bit GPU virtual address support matching the arena, and maps `D3D12_FEATURE_FORMAT_SUPPORT` to Vulkan format properties plus multisample render-target/resolve support and one quality level per supported sample count. | 2573| 11 | What should `CheckFeatureSupport` answer for UMA, resource binding tier, mesh tier, RT tier? | **Implemented** (D3D-11). Reports truthful host architecture (discrete desktop GPU: non-UMA), ResourceBindingTier 3 (descriptor indexing / bindless support), 48-bit GPU virtual address support matching the arena, and maps `D3D12_FEATURE_FORMAT_SUPPORT` to Vulkan format properties plus multisample render-target/resolve support and one quality level per supported sample count. |
@@ -2577,7 +2580,7 @@ Xodus is LGPL-2.1 and is cited only for its coverage number, not as a code sourc
2577| 17 | Do upload/readback resources ever reach shaders (as vertex/index buffers or descriptors), and does the `-heap_base` bias work for them? | Trace `CreateCommittedResource` heap types and every VB/IB/descriptor that points at an upload resource; test the bias with a synthetic draw. | 2580| 17 | Do upload/readback resources ever reach shaders (as vertex/index buffers or descriptors), and does the `-heap_base` bias work for them? | Trace `CreateCommittedResource` heap types and every VB/IB/descriptor that points at an upload resource; test the bias with a synthetic draw. |
2578| 18 | Does the game alias buffers/images in a heap, or use reserved/tiled resources? | Trace `CreatePlacedResource` ranges, aliasing barriers, `CreateReservedResource` and tile mappings. If yes, implement shared memory per heap range or fall back to linear allocations with a clear log. Shaders: 30 declare `TILED_RESOURCES` in SFI0 (`tools/feature_scan.py`), so reserved/tiled resources are likely used. Placed resources are D3D-16 and reserved resources D3D-20 (#313). | 2581| 18 | Does the game alias buffers/images in a heap, or use reserved/tiled resources? | Trace `CreatePlacedResource` ranges, aliasing barriers, `CreateReservedResource` and tile mappings. If yes, implement shared memory per heap range or fall back to linear allocations with a clear log. Shaders: 30 declare `TILED_RESOURCES` in SFI0 (`tools/feature_scan.py`), so reserved/tiled resources are likely used. Placed resources are D3D-16 and reserved resources D3D-20 (#313). |
2579| 19 | What do the `0x03000000` root-signature flag bits mean? | Masking them on a copy works around the PC serializer; the semantics remain unknown. Compare against the public flag enum and observe the game's behaviour with and without the mask. | 2582| 19 | What do the `0x03000000` root-signature flag bits mean? | Masking them on a copy works around the PC serializer; the semantics remain unknown. Compare against the public flag enum and observe the game's behaviour with and without the mask. |
2580| 20 | Which of the BVH builder's 53 Xbox DXIL shaders does the game actually use, and can the 31 raw-address shaders be lowered without a reference? | Dump the slot-62 compute PSOs on the first RT frame; lower and compile each; compare against the builder's CPU validation (`CpuValidateResultX`) or a captured reference. | 2583| 20 | Which of the BVH builder's 52 `FSSM` programs does the game actually use, and do the translated programs match a reference? | Dump the slot-62 compute PSOs on the first RT frame and map each to its container by the `ILDN` name; 41/52 pass `spirv-val` today and the four missing rules are named in [embedded_shaders.md](embedded_shaders.md); compare against the builder's CPU validation (`CpuValidateResultX`) or a captured reference. |
2581| 21 | Which `Metadata` values and blob format does the console's PIX use for `SetMarker`/`BeginEvent`? The layer reads 0 and 1 as strings and labels 2 (the PC PIX3 blob) `PIX event` (section 4.10). | Log the `Metadata` values the game passes; if it is 2, decode the console blob from the executable's PIX calls rather than assuming the PC WinPixEventRuntime layout. | 2584| 21 | Which `Metadata` values and blob format does the console's PIX use for `SetMarker`/`BeginEvent`? The layer reads 0 and 1 as strings and labels 2 (the PC PIX3 blob) `PIX event` (section 4.10). | Log the `Metadata` values the game passes; if it is 2, decode the console blob from the executable's PIX calls rather than assuming the PC WinPixEventRuntime layout. |
2582 2585
2583## 9. Risks and non-goals 2586## 9. Risks and non-goals
@@ -2605,9 +2608,10 @@ Xodus is LGPL-2.1 and is cited only for its coverage number, not as a code sourc
2605 the layer. 2608 the layer.
2606- **Xbox tiling/DCC.** Slot 76 and layout `0x101` are known, but the tiled data layout, detile path and DCC remain 2609- **Xbox tiling/DCC.** Slot 76 and layout `0x101` are known, but the tiled data layout, detile path and DCC remain
2607 unknown. If the game assumes console tiling or compression metadata, the layer needs a detile/repack step. 2610 unknown. If the game assumes console tiling or compression metadata, the layer needs a detile/repack step.
2608- **BVH builder DXIL.** 44 of the builder's 53 Xbox DXIL shaders fail the PC compiler; 22 have been lowered to 2611- **BVH builder shaders.** The container's DXIL bitcode is Xbox DXIL that PC drivers reject; its console `XBCH`
2609 standard DXIL and compile, and 31 use raw 64-bit addresses. The lowered shaders have no reference output yet, and 2612 record is `FSSM`, and 41 of the 52 programs already pass `spirv-val` through the same translator as the game
2610 this is a separate front end from the FSSM translator. 2613 ([embedded_shaders.md](embedded_shaders.md)). The 10 left need four small rules. Translation is not execution:
2614 there is no GPU reference for any of the 52 yet.
2611- **Ray tracing.** The game's RT work includes 64 compute shaders that traverse AMD-format BVH nodes, and it ships 2615- **Ray tracing.** The game's RT work includes 64 compute shaders that traverse AMD-format BVH nodes, and it ships
2612 a BVH builder; a standard D3D12 AS path may also exist. If it is used, the layer must build AMD-format nodes, not 2616 a BVH builder; a standard D3D12 AS path may also exist. If it is used, the layer must build AMD-format nodes, not
2613 a Vulkan AS. 2617 a Vulkan AS.
@@ -2725,8 +2729,8 @@ on a PC device behind the Xbox-ABI proxy). Measured:
2725 `(desc, riid, out)`, so the first call returned `E_POINTER` and the constructor threw it. 2729 `(desc, riid, out)`, so the first call returned `E_POINTER` and the constructor threw it.
2726- With slot 62 read that way, on **WARP** the constructor returns after 62 ms: 17 root signatures (slot 16) and 53 2730- With slot 62 read that way, on **WARP** the constructor returns after 62 ms: 17 root signatures (slot 16) and 53
2727 compute PSOs (slot 62, 53 of 53 `S_OK`), CS bytecode 4–75 KB each. `~XboxBvhBuilder` returns and makes no device 2731 compute PSOs (slot 62, 53 of 53 `S_OK`), CS bytecode 4–75 KB each. `~XboxBvhBuilder` returns and makes no device
2728 call. Created is not the same as correct: the shaders are Xbox DXIL with `@xbox.*` intrinsics (section 7.2), and 2732 call. Created is not the same as correct: the container's DXIL bitcode is Xbox DXIL with `@xbox.*` intrinsics
2729 nothing has been dispatched yet. 2733 (section 7.2), its console `XBCH` record is `FSSM`, and nothing has been dispatched yet.
2730- **NVIDIA (RT-54).** On an RTX 3060 (616.64), an RTX 4090 (621.14) and an RTX 5070 Ti (621.24), all on Windows 11, 2734- **NVIDIA (RT-54).** On an RTX 3060 (616.64), an RTX 4090 (621.14) and an RTX 5070 Ti (621.24), all on Windows 11,
2731 the first 48 PSOs return `S_OK`, and the 49th (38,248 bytes) never does. Some runs return `E_OUTOFMEMORY` for it, 2735 the first 48 PSOs return `S_OK`, and the 49th (38,248 bytes) never does. Some runs return `E_OUTOFMEMORY` for it,
2732 which the constructor throws. Other runs end the process inside `nvwgf2umx.dll` with `0xC0000409`, after the 2736 which the constructor throws. Other runs end the process inside `nvwgf2umx.dll` with `0xC0000409`, after the
@@ -2734,7 +2738,7 @@ on a PC device behind the Xbox-ABI proxy). Measured:
2734 can't be caught. The D3D12 debug layer prints nothing first. 2738 can't be caught. The D3D12 debug layer prints nothing first.
2735 - **Cause: the input, not Leonida.** The proxy passes the bytecode through unchanged, so nothing is wrong in what 2739 - **Cause: the input, not Leonida.** The proxy passes the bytecode through unchanged, so nothing is wrong in what
2736 it forwards. The input is the problem: `LEONIDA_BVH_RECORD62=1 LEONIDA_BVH_DXIL=1` shows that every one of the 2740 it forwards. The input is the problem: `LEONIDA_BVH_RECORD62=1 LEONIDA_BVH_DXIL=1` shows that every one of the
2737 53 containers is signed, has the same 9 parts, and is shader model 6.5 / DXIL 1.5. But dxil.dll (Windows SDK 2741 53 PSO calls (52 distinct containers) is signed, has the same 9 parts, and is shader model 6.5 / DXIL 1.5. But dxil.dll (Windows SDK
2738 10.0.26100) rejects all 53 (`0x80aa0009`): the target triple is `dxil-ms-xb2` and the module carries 2742 10.0.26100) rejects all 53 (`0x80aa0009`): the target triple is `dxil-ms-xb2` and the module carries
2739 `xbox.compiler.options` metadata. Most also have Xbox-only externals (44 of 53), `extractvalue` on non-DXIL types 2743 `xbox.compiler.options` metadata. Most also have Xbox-only externals (44 of 53), `extractvalue` on non-DXIL types
2740 (16) or other disallowed instruction types (5). No PC driver has to accept this, and WARP happens to. 2744 (16) or other disallowed instruction types (5). No PC driver has to accept this, and WARP happens to.
@@ -2746,8 +2750,10 @@ on a PC device behind the Xbox-ABI proxy). Measured:
2746 So `bvh_builder_test` uses WARP whenever there is a hardware adapter, unless `LEONIDA_BVH_HARDWARE=1`, and it 2750 So `bvh_builder_test` uses WARP whenever there is a hardware adapter, unless `LEONIDA_BVH_HARDWARE=1`, and it
2747 prints the reason with the adapter's PCI vendor id. WARP creates all 53 PSOs, and the constructor and destructor 2751 prints the reason with the adapter's PCI vendor id. WARP creates all 53 PSOs, and the constructor and destructor
2748 return. 2752 return.
2749 - **The runtime itself still shouldn't hand Xbox DXIL to a PC driver.** These shaders need lowering to PC DXIL or a 2753 - **The runtime itself still shouldn't hand Xbox DXIL to a PC driver.** The same container carries the console
2750 translation of their own (section 7.2, M6) before they can run on hardware. 2754 `XBCH` record, which decompresses to `FSSM`; 41 of the 52 programs translate and pass `spirv-val` today
2755 ([embedded_shaders.md](embedded_shaders.md)). Translating that record is the path that avoids a DXIL lowering
2756 front end (section 7.2, M6); the bitcode is a second representation.
2751 2757
2752### A.3 `amd_fidelityfx_upscaler_xbox.dll` 2758### A.3 `amd_fidelityfx_upscaler_xbox.dll`
2753 2759
diff --git a/docs/embedded_shaders.md b/docs/embedded_shaders.md
new file mode 100644
index 000000000..0f74f0fc3
--- /dev/null
+++ b/docs/embedded_shaders.md
@@ -0,0 +1,125 @@
1# Shader containers embedded in the package's DLLs
2
3**Status: measured** on the 1.0.2.1 package. This note covers the shader programs that ship outside
4`shaders.rpf`: the DXBC containers inside the package's DLLs, what each one carries, and what the measurement
5changes for the ray-tracing and upscaling paths. No container, shader or payload is reproduced here; the tables
6hold counts, offsets, chunk names and module identifiers.
7
8## 1. Why they matter
9
10`make_game.py`'s `shaders` stage carves `shaders.rpf` only (`make_game.py`:655). Two DLLs in the same package
11carry compute programs of their own:
12
13* `XboxBvhBuilder.dll`, Microsoft's XDXR acceleration-structure builder. Its constructor creates compute PSOs
14 through device slot 62, and the builder is on the critical path for ray tracing.
15* `amd_fidelityfx_upscaler_xbox.dll`, the FidelityFX 4.1.1 upscaler. Its programs are the `ACCC`/`FSPX` format
16 covered in [fspx.md](fspx.md); this note only counts them.
17
18`tools/pe_shader_containers.py` scans a binary for DXBC containers, validates the chunk table, reads the `ILDN`
19module name and reports what each container carries. `--extract` writes the containers and an `index.json` the
20translator reads; extracted shaders are game data and must stay in the user's work folder.
21
22```sh
23python -I tools/pe_shader_containers.py <dll> --json <work>/containers.json --extract <work>/embedded/dxbc
24```
25
26## 2. Inventory
27
28The 16 DLLs and the package's root files were scanned. All the containers are in two DLLs:
29
30| image | containers | bytes | min / median / max | chunks |
31|---|---:|---:|---:|---|
32| `XboxBvhBuilder.dll` | 52 | 674,404 | 4,072 / 7,454 / 74,508 | `SFI0 ISG1 OSG1 PSV0 RTS0 STAT ILDN HASH DXIL` |
33| `amd_fidelityfx_upscaler_xbox.dll` | 29 | 289,656 | 1,764 / 5,176 / 42,616 | `SFI0 ISG1 OSG1 PSV0 RTS0 HASH ACCC` |
34| other 14 DLLs | 0 | 0 | — | — |
35
36The 29 `ACCC` containers hold `FSPX` payloads ([fspx.md](fspx.md)); the 52 `DXIL` containers are the subject of
37this note. The FSR DLL has one rejected `DXBC` hit: the bytes are an immediate in its own magic check, and the
38validator rejects it (the scan reports both counts).
39
40**Every one of the 52 containers carries two representations of its program:**
41
42* an LLVM bitcode blob in the `DXIL` chunk (`BC C0 DE`, 1,820 to 70,276 bytes), and
43* an `XDAT` directory with tag `0x0d` whose payload starts with `XBCH`: the console program. The same chunk also
44 holds tag `0x07` (a second `DXIL` program header) and tag `0x12` (a 16-byte hash). The `STAT` chunk holds a
45 second, different bitcode blob, not the same one.
46
47The bitcode is what a PC D3D12 compiler consumes; the runtime path is the `XBCH` record. The constructor passes
48the **whole container** to the compute-PSO call: at `0x180021330` it loads `DAT_180025700` with size `0x1134`
49(4,404 bytes, the size of container 0, `CopyAndCompactBVH`) and calls `FUN_18000c470`, whose vtable call at
50`+0x1f0` (slot 62) receives that pointer, its size and two zero words. `FUN_18001d400` adds two more PSOs,
51`XDXR PostBuildInfoQuery` (0x14a4 bytes) and `XDXR GetBVHCompactedSize`. `bvh_builder_test` measures **53** PSO
52creations during construction over the **52** containers ([d3d12_vulkan.md](d3d12_vulkan.md) A.2), so one
53container is created twice; which one is **Open**.
54
55## 3. The 52 modules
56
57The `ILDN` PDB path gives one module per container, all under
58`X:\americas\src\dev\rage\3rdparty\Microsoft\XboxBvhBuilder\Build\Release\Output\XboxBvhBuilder\` (Microsoft's
59component integrated into RAGE, not Rockstar shader code). Grouped by phase:
60
61| phase | modules |
62|---|---|
63| sort (11) | `BitonicPreSortCS`, `BitonicPreSort64CS`, `BitonicInnerSortCS`, `BitonicInnerSort64CS`, `BitonicOuterSortCS`, `BitonicOuterSort64CS`, `RadixCount`, `RadixAlloc`, `RadixReset`, `CalculateMortonCodes`, `CalculateMortonCodes64` |
64| prefix (7) | `PrefixSum64`, `PrefixSum128`, `PrefixSum256`, `PrefixSum512`, `PrefixSum1024`, `PrefixSum2048`, `PrefixSum4096` |
65| kdop (3) | `BuildKDOP`, `ResetKDOP`, `BuildApexPointMap` |
66| build (7) | `ConstructBVH4`, `BuildBVHSplits`, `BuildBVHSplits64`, `SplitInstances`, `FindTreelets`, `RearrangeBVHs`, `RearrangeTriangles` |
67| refit (2) | `RefitBVH4`, `CopyForBVHUpdate` |
68| load (6) | `LoadTriangles`, `ReloadTriangles`, `LoadInstances`, `LoadProceduralGeometry`, `ReloadProcedurals`, `ResetToIndexBuffer` |
69| path tracing (6) | `PT_ConstructBVH4`, `PT_BeginPass`, `PT_LoadInstances`, `PT_WriteInstances`, `PT_WritePartitions`, `PT_WriteOfflinePartition` |
70| rehydration (3) | `Box16Rehydration`, `Box32Rehydration`, `LeafRehydration` |
71| headers/util (7) | `DecompressHeader`, `InitHeaders`, `InitPartitionedHeaders`, `GetBVHCompactedSize`, `CopyCounters`, `ResetCounterValues`, `CopyAndCompactBVH` |
72
73## 4. They are console FSSM, and the existing translator already takes them
74
75The `XBCH` record has the same shape as the game's own shaders: `XBCH` + stored/unpacked sizes + a zlib stream
76that expands to `FSSM` ([fssm_crosscheck.md](fssm_crosscheck.md)). On all 52 containers:
77
78| step | result |
79|---|---|
80| `tools/fssm_unpack.py` | **52/52** decompress to a valid `FSSM` blob (716 B to 101,320 B, median 2,200 B) |
81| `tools/shader_disasm.py --mcpu gfx1013` | **52/52** disassemble; 42 with no invalid word, 10 with invalid words in the code |
82| `tools/rdna2spirv.py` | **42** translate to SPIR-V assembly; **41** assemble and pass `spirv-val` |
83
84The 10 untranslated programs stop at four rules, and the one SPIR-V assembly failure is a separate emission bug:
85
86| module(s) | blocker |
87|---|---|
88| `BuildKDOP`, `LoadInstances`, `ReloadProcedurals`, `LoadProceduralGeometry`, `LoadTriangles` | `global_atomic_fmax` |
89| `PT_LoadInstances` | `global_atomic_fmin` |
90| `Box16Rehydration`, `Box32Rehydration`, `ReloadTriangles` | `buffer_load_ushort` |
91| `LeafRehydration` | `tbuffer_load_format_x GFX10_FORMAT_8_UINT` |
92| `FindTreelets` | translates, but its assembly fails with `OpSelectionMerge must immediately precede either an OpBranchConditional...` |
93
94Reproduction, after `--extract` above:
95
96```sh
97python -I tools/fssm_unpack.py <work>/embedded/dxbc
98python -I tools/shader_disasm.py <work>/embedded/dxbc/fssm --out <work>/embedded/dxbc/disasm --mcpu gfx1013
99python -I tools/rdna2spirv.py <work>/embedded/dxbc/disasm --out <work>/embedded/spirv
100```
101
102## 5. What this changes
103
104* **The RT builder does not need a DXIL path for the console code.** Its programs are RDNA2 `FSSM`, and 41 of
105 52 already pass `spirv-val` with the translator the project uses for the game's 26,503 shaders. The bitcode in
106 the same container is a second representation (the one the PC-compiler experiment measured); it is not what
107 the console runtime executes.
108* **The four missing rules are small and have real fixtures.** `global_atomic_fmax`/`fmin` cover 6 programs,
109 `buffer_load_ushort` 3 and `tbuffer_load_format_x` with format 8 one. They are ordinary translator rules, not
110 a new compiler backend.
111* **The rehydration programs are the ones closest to the shipped data.** `Box16Rehydration`,
112 `Box32Rehydration` and `LeafRehydration` are exactly the programs that would turn the dehydrated BVH packs
113 into runtime trees ([bvh.md](bvh.md) §3.1). Two of the four rules stand between them and translation.
114* **What is still open.** None of the 52 has been executed on a GPU; translation and `spirv-val` do not prove the
115 output. Which of them the game actually creates is a call-site question (RT-5). The module-to-pipeline order
116 above comes from `ILDN`, not from a runtime trace. The `STAT` bitcode and the `0x07 NOBC` record are not
117 explained.
118
119## 6. Tool and tests
120
121`tools/pe_shader_containers.py` is standard library only and reads the file, never runs it. It accepts a
122container only when the chunk table is sorted, 4-byte aligned, entirely inside the declared total and its last
123chunk ends exactly at that total; that is what rejects the FSR DLL's `DXBC` immediate. The synthetic tests in
124`tests/test_pe_shader_containers.py` build containers by hand (no game data) and cover the accepted layout, a
125bare magic, a truncated chunk, an `ACCC`/`FSPX` container, the `ILDN` name and the extraction index.