diff options
| author | Diesel <dev.diesel@proton.me> | 2026-11-21 22:44:07 +0100 |
|---|---|---|
| committer | Diesel <dev.diesel@proton.me> | 2026-11-21 22:44:07 +0100 |
| commit | 5c1a1fbb6bf6f609eb4e61baa4961ce382743a4e (patch) | |
| tree | ac8ad90058b97ab241fdc65edae3d4628d20ee1e /docs | |
| parent | c45309e29f21c1d5b75678db0e2dc2dd11cff25b (diff) | |
| parent | 4e390e0871d7265e629b51aca8ff99a15a6a6845 (diff) | |
Merge main to include the compute Y/Z harness test fix
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/README.md | 3 | ||||
| -rw-r--r-- | docs/animation.md | 7 | ||||
| -rw-r--r-- | docs/audio.md | 10 | ||||
| -rw-r--r-- | docs/d3d12_command_objects.md | 19 | ||||
| -rw-r--r-- | docs/d3d12_vulkan.md | 14 | ||||
| -rw-r--r-- | docs/design.md | 32 | ||||
| -rw-r--r-- | docs/gamedata.md | 54 | ||||
| -rw-r--r-- | docs/rbf0.md | 178 | ||||
| -rw-r--r-- | docs/textures.md | 195 | ||||
| -rw-r--r-- | docs/world.md | 33 | ||||
| -rw-r--r-- | docs/world_census.md | 97 |
11 files changed, 579 insertions, 63 deletions
diff --git a/docs/README.md b/docs/README.md index 0ecfe13a6..3facc8195 100644 --- a/docs/README.md +++ b/docs/README.md | |||
| @@ -21,9 +21,10 @@ method, scope and caveats. No game data is included. | |||
| 21 | | [animation.md](animation.md) | 130,470 `anim.rpf` streams, 95.4% readable; 1,126 rig sets / 6,677 source-to-rig entries / 3,669 rigs. | | 21 | | [animation.md](animation.md) | 130,470 `anim.rpf` streams, 95.4% readable; 1,126 rig sets / 6,677 source-to-rig entries / 3,669 rigs. | |
| 22 | | [navmesh.md](navmesh.md) | 90,295 `navmeshes.rpf` streams, 97.5% readable; `0DRP` pages, no navmesh-specific magic. | | 22 | | [navmesh.md](navmesh.md) | 90,295 `navmeshes.rpf` streams, 97.5% readable; `0DRP` pages, no navmesh-specific magic. | |
| 23 | | [bvh.md](bvh.md) | 565,596 `core_bvh4.rpf` streams; 271,627 BVH4 streams and 269,106 instances, prebuilt acceleration data. | | 23 | | [bvh.md](bvh.md) | 565,596 `core_bvh4.rpf` streams; 271,627 BVH4 streams and 269,106 instances, prebuilt acceleration data. | |
| 24 | | [rbf0.md](rbf0.md) | 1,263 RBF0 resources, 475,461 elements; UI/Scaleform definitions, not a sectioned container. | | 24 | | [rbf0.md](rbf0.md) | 1,263 RBF0 resources, 475,461 elements; UI/Scaleform definitions, not a sectioned container; strict JSON/XML tree decoder. | |
| 25 | | [gamedata.md](gamedata.md) | `common.rpf`: 954 streams, 266 XML documents / 118 roots; 0 RBF0/PSIN. | | 25 | | [gamedata.md](gamedata.md) | `common.rpf`: 954 streams, 266 XML documents / 118 roots; 0 RBF0/PSIN. | |
| 26 | | [world.md](world.md) | `levels.rpf` placement: 9,918 map files / 680,228 entities measured in 55% of the archive (lower bound; estimate 16k-39.6k / 1.03M-2.64M); `0x7a` resource layout. | | 26 | | [world.md](world.md) | `levels.rpf` placement: 9,918 map files / 680,228 entities measured in 55% of the archive (lower bound; estimate 16k-39.6k / 1.03M-2.64M); `0x7a` resource layout. | |
| 27 | | [world_census.md](world_census.md) | Full `levels.rpf` pass: 23,535 maps / 1,670,442 entities, 98.32% stream coverage, sharded and exact. | | ||
| 27 | | [page_directory.md](page_directory.md) | RPF9 `0DRP`: 0x60-byte header, `q38` 16-byte records; 15,768 pages / 60,880 records in `data.rpf`; targets and sizes, names still TOC-only. | | 28 | | [page_directory.md](page_directory.md) | RPF9 `0DRP`: 0x60-byte header, `q38` 16-byte records; 15,768 pages / 60,880 records in `data.rpf`; targets and sizes, names still TOC-only. | |
| 28 | | [psin.md](psin.md) | PSIN metadata container: header, section walk, 671 streams in the `script.rpf` carve. | | 29 | | [psin.md](psin.md) | PSIN metadata container: header, section walk, 671 streams in the `script.rpf` carve. | |
| 29 | | [story.md](story.md) | `story000.rpf` 18.65 GiB mixed: 264 Bink 2 streams / 3.33 GB, 225,281 `RSC8` headers, 442 nested RPF9; `story000_script` PSIN, `shared_minigame` mixed content. | | 30 | | [story.md](story.md) | `story000.rpf` 18.65 GiB mixed: 264 Bink 2 streams / 3.33 GB, 225,281 `RSC8` headers, 442 nested RPF9; `story000_script` PSIN, `shared_minigame` mixed content. | |
diff --git a/docs/animation.md b/docs/animation.md index 744d86e79..8d082eb24 100644 --- a/docs/animation.md +++ b/docs/animation.md | |||
| @@ -224,6 +224,13 @@ The first rig-set block starts at 0x0045. The tag/length layout is visible direc | |||
| 224 | `deformation[2]` (1,702), `identity` (1,109), `pose` (938), `pose.ragdoll.post` (160), `facial` (152), and | 224 | `deformation[2]` (1,702), `identity` (1,109), `pose` (938), `pose.ragdoll.post` (160), `facial` (152), and |
| 225 | ten smaller values. | 225 | ten smaller values. |
| 226 | 226 | ||
| 227 | The grammar-driven tree decoder (`tools/rbf0_tree.py`; `docs/rbf0.md` section 9) parses the same 1,348,436-byte | ||
| 228 | blob to its last byte and confirms the counts above: 9 descriptors, 28,962 elements, 20,031 text records, 1,126 | ||
| 229 | string values, 6,677 integer values and maximum element depth 6. The 1,126 string values are the `key` attributes | ||
| 230 | on the rig-set `Item` elements. Each of the 6,677 entry `Item` elements contains `Dictionary`, `Rig` and `Group` | ||
| 231 | text children followed by a `Priority` integer. The record framing is consumed exactly; the numeric field | ||
| 232 | semantics and the rig-to-skeleton link remain unresolved. | ||
| 233 | |||
| 227 | Mapping to the name tables: | 234 | Mapping to the name tables: |
| 228 | 235 | ||
| 229 | - The 2,298 distinct `pack:/...` paths resolve to a stored joaat32 stem hash for **1,901** names (82.7%); | 236 | - The 2,298 distinct `pack:/...` paths resolve to a stored joaat32 stem hash for **1,901** names (82.7%); |
diff --git a/docs/audio.md b/docs/audio.md index dcf8fee7a..6799be83a 100644 --- a/docs/audio.md +++ b/docs/audio.md | |||
| @@ -99,7 +99,13 @@ then 16 bytes per channel: | |||
| 99 | At the `0x55` data offset, each chunk starts with a 24-byte record per channel. The record's `+4` word is the | 99 | At the `0x55` data offset, each chunk starts with a 24-byte record per channel. The record's `+4` word is the |
| 100 | channel's subblock count and `+8` is a repeated-prefix sample count to skip. The channel data are its run of | 100 | channel's subblock count and `+8` is a repeated-prefix sample count to skip. The channel data are its run of |
| 101 | 2048-byte subblocks after the 2048-aligned header. The skipped samples repeat the previous chunk's tail, so the | 101 | 2048-byte subblocks after the 2048-aligned header. The skipped samples repeat the previous chunk's tail, so the |
| 102 | exporter drops whole packets until the count is consumed. Each Opus channel becomes one mono Ogg Opus file. | 102 | exporter drops whole packets until the count is consumed. Each descriptor channel becomes one Ogg Opus file. |
| 103 | |||
| 104 | The descriptor's `channels` field is the number of channel groups, not necessarily the packet channel count. | ||
| 105 | An Opus packet's TOC stereo bit (`packet[0] & 0x04`) gives the real count, and the descriptor's `samples` field | ||
| 106 | counts interleaved samples across those packet channels. The exporter therefore writes a stereo Ogg with | ||
| 107 | `OpusHead channels=2` and `samples / 2` as the end granule when the packets are stereo; mono groups keep their | ||
| 108 | count unchanged. Reading `samples` as a frame count produces a file that reports twice its real duration. | ||
| 103 | 109 | ||
| 104 | ## What the exporters write | 110 | ## What the exporters write |
| 105 | 111 | ||
| @@ -170,6 +176,8 @@ the audio itself is not. See the ground rules in [design.md](design.md#ground-ru | |||
| 170 | - 300 random Opus streams decode with ffmpeg with no errors; their lengths match the declared sample counts. | 176 | - 300 random Opus streams decode with ffmpeg with no errors; their lengths match the declared sample counts. |
| 171 | - All 1,818 XMA2 streams decode after `rpf9dump xma`. | 177 | - All 1,818 XMA2 streams decode after `rpf9dump xma`. |
| 172 | - A 4-channel streamed-music bank gives four 42.0 s mono channels with real levels and no decoder errors. | 178 | - A 4-channel streamed-music bank gives four 42.0 s mono channels with real levels and no decoder errors. |
| 179 | - A 1-channel streamed-music descriptor can carry stereo Opus packets; it exports as one stereo Ogg with the | ||
| 180 | interleaved sample count halved, and a 3-channel descriptor with stereo packets exports three stereo Oggs. | ||
| 173 | - All exported WAVs decode. Codec 2 values are stored as-is, so a float WAV can exceed ±1. | 181 | - All exported WAVs decode. Codec 2 values are stored as-is, so a float WAV can exceed ±1. |
| 174 | 182 | ||
| 175 | The tools export the streams and channels as stored. They do not reconstruct runtime mixing, looping, ducking or | 183 | The tools export the streams and channels as stored. They do not reconstruct runtime mixing, looping, ducking or |
diff --git a/docs/d3d12_command_objects.md b/docs/d3d12_command_objects.md index 27e8986f4..a064eb5bd 100644 --- a/docs/d3d12_command_objects.md +++ b/docs/d3d12_command_objects.md | |||
| @@ -423,17 +423,14 @@ command object. | |||
| 423 | | Builder's internal field layout (`+0x18`, `+0x30`, `+0x140`, `+0x344`, `+0x350`, `+0x544`) | No header or symbol; the helper's writes prove the contract is wider than the public vtable, but not what the fields mean. | | 423 | | Builder's internal field layout (`+0x18`, `+0x30`, `+0x140`, `+0x344`, `+0x350`, `+0x544`) | No header or symbol; the helper's writes prove the contract is wider than the public vtable, but not what the fields mean. | |
| 424 | | DMA list use/value | The IID is prior art; type 6 is derived; no shipped module uses it. | | 424 | | DMA list use/value | The IID is prior art; type 6 is derived; no shipped module uses it. | |
| 425 | 425 | ||
| 426 | ### 5.4 A concrete current gap: GCL8 | 426 | ### 5.4 GCL8 (resolved in PR #164) |
| 427 | 427 | ||
| 428 | The shipped builder's rehydrate exports name `ID3D12GraphicsCommandList8`, and | 428 | The shipped builder's rehydrate exports name `ID3D12GraphicsCommandList8`, and |
| 429 | `OMSetFrontAndBackStencilRef` is public GCL8 at slot 81. The repository's command-list class is | 429 | `OMSetFrontAndBackStencilRef` is public GCL8 at slot 81. **PR #164 adds the public GCL8 interface** |
| 430 | `ID3D12GraphicsCommandList7` (`runtime/shims/d3d12_com.cpp:57-61`), so it cannot answer | 430 | to `runtime/shims/d3d12_com.cpp`: it records the front/back values, resets them in `Reset`, answers |
| 431 | `IID_ID3D12GraphicsCommandList8` and has no slot 81. `d3d12_vulkan.md` §4's table says the | 431 | `IID_ID3D12GraphicsCommandList8`, and registers the `d3d12_gcl8` CTest (9/9). The values are recorded |
| 432 | command list "supports … front/back stencil ref", but no such implementation exists in | 432 | but not applied because this layer still has no pipeline/draw path. It does **not** close the |
| 433 | `runtime/` (a source grep finds no `OMSetFrontAndBackStencilRef` or front/back stencil command). | 433 | builder's `+0x490` gap, but a GCL8 pointer is now served instead of refused. |
| 434 | Adding the public GCL8 interface is a small, justified runtime change: one method, one standard | ||
| 435 | IID, no Xbox extension. It would not close the builder's `+0x490` gap, but it would let a GCL8 | ||
| 436 | pointer be served instead of refused. | ||
| 437 | 434 | ||
| 438 | ## 6. Return conventions | 435 | ## 6. Return conventions |
| 439 | 436 | ||
| @@ -463,8 +460,8 @@ than invent slots. | |||
| 463 | builder validates its inputs before reaching the dispatch, use a descriptor shaped like the | 460 | builder validates its inputs before reaching the dispatch, use a descriptor shaped like the |
| 464 | one its own `GetRaytracingAccelerationStructurePrebuildInfo` accepts (prior art measured a | 461 | one its own `GetRaytracingAccelerationStructurePrebuildInfo` accepts (prior art measured a |
| 465 | 3,000-vertex triangle geometry; the prebuild answer is 204,800 bytes / 128,704 scratch). | 462 | 3,000-vertex triangle geometry; the prebuild answer is 204,800 bytes / 128,704 scratch). |
| 466 | 2. **Add GCL8 to the runtime** (public, one method, slot 81) so the rehydrate entry points can | 463 | 2. **GCL8 is now implemented** in PR #164 (public slot 81, recorded/reset, CTest 9/9); the |
| 467 | be handed a real object. This is a code change for a separate PR, not this document. | 464 | remaining builder gap is the `+0x490` method. |
| 468 | 3. **When the executable appears, trace the four creation calls first.** Per-slot counters on | 465 | 3. **When the executable appears, trace the four creation calls first.** Per-slot counters on |
| 469 | device slots 8/9/12/36, then queue slots 10/14/15, fence slots 8/9/10, and every slot beyond | 466 | device slots 8/9/12/36, then queue slots 10/14/15, fence slots 8/9/10, and every slot beyond |
| 470 | the public chain. The first `PresentX` call and the queue vtable tail are the only way to | 467 | the public chain. The first `PresentX` call and the queue vtable tail are the only way to |
diff --git a/docs/d3d12_vulkan.md b/docs/d3d12_vulkan.md index 5e0bde9bc..a232c361b 100644 --- a/docs/d3d12_vulkan.md +++ b/docs/d3d12_vulkan.md | |||
| @@ -383,7 +383,8 @@ This is the least verifiable part of the layer. D3D12 gives the application a ro | |||
| 383 | turns it into the user SGPRs (`s0..s31`) that the shader reads. The translator already copies those 32 dwords from | 383 | turns it into the user SGPRs (`s0..s31`) that the shader reads. The translator already copies those 32 dwords from |
| 384 | push constants into `s0..s31`. The layer must produce them. | 384 | push constants into `s0..s31`. The layer must produce them. |
| 385 | 385 | ||
| 386 | The default mapping (**Assumption**) follows root parameter order: | 386 | The default mapping (implemented by `rt::rootsig::pack` in `runtime/src/root_signature.{h,cpp}`) follows root |
| 387 | parameter order: | ||
| 387 | 388 | ||
| 388 | | Root parameter | User-data dwords | | 389 | | Root parameter | User-data dwords | |
| 389 | |---|---| | 390 | |---|---| |
| @@ -395,6 +396,15 @@ The default mapping (**Assumption**) follows root parameter order: | |||
| 395 | Before the draw/dispatch, the layer copies the current root arguments into a 32-dword block in that order and | 396 | Before the draw/dispatch, the layer copies the current root arguments into a 32-dword block in that order and |
| 396 | uploads it as push constants. Missing parameters are zero. | 397 | uploads it as push constants. Missing parameters are zero. |
| 397 | 398 | ||
| 399 | Spill policy: a signature needing more than 32 user SGPRs, or more than the 64-dword D3D12 cost limit, is | ||
| 400 | refused loudly (`pack` returns the offending parameter) instead of being truncated. The console spills through | ||
| 401 | `__XB_GetRootSignatureSpillPointer`; until that layout is measured, refusing is the only correct behaviour. | ||
| 402 | |||
| 403 | Reconciliation: `tools/root_sig_contract.py` checks a candidate root signature against every shader's | ||
| 404 | `user_sgpr_reads` from `spirv/index.json` (const32 vs constant dwords, 64-bit VAs vs view/table pairs) and fails | ||
| 405 | the build on the first contradiction. Until the console mapping in §3.5 is confirmed by a PSO, this check — not | ||
| 406 | a rendered frame — is the acceptance gate for the mapping above. | ||
| 407 | |||
| 398 | **Root-signature flag quirk.** Prior art measured Xbox root-signature descriptors carrying flags `0x03000000`; the | 408 | **Root-signature flag quirk.** Prior art measured Xbox root-signature descriptors carrying flags `0x03000000`; the |
| 399 | PC serializer rejects them with `E_INVALIDARG` because its flags live in the low 16 bits. Clear the high byte on a | 409 | PC serializer rejects them with `E_INVALIDARG` because its flags live in the low 16 bits. Clear the high byte on a |
| 400 | private copy before calling the host serializer/deserializer; never modify the game's descriptor. The meaning of the | 410 | private copy before calling the host serializer/deserializer; never modify the game's descriptor. The meaning of the |
| @@ -756,7 +766,7 @@ store, load, mesh, geometry and BVH tests; this layer is the other half. | |||
| 756 | | `s0..s31` user data | Root signature state at draw/dispatch: root constants copied, root CBV/SRV/UAV addresses and descriptor-table base addresses as 64-bit console VAs. Mapping per section 3.5; absent parameters zero. | | 766 | | `s0..s31` user data | Root signature state at draw/dispatch: root constants copied, root CBV/SRV/UAV addresses and descriptor-table base addresses as 64-bit console VAs. Mapping per section 3.5; absent parameters zero. | |
| 757 | | `heap_base` (dwords 32–33) | The arena's `vkGetBufferDeviceAddress`. One value per command buffer; updated only if the arena is recreated. | | 767 | | `heap_base` (dwords 32–33) | The arena's `vkGetBufferDeviceAddress`. One value per command buffer; updated only if the arena is recreated. | |
| 758 | | `code_base` (dwords 34–35) | The console VA of the current shader's FSSM blob in the arena. Per-stage conflict: see below. | | 768 | | `code_base` (dwords 34–35) | The console VA of the current shader's FSSM blob in the arena. Per-stage conflict: see below. | |
| 759 | | Descriptor hash table (set 0, binding 2) | `uint mask` + entries of `key[8], index, pad`; FNV-1a over the 8 key dwords; linear probe up to 8; miss = index 0. The layer inserts every T#/S# it sees and keeps a fallback image/sampler at index 0. | | 769 | | Descriptor hash table (set 0, binding 2) | `uint mask` + entries of `key[8], index, pad`; FNV-1a over the 8 key dwords; linear probe up to 8; miss = index 0. Implemented in `runtime/src/descriptor_table.h` (`DescriptorTable`). The layer inserts every T#/S# it sees and keeps a fallback image/sampler at index 0. | |
| 760 | | Bindless images (bindings 0, 3, 5, 6) | 2D, 2D-array/cube, 1D, 3D sampled-image arrays; one `VkImageView` per distinct T#. Cube textures are 6-layer 2D arrays, as the translator expects. | | 770 | | Bindless images (bindings 0, 3, 5, 6) | 2D, 2D-array/cube, 1D, 3D sampled-image arrays; one `VkImageView` per distinct T#. Cube textures are 6-layer 2D arrays, as the translator expects. | |
| 761 | | Samplers (binding 1) | One `VkSampler` per distinct S#; literal S# values from shader constants are pre-registered. | | 771 | | Samplers (binding 1) | One `VkSampler` per distinct S#; literal S# values from shader constants are pre-registered. | |
| 762 | | Storage images (bindings 4, 7, 8–19) | r32ui/float/sint views by dimension and numeric class; the layer binds each storage image into the float/uint/sint arrays of its dimension (the translator picks by the T# format at run time), with all three arrays as the safe default. | | 772 | | Storage images (bindings 4, 7, 8–19) | r32ui/float/sint views by dimension and numeric class; the layer binds each storage image into the float/uint/sint arrays of its dimension (the translator picks by the T# format at run time), with all three arrays as the safe default. | |
diff --git a/docs/design.md b/docs/design.md index dd1172545..debd059c0 100644 --- a/docs/design.md +++ b/docs/design.md | |||
| @@ -94,11 +94,11 @@ add a source file, add it to `runtime\CMakeLists.txt` and to the file list in `b | |||
| 94 | | Texture dictionaries | Same tool: TXD resources become DDS per texture. | `<work>\assets\<archive>\textures\` | | 94 | | Texture dictionaries | Same tool: TXD resources become DDS per texture. | `<work>\assets\<archive>\textures\` | |
| 95 | | World textures (TTPF) | **Done: 308,895 textures from all 57 pools, 0 failures, 48,220 entries skipped** (33,507 BCPack, 14,030 compact mapping, 678 arrays/volumes, 5 unsupported format, 0 unmapped). 46 pools are in `data\ttdb\**`, 11 in `pack\<name>\data\ttdb\**` (exported under `ttpf_pack\<pack>\`). `data\ttdb\**\*.ttpf` (57 pools, 58 GiB) are loose RDS5 texture pools, **not** inside RPFs. rpf9-explorer's `TtpfReader` reads the catalog and detiles them; checked visually (`ttdb_graphics`: scope reticles, clean lines). Names are generated (`texture_N_<assetkey>`); models reference textures by asset key. Some rows are skipped; the measured breakdown and the BCPack next step are in [textures.md](textures.md). | `<work>\assets\ttpf\<pool>\` + `manifest.json` | | 95 | | World textures (TTPF) | **Done: 308,895 textures from all 57 pools, 0 failures, 48,220 entries skipped** (33,507 BCPack, 14,030 compact mapping, 678 arrays/volumes, 5 unsupported format, 0 unmapped). 46 pools are in `data\ttdb\**`, 11 in `pack\<name>\data\ttdb\**` (exported under `ttpf_pack\<pack>\`). `data\ttdb\**\*.ttpf` (57 pools, 58 GiB) are loose RDS5 texture pools, **not** inside RPFs. rpf9-explorer's `TtpfReader` reads the catalog and detiles them; checked visually (`ttdb_graphics`: scope reticles, clean lines). Names are generated (`texture_N_<assetkey>`); models reference textures by asset key. Some rows are skipped; the measured breakdown and the BCPack next step are in [textures.md](textures.md). | `<work>\assets\ttpf\<pool>\` + `manifest.json` | |
| 96 | | Animation | Indexed without the TOC: 130,470 zlib streams (4,203,762,662 stored / 11,593,460,132 inflated), 95.4% readable. New RAGE page directories (`0DRP`, version 122), `MoVE` (version 19), 273 `pack:/` name tables (2,298 paths), and a tail `RBF0` rig-set manager (`rage__crRigSetManager`: 1,126 rig sets, 6,677 source→rig entries, 3,669 distinct rigs; 56 empty). Bone data: one standalone 28-name table and 3 motion-matcher streams with embedded bone tables (30-name union, 19 joaat32 hashes present, 4 motionmatcher paths); no rig→skeleton link was found. No `YCD`/`RSC7` at any stream start. The `rpf9_carve` tail overread is measured in `docs/animation.md`. | `tools\anim_index.py`, `<work>\anim-index\` | | 96 | | Animation | Indexed without the TOC: 130,470 zlib streams (4,203,762,662 stored / 11,593,460,132 inflated), 95.4% readable. New RAGE page directories (`0DRP`, version 122), `MoVE` (version 19), 273 `pack:/` name tables (2,298 paths), and a tail `RBF0` rig-set manager (`rage__crRigSetManager`: 1,126 rig sets, 6,677 source→rig entries, 3,669 distinct rigs; 56 empty). Bone data: one standalone 28-name table and 3 motion-matcher streams with embedded bone tables (30-name union, 19 joaat32 hashes present, 4 motionmatcher paths); no rig→skeleton link was found. No `YCD`/`RSC7` at any stream start. The `rpf9_carve` tail overread is measured in `docs/animation.md`. | `tools\anim_index.py`, `<work>\anim-index\` | |
| 97 | | Audio | `audio.rpf` holds raw (not zlib) **AWC** banks: Opus (codec 0x0B) and XMA2 streams. Exported as whole `.awc` files plus `audio_manifest.json` (stream ids, codec, channels, rate, duration). **Done: 7,162 banks, 27 GiB, 1,603,231 streams, about 1,324 hours** (codec 0x0B Opus 1,601,167; 5: 1,818; 2: 227; 0 PCM: 19). `tools/awc_opus.py` repackages every Opus stream **losslessly** into a standard Ogg Opus file (no re-encode; PCM streams become .wav). The AWC framing is 2048-byte blocks of [u16 length][packet], with a zero length padding the block (as rpf9-explorer's OpusPreview reads it). The final granule is trimmed to the declared sample count. Checked: 300 random streams decode with ffmpeg with no errors, lengths match the declared counts. XMA2 streams (codec 5, 1,818) are written as RIFF XMA2 files by `rpf9dump xma` (rpf9-explorer's `AwcRecovery.WriteXmaWave`) and decoded to PCM WAV by ffmpeg: all 1,818 decode. Streamed music (tag 0x48: chunks with a per-channel record table, each channel's 2048-byte subblocks after the aligned header, and a repeated-prefix skip per chunk) becomes one mono Ogg Opus per channel (3,008 banks contain music). Checked: a 4-channel music bank gives four 42.0 s channels with real levels and no decoder errors. Output: `<work>\assets\audio\ogg\<bank>\<stream id>.ogg`. **Done: 1,598,051 Opus streams + 3,116 music channels as Ogg Opus (22 GB), 19 PCM16 and 227 codec-2 streams (32-bit float PCM, 4 bytes per sample; values can exceed ±1) as WAV, 1,818 XMA2 as WAV. Every audio stream is converted; all WAVs decode.** `make_game.py --wav` also decodes the Ogg Opus output to 16-bit PCM WAV with `tools/audio_wav.py` (ffmpeg required; existing WAVs are skipped on resume). | `<work>\assets\audio\awc\` | | 97 | | Audio | `audio.rpf` holds raw (not zlib) **AWC** banks: Opus (codec 0x0B) and XMA2 streams. Exported as whole `.awc` files plus `audio_manifest.json` (stream ids, codec, channels, rate, duration). **Done: 7,162 banks, 27 GiB, 1,603,231 streams, about 1,324 hours** (codec 0x0B Opus 1,601,167; 5: 1,818; 2: 227; 0 PCM: 19). `tools/awc_opus.py` repackages every Opus stream **losslessly** into a standard Ogg Opus file (no re-encode; PCM streams become .wav). The AWC framing is 2048-byte blocks of [u16 length][packet], with a zero length padding the block (as rpf9-explorer's OpusPreview reads it). The final granule is trimmed to the declared sample count. Checked: 300 random streams decode with ffmpeg with no errors, lengths match the declared counts. XMA2 streams (codec 5, 1,818) are written as RIFF XMA2 files by `rpf9dump xma` (rpf9-explorer's `AwcRecovery.WriteXmaWave`) and decoded to PCM WAV by ffmpeg: all 1,818 decode. Streamed music (tag 0x48: chunks with a per-channel record table, each channel's 2048-byte subblocks after the aligned header, and a repeated-prefix skip per chunk) becomes one Ogg Opus per descriptor channel (3,008 banks contain music). The Opus TOC stereo bit gives the packet channel count; a 1-channel descriptor can carry stereo packets, whose interleaved sample count is halved for the end granule. Checked: a 4-channel bank gives four 42.0 s mono channels; 1-channel stereo banks export at the config duration. Output: `<work>\assets\audio\ogg\<bank>\<stream id>.ogg`. **Done: 1,598,051 Opus streams + 3,116 music channels as Ogg Opus (22 GB), 19 PCM16 and 227 codec-2 streams (32-bit float PCM, 4 bytes per sample; values can exceed ±1) as WAV, 1,818 XMA2 as WAV. Every audio stream is converted; all WAVs decode.** `make_game.py --wav` also decodes the Ogg Opus output to 16-bit PCM WAV with `tools/audio_wav.py` (ffmpeg required; existing WAVs are skipped on resume). | `<work>\assets\audio\awc\` | |
| 98 | | World placement | **Measured in `levels.rpf`:** map files occupy a continuous band from ~7.5 to ~62.9 GiB; 9,918 map files / 680,228 entities in 29 GiB of the 57 GiB band (50.9%, lower bound; block estimate 16.0k-39.6k maps / 1.03M-2.64M entities). `0x7a` resources: `CMapData` root, 0x90-byte `CEntityDef` with position/quaternion/scale/archetype/flags/GUID/LOD fields; names and most archetypes are hash-only. | `tools\world_index.py`; [world.md](world.md) | | 98 | | World placement | **Full census of `levels.rpf`:** 23,535 map resources / 1,670,442 entities; all maps/entities exact, 36/36 shards, 98.32% stream coverage. Map files occupy a continuous band from ~7.5 to ~62.9 GiB; the earlier 9,918 / 680,228 sample was a 55% lower bound. `0x7a` resources: `CMapData` root, 0x90-byte `CEntityDef` with position/quaternion/scale/archetype/flags/GUID/LOD fields; names and most archetypes are hash-only. | `tools\world_index.py`, `tools\world_census.py`; [world.md](world.md), [world_census.md](world_census.md) | |
| 99 | | Navmeshes | `navmeshes.rpf`: 90,295 zlib streams (6,540,238,392 stored / 20,551,068,624 inflated), 97.5% readable; 9,603 `0DRP` pages and 27,644 `0x00010015` pages, no `NAVM`/`CNavMesh`/`NVMS` magic. `0DRP` is generic RPF paging, not a navmesh container. | `tools\navmesh_index.py`; [navmesh.md](navmesh.md) | | 99 | | Navmeshes | `navmeshes.rpf`: 90,295 zlib streams (6,540,238,392 stored / 20,551,068,624 inflated), 97.5% readable; 9,603 `0DRP` pages and 27,644 `0x00010015` pages, no `NAVM`/`CNavMesh`/`NVMS` magic. `0DRP` is generic RPF paging, not a navmesh container. | `tools\navmesh_index.py`; [navmesh.md](navmesh.md) | |
| 100 | | BVH | `core_bvh4.rpf`: 565,596 streams, 271,627 complete BVH4 streams + 10 eight-MiB split continuations, 269,106 instance records. Header `0x81020006` at +0x100, 64-byte node units, 208-byte instances with a 3x4 transform; prebuilt acceleration data, not source meshes or shaders. | `tools\bvh_index.py`; [bvh.md](bvh.md) | | 100 | | BVH | `core_bvh4.rpf`: 565,596 streams, 271,627 complete BVH4 streams + 10 eight-MiB split continuations, 269,106 instance records. Header `0x81020006` at +0x100, 64-byte node units, 208-byte instances with a 3x4 transform; prebuilt acceleration data, not source meshes or shaders. | `tools\bvh_index.py`; [bvh.md](bvh.md) | |
| 101 | | RBF0 | 1,263 `data.rpf` resources, 475,461 elements, 44,887 descriptors and 340,859 strings. Inline record stream with no section table; UI/Scaleform (`rage__fwui*`, screens, subtitles, settings). The `anim.rpf` tail uses the same format (`rage__crRigSetManager`). | `tools\rbf0_index.py`; [rbf0.md](rbf0.md) | | 101 | | RBF0 | 1,263 `data.rpf` resources, 475,461 elements, 44,887 descriptors and 340,859 strings. Inline record stream with no section table; UI/Scaleform (`rage__fwui*`, screens, subtitles, settings). The `anim.rpf` tail uses the same format (`rage__crRigSetManager`). `tools/rbf0_tree.py` decodes every resource to a strict JSON/XML element, value and text tree. | `tools\rbf0_index.py`, `tools\rbf0_tree.py`; [rbf0.md](rbf0.md) | |
| 102 | | Gamedata | `common.rpf`: 954 streams (5,647,255 stored / 50,231,123 inflated), 85.5% readable; 266 XML documents / 118 roots (time/weather, vehicles/handling, peds/schedules, tuning, manifests, world/navigation). No RBF0/PSIN. | `tools\gamedata_index.py`; [gamedata.md](gamedata.md) | | 102 | | Gamedata | `common.rpf`: 954 streams (5,647,255 stored / 50,231,123 inflated), 85.5% readable; 266 XML documents / 118 roots (time/weather, vehicles/handling, peds/schedules, tuning, manifests, world/navigation). No RBF0/PSIN. | `tools\gamedata_index.py`; [gamedata.md](gamedata.md) | |
| 103 | | PSIN | `script.rpf`: 671 streams start with `PSIN`, 670 complete; sections `LSCH`, `LENM`, `LSNS`, `LGID`, `LRSC`, `CHKS`. `data.rpf`: 2,281 streams, 1,045 complete after joining. `LSNS` is high-entropy; no plaintext scripts or names. | `tools/psin_index.py`; [psin.md](psin.md) | | 103 | | PSIN | `script.rpf`: 671 streams start with `PSIN`, 670 complete; sections `LSCH`, `LENM`, `LSNS`, `LGID`, `LRSC`, `CHKS`. `data.rpf`: 2,281 streams, 1,045 complete after joining. `LSNS` is high-entropy; no plaintext scripts or names. | `tools/psin_index.py`; [psin.md](psin.md) | |
| 104 | | Audio config | `audio.rpf` first 19.5 MiB: 837 zlib streams / 54,143,493 inflated bytes. 1,589 music records, 1,589 distinct ids, exact milliseconds; `hash & 0x1fffffff` is the AWC stream id. 1,584/1,589 durations match the AWC manifest / 2; no per-track start offsets. | `tools/audio_config.py`; [audio_config.md](audio_config.md) | | 104 | | Audio config | `audio.rpf` first 19.5 MiB: 837 zlib streams / 54,143,493 inflated bytes. 1,589 music records, 1,589 distinct ids, exact milliseconds; `hash & 0x1fffffff` is the AWC stream id. 1,584/1,589 durations match the AWC manifest / 2; no per-track start offsets. | `tools/audio_config.py`; [audio_config.md](audio_config.md) | |
| @@ -207,14 +207,14 @@ How the generated SPIR-V expects the runtime to work: | |||
| 207 | | Code-embedded data | 155 VS/PS had "undecodable words". They're **constant tables inside the code range** (float values like 0x3EF7…, plus zeros), read through `s_getpc_b64` + `s_add_u32`/`s_addc_u32` + `s_load` (147 of 155). The translator re-anchors each instruction to its true FSSM offset by matching encodings, translates only code reachable from entry (a branch into data is rejected), and turns `s_getpc_b64` into code base + next-instruction offset. **The runtime uploads each shader's FSSM blob into the heap and passes that VA as the code base.** Re-anchoring compares bytes exactly, except that VOP3P `op_sel_hi[2]` (bit 14) is ignored on two-source packed ops: the compiler stores 0 there, and LLVM prints its default of 1. Data words that decode with ignored fields set are printed re-encoded (e.g. `0xbe8d2242` as `s_rfe_b64` `0xbe802242`), so they can never match. Since the decoder consumed the same length, they are anchored in sequence and marked. A shader that can *reach* a marked word is rejected; none of the corpus does. All 155 now translate. | | 207 | | Code-embedded data | 155 VS/PS had "undecodable words". They're **constant tables inside the code range** (float values like 0x3EF7…, plus zeros), read through `s_getpc_b64` + `s_add_u32`/`s_addc_u32` + `s_load` (147 of 155). The translator re-anchors each instruction to its true FSSM offset by matching encodings, translates only code reachable from entry (a branch into data is rejected), and turns `s_getpc_b64` into code base + next-instruction offset. **The runtime uploads each shader's FSSM blob into the heap and passes that VA as the code base.** Re-anchoring compares bytes exactly, except that VOP3P `op_sel_hi[2]` (bit 14) is ignored on two-source packed ops: the compiler stores 0 there, and LLVM prints its default of 1. Data words that decode with ignored fields set are printed re-encoded (e.g. `0xbe8d2242` as `s_rfe_b64` `0xbe802242`), so they can never match. Since the decoder consumed the same length, they are anchored in sequence and marked. A shader that can *reach* a marked word is rejected; none of the corpus does. All 155 now translate. | |
| 208 | | Global memory | `global_load/store_dword*`: address = (64-bit SGPR base + zero-extended 32-bit VGPR offset, or a 64-bit VGPR address) + signed 12-bit offset, translated through the heap base. Inactive lanes don't access memory, and loads merge their previous values with OpPhi. | | 208 | | Global memory | `global_load/store_dword*`: address = (64-bit SGPR base + zero-extended 32-bit VGPR offset, or a 64-bit VGPR address) + signed 12-bit offset, translated through the heap base. Inactive lanes don't access memory, and loads merge their previous values with OpPhi. | |
| 209 | | Literal samplers | Some shaders build their S# from immediates (for example `0x92, 0xC00000, 0x14500000, 0`). The runtime registers those in the descriptor hash table too, by scanning the translated shaders' constant S# values, not only S#s the game binds. | | 209 | | Literal samplers | Some shaders build their S# from immediates (for example `0x92, 0xC00000, 0x14500000, 0`). The runtime registers those in the descriptor hash table too, by scanning the translated shaders' constant S# values, not only S#s the game binds. | |
| 210 | | Scalar/buffer memory | `s_load*`, `s_buffer_load*`, `buffer_load*` and `buffer_store*` use buffer device addresses (`PhysicalStorageBuffer64`). The base comes from the 64-bit SGPR pointer or the V# (dword0 \| dword1[15:0] << 32), and the stride is V# dword1[29:16]. **The runtime must put the game's GPU heap in buffer-device-addressable memory at the same addresses the game writes into descriptors** (or remap them). See *Buffer bounds checking* below for `num_records` checks. | | 210 | | Scalar/buffer memory | `s_load*`, `s_buffer_load*`, `buffer_load*` and `buffer_store*` use buffer device addresses (`PhysicalStorageBuffer64`). The base comes from the 64-bit SGPR pointer or the V# (dword0 \| dword1[15:0] << 32), and the stride is V# dword1[29:16]. **The runtime must put the game's GPU heap in buffer-device-addressable memory at the same addresses the game writes into descriptors** (or remap them). `s_load*` and `s_buffer_load*` take an immediate or an SGPR offset, or both at once (llvm-mc prints `sOFF offset:IMM`): the address is base + sOFF + IMM + 4·i for dword i. Measured on AMD Radeon RX 6800 (gfx1030) by running the instructions as a raw compute kernel: soffset 8 + imm 4 reads +12 (`s_buffer_load_dword`, `x2`, `x4`, `x8`); `s_load_dword*` with both offsets wasn't measured and gets the same rule because it shares the SMEM encoding. The translator used to drop the immediate of that form. The translator's arithmetic is checked by `tests/semantic/test_scalar_mem_smem.py` (`SmemSoffsetImmTranslatorTests`); a GPU test, `runtime/test/shaders/cs_smem_soffset_imm.asm`, is in `check.py` and `scripts/run_gpu_tests.py`. Known remaining differences, from the same measurement of `s_buffer_load*`: the hardware truncates base, sOFF and IMM each to a multiple of 4 and returns 0 past NUM_RECORDS; the translator does neither yet. See *Buffer bounds checking* below for the MUBUF `num_records` checks. | |
| 211 | | Typed buffer loads | The format is V# word3[18:12] (GFX10_FORMAT, from Mesa's `gfx10-rsrc.json`, saved as `tools\gfx10_formats.json`). Supported: f32 ×1–4, u32 ×1/2/4, f16 ×1/2/4, unorm8 ×1/2/4, snorm8 ×4, uint8 ×4, unorm16 ×1/2/4, snorm16 ×2/4, 10-10-10-2 and 2-10-10-10 unorm. Others give 0. DST_SEL swizzle is applied. | | 211 | | Typed buffer loads | The format is V# word3[18:12] (GFX10_FORMAT, from Mesa's `gfx10-rsrc.json`, saved as `tools\gfx10_formats.json`). Supported: f32 ×1–4, u32 ×1/2/4, f16 ×1/2/4, unorm8 ×1/2/4, snorm8 ×4, uint8 ×4, unorm16 ×1/2/4, snorm16 ×2/4, 10-10-10-2 and 2-10-10-10 unorm. Others give 0. DST_SEL swizzle is applied. | |
| 212 | | Images and samplers | `image_sample_l` on 2D arrays used to read its LOD from the array layer; it now reads the LOD after all coordinates. `image_get_lod` and `image_gather4_lz` also work on 2D arrays. | | 212 | | Images and samplers | `image_sample_l` on 2D arrays used to read its LOD from the array layer; it now reads the LOD after all coordinates. `image_get_lod` and `image_gather4_lz` also work on 2D arrays. | |
| 213 | | Images and samplers (core) | Bindless. Set 0: binding 0 = 2D sampled images, 1 = samplers, 2 = descriptor hash table (storage buffer), 3 = 2D-array images (**cube textures are bound here as 6-layer 2D-array views**: the shader already selected the face with `v_cube*`), 4 = r32ui storage images, 5 = 1D, 6 = 3D. | | 213 | | Images and samplers (core) | Bindless. Set 0: binding 0 = 2D sampled images, 1 = samplers, 2 = descriptor hash table (storage buffer), 3 = 2D-array images (**cube textures are bound here as 6-layer 2D-array views**: the shader already selected the face with `v_cube*`), 4 = r32ui storage images, 5 = 1D, 6 = 3D. | |
| 214 | | Descriptor hash table | `uint mask; entries[mask+1] of 10 uints: key[0..7], index, pad`. The key is a T# or a padded S#. FNV-1a over the eight key words selects the first slot. The shared SPIR-V lookup probes up to eight slots and returns index 0 on a miss. The runtime supplies a fallback at index 0 and maps live descriptor keys to bindless indices. | | 214 | | Descriptor hash table | `uint mask; entries[mask+1] of 10 uints: key[0..7], index, pad`. The key is a T# or a padded S#. FNV-1a over the eight key words selects the first slot. The shared SPIR-V lookup probes up to eight slots and returns index 0 on a miss. The runtime supplies a fallback at index 0 and maps live descriptor keys to bindless indices. | |
| 215 | | Vertex fetch | `s_swappc_b64` at the start of a VS calls a driver-generated fetch program that isn't in the blob. It's replaced by Vulkan vertex inputs: each `ISG1` input-signature element (DXBC container) becomes an input at **location = its D3D input register**, typed by its component type, and is written to **v(4 + 4·register + component)**. That rule was checked over all 788 fetch-calling shaders: in 783 every read-before-write VGPR is predicted by it (715 exact). Reads of components the element doesn't declare (e.g. `.w` of an `xyz` position, 3 VS) are allowed: the fetch returns the format defaults (0, 0, 1), and Vulkan fills a `vec4` input from a narrower format the same way. Inputs are declared as `vec4`. **The runtime must bind vertex buffers by the game's D3D12 input layout, location = input register.** | | 215 | | Vertex fetch | `s_swappc_b64` at the start of a VS calls a driver-generated fetch program that isn't in the blob. It's replaced by Vulkan vertex inputs: each `ISG1` input-signature element (DXBC container) becomes an input at **location = its D3D input register**, typed by its component type, and is written to **v(4 + 4·register + component)**. That rule was checked over all 788 fetch-calling shaders: in 783 every read-before-write VGPR is predicted by it (715 exact). Reads of components the element doesn't declare (e.g. `.w` of an `xyz` position, 3 VS) are allowed: the fetch returns the format defaults (0, 0, 1), and Vulkan fills a `vec4` input from a narrower format the same way. Inputs are declared as `vec4`. **The runtime must bind vertex buffers by the game's D3D12 input layout, location = input register.** | |
| 216 | | PS system inputs | v0–v1 = barycentrics (consumed by `v_interp`, which becomes attribute inputs). **v2.. = the `SV_Position` components the shader reads, packed in order**. Verified on 2,531 of 3,000 PS: the VGPRs they read before writing equal exactly the position components their input signature reads. Filled from `FragCoord`: xy/z directly, and **w directly too**, because AMD's position-w register holds 1/w (Mesa lowers `load_frag_coord_w_rcp` straight to `frag_pos[3]`, `ac_nir_lower_intrinsics_to_args.c`), the same as Vulkan's `FragCoord.w`. **Front face** follows the used position components when the signature declares `SV_IsFrontFace`, as ±1.0 (Mesa: `load_front_face` = `front_face > 0`). Only enabled inputs are packed, in hardware order (Mesa `radv_shader_args.c`: barycentric pairs, POS_X/Y/Z/W, FRONT_FACE, ANCILLARY, SAMPLE_COVERAGE, POS_FIXED_PT). That explains the earlier "unverified" shaders: 102 read pos.xy + front face, and 76 read pos.x/y/w + front face. **Raw barycentric reads** (321 PS, e.g. `v_readfirstlane_b32 s41, v1`): AMD interpolates P = P0 + i(P1 − P0) + j(P2 − P0), so i/j are the weights of vertices 1/2, which is `BaryCoordKHR.y`/`.z` (`VK_KHR_fragment_shader_barycentric`). GPU-checked with `runtime/test/shaders/ps_bary.asm`: raw i/j equal the interpolated weights on every pixel. This assumes the pair is perspective-center, the only pair this layout models. A PS that reads any other unexplained register inside the system-input range is still rejected (none left in the corpus). Reads past the last hardware input are values undefined on some path, so zero stands in for them. All register arrays start at zero, so translated shaders are deterministic. | | 216 | | PS system inputs | v0–v1 = barycentrics (consumed by `v_interp`, which becomes attribute inputs). **v2.. = the `SV_Position` components the shader reads, packed in order**. Verified on 2,531 of 3,000 PS: the VGPRs they read before writing equal exactly the position components their input signature reads. Filled from `FragCoord`: xy/z directly, and **w directly too**, because AMD's position-w register holds 1/w (Mesa lowers `load_frag_coord_w_rcp` straight to `frag_pos[3]`, `ac_nir_lower_intrinsics_to_args.c`), the same as Vulkan's `FragCoord.w`. **Front face** follows the used position components when the signature declares `SV_IsFrontFace`, as ±1.0 (Mesa: `load_front_face` = `front_face > 0`). Only enabled inputs are packed, in hardware order (Mesa `radv_shader_args.c`: barycentric pairs, POS_X/Y/Z/W, FRONT_FACE, ANCILLARY, SAMPLE_COVERAGE, POS_FIXED_PT). That explains the earlier "unverified" shaders: 102 read pos.xy + front face, and 76 read pos.x/y/w + front face. **Raw barycentric reads** (321 PS, e.g. `v_readfirstlane_b32 s41, v1`): AMD interpolates P = P0 + i(P1 − P0) + j(P2 − P0), so i/j are the weights of vertices 1/2, which is `BaryCoordKHR.y`/`.z` (`VK_KHR_fragment_shader_barycentric`). GPU-checked with `runtime/test/shaders/ps_bary.asm`: raw i/j equal the interpolated weights on every pixel. This assumes the pair is perspective-center, the only pair this layout models. A PS that reads any other unexplained register inside the system-input range is still rejected (none left in the corpus). Reads past the last hardware input are values undefined on some path, so zero stands in for them. All register arrays start at zero, so translated shaders are deterministic. | |
| 217 | | Inputs and outputs | VS: `v0` = `VertexIndex` (**unverified**: if the console runs vertex shaders as NGG, the input VGPR layout differs). `exp pos0` → `Position`, `exp pos1..pos3` → `ClipDistance` / `CullDistance` (and `Layer`/`ViewportIndex` in VS when `pos1` is the misc vector), `exp paramN` → location N. RDNA2/GFX10 packs clip distances before cull distances contiguously across 4-component `pos` exports (up to 8 floats total), starting at `pos2` when a misc vector (`PointSize`, `EdgeFlag`, `ShadingRate`, `Layer`, `ViewportIndex`; GFX9+ packs `Layer` in `z[10:0]` and `ViewportIndex` in `z[19:16]`) occupies `pos1`, and at `pos1` otherwise (Mesa `src/amd/common/nir/ac_nir_prerast_utils.c`: `ac_nir_export_position`; AMD LLPC `lgc/lowering/LowerInOut.cpp`: `LowerInOut::visitReturnInst`). Slot assignment follows the DXBC `OSG1` signature (`SV_ClipDistance` = 2, `SV_CullDistance` = 3, `SV_RenderTargetArrayIndex` = 4, `SV_ViewportArrayIndex` = 5, `SV_ShadingRate` = 23), ordered by `(semantic_index, register, component)` with clip before cull; when `OSG1` is absent, non-`off` `pos1..pos2` components default to `ClipDistance`. PS: `v_interp_*` attribute N → input location N. `exp mrtN` → location N, `exp mrtz` x → `FragDepth`. | | 217 | | Inputs and outputs | VS: `v0` = `VertexIndex` (**unverified**: if the console runs vertex shaders as NGG, the input VGPR layout differs). `exp pos0` → `Position`, `exp pos1..pos3` → `ClipDistance` / `CullDistance` (and `Layer`/`ViewportIndex` in VS when `pos1` is the misc vector), `exp paramN` → location N. RDNA2/GFX10 packs clip distances before cull distances contiguously across 4-component `pos` exports (up to 8 floats total), starting at `pos2` when a misc vector (`PointSize`, `EdgeFlag`, `ShadingRate`, `Layer`, `ViewportIndex`; GFX9+ packs `Layer` in `z[10:0]` and `ViewportIndex` in `z[19:16]`) occupies `pos1`, and at `pos1` otherwise (Mesa `src/amd/common/nir/ac_nir_prerast_utils.c`: `ac_nir_export_position`; AMD LLPC `lgc/lowering/LowerInOut.cpp`: `LowerInOut::visitReturnInst`). Slot assignment follows the DXBC `OSG1` signature (`SV_ClipDistance` = 2, `SV_CullDistance` = 3, `SV_RenderTargetArrayIndex` = 4, `SV_ViewportArrayIndex` = 5, `SV_ShadingRate` = 23), ordered by `(semantic_index, register, component)` with clip before cull; when `OSG1` is absent (or declares none of those system values), `pos1..pos3` exports are discarded. PS: `v_interp_*` attribute N → input location N. `exp mrtN` → location N, `exp mrtz` x → `FragDepth`. | |
| 218 | | 16-bit results | From Mesa ACO (`aco_ir.cpp`: `instr_is_16bit`, `can_use_opsel`) for GFX10: **f16 VOP1/VOP2 ops** (`v_add/sub/mul/max/min_f16`, `v_fmac_f16`, `v_cvt_f16_f32`, f16 unary) and **opsel-capable VOP3 ops** (`v_fma_f16`, `_e64` forms of the 16-bit integer ops) are **partial writes that keep the high half**. The **VOP2 (`_e32`) 16-bit integer ops** (`v_lshrrev_b16`…) define the whole register, so the high half is modelled as zero. An op_sel destination bit writes the high half. The translator used to clear the high half on f16 ops; that's fixed. **op_sel on f16 VOP3 ops** (`v_fma_f16`, `v_med3_f16`, `v_add/sub/mul/max/min_f16`, f16 unary, `v_fmac_f16`): bit i (i < number of sources) reads the high half of source i, the last bit writes the high half of the destination; neg/abs apply to the selected half. Source: Mesa ACO `can_use_opsel` and the RDNA2 ISA VOP3 `OP_SEL` field. Checked by the structural tests in `tests/test_f16_op_sel.py` (which half is read, where the result goes); **not yet GPU-verified**. | | 218 | | 16-bit results | From Mesa ACO (`aco_ir.cpp`: `instr_is_16bit`, `can_use_opsel`) for GFX10: **f16 VOP1/VOP2 ops** (`v_add/sub/mul/max/min_f16`, `v_fmac_f16`, `v_cvt_f16_f32`, f16 unary) and **opsel-capable VOP3 ops** (`v_fma_f16`, `_e64` forms of the 16-bit integer ops) are **partial writes that keep the high half**. The **VOP2 (`_e32`) 16-bit integer ops** (`v_lshrrev_b16`…) define the whole register, so the high half is modelled as zero. An op_sel destination bit writes the high half. The translator used to clear the high half on f16 ops; that's fixed. **op_sel on f16 VOP3 ops** (`v_fma_f16`, `v_med3_f16`, `v_add/sub/mul/max/min_f16`, f16 unary, `v_fmac_f16`): bit i (i < number of sources) reads the high half of source i, the last bit writes the high half of the destination; neg/abs apply to the selected half. Source: Mesa ACO `can_use_opsel` and the RDNA2 ISA VOP3 `OP_SEL` field. Checked by the structural tests in `tests/test_f16_op_sel.py` (which half is read, where the result goes); **not yet GPU-verified**. | |
| 219 | | POPS | Primitive-ordered pixel shading (10 PS, `src_pops_exiting_wave_id` wait loop, `s_sleep`, `MSG_ORDERED_PS_DONE`) becomes **fragment-shader interlock** (`PixelInterlockOrderedEXT`). It begins at the end of the entry block and ends at shader exit: a longer critical section with the same ordering. `src_pops_exiting_wave_id` reads 0, and **the runtime must put 0 (no collision, bit 31 clear) in the POPS collision SGPR**, so the hardware wait loop is skipped. Needs `VK_EXT_fragment_shader_interlock` (`fragmentShaderPixelInterlock`). | | 219 | | POPS | Primitive-ordered pixel shading (10 PS, `src_pops_exiting_wave_id` wait loop, `s_sleep`, `MSG_ORDERED_PS_DONE`) becomes **fragment-shader interlock** (`PixelInterlockOrderedEXT`). It begins at the end of the entry block and ends at shader exit: a longer critical section with the same ordering. `src_pops_exiting_wave_id` reads 0, and **the runtime must put 0 (no collision, bit 31 clear) in the POPS collision SGPR**, so the hardware wait loop is skipped. Needs `VK_EXT_fragment_shader_interlock` (`fragmentShaderPixelInterlock`). | |
| 220 | | Texel offsets | `image_sample*_o`: the first address dword packs signed 6-bit offsets (x [5:0], y [13:8], z [21:16]), which become the SPIR-V `Offset` operand. A non-constant `Offset` outside gather needs **`VK_KHR_maintenance8`**, and is validated with `spirv-val --allow-offset-texture-operand`. Not yet GPU-tested. | | 220 | | Texel offsets | `image_sample*_o`: the first address dword packs signed 6-bit offsets (x [5:0], y [13:8], z [21:16]), which become the SPIR-V `Offset` operand. A non-constant `Offset` outside gather needs **`VK_KHR_maintenance8`**, and is validated with `spirv-val --allow-offset-texture-operand`. Not yet GPU-tested. | |
| @@ -241,7 +241,7 @@ How the generated SPIR-V expects the runtime to work: | |||
| 241 | | Typed image stores | `image_store` (2D, 2D array, 3D) writes the dmask components (missing ones = 0). The image's numeric type lives in the T# (word 1 FORMAT [28:20], 512 GFX10 formats), so it is decided at run time. A 512-bit table built from `tools/gfx10_formats.json` (30 UINT and 15 SINT formats) picks a **sint**, **uint** or **float** view (bindings 8 + 3·dim + class; dim 0 = 2D, 1 = 2D array, 2 = 3D; class 0 float, 1 uint, 2 sint). Views have Unknown format (`shaderStorageImageWriteWithoutFormat`). **The runtime binds every storage image into all three arrays of its dimension, or at least the one matching its format.** The earlier path wrote only component 0 as `r32ui`, which was wrong for every other format. GPU-checked with `runtime/test/shaders/cs_imgstore.asm` through `runtime/test/vk_store_test.cpp`: rgba8 unorm, r32 uint and r32 sint images, every texel correct. | | 241 | | Typed image stores | `image_store` (2D, 2D array, 3D) writes the dmask components (missing ones = 0). The image's numeric type lives in the T# (word 1 FORMAT [28:20], 512 GFX10 formats), so it is decided at run time. A 512-bit table built from `tools/gfx10_formats.json` (30 UINT and 15 SINT formats) picks a **sint**, **uint** or **float** view (bindings 8 + 3·dim + class; dim 0 = 2D, 1 = 2D array, 2 = 3D; class 0 float, 1 uint, 2 sint). Views have Unknown format (`shaderStorageImageWriteWithoutFormat`). **The runtime binds every storage image into all three arrays of its dimension, or at least the one matching its format.** The earlier path wrote only component 0 as `r32ui`, which was wrong for every other format. GPU-checked with `runtime/test/shaders/cs_imgstore.asm` through `runtime/test/vk_store_test.cpp`: rgba8 unorm, r32 uint and r32 sint images, every texel correct. | |
| 242 | | Typed image loads | `image_load` on 1D/2D/2D-array/3D images uses the same T# FORMAT tables as stores: UINT/SINT formats are read with `OpImageRead` through the uint/sint storage views (`shaderStorageImageReadWithoutFormat`), everything else with `OpImageFetch` through the float sampled view as before. Results are the raw bits of the dmask components. **The runtime binds integer-format images into the uint/sint storage arrays of their dimension** (bindings 8–19), as for stores. Before this, every load went through the float view, which is undefined for integer formats. GPU-checked with `runtime/test/shaders/cs_imgload.asm` (r32 uint read back exactly). | | 242 | | Typed image loads | `image_load` on 1D/2D/2D-array/3D images uses the same T# FORMAT tables as stores: UINT/SINT formats are read with `OpImageRead` through the uint/sint storage views (`shaderStorageImageReadWithoutFormat`), everything else with `OpImageFetch` through the float sampled view as before. Results are the raw bits of the dmask components. **The runtime binds integer-format images into the uint/sint storage arrays of their dimension** (bindings 8–19), as for stores. Before this, every load went through the float view, which is undefined for integer formats. GPU-checked with `runtime/test/shaders/cs_imgload.asm` (r32 uint read back exactly). | |
| 243 | | SDWA | `_sdwa` forms: each source is narrowed to `src0_sel`/`src1_sel` (BYTE_n/WORD_n, zero-extended, or sign-extended under `sext()`) **before** neg/abs and the op. A VGPR result goes to `dst_sel`, with `dst_unused` setting the other bits: PAD = 0, SEXT = sign copies above the field, PRESERVE = old bits kept. VOPC has no `dst_sel`, and GFX10 `v_cmpx` has no written destination. **Until 2026-11-20 the selects were silently ignored.** That affected 3,826 of the 13,926 translated shaders: they passed `spirv-val` but computed wrong values. GPU-checked with `runtime/test/shaders/ps_sdwa.asm` and `ps_ops.asm` (also `v_pk_fma_f16`, `v_min3_u32`, `v_max3_i32`, `v_bfe_i32`): byte/word source selects, `sext()`, `UNUSED_PRESERVE` into WORD_1 and `UNUSED_SEXT` at BYTE_2 all match on every pixel. | | 243 | | SDWA | `_sdwa` forms: each source is narrowed to `src0_sel`/`src1_sel` (BYTE_n/WORD_n, zero-extended, or sign-extended under `sext()`) **before** neg/abs and the op. A VGPR result goes to `dst_sel`, with `dst_unused` setting the other bits: PAD = 0, SEXT = sign copies above the field, PRESERVE = old bits kept. VOPC has no `dst_sel`, and GFX10 `v_cmpx` has no written destination. **Until 2026-11-20 the selects were silently ignored.** That affected 3,826 of the 13,926 translated shaders: they passed `spirv-val` but computed wrong values. GPU-checked with `runtime/test/shaders/ps_sdwa.asm` and `ps_ops.asm` (also `v_pk_fma_f16`, `v_min3_u32`, `v_max3_i32`, `v_bfe_i32`): byte/word source selects, `sext()`, `UNUSED_PRESERVE` into WORD_1 and `UNUSED_SEXT` at BYTE_2 all match on every pixel. | |
| 244 | | Known approximations | `v_cvt_pkrtz_f16_f32` is now **exact round-toward-zero** (finite overflow gives ±65504, not inf). The GPU smoke test caught the old round-to-nearest version producing inf in `PS_ImposterShadow`. The other f16 packs (`v_cvt_f16_f32`, d16 results, mix ops) round to nearest, which matches the default mode. The MODE register (`s_setreg`) is ignored, so denormal and rounding behaviour is Vulkan's default. Whole-quad mode on non-EXEC masks is the identity. `v_mul_legacy_f32` now keeps the `0 × anything = 0` rule like `v_mad_legacy_f32` (GPU-checked with `runtime/test/shaders/ps_legacy_mul.asm` on AMD Radeon RX 9070 XT). For `pos1..pos3` exports, because `PA_CL_VS_OUT_CNTL` is not in the shader blob, the clip/cull/misc split and component indices follow `OSG1` (assuming contiguous hardware packing clip→cull as in Mesa/LLPC); `PointSize`/`EdgeFlag`/`ShadingRate` in `pos1` misc are not emitted as Vulkan built-ins, and in mesh shaders a misc `OSG1` entry shifts clip/cull to `pos2..pos3` without emitting per-vertex `Layer`/`ViewportIndex`. | | 244 | | Known approximations | `v_cvt_pkrtz_f16_f32` is now **exact round-toward-zero** (finite overflow gives ±65504, not inf). The GPU smoke test caught the old round-to-nearest version producing inf in `PS_ImposterShadow`. The other f16 packs (`v_cvt_f16_f32`, d16 results, mix ops) round to nearest, which matches the default mode. The MODE register (`s_setreg`) is ignored, so denormal and rounding behaviour is Vulkan's default. Whole-quad mode on non-EXEC masks is the identity. `v_mul_legacy_f32` now keeps the `0 × anything = 0` rule like `v_mad_legacy_f32` (GPU-checked with `runtime/test/shaders/ps_legacy_mul.asm` on AMD Radeon RX 9070 XT). For `pos1..pos3` exports, because `PA_CL_VS_OUT_CNTL` is not in the shader blob, the clip/cull/misc split and component indices follow `OSG1` (assuming contiguous hardware packing clip→cull as in Mesa/LLPC), and without `OSG1` declaring `SV_ClipDistance`/`SV_CullDistance` any `pos1..pos3` export is discarded rather than guessed; `PointSize`/`EdgeFlag`/`ShadingRate` in `pos1` misc are not emitted as Vulkan built-ins, and in mesh shaders a misc `OSG1` entry shifts clip/cull to `pos2..pos3` without emitting per-vertex `Layer`/`ViewportIndex`. | |
| 245 | | Buffer bounds checking | MUBUF `buffer_load*`, `buffer_store*`, and `buffer_atomic*` enforce `num_records` (V# word 2): raw buffers (`stride == 0`) check the starting byte offset (`offset < num_records`; per-dword tail bounds on multi-dword accesses aren't split yet), and structured buffers (`stride != 0`) check `index < num_records` (`idxen`) or `offset < num_records * stride`. Out-of-bounds stores/atomics skip memory access completely and out-of-bounds loads return 0. GPU-checked with `runtime/test/shaders/cs_bounds.asm` on AMD Radeon RX 9070 XT. | | 245 | | Buffer bounds checking | MUBUF `buffer_load*`, `buffer_store*`, and `buffer_atomic*` enforce `num_records` (V# word 2): raw buffers (`stride == 0`) check the starting byte offset (`offset < num_records`; per-dword tail bounds on multi-dword accesses aren't split yet), and structured buffers (`stride != 0`) check `index < num_records` (`idxen`) or `offset < num_records * stride`. Out-of-bounds stores/atomics skip memory access completely and out-of-bounds loads return 0. GPU-checked with `runtime/test/shaders/cs_bounds.asm` on AMD Radeon RX 9070 XT. | |
| 246 | | Wave64 mask ballot | `tools/lane_masks.py` tracks per-lane masks (including 32-bit `MASK_LO`/`MASK_HI` halves, `vcc_lo`/`vcc_hi`, and `s_bfm_b64` bitfields). `s_bcnt1_i32_b64`/`b32`, `s_bcnt0_i32_b64`/`b32`, `s_ff1_i32_b64`/`b32`, `s_ff0_i32_b64`/`b32`, and `s_bitcmp0/1_b32/b64` reconstruct the 64-bit wave mask via `OpGroupNonUniformBitwiseOr` (`GroupNonUniformArithmetic`), restricting 32-bit half ops and `s_cmp_eq/lg_u32` (`wave_equal`) to the known 32-bit half in wave64. Known remaining gaps: `s_cmp_eq/lg_u32` comparing opposite halves (lo vs hi) falls back to a whole-wave vote. GPU-checked with `runtime/test/shaders/cs_wave64_ballot.asm` and `cs_wm_*.asm` on AMD Radeon RX 9070 XT (64-wide subgroup); semantic test coverage in `tests/semantic/test_scalar_bitcmp.py` and `tests/semantic/test_scalar_alu_shifts.py`. | | 246 | | Wave64 mask ballot | `tools/lane_masks.py` tracks per-lane masks (including 32-bit `MASK_LO`/`MASK_HI` halves, `vcc_lo`/`vcc_hi`, and `s_bfm_b64` bitfields). `s_bcnt1_i32_b64`/`b32`, `s_bcnt0_i32_b64`/`b32`, `s_ff1_i32_b64`/`b32`, `s_ff0_i32_b64`/`b32`, and `s_bitcmp0/1_b32/b64` reconstruct the 64-bit wave mask via `OpGroupNonUniformBitwiseOr` (`GroupNonUniformArithmetic`), restricting 32-bit half ops and `s_cmp_eq/lg_u32` (`wave_equal`) to the known 32-bit half in wave64. Known remaining gaps: `s_cmp_eq/lg_u32` comparing opposite halves (lo vs hi) falls back to a whole-wave vote. GPU-checked with `runtime/test/shaders/cs_wave64_ballot.asm` and `cs_wm_*.asm` on AMD Radeon RX 9070 XT (64-wide subgroup); semantic test coverage in `tests/semantic/test_scalar_bitcmp.py` and `tests/semantic/test_scalar_alu_shifts.py`. | |
| 247 | | Mesh/compute input registers (historical measurement) | An early read-before-write analysis over all compute and mesh shaders found **compute** v0 (880), v0–v1 (614), v0–v2 (50), consistent with AMD's local thread ID x/y/z in v0/v1/v2, and scalar inputs centred on a pointer at s[4:5] and s6/s7. **Mesh:** every one of 2,969 reads exactly **v5**, plus s3 (always arithmetic), s[16:17] and s19–s23. The early pass also read FSSM 0x13C as the group width and compared the first SGPR multiply against it (82 match, 151 don't, 1,447 no simple multiply) and wrongly concluded that 0x13C was not the group width; the matching register varied by shader (s6/s10/s7/s9…). PSV0 gave the real thread-group sizes (32×1×1 for 1,253, 8×8×1 for 416, …). **Superseded:** 0x13C/0x140/0x144 are the thread-group size, `COMPUTE_PGM_RSRC2` at 0x138 gives the per-shader user-SGPR count and enabled workgroup IDs, and mesh takes NumThreads, limits and topology from PSV0 with v5 as the workgroup index. All 2,689 CS and 9,282 mesh shaders translate now (see the Compute shaders and Mesh shaders rows). | | 247 | | Mesh/compute input registers (historical measurement) | An early read-before-write analysis over all compute and mesh shaders found **compute** v0 (880), v0–v1 (614), v0–v2 (50), consistent with AMD's local thread ID x/y/z in v0/v1/v2, and scalar inputs centred on a pointer at s[4:5] and s6/s7. **Mesh:** every one of 2,969 reads exactly **v5**, plus s3 (always arithmetic), s[16:17] and s19–s23. The early pass also read FSSM 0x13C as the group width and compared the first SGPR multiply against it (82 match, 151 don't, 1,447 no simple multiply) and wrongly concluded that 0x13C was not the group width; the matching register varied by shader (s6/s10/s7/s9…). PSV0 gave the real thread-group sizes (32×1×1 for 1,253, 8×8×1 for 416, …). **Superseded:** 0x13C/0x140/0x144 are the thread-group size, `COMPUTE_PGM_RSRC2` at 0x138 gives the per-shader user-SGPR count and enabled workgroup IDs, and mesh takes NumThreads, limits and topology from PSV0 with v5 as the workgroup index. All 2,689 CS and 9,282 mesh shaders translate now (see the Compute shaders and Mesh shaders rows). | |
| @@ -271,13 +271,31 @@ cross-half code on 32-wide subgroups. | |||
| 271 | 271 | ||
| 272 | The AMDGPU disassembler needs LLVM 21+ built with the AMDGPU target (`llvm-mc`; on Linux the `llvm-21` package | 272 | The AMDGPU disassembler needs LLVM 21+ built with the AMDGPU target (`llvm-mc`; on Linux the `llvm-21` package |
| 273 | installs it at `/usr/lib/llvm-21/bin/llvm-mc`). The official Windows LLVM build has no AMDGPU target and ships no | 273 | installs it at `/usr/lib/llvm-21/bin/llvm-mc`). The official Windows LLVM build has no AMDGPU target and ships no |
| 274 | `llvm-mc.exe`, so on Windows run it from WSL and give `LLVM_MC` the whole command: | 274 | `llvm-mc.exe`. On Windows, either build a native one or run it from WSL. |
| 275 | |||
| 276 | Native: `scripts\build_llvm_mc.ps1` fetches the LLVM sources the tool needs (sparse, shallow), builds `llvm-mc` alone | ||
| 277 | with `LLVM_TARGETS_TO_BUILD=AMDGPU`, static CRT and the DIA SDK off (its headers need ATL, which the C++ build tools | ||
| 278 | don't always include), checks it disassembles an `s_endpgm` for `gfx1013`, keeps only `llvm-mc.exe` (by default in | ||
| 279 | `%LOCALAPPDATA%\Leonida\llvm-mc`) and sets `LLVM_MC` for the user. It needs git, Python and Visual Studio with the C++ | ||
| 280 | x64 tools, about 2 GB of temporary space and 20-40 minutes. `-Dest`, `-NoEnv`, `-Keep` and `-Version` change the | ||
| 281 | defaults. | ||
| 282 | |||
| 283 | ``` | ||
| 284 | powershell -ExecutionPolicy Bypass -File scripts\build_llvm_mc.ps1 | ||
| 285 | python -I make_game.py --game "D:\path\to\your\package" --stages shaders | ||
| 286 | ``` | ||
| 287 | |||
| 288 | WSL: install `llvm-21` and give `LLVM_MC` the whole command: | ||
| 275 | 289 | ||
| 276 | ``` | 290 | ``` |
| 277 | set LLVM_MC=wsl -d Ubuntu -e /usr/lib/llvm-21/bin/llvm-mc | 291 | set LLVM_MC=wsl -d Ubuntu -e /usr/lib/llvm-21/bin/llvm-mc |
| 278 | python -I make_game.py --game "D:\path\to\your\package" --stages shaders | 292 | python -I make_game.py --game "D:\path\to\your\package" --stages shaders |
| 279 | ``` | 293 | ``` |
| 280 | 294 | ||
| 295 | The same form works in every tool that reads `LLVM_MC`. `tools/mc_command.py` splits it for `shader_disasm.py`, | ||
| 296 | the tests, `runtime/test/shaders/build.py` and `scripts/run_gpu_tests.py`; the assembler callers pass the assembly | ||
| 297 | on stdin, so a WSL command never receives a Windows file path. | ||
| 298 | |||
| 281 | `shader_disasm.py` disassembles one `s_endpgm` before starting, so a missing tool or AMDGPU target stops the run | 299 | `shader_disasm.py` disassembles one `s_endpgm` before starting, so a missing tool or AMDGPU target stops the run |
| 282 | with that reason instead of writing empty `.s` files. To disassemble by hand inside WSL: | 300 | with that reason instead of writing empty `.s` files. To disassemble by hand inside WSL: |
| 283 | 301 | ||
diff --git a/docs/gamedata.md b/docs/gamedata.md index 8e7f73847..88b8f57e6 100644 --- a/docs/gamedata.md +++ b/docs/gamedata.md | |||
| @@ -176,6 +176,60 @@ A runtime consumer needs: | |||
| 176 | - strict handling of the 9 tail-only and 1 unattributed blocks: they are incomplete evidence, not documents | 176 | - strict handling of the 9 tail-only and 1 unattributed blocks: they are incomplete evidence, not documents |
| 177 | to guess at. | 177 | to guess at. |
| 178 | 178 | ||
| 179 | ## XML catalog | ||
| 180 | |||
| 181 | `tools/gamedata_xml.py` turns a carve into a per-file and per-root catalog. It is stdlib-only and rebuilds | ||
| 182 | multi-stream documents with `gamedata_index.py`, so it reads the same 267 XML payloads the index reports: | ||
| 183 | |||
| 184 | ```powershell | ||
| 185 | python -I tools/gamedata_xml.py <work>\carve\common --json xml.json --csv xml.csv --check | ||
| 186 | ``` | ||
| 187 | |||
| 188 | The file rows carry offset/bytes/chunks, root, category, element count, maximum depth, attribute names, `$(name)` | ||
| 189 | and `platform:/` counts, include-like counts and the well-formed/fragment flags. The root rows add the | ||
| 190 | element-name and attribute histograms and the reference targets. `--check` separates a rootless fragment, a | ||
| 191 | tail-only document and a malformed document instead of treating all three as parse failures. | ||
| 192 | |||
| 193 | Measured over the 267 payloads (43,284,925 B): | ||
| 194 | |||
| 195 | | Measure | Value | | ||
| 196 | |---|---:| | ||
| 197 | | Well-formed | 259 (257 with a declaration, 2 tail-only) | | ||
| 198 | | Truncated at the start | 7 | | ||
| 199 | | Rootless fragment | 1 | | ||
| 200 | | Malformed | 0 | | ||
| 201 | | Named roots / catalogued roots | 118 (+1 unattributed) / 118 | | ||
| 202 | | Elements / distinct element names | 428,611 / 5,293 | | ||
| 203 | | Attribute names / `type` values / `content` kinds | 33 / 318 / 7 | | ||
| 204 | | Maximum depth | 17 | | ||
| 205 | | Comment starts (all / declaration-bearing) | 507 / 412 | | ||
| 206 | | `filename` / `parentPath` / `parentFile` / XInclude | 3,315 / 40 / 3 / 0 | | ||
| 207 | | `platform:/` references (levels / other) | 2,674 (2,346 / 328) | | ||
| 208 | | `$(common)` / `$(root)` / `$(target)` references | 588 / 28 / 23 | | ||
| 209 | |||
| 210 | Macro counts cover all element text; 587 of the 588 `$(common)` hits are in `<filename>` elements, which is the | ||
| 211 | filename-only bucket in the table above. | ||
| 212 | |||
| 213 | The root and element distribution is the one in the tables above: the five repeated roots hold 141 of the 266 | ||
| 214 | documents, and the element histogram is dominated by the general node names `Item` (118,179), `item` (16,316) | ||
| 215 | and `Name` (12,850). The long tail is per-system parameter names; the manifest and timecycle names are a small | ||
| 216 | part of it. A category is a dispatch bucket, not a schema: for the 266 documents the catalog reproduces the | ||
| 217 | file and root counts in the functional table and assigns each root one category. No root has more than one | ||
| 218 | handler. | ||
| 219 | |||
| 220 | Reference handling is narrow. Every `$(...)` and `platform:/` string is element text, not an attribute; no | ||
| 221 | document uses XInclude. The macro alphabet is `$(common)`, `$(target)` and `$(root)`, and the platform targets | ||
| 222 | split into `platform:/levels/` and everything else. `filename` is the only include-like element with a large | ||
| 223 | population; `parentPath`/`parentFile` are the only relative references outside it. A resolver therefore needs | ||
| 224 | four prefix rules and a content-set/mount walk, not a general include processor. | ||
| 225 | |||
| 226 | A runtime dispatcher needs the 118-root table (or an RTTI class bridge), the 12 category buckets, the 318-value | ||
| 227 | `type` registry, the 33-name attribute whitelist, the `content=` array decoders and a streaming reader for the | ||
| 228 | 14 MB document. It also needs to mark the 9 tail-only documents and the one rootless block as incomplete | ||
| 229 | evidence: `gamedata_xml.py --check` is the reference for that split. The catalog is a local work product. Only | ||
| 230 | aggregate counts and schema/root/element/attribute names belong in git; the CSV/JSON, the element values, the | ||
| 231 | `type`/`content` values and per-file paths stay on the local machine. The tests are synthetic. | ||
| 232 | |||
| 179 | ## Relationship to `data.rpf` and `script.rpf` | 233 | ## Relationship to `data.rpf` and `script.rpf` |
| 180 | 234 | ||
| 181 | | Archive | Size | Streams | Inflated | Dominant payloads | XML | `RBF0` | `PSIN` | | 235 | | Archive | Size | Streams | Inflated | Dominant payloads | XML | `RBF0` | `PSIN` | |
diff --git a/docs/rbf0.md b/docs/rbf0.md index a07d7962e..5322fda3d 100644 --- a/docs/rbf0.md +++ b/docs/rbf0.md | |||
| @@ -15,6 +15,7 @@ payload, carved stream, path list or string dump is committed here. | |||
| 15 | | Is there a name or hash table? | **No.** Schema names are inline UTF-8 with a u16 length. There is no hash table and no readable hash string. The 64-bit integers are mostly small codes; none is identified as a name hash. | | 15 | | Is there a name or hash table? | **No.** Schema names are inline UTF-8 with a u16 length. There is no hash table and no readable hash string. The 64-bit integers are mostly small codes; none is identified as a name hash. | |
| 16 | | What do the streams carry? | UI framework and UI data schemas, movie-subtitle containers, and three tuning/config schemas. No animation, mesh or audio payload. | | 16 | | What do the streams carry? | UI framework and UI data schemas, movie-subtitle containers, and three tuning/config schemas. No animation, mesh or audio payload. | |
| 17 | | Is it the same format as the `anim.rpf` rig blob? | **Yes, same container and grammar.** That blob is one `rage__crRigSetManager` resource; its 9 descriptors and 28,962 elements parse with the same rules. | | 17 | | Is it the same format as the `anim.rpf` rig blob? | **Yes, same container and grammar.** That blob is one `rage__crRigSetManager` resource; its 9 descriptors and 28,962 elements parse with the same rules. | |
| 18 | | Can it be decoded to a tree? | **Yes.** `tools/rbf0_tree.py` decodes all 1,263 resources to element/value/text trees. Unknown descriptors and record types fail closed. | | ||
| 18 | | Compression inside `RBF0`? | **None observed.** The only compression is the outer RPF9 zlib framing. | | 19 | | Compression inside `RBF0`? | **None observed.** The only compression is the outer RPF9 zlib framing. | |
| 19 | 20 | ||
| 20 | ## 1. Method and coverage | 21 | ## 1. Method and coverage |
| @@ -229,6 +230,12 @@ The rig blob's nine descriptors are `rage__crRigSetManager`, `RigSet`, `Item`, ` | |||
| 229 | strings. The element words are again `0, 0, attrs` (27,836 with 0, 1,126 with 1) and there are no attribute | 230 | strings. The element words are again `0, 0, attrs` (27,836 with 0, 1,126 with 1) and there are no attribute |
| 230 | mismatches. | 231 | mismatches. |
| 231 | 232 | ||
| 233 | The grammar-driven tree decoder in section 9 reproduces those counts and resolves the nesting. The root contains | ||
| 234 | one `RigSet`, whose 1,126 `Item` elements each carry one `key` string attribute and one `Entries` element. Under | ||
| 235 | `Entries`, the 6,677 entry `Item` elements contain a `Dictionary` text, a `Rig` text, a `Group` text and a | ||
| 236 | `Priority` integer after the three child elements. Maximum element depth is 6. The decoder does not resolve the | ||
| 237 | rig-to-skeleton link. | ||
| 238 | |||
| 232 | So the container, prologue, record grammar and element header are shared. The difference is the root schema: | 239 | So the container, prologue, record grammar and element header are shared. The difference is the root schema: |
| 233 | `anim.rpf` carries a rig-set manager, while `data.rpf` carries UI and config schemas. No `data.rpf` resource has | 240 | `anim.rpf` carries a rig-set manager, while `data.rpf` carries UI and config schemas. No `data.rpf` resource has |
| 234 | the rig-set root, an `anim/` string or a `SKEL_` string. The `data.rpf` RBF0s are not animation data. | 241 | the rig-set root, an `anim/` string or a `SKEL_` string. The `data.rpf` RBF0s are not animation data. |
| @@ -263,7 +270,163 @@ the rig-set root, an `anim/` string or a `SKEL_` string. The `data.rpf` RBF0s ar | |||
| 263 | 7. **Keep the compression boundary explicit.** The RBF0 bytes are uncompressed after the outer RPF9 zlib inflate. | 270 | 7. **Keep the compression boundary explicit.** The RBF0 bytes are uncompressed after the outer RPF9 zlib inflate. |
| 264 | There is no byte-blob value type and the parse consumes every byte, so there is no place for a nested frame. | 271 | There is no byte-blob value type and the parse consumes every byte, so there is no place for a nested frame. |
| 265 | 272 | ||
| 266 | ## 9. Reproduction | 273 | The chunk join, descriptor/type pairing, width selection, attribute count and tree build are implemented in |
| 274 | `tools/rbf0_tree.py`; section 9 records what that decoder measured and what it still cannot name. | ||
| 275 | |||
| 276 | ## 9. Tree decoder | ||
| 277 | |||
| 278 | `tools/rbf0_tree.py` turns the record stream into a tree. It reads a carve directory or one complete resource, | ||
| 279 | joins the 64 KiB continuations, and writes one JSON file with one object per resource, plus optional per-resource | ||
| 280 | generic XML files. It is stdlib-only and uses no schema file. | ||
| 281 | |||
| 282 | The full `data.rpf` carve decodes **1,263 of 1,263 resources with status `ok`**, and the totals are identical to the | ||
| 283 | index counts in section 3: 475,461 elements, 254,935 text records, 85,924 string values, 160,490 value records, | ||
| 284 | 44,887 descriptors (698 distinct names) and maximum element depth 36. No unknown record type occurs in the corpus. | ||
| 285 | |||
| 286 | ### 9.1 Grammar used by the decoder | ||
| 287 | |||
| 288 | | Bytes | Meaning | | ||
| 289 | |---|---| | ||
| 290 | | `RBF0` + `FB FF 01 00` | magic and the wide (64-bit integer/float) prologue; without the prologue values are 32-bit | | ||
| 291 | | `idx type` | one record; `idx < descriptor_count` reuses a descriptor, `idx == descriptor_count` adds one | | ||
| 292 | | `u16 len` + UTF-8 | descriptor name, present only when the record adds a descriptor | | ||
| 293 | | `0x00` | element open; three u16 words follow, words 0 and 1 are zero and word 2 is the attribute count | | ||
| 294 | | `0x10` | unsigned integer, 8 bytes wide or 4 bytes narrow | | ||
| 295 | | `0x20` / `0x30` | true / false, no payload | | ||
| 296 | | `0x40` | float, 8 bytes wide or 4 bytes narrow | | ||
| 297 | | `0x50` | three floats, 3 x width (not present in this corpus) | | ||
| 298 | | `0x60` | string; u16 length followed by that many UTF-8 bytes | | ||
| 299 | | `FD FF` | text for the open element; u32 length followed by that many bytes (NUL-terminated in this corpus) | | ||
| 300 | | `FF FF` | close the open element | | ||
| 301 | |||
| 302 | A descriptor is a name index, not a type declaration. The decoder records the type that introduced the descriptor | ||
| 303 | and all later types used with the same index. | ||
| 304 | |||
| 305 | In every one of the 1,263 resources, the declared attributes are the first value records of their element: no child | ||
| 306 | element or text record precedes them (0 violations). Values after the attribute prefix are content in stream order, | ||
| 307 | and a value can follow a child element. A text record attaches to the open element. | ||
| 308 | |||
| 309 | ### 9.2 Measured tree facts | ||
| 310 | |||
| 311 | | Measure | Value | | ||
| 312 | |---|---:| | ||
| 313 | | Resources decoded | 1,263 / 1,263 `ok` | | ||
| 314 | | Elements | 475,461 | | ||
| 315 | | Elements with 0 / 1 / 2 declared attributes | 389,525 / 84,541 / 1,395 | | ||
| 316 | | Attribute values | 87,331: 85,924 string, 1,111 integer, 296 float | | ||
| 317 | | Two-attribute type pairs | float/float 128, string/int 1,111, string/float 40, string/string 116 | | ||
| 318 | | Non-attribute values | 73,159: 38,008 float, 28,289 integer, 6,862 boolean | | ||
| 319 | | Non-attribute values after a child element | 22,977 | | ||
| 320 | | Text records | 254,935, all NUL-terminated | | ||
| 321 | | Text-only elements | 254,935; one text record, first content, no child or value | | ||
| 322 | | String values | 85,924; all are attributes and none is NUL-terminated | | ||
| 323 | | Text / string length | 2-1,006 / 1-126 bytes (the text length includes its trailing NUL) | | ||
| 324 | | Descriptor instances reused with more than one type | 564 | | ||
| 325 | | Root with an attribute | 1: `rage__SafeframeConfig` | | ||
| 326 | | Descriptor names not usable as XML element names | 1: `xmlns:xi` | | ||
| 327 | | Unknown record types | 0 | | ||
| 328 | |||
| 329 | The single root attribute is `xmlns:xi` on the narrow `rage__SafeframeConfig` resource at archive offset | ||
| 330 | `0x1c33e000` (18,317 inflated bytes). The same name is declared as descriptor 1 at offset `0x23` and is used 14 times | ||
| 331 | in that resource. It is also the only descriptor name that cannot be used as an XML element name (the `xmlns` | ||
| 332 | prefix is reserved), which is why the XML writer uses fixed tags and puts the exact name in a `name` attribute. | ||
| 333 | |||
| 334 | Of the 26 text payloads that are not valid UTF-8, all are text records; no string value or descriptor name failed | ||
| 335 | a strict UTF-8 decode. The decoder replaces invalid bytes with U+FFFD and sets `utf8_valid: false`; the original | ||
| 336 | encoding is not established. | ||
| 337 | |||
| 338 | ### 9.3 Sample trees | ||
| 339 | |||
| 340 | The three samples below are the smallest resources of their root schema that decode completely. Offsets are | ||
| 341 | relative to the start of the joined resource. | ||
| 342 | |||
| 343 | | Root schema | Archive offset | Inflated | Layout | Descriptors | Elements | Texts | Strings | Depth | | ||
| 344 | |---|---|---:|---|---:|---:|---:|---:|---:| | ||
| 345 | | `CMovieSubtitleContainer` | `0x9ed7280` | 490 | wide-64 | 13 | 11 | 3 | 3 | 4 | | ||
| 346 | | `rage__fwuiPrefab` | `0x11dd8950` | 195 | wide-64 | 5 | 4 | 2 | 1 | 3 | | ||
| 347 | | `UIScreen` | `0x12059180` | 385 | wide-64 | 9 | 9 | 6 | 0 | 3 | | ||
| 348 | |||
| 349 | `CMovieSubtitleContainer` descriptor table: | ||
| 350 | |||
| 351 | | ID | Name | First type | Uses | | ||
| 352 | |---:|---|---|---:| | ||
| 353 | | 0 | `CMovieSubtitleContainer` | open | 1 | | ||
| 354 | | 1 | `TextBlockName` | open | 1 | | ||
| 355 | | 2 | `pCutsceneEventArgsList` | open | 1 | | ||
| 356 | | 3 | `Item` | open | 3 | | ||
| 357 | | 4 | `type` | string | 3 | | ||
| 358 | | 5 | `cName` | open | 2 | | ||
| 359 | | 6 | `m_cOptionalActor` | open | 2 | | ||
| 360 | | 7 | `fSubtitleDuration` | float | 2 | | ||
| 361 | | 8 | `pCutsceneEventList` | open | 1 | | ||
| 362 | | 9 | `fTime` | float | 1 | | ||
| 363 | | 10 | `iEventId` | int | 1 | | ||
| 364 | | 11 | `iEventArgsIndex` | int | 1 | | ||
| 365 | | 12 | `iObjectId` | int | 1 | | ||
| 366 | |||
| 367 | The tree shows the attribute/content split directly: | ||
| 368 | |||
| 369 | ``` | ||
| 370 | 0x0008 element 0 CMovieSubtitleContainer attrs=0 end 0x01ea | ||
| 371 | 0x0029 element 1 TextBlockName | ||
| 372 | 0x0040 text length 8 | ||
| 373 | 0x0050 element 2 pCutsceneEventArgsList | ||
| 374 | 0x0070 element 3 Item attrs=1 | ||
| 375 | 0x007e value 4 type (string, attribute) | ||
| 376 | 0x009e element 5 cName | ||
| 377 | 0x00ad text length 12 | ||
| 378 | 0x00c1 element 6 m_cOptionalActor | ||
| 379 | 0x00dd value 7 fSubtitleDuration (float, content after the child) | ||
| 380 | 0x0154 element 8 pCutsceneEventList | ||
| 381 | 0x0170 element 3 Item attrs=1 | ||
| 382 | 0x018f value 9 fTime (float) | ||
| 383 | 0x01a0 value 10 iEventId (int) | ||
| 384 | 0x01b4 value 11 iEventArgsIndex (int) | ||
| 385 | 0x01cf value 12 iObjectId (int) | ||
| 386 | 0x01e8 close root; end 0x01ea | ||
| 387 | ``` | ||
| 388 | |||
| 389 | The 195-byte `rage__fwuiPrefab` uses descriptor IDs 0-4: root, `Id`, `PrefabObject`, `type` (string) and `Style`. | ||
| 390 | Its root is at 0x08; `Id` at 0x22 with a 42-byte text at 0x2e; `PrefabObject` at 0x60 with one attribute `type` | ||
| 391 | at 0x76; `Style` at 0x8f with a 25-byte text at 0x9e; root close at 0xc1, end 0xc3. | ||
| 392 | |||
| 393 | The 385-byte `UIScreen` uses descriptor IDs 0-8: `UIScreen`, `LayoutParams`, `widthContentMode`, | ||
| 394 | `heightContentMode`, `horizontalAlignment`, `verticalAlignment`, `Name`, `Screen` and `ID`. It has nine elements | ||
| 395 | and six text leaves; `LayoutParams` contains four text-valued children and the root contains `Name`, `Screen` and | ||
| 396 | `ID` siblings. No attribute is present. | ||
| 397 | |||
| 398 | ### 9.4 Output and failure behavior | ||
| 399 | |||
| 400 | JSON carries one object per resource: `offset`, `size`, `chunks`, `layout`, `root_name`, `status`, `error`, | ||
| 401 | `descriptors`, `counts` and `tree`. Every node has a `kind` and a byte `offset`. Elements carry `descriptor`, | ||
| 402 | `attrs_declared`, `attributes`, ordered `content` and `end`; values carry `descriptor`, `type`, `payload_offset`, | ||
| 403 | `size` and `value`; text nodes carry `length`, `nul_terminated`, `text` and `utf8_valid`. | ||
| 404 | |||
| 405 | XML is a rendering, not a round-trip. Fixed tags avoid descriptor names that are not legal XML names: | ||
| 406 | `<node name="...">`, `<attr>`, `<value>` and `<text>`. A string containing XML markup is escaped by the writer. | ||
| 407 | |||
| 408 | The decoder fails closed. An index beyond the current descriptor table, an unknown record type, a non-zero element | ||
| 409 | header word, a close or text with no open element, and a truncated payload stop that resource with `status` `bad` | ||
| 410 | or `truncated`; the partial tree is kept and no value is invented. `status` `trailing` means the root closed before | ||
| 411 | the last byte. The corpus has 0 bad, 0 truncated and 0 trailing resources. | ||
| 412 | |||
| 413 | ### 9.5 Remaining unknowns | ||
| 414 | |||
| 415 | - There is no schema: descriptor names are fields, but value meaning, enum spelling and units are not stored. | ||
| 416 | - The prologue's meaning is still not established; the decoder uses it only to select 4- or 8-byte values. | ||
| 417 | - Element header words 0 and 1 are zero in all 475,461 elements. Their intended meaning is unknown; the decoder | ||
| 418 | rejects a non-zero value instead of guessing. | ||
| 419 | - The attribute rule is measured, not proven universal: every corpus attribute leads its element and every text | ||
| 420 | element is a text-only leaf. The decoder marks `attribute_order_violation`, `multiple_text` and | ||
| 421 | `text_after_child` if a future resource departs from it; the corpus has none of these. | ||
| 422 | - The 26 invalid UTF-8 text payloads have no established encoding. The XML writer replaces bad bytes, so it is | ||
| 423 | lossy for those records. | ||
| 424 | - `xmlns:xi` is a literal field name. Its namespace meaning is not decoded. | ||
| 425 | - `0x50` (three floats) is accepted by the grammar but never occurs in this corpus. | ||
| 426 | - No external schema or XSD validates the tree; XML output is a structural rendering only. | ||
| 427 | - A resource does not store its archive path. The source label is the carve offset or file name, not a game path. | ||
| 428 | |||
| 429 | ## 10. Reproduction | ||
| 267 | 430 | ||
| 268 | ```powershell | 431 | ```powershell |
| 269 | # Index the archive: CSV or JSON, root/counts/strings; no payload is written | 432 | # Index the archive: CSV or JSON, root/counts/strings; no payload is written |
| @@ -273,16 +436,23 @@ python -I tools/rbf0_index.py <package>\data.rpf <work>\rbf0.csv --quiet | |||
| 273 | # Index a directory of already-carved streams (offsets from leading hex file names) | 436 | # Index a directory of already-carved streams (offsets from leading hex file names) |
| 274 | python -I tools/rbf0_index.py <work>\data-carve <work>\rbf0.json | 437 | python -I tools/rbf0_index.py <work>\data-carve <work>\rbf0.json |
| 275 | 438 | ||
| 276 | # Unit test: synthetic headers only | 439 | # Decode trees from the same carve; JSON plus optional per-resource XML |
| 440 | python -I tools/rbf0_tree.py <work>\data-carve <work>\rbf0-tree.json | ||
| 441 | python -I tools/rbf0_tree.py <work>\data-carve <work>\rbf0-tree.json --xml <work>\rbf0-xml | ||
| 442 | python -I tools/rbf0_tree.py <work>\data-carve <work>\subtitle.json --root CMovieSubtitleContainer --limit 1 | ||
| 443 | |||
| 444 | # Unit tests: synthetic headers and trees only | ||
| 277 | python -I tests/test_rbf0_index.py | 445 | python -I tests/test_rbf0_index.py |
| 446 | python -I tests/test_rbf0_tree.py | ||
| 278 | ``` | 447 | ``` |
| 279 | 448 | ||
| 280 | The JSON summary carries the corpus totals used above (`streams`, `compressed_bytes`, `inflated_bytes`, | 449 | The JSON summary carries the corpus totals used above (`streams`, `compressed_bytes`, `inflated_bytes`, |
| 281 | `rbf0.resources`, `rbf0.multi_chunk`, `rbf0.by_root`, `rbf0.size_buckets`, record counts, string categories and | 450 | `rbf0.resources`, `rbf0.multi_chunk`, `rbf0.by_root`, `rbf0.size_buckets`, record counts, string categories and |
| 282 | keyword occurrences), so the numbers can be re-measured without committing an index. `--all-strings` writes the | 451 | keyword occurrences), so the numbers can be re-measured without committing an index. `--all-strings` writes the |
| 283 | full readable string list to JSON; that file is game data and must stay out of git. | 452 | full readable string list to JSON; that file is game data and must stay out of git. The tree output and XML files |
| 453 | contain names and payloads and are game data too. | ||
| 284 | 454 | ||
| 285 | ## 10. No-sharing rule | 455 | ## 11. No-sharing rule |
| 286 | 456 | ||
| 287 | Game files, carved streams, inflated RBF0 blobs, readable string lists, parsed trees and reports that quote them | 457 | Game files, carved streams, inflated RBF0 blobs, readable string lists, parsed trees and reports that quote them |
| 288 | stay on the machine that owns the package. Do not commit them, attach them to an issue or pull request, or paste | 458 | stay on the machine that owns the package. Do not commit them, attach them to an issue or pull request, or paste |
diff --git a/docs/textures.md b/docs/textures.md index 7ed20c0ae..52b085931 100644 --- a/docs/textures.md +++ b/docs/textures.md | |||
| @@ -16,8 +16,9 @@ field. | |||
| 16 | | skipped | 48,220 | | 16 | | skipped | 48,220 | |
| 17 | 17 | ||
| 18 | **Bottom line:** the gap is measurable and the codec mapping is certain, but BCPack itself is | 18 | **Bottom line:** the gap is measurable and the codec mapping is certain, but BCPack itself is |
| 19 | not decodable from public facts. No decoder is added; the next tractable work is the compact | 19 | not decodable from public facts. No BCPack decoder is added. The compact mip chain, which the |
| 20 | packed tail, not BCPack. | 20 | first measurement called the next tractable work, is now decoded and validated below; the |
| 21 | remaining gap is BCPack. | ||
| 21 | 22 | ||
| 22 | This is the same 308,895 / 48,220 total already recorded in `docs/design.md`. The recount | 23 | This is the same 308,895 / 48,220 total already recorded in `docs/design.md`. The recount |
| 23 | splits the 48,220 by cause: the old "(BCPack or unmapped)" label hides 14,713 skips whose | 24 | splits the 48,220 by cause: the old "(BCPack or unmapped)" label hides 14,713 skips whose |
| @@ -96,8 +97,137 @@ The partial exports are a separate gap. Of the 210,292: | |||
| 96 | 97 | ||
| 97 | The packed-tail gap affects more textures than the BCPack skip count (196,257 partial | 98 | The packed-tail gap affects more textures than the BCPack skip count (196,257 partial |
| 98 | exports vs 33,507 skips), but it loses only the small mips. It is also not a BCPack problem: | 99 | exports vs 33,507 skips), but it loses only the small mips. It is also not a BCPack problem: |
| 99 | 196,257 textures stop at the last standalone mip because `UsableMipLimit = NonTailMipCount` | 100 | 196,257 textures stop at the descriptor's `non_tail` field because `UsableMipLimit = |
| 100 | for compact profiles, regardless of codec. | 101 | NonTailMipCount` for compact profiles, regardless of codec. The next section measures that |
| 102 | field against the layout and finds that it is not the tail boundary: most of the "packed | ||
| 103 | tail" is standalone mips the reader drops. | ||
| 104 | |||
| 105 | ## The compact mip chain | ||
| 106 | |||
| 107 | The 196,257 partial exports and the 14,030 compact-profile skips are the same layout | ||
| 108 | problem, not a codec problem. `tools/ttpf_mips.py` measures and decodes it; the counts below | ||
| 109 | come from its `scan` and `check` over the same 57 pools. | ||
| 110 | |||
| 111 | ### The descriptor mode is a flag plus a tile mode | ||
| 112 | |||
| 113 | `TtpfReader` reads the descriptor mode as one number (`b >> 23`) and selects a 64 KiB tile | ||
| 114 | only for mode 0. The observed values split into a low flag bit and a 4-bit Gfx10 tile mode at | ||
| 115 | bit 1: | ||
| 116 | |||
| 117 | | `(mode >> 1) & 0xF` | Gfx10 mode | Tile | Descriptors | | ||
| 118 | |---:|---|---:|---:| | ||
| 119 | | 0 | `SW_64KB_D` | 64 KiB | 39,283 | | ||
| 120 | | 1 | `SW_4KB_S` | 4 KiB | 70,497 | | ||
| 121 | | 2 | `SW_4KB_S` | 4 KiB | 195,957 | | ||
| 122 | | 3 | `SW_4KB_S` | 4 KiB | 50,811 | | ||
| 123 | | 9–12 | array/volume | — | 567 | | ||
| 124 | |||
| 125 | Modes 9–12 are exactly the 567 cube descriptors; the other 111 array/volume records use tile | ||
| 126 | mode 0 or 1. Bit 0 of the field is independent: modes 4/5 share tile mode 2, 6/7 share tile | ||
| 127 | mode 3, and 36/38 share tile modes 2/3. The reader's `mode == 0` test therefore gives a 4 KiB | ||
| 128 | layout to modes 1 and 32, which are 64 KiB. Fifteen mode 1/32 descriptors have a known element | ||
| 129 | size; all fifteen match a 64 KiB allocation span and one (`maps_4_7` #6034) decodes at | ||
| 130 | 0.00–0.33 levels (see below). The other 19 mode 1/32 records are the unknown-format ones in | ||
| 131 | the table below. | ||
| 132 | |||
| 133 | ### The layout is the AMD mip tail | ||
| 134 | |||
| 135 | The compact profile is the Gfx10 mip chain: standalone mips are padded to whole blocks and | ||
| 136 | stored smallest-first; a mip whose element count fits half a tile width and a tile height, | ||
| 137 | among the last 8 (4 KiB) or 12 (64 KiB) mips, goes into one shared tile at offset 0 at the | ||
| 138 | AMD entry offset (`m = max_tail - 1 - k`; `entry = m > 6 ? 16 << m : m << 8`). | ||
| 139 | |||
| 140 | On all 356,413 2D descriptors with a known element size — the 232,789 already-trusted compact | ||
| 141 | exports, the 14,011 layout-capable records the profile table rejects, and every non-compact | ||
| 142 | mode — the computed size equals `next_allocation - base`. There are **0 mismatches**. The | ||
| 143 | remaining 702 descriptors are 678 arrays/volumes and 24 formats without an element-size | ||
| 144 | mapping. | ||
| 145 | |||
| 146 | ### `non_tail` is not the layout boundary | ||
| 147 | |||
| 148 | The descriptor's 3-bit `non_tail` field (`b & 7`) is where the reader stops, and its note calls | ||
| 149 | the remaining mips "packed tail". The bytes do not follow that split: | ||
| 150 | |||
| 151 | - 177,111 of the 232,789 compact exports have `non_tail < first_tail`; 214,298 standalone | ||
| 152 | mips lie beyond the limit, 204,108 of them in zlib/raw chunks. | ||
| 153 | - 196,257 partial exports stop exactly at `non_tail`; 158,272 of them stop **before** the | ||
| 154 | computed tail boundary, and only 37,985 stop at it. | ||
| 155 | - Of the 1,072,068 missing mips, 1,065,138 are in zlib/raw chunks. That decodable part splits | ||
| 156 | into 193,019 standalone mips and 872,119 packed-tail mips; the other 6,930 missing mips (in | ||
| 157 | 1,166 textures) touch BCPack. | ||
| 158 | |||
| 159 | `UsableMipLimit = NonTailMipCount` therefore drops decodable standalone mips, not only the | ||
| 160 | tile. The allocation spans and the decoded content both put the tail at the computed index. | ||
| 161 | |||
| 162 | ### The 14,030 profile-table records | ||
| 163 | |||
| 164 | | | Textures | | ||
| 165 | |---|---:| | ||
| 166 | | same layout, new tuple (4 KiB) | 13,956 | | ||
| 167 | | same layout, modes 5/7/34/38 | 40 | | ||
| 168 | | same layout, 64 KiB (modes 1/32) | 15 | | ||
| 169 | | **layout resolved** | **14,011** | | ||
| 170 | | format without an element-size mapping | 19 | | ||
| 171 | | **total** | **14,030** | | ||
| 172 | |||
| 173 | - 11,570 have every mip in a zlib/raw chunk: all 35,727 mips decode (2.91 GiB decompressed). | ||
| 174 | - 469 more have a zlib/raw tail tile but a BCPack larger mip, so only their lower mips can be | ||
| 175 | exported. | ||
| 176 | - The 19 blocked records are mode 1 (64 KiB) with DXGI formats 156, 199, 211 and 226; the | ||
| 177 | format-to-element-size mapping is the only unknown, not the mip layout. | ||
| 178 | |||
| 179 | The five DXGI 11 (`R16G16B16A16_UNORM`) records are a separate one-line gap: DXGI 11 is 8 | ||
| 180 | bytes per element, but the vendored element table has no entry. Their layout then matches, | ||
| 181 | but uncompressed tiling is not validated, so they are not exported here. | ||
| 182 | |||
| 183 | ### Sample validation | ||
| 184 | |||
| 185 | `tools/ttpf_mips.py check` detiles one chain, decodes BC1/BC3/BC4/BC5 and compares each mip | ||
| 186 | with a 2x2 box downsample of its parent at BC-block resolution (one block is 4x4 pixels). A | ||
| 187 | correct chain is 0–4 levels, as in the SixNG notes; the control is the first tail mip detiled | ||
| 188 | at origin (0,0). | ||
| 189 | |||
| 190 | | Pool # | Descriptor | Mips | non_tail / first_tail | Max error | Tail control | | ||
| 191 | |---|---|---:|---:|---:|---:| | ||
| 192 | | `interiors_0_3` #19 | 512×256 BC1 | 7 | 1 / 3 | 0.38 | 126.06 | | ||
| 193 | | `interiors_0_3` #10 | 512×512 BC1 | 8 | 3 / 3 | 0.46 | 57.94 | | ||
| 194 | | `graphics` #43 | 64×512 BC1 | 10 | 1 / 3 | 1.08 | 132.31 | | ||
| 195 | | `interiors_2_3` #468 | 512×512 BC1 | 8 | 3 / 3 | 0.60 | 113.83 | | ||
| 196 | | `maps_0_7` #3217 | 128×128 BC1 | 6 | 0 / 1 | 0.79 | 114.71 | | ||
| 197 | | `peds_1_3` #527 | 512×512 BC1 | 8 | 3 / 3 | 3.87 | 83.83 | | ||
| 198 | | `maps_1_7` #1500 | 128×256 BC4 | 6 | 1 / 2 | 0.34 | 72.08 | | ||
| 199 | | `decorations_0_3` #818 | 128×128 BC5 | 6 | 1 / 2 | 0.02 | 85.48 | | ||
| 200 | | `interiors_1_3` #507 | 256×256 BC3 | 7 | 1 / 2 | 1.21 | 51.84 | | ||
| 201 | |||
| 202 | `interiors_0_3` #19 is a partial export: the reader emits one mip, while all seven decode and | ||
| 203 | match. `graphics` #43 and `interiors_2_3` #468 are tuples outside the table; `maps_0_7` #3217 | ||
| 204 | is mode 34 with `non_tail = 0`, which would leave zero standalone mips even if the mode gate | ||
| 205 | passed. | ||
| 206 | |||
| 207 | BC7 was checked on two samples with an external decoder (Pillow, not a dependency of the | ||
| 208 | tool): `terrain_4_7` #23 (512×512, 3 mips, 0.35–0.49) and `maps_4_7` #6034 (1024×1024, mode | ||
| 209 | 32, 64 KiB, 0.00–0.33, control 4.44). | ||
| 210 | |||
| 211 | For `interiors_0_3` #19 the tool reports the byte layout: mip 0 (512×256, 128×64 blocks) at | ||
| 212 | 24,576, mip 1 (256×128, 64×32) at 8,192, mip 2 (128×64, 32×16) at 4,096, then the 4 KiB tile | ||
| 213 | at 0 with mip 3 (64×32 px, 16×8 blocks) at origin (16,0), mip 4 (32×16 px, 8×4) at (8,8), | ||
| 214 | mip 5 (16×8 px, 4×2) at (0,12) and mip 6 (8×4 px, 2×1) at (0,8). The mip byte sizes 65,536 / | ||
| 215 | 16,384 / 4,096 / 1,024 / 256 / 64 / 16 are exactly the BC1 block counts, and the exported DDS | ||
| 216 | is 87,524 bytes (148 + 87,376). | ||
| 217 | |||
| 218 | ### What this unlocks | ||
| 219 | |||
| 220 | "Decompressed" is the block-linear BC payload size (`blocks × block bytes`), not the inflated | ||
| 221 | chunk size, which includes tile padding. | ||
| 222 | |||
| 223 | | | Textures | New mips | Decompressed | | ||
| 224 | |---|---:|---:|---:| | ||
| 225 | | partial exports that become complete | 195,091 | 1,065,138 | 1.69 GiB | | ||
| 226 | | compact skips that become complete | 11,570 | 35,727 | 2.91 GiB | | ||
| 227 | | **total** | **206,661** | **1,100,865** | **4.59 GiB** | | ||
| 228 | |||
| 229 | 1,166 of the 196,257 partials still miss 6,930 mips that touch BCPack; those and the 33,507 | ||
| 230 | fully blocked textures wait on the codec. Nothing here decodes BCPack. | ||
| 101 | 231 | ||
| 102 | ## What BCPack is | 232 | ## What BCPack is |
| 103 | 233 | ||
| @@ -265,25 +395,46 @@ and the algorithm class are known; the bitstream is not. | |||
| 265 | 395 | ||
| 266 | ## Next step | 396 | ## Next step |
| 267 | 397 | ||
| 268 | 1. **Do not fake a BCPack decoder.** The current fallback (export the largest lower mip that | 398 | 1. **Port the tile-mode split and the computed tail boundary.** In `TtpfReader`, select |
| 269 | is zlib/raw) is used by 5,845 textures and should stay. | 399 | `tile = 65536` when `((mode >> 1) & 0xF) == 0` and 4096 otherwise, replace |
| 270 | 2. **Fix the compact packed tail first.** 196,257 of the 210,292 partial exports stop at | 400 | `ValidatedCompactProfile` with the allocation-span check, and set `UsableMipLimit` to the |
| 271 | `NonTailMipCount`; the tail layout is documented (SixNG §5) and needs no BCPack decoder. | 401 | computed `FirstTail` (or `mips` when the tail tile is zlib/raw). On this install that |
| 272 | This is the largest tractable texture gap. | 402 | completes 206,661 textures without touching BCPack. |
| 273 | 3. **Then the small independent gaps:** 678 array/volume layouts and 5 DXGI 11 textures. | 403 | 2. **Decode BC6H/BC7 in the validator.** `tools/ttpf_mips.py` decodes BC1/3/4/5; the BC7 |
| 274 | Neither needs BCPack. | 404 | samples were checked with an external decoder. The layout is the same formula (16-byte |
| 275 | 4. **If a public decoder or bitstream spec appears under a compatible licence,** add it behind | 405 | elements), so this is validation breadth, not a new mapping. |
| 276 | `TtpfReader.DecodeChunk`; the container already carries the mode (codec id) and decoded | 406 | 3. **Identify DXGI 156/199/211/226 (19 records) and validate uncompressed tiling (formats |
| 277 | size, so no index work is needed. | 407 | 11, 28, 49, 56).** These are the remaining non-BCPack blockers besides arrays. |
| 278 | 5. **If someone resumes the reverse engineering,** use the hard check the SixNG notes propose: | 408 | 4. **Arrays/volumes: 678 descriptors.** 567 use tile modes 9–12 and 111 are 2-slice; no |
| 279 | every lane must consume exactly its byte budget and finish at the rANS lower bound, with a | 409 | validated slice layout exists yet. |
| 280 | fixed symbol count. Reference blocks are the missing input; none are public. | 410 | 5. **Do not fake a BCPack decoder.** The current fallback (export the largest lower mip that |
| 411 | is zlib/raw) is used by 5,845 textures and should stay. If a public decoder or bitstream | ||
| 412 | spec appears under a compatible licence, add it behind `TtpfReader.DecodeChunk`; the | ||
| 413 | container already carries the mode (codec id) and decoded size, so no index work is | ||
| 414 | needed. | ||
| 415 | 6. **If someone resumes the BCPack reverse engineering,** use the hard check the SixNG notes | ||
| 416 | propose: every lane must consume exactly its byte budget and finish at the rANS lower | ||
| 417 | bound, with a fixed symbol count. Reference blocks are the missing input; none are public. | ||
| 281 | 418 | ||
| 282 | ## Reproduce | 419 | ## Reproduce |
| 283 | 420 | ||
| 421 | `tools/ttpf_mips.py` is the read-only measurement and decode tool: | ||
| 422 | |||
| 423 | ``` | ||
| 424 | python -I tools/ttpf_mips.py scan <game root> --json scan.json | ||
| 425 | python -I tools/ttpf_mips.py layout <pool.ttpf> <index> | ||
| 426 | python -I tools/ttpf_mips.py check <pool.ttpf> <index> | ||
| 427 | python -I tools/ttpf_mips.py export <pool.ttpf> <index> <out.dds> | ||
| 428 | ``` | ||
| 429 | |||
| 430 | `scan` reproduces the 357,115 / 98,603 / 210,292 / 48,220 split of this note and adds the | ||
| 431 | layout and recovery columns. `check` reports the per-mip downsample error. `export` writes a | ||
| 432 | full BC chain only when every source mip is zlib/raw. The tool writes no texture data and | ||
| 433 | `tests/test_ttpf_mips.py` runs on a synthetic RDS5 pool, so the test needs no game files. | ||
| 434 | |||
| 284 | `rpf9dump ttpf` writes one `manifest.json` per pool with a `Limitation` field for every | 435 | `rpf9dump ttpf` writes one `manifest.json` per pool with a `Limitation` field for every |
| 285 | catalog record, and its summary line has the same `ok` / `skip` totals. The split above comes | 436 | catalog record, and its summary line has the same `ok` / `skip` totals. The first split above |
| 286 | from a read-only mirror of `TtpfReader`'s catalog checks: it mmaps each pool and reads only | 437 | came from a read-only mirror of `TtpfReader`'s catalog checks: it mmapped each pool and read |
| 287 | the 24-byte RDS5 header, the chunk table, the ETPF records and the chunk ranges. It writes no | 438 | only the 24-byte RDS5 header, the chunk table, the ETPF records and the chunk ranges, and it |
| 288 | texture data. The mirror is not committed because it duplicates `TtpfReader`; the counts are | 439 | wrote no texture data. `tools/ttpf_mips.py scan` is that mirror, now committed with the |
| 289 | the evidence. | 440 | compact-layout work; it reproduces the split and adds the recovery columns. |
diff --git a/docs/world.md b/docs/world.md index 8d32b951a..718e9abc4 100644 --- a/docs/world.md +++ b/docs/world.md | |||
| @@ -238,21 +238,19 @@ pattern in the 0–2 GiB family is a hash-table slot, not a matrix row. | |||
| 238 | 238 | ||
| 239 | ### How many are there? | 239 | ### How many are there? |
| 240 | 240 | ||
| 241 | The measured 9,918 files and 680,228 entities are a **lower bound**, not a whole-archive total. The sample is | 241 | A full sharded census of the `levels.rpf` data area now gives a measured total: **23,535 map resources / |
| 242 | 29 GiB of the 57 GiB map band (50.9%) and 39.23 GiB of the archive (55.3%, including the carver-indexed 0–2 GiB | 242 | 1,670,442 placement entities**. Every map row is exact against its declared entity size and every expected |
| 243 | window). | 243 | shard completed. The earlier bounded passes measured 9,918 files and 680,228 entities in 55.3% of the archive; |
| 244 | 244 | that was a lower bound, and the full pass settles the extrapolation. See | |
| 245 | A single multiplier is weak because density is not uniform: sampled 1-GiB blocks range from 96 to 2,174 map | 245 | [world_census.md](world_census.md) for the shard layout, the exactness condition and the 98.32% stream |
| 246 | files and from 4,754 to 145,118 entities. Treating the 29 sampled 1-GiB units as exchangeable gives a | 246 | coverage. |
| 247 | uniform-block estimate of **~26,600 map files / ~1.77 million entities**. A 20,000-resample block bootstrap | 247 | |
| 248 | gives an approximate 95% interval of 16.0k–39.6k map files and 1.03M–2.64M entities. The selection was | 248 | The full count is lower than SixNG's published 30,785 map files / 2,249,490 entities |
| 249 | purposive, not random, so those bounds are approximate; they are not a census. | 249 | (https://github.com/holdmysocks/SixNG). The difference is not yet explained. The census counts only |
| 250 | 250 | validated `0x7a` resources whose schema includes `CMapData` and whose entity table is self-consistent; | |
| 251 | SixNG's published full-archive measurement, 30,785 map files / 2,249,490 entities | 251 | SixNG may count archive entries, nested maps, or map resources that this scanner rejects. Treat the |
| 252 | (https://github.com/holdmysocks/SixNG), lies inside that interval. It is external evidence, not a measurement | 252 | 23,535 / 1,670,442 figure as the measured count for this package and this validation rule, not as a |
| 253 | made here. The observed 9,918 files are 32.2% of that count and 680,228 entities are 30.2%, even though 50.9% of | 253 | claim about a different enumeration method. |
| 254 | the map band was scanned. That gap is consistent with the unsampled parts being denser, with map files whose | ||
| 255 | entity blocks live in graphics pages, or with both; only a full band scan can settle it. | ||
| 256 | 254 | ||
| 257 | ## What is readable, what is hash-only | 255 | ## What is readable, what is hash-only |
| 258 | 256 | ||
| @@ -304,6 +302,11 @@ Hash-only or opaque: | |||
| 304 | It implements the header/schema validation above and the continuation join. It does not decrypt anything, | 302 | It implements the header/schema validation above and the continuation join. It does not decrypt anything, |
| 305 | does not extract models/textures, and keeps the output aggregate (one row per resource, no entity dump). | 303 | does not extract models/textures, and keeps the output aggregate (one row per resource, no entity dump). |
| 306 | 304 | ||
| 305 | `tools/world_census.py` scans the whole `levels.rpf` data area in shards and counts every validated | ||
| 306 | `0x7a` map resource and placement entity. The measured full pass is 23,535 maps / 1,670,442 entities | ||
| 307 | with 98.32% stream coverage; the exactness condition and byte accounting are in | ||
| 308 | [world_census.md](world_census.md). | ||
| 309 | |||
| 307 | ```powershell | 310 | ```powershell |
| 308 | python -I tools\world_index.py <levels.rpf> --start 21474836480 --limit 1073741824 ` | 311 | python -I tools\world_index.py <levels.rpf> --start 21474836480 --limit 1073741824 ` |
| 309 | --out work\world\levels-20-21.json --csv work\world\levels-20-21.csv | 312 | --out work\world\levels-20-21.json --csv work\world\levels-20-21.csv |
diff --git a/docs/world_census.md b/docs/world_census.md new file mode 100644 index 000000000..128151954 --- /dev/null +++ b/docs/world_census.md | |||
| @@ -0,0 +1,97 @@ | |||
| 1 | # Census of `levels.rpf` | ||
| 2 | |||
| 3 | `levels.rpf` is 76,155,065,056 bytes. Its table of contents is encrypted, so the archive cannot be | ||
| 4 | enumerated by name. `tools/world_census.py` measures the data area directly: it inflates every zlib | ||
| 5 | stream, validates each `0DRP` / version `0x7a` resource, joins continuation streams, and counts the | ||
| 6 | map resources and placement entities they contain. | ||
| 7 | |||
| 8 | ## Result | ||
| 9 | |||
| 10 | | Measure | Value | | ||
| 11 | |---|---:| | ||
| 12 | | Data area scanned | 76,154,954,352 bytes (start `0x1B070`) | | ||
| 13 | | Map resources (`kind=map`) | **23,535** | | ||
| 14 | | Placement entities | **1,670,442** | | ||
| 15 | | Complete / validated map rows | **23,535 / 23,535** | | ||
| 16 | | Exact entity counts | **1,670,442 / 1,670,442** | | ||
| 17 | | Shards complete | **36 / 36** | | ||
| 18 | | Zlib streams inflated | **1,122,614** | | ||
| 19 | | Stored stream bytes | 75,165,813,806 | | ||
| 20 | | Inflated bytes (all streams) | 175,587,890,693 | | ||
| 21 | | Rejected zlib candidates | 906 | | ||
| 22 | | Adopted continuation streams | 174 | | ||
| 23 | | Metadata streams | 165,880 | | ||
| 24 | | Duplicate content groups | 0 | | ||
| 25 | | Scan time | 290.8 s | | ||
| 26 | |||
| 27 | A map row is a resource whose schema includes `CMapData`. `maps_exact` means every entity block | ||
| 28 | counted against the declared `entity_size` and no entity block was left in a graphics page. | ||
| 29 | `entities_exact` is the same check summed over all rows. Six entities of the 23,535 maps were split | ||
| 30 | across a continuation; the joiner adopted 174 streams in total. | ||
| 31 | |||
| 32 | ## Coverage | ||
| 33 | |||
| 34 | | Byte class | Bytes | Share of data area | | ||
| 35 | |---|---:|---:| | ||
| 36 | | Accepted stream payload | 74,877,281,159 | 98.32% | | ||
| 37 | | Raw graphics pages (`0x6`) | 2,762,232 | 0.004% | | ||
| 38 | | Raw system continuation | 44,304 | 0.0001% | | ||
| 39 | | Zero padding | 1,058,806,784 | 1.39% | | ||
| 40 | | Unread non-zero bytes | 216,059,873 | 0.28% | | ||
| 41 | | **Accounted** | **76,154,954,352** | **100%** | | ||
| 42 | |||
| 43 | The unread bytes are mostly small alignment and metadata gaps between streams. The gap audit found | ||
| 44 | **23** `0DRP` signatures in unread ranges, but none resolved to a map or metadata resource | ||
| 45 | (`raw_maps = 0`, `raw_meta = 0`), so the census is not missing a map class. No unaligned zlib stream | ||
| 46 | that inflates to a `0DRP` header was found in a gap (`missed_zlib_meta = 0`). The 906 rejected | ||
| 47 | candidates are zlib streams that do not form a complete `0x7a` resource; they are ordinary archive | ||
| 48 | payload, not counted maps. | ||
| 49 | |||
| 50 | ## Exactness condition | ||
| 51 | |||
| 52 | `summary.json` sets `census_exact` only when all of these hold: | ||
| 53 | |||
| 54 | - `complete` is true and every expected shard was written; | ||
| 55 | - `maps_exact == maps` and `entities_exact == entities`; | ||
| 56 | - `entity_gfx == 0` and `entity_unresolved == 0`; | ||
| 57 | - `raw_maps == 0` and `missed_zlib_meta == 0`. | ||
| 58 | |||
| 59 | The run above satisfies every condition. `accounted_ratio` is 1.0 because every byte is assigned to | ||
| 60 | accepted payload, a raw page, zero padding or counted unread data. | ||
| 61 | |||
| 62 | ## Method | ||
| 63 | |||
| 64 | The scan starts at the data-area offset from the `9FPR` header. It walks 16-byte-aligned zlib | ||
| 65 | candidates in independent shards and: | ||
| 66 | |||
| 67 | 1. inflates each stream, keeping the first bytes needed to recognize `0DRPz`; | ||
| 68 | 2. validates the little-endian `0x7a` header, struct table, block table and member offsets; | ||
| 69 | 3. follows a contiguous split resource, either another zlib page or a raw system page whose length | ||
| 70 | the resource's pointers require; | ||
| 71 | 4. counts `CEntityDef` blocks against the declared entity size, and records `0x6` graphics extents; | ||
| 72 | 5. merges shard rows, checks duplicate names and content hashes, and audits every gap for a missed | ||
| 73 | `0DRP` signature or unaligned zlib stream. | ||
| 74 | |||
| 75 | Each shard is written to `shard_<index>_<start>_<end>.json`; `summary.json` and `maps.json` are | ||
| 76 | rebuilt from the shards, so an interrupted run resumes with `--resume` or `--merge-only`. | ||
| 77 | |||
| 78 | ```powershell | ||
| 79 | python -I tools\world_census.py <levels.rpf> --out work\world\census --shard-size 2147483648 --jobs 12 | ||
| 80 | python -I tools\world_census.py <levels.rpf> --out work\world\census --merge-only | ||
| 81 | python -I tests\test_world_census.py | ||
| 82 | ``` | ||
| 83 | |||
| 84 | The default shard size is 2 GiB, the default job count is half the logical CPUs, and the scan is | ||
| 85 | bounded by `--start` / `--limit` when a partial pass is wanted. | ||
| 86 | |||
| 87 | ## Limits | ||
| 88 | |||
| 89 | - The census counts resources, not names. It does not decrypt the RPF9 TOC, so it cannot say which | ||
| 90 | archive entry owns a map; `docs/world.md` correlates the measured bands with the placement files | ||
| 91 | it could carve. | ||
| 92 | - Only `0x7a` resources are validated. Other resource types contribute to stream and byte counts but | ||
| 93 | are not classified. | ||
| 94 | - A map row proves the resource has a `CMapData` root and a self-consistent entity table. It does not | ||
| 95 | prove the map is reachable, loaded, or complete in the runtime. | ||
| 96 | - Output contains resource offsets, sizes, counts and content hashes only. It is aggregate metadata; | ||
| 97 | keep it out of git along with the archive and carved streams. | ||