Decode TTPF 2D arrays, streaming cubemaps, and 3D volumes #6

Manually merged
github merged 2 commits from gh-pr/6/head into gh-pr/6/base 2026-11-26 19:04:34 +00:00
Owner

@⁠sombraSoft on GitHub · 2026-11-21 22:57 UTC · original
feat/ttpf-arrays-cubes-volumes → main · +823 −130 · 5 files · 2 commits · merged 2026-11-22 00:04 UTC

Summary

Stacked on #5. Decodes all supported multi-slice TTPF layouts (2D arrays, streaming cubemaps, and 3D volumes) and wires the viewer's slice/face selector for TTPF previews. Intentionally leaves DXGI format 11 (Core/RageTextureDecoder.cs) untouched to avoid conflicting with #4.

What changed

  • Core/TtpfReader.cs:
    • Fixes the format / depth bit boundary in ETPF descriptor word b: format is 7 bits ((b >> 3) & 0x7F) and depth is 11 bits (((b >> 10) & 0x7FF) + 1). This resolves the 19 previously misparsed 2-slice arrays (format >= 128) as well as all 2D arrays, cubemaps, and volumes.
    • 2D arrays (dim=1, depth>1, mode=1, 127 records): adds mip-major SW_64KB_D ArrayLayout (packed tail depth * 64 KiB at offset 0, followed by standalone mips firstTail - 1 .. 0 laid out mip-major across slices).
    • Streaming cubemaps (dim=2, depth=6, mode=18 + 2*nonTail, 567 records): validates all nonTail + 1 streaming snapshot chunks (ValidateCubemapStreamingChunks reusing TryValidateChunkSizes) and reads the full-resolution 6-face slice-major SW_4KB_S cubemap from the final chunk (with 64 KiB alignment check when nonTail > 0 and facesBytes >= 36 * 4096).
    • 3D volumes (dim=3, depth>=2, mode=2, mips=1, 3 records): adds overflow-checked SW_4KB_S 3D VolumeLayout + VolumePatterns (rejecting unvalidated mips != 1).
    • Exports DX10 TEXTURE2D arrays, TEXTURECUBE, and TEXTURE3D DDS files, supports multi-slice DecodeTexturePixels(path, index, slice), adds ExportDepth / Shape on TtpfTextureInfo, preserves full allocation spans in Layout.Size for Rds5TextureWriter, and keeps SupportsNativeReplacement disabled for all multi-slice textures.
  • App/MainWindow.Assets.cs:
    • Wires AssetSliceSelector and ShowTtpfSliceAsync for TTPF arrays, cubemaps, and 3D volumes, and displays texture shape/3D depth in Details and preview metadata.
  • Tests/TtpfLayoutSmoke/Program.cs:
    • Adds synthetic positive + negative tests for 2-slice mip-major 2D arrays (exercising the bit-10 boundary), partial-mip BCPack fallback on arrays, streaming cubemaps, 3D volumes, multi-mip volume rejection, invalid cubemap chunk counts, out-of-range slices, and Rds5TextureWriter rejection.

Verification

  • Synthetic smoke tests: Tests/TtpfLayoutSmoke (.NET 8, Release) — passed (0 warnings, 0 errors).
  • Builds (0 warnings, 0 errors): App/RpfPreview.App.csproj (.NET 10), Tools/IndexBuilder/IndexBuilder.csproj (.NET 8), tools/rpf9dump/rpf9dump.csproj (.NET 8).
  • Full local corpus (all 57 RDS5 pools, 357,115 descriptors, no game files committed):
    • Exported: 330,892 (+21,997 over main; Full: 305,954, Partial: 24,938)
    • 2D arrays: 124 / 127 exported (120 full, 4 partial, 3 all-BCPack)
    • Cubemaps: 567 / 567 exported (567 full)
    • 3D volumes: 3 / 3 exported (3 full)
    • Remaining skips: 26,223 (26,218 all-BCPack + 5 DXGI format 11 handled by #4; 0 layout skips).
    • Deep DDS + pixel round-trip across all 124 arrays, 567 cubemaps, 3 volumes, and every 2D format/partial class: ddsOk=722, ddsFail=0, pxOk=1,416, pxFail=0.
    • rpf9dump ttpf smoke test on ttdb_graphics.ttpf: ok=903 fail=0 skip=9.

AI-assisted. Tested on Windows x64, .NET 10.0.401 SDK, NVIDIA GeForce RTX 3060 Ti (driver 621.24).

**@⁠sombraSoft** on GitHub · 2026-11-21 22:57 UTC · [original](https://github.com/breadbbbb/rpf9-explorer/pull/6) `feat/ttpf-arrays-cubes-volumes` → `main` · +823 −130 · 5 files · 2 commits · merged 2026-11-22 00:04 UTC ## Summary Stacked on #5. Decodes all supported multi-slice TTPF layouts (2D arrays, streaming cubemaps, and 3D volumes) and wires the viewer's slice/face selector for TTPF previews. Intentionally leaves DXGI format 11 (`Core/RageTextureDecoder.cs`) untouched to avoid conflicting with #4. ### What changed - **`Core/TtpfReader.cs`**: - Fixes the `format` / `depth` bit boundary in ETPF descriptor word `b`: `format` is 7 bits (`(b >> 3) & 0x7F`) and `depth` is 11 bits (`((b >> 10) & 0x7FF) + 1`). This resolves the 19 previously misparsed 2-slice arrays (`format >= 128`) as well as all 2D arrays, cubemaps, and volumes. - **2D arrays (`dim=1, depth>1, mode=1`, 127 records)**: adds mip-major `SW_64KB_D` `ArrayLayout` (packed tail `depth * 64 KiB` at offset 0, followed by standalone mips `firstTail - 1 .. 0` laid out mip-major across slices). - **Streaming cubemaps (`dim=2, depth=6, mode=18 + 2*nonTail`, 567 records)**: validates all `nonTail + 1` streaming snapshot chunks (`ValidateCubemapStreamingChunks` reusing `TryValidateChunkSizes`) and reads the full-resolution 6-face slice-major `SW_4KB_S` cubemap from the final chunk (with 64 KiB alignment check when `nonTail > 0` and `facesBytes >= 36 * 4096`). - **3D volumes (`dim=3, depth>=2, mode=2, mips=1`, 3 records)**: adds overflow-checked `SW_4KB_S` 3D `VolumeLayout` + `VolumePatterns` (rejecting unvalidated `mips != 1`). - Exports DX10 `TEXTURE2D` arrays, `TEXTURECUBE`, and `TEXTURE3D` DDS files, supports multi-slice `DecodeTexturePixels(path, index, slice)`, adds `ExportDepth` / `Shape` on `TtpfTextureInfo`, preserves full allocation spans in `Layout.Size` for `Rds5TextureWriter`, and keeps `SupportsNativeReplacement` disabled for all multi-slice textures. - **`App/MainWindow.Assets.cs`**: - Wires `AssetSliceSelector` and `ShowTtpfSliceAsync` for TTPF arrays, cubemaps, and 3D volumes, and displays texture shape/3D depth in Details and preview metadata. - **`Tests/TtpfLayoutSmoke/Program.cs`**: - Adds synthetic positive + negative tests for 2-slice mip-major 2D arrays (exercising the bit-10 boundary), partial-mip BCPack fallback on arrays, streaming cubemaps, 3D volumes, multi-mip volume rejection, invalid cubemap chunk counts, out-of-range slices, and `Rds5TextureWriter` rejection. ## Verification - **Synthetic smoke tests**: `Tests/TtpfLayoutSmoke` (.NET 8, Release) — passed (0 warnings, 0 errors). - **Builds (0 warnings, 0 errors)**: `App/RpfPreview.App.csproj` (.NET 10), `Tools/IndexBuilder/IndexBuilder.csproj` (.NET 8), `tools/rpf9dump/rpf9dump.csproj` (.NET 8). - **Full local corpus (all 57 RDS5 pools, 357,115 descriptors, no game files committed)**: - Exported: `330,892` (`+21,997` over `main`; Full: `305,954`, Partial: `24,938`) - 2D arrays: `124 / 127` exported (`120` full, `4` partial, `3` all-BCPack) - Cubemaps: `567 / 567` exported (`567` full) - 3D volumes: `3 / 3` exported (`3` full) - Remaining skips: `26,223` (`26,218` all-BCPack + `5` DXGI format 11 handled by #4; `0` layout skips). - Deep DDS + pixel round-trip across all 124 arrays, 567 cubemaps, 3 volumes, and every 2D format/partial class: `ddsOk=722, ddsFail=0, pxOk=1,416, pxFail=0`. - `rpf9dump ttpf` smoke test on `ttdb_graphics.ttpf`: `ok=903 fail=0 skip=9`. AI-assisted. Tested on Windows x64, .NET 10.0.401 SDK, NVIDIA GeForce RTX 3060 Ti (driver 621.24).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 19:04:33 +00:00
github manually merged commit 359636a91f into gh-pr/6/base 2026-11-26 19:04:34 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.