Decode compact TTPF 2D streaming profiles and packed mip tails #5

Manually merged
github merged 1 commit from gh-pr/5/head into gh-pr/5/base 2026-11-26 19:04:29 +00:00
Owner

@⁠sombraSoft on GitHub · 2026-11-21 22:49 UTC · original
feat/ttpf-compact-packed-tail → main · +452 −94 · 4 files · 1 commits · merged 2026-11-22 00:04 UTC

Summary

Replaces the 55-entry ValidatedCompactProfile / ValidatedAuxiliaryProfile tables in TtpfReader with a direct validator for the ETPF634 streaming chunk metadata, generalizes the 2D tile-size rule, and enables full mip-chain decoding (including packed mip tails) for compact 2D textures.

What changed

  • Core/TtpfReader.cs:
    • Validates the 43-bit streaming metadata across meta = c >> 21 and d (TryDecodeChunkPages / TryValidateChunkSizes / ValidateCompactStreamingChunks): four 5-bit zero-terminated chunk page-count codes checked against actual RDS5 chunk virtual sizes, plus d >> 19 alignment-group padding checks for nonTail == 3 chains (alignGroup 1: c0 + pad = 16, 2: c0 + c1 + pad = 16, 3: c0 + c1 + pad = 8).
    • Uses (mode & 6) == 0 ? 65536 : 4096 for single-slice 2D tiling (SW_64KB_D for modes 0, 1, 32; SW_4KB_S for modes 2, 4, 5, 6, 7, 34, 36, 38).
    • Removes the NonTailMipCount cap so packed mip tails decode through standard SurfaceLayout whenever their chunks are raw/zlib.
    • Preserves LegacyTopOnlyName behavior (297 entries) and keeps SupportsNativeReplacement strictly restricted to single-slice 2D non-compact mode is 0 or 2 textures (78,624 entries, unchanged).
  • Core/ArchiveReader.cs:
    • Updates the RDS5 limitation summary now that validated auxiliary compact profiles are decoded.
  • Tests/TtpfLayoutSmoke/:
    • Adds an asset-free .NET 8 synthetic RDS5/ETPF634 smoke test verifying mode=4 (nt=1 and nt=3), mode=6 (nt=3), mode=1 (SW_64KB_D), packed mip-tail detiling, BCPack lower-mip fallback, and negative controls (mismatched chunk codes, bad alignment padding, reserved bits, all-BCPack rejection, Rds5TextureWriter rejection).

Verification

  • Synthetic smoke tests: dotnet build Tests/TtpfLayoutSmoke/TtpfLayoutSmoke.csproj -c Release + run — passed (0 warnings, 0 errors).
  • Builds (0 warnings, 0 errors): App/RpfPreview.App.csproj (.NET 10), Tools/IndexBuilder/IndexBuilder.csproj (.NET 8), and Leonida tools/rpf9dump/rpf9dump.csproj (.NET 8).
  • Full local corpus (all 57 RDS5 pools, 357,115 descriptors, no game files committed):
    • Exported: 308,895 → 330,198 (+21,303)
    • Complete mip chains: 98,603 → 305,264 (+206,661)
    • Partial exports: 210,292 → 24,934 (-185,358)
    • Skipped: 48,220 → 26,917 (26,215 all-BCPack, 678 array/volume, 24 unsupported format = 5 DXGI 11 + 19 2-slice arrays addressed in a follow-up PR).
    • Compact/packed-tail pixel continuity verified via mip-to-mip PSNR across all compact modes.

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:49 UTC · [original](https://github.com/breadbbbb/rpf9-explorer/pull/5) `feat/ttpf-compact-packed-tail` → `main` · +452 −94 · 4 files · 1 commits · merged 2026-11-22 00:04 UTC ## Summary Replaces the 55-entry `ValidatedCompactProfile` / `ValidatedAuxiliaryProfile` tables in `TtpfReader` with a direct validator for the ETPF634 streaming chunk metadata, generalizes the 2D tile-size rule, and enables full mip-chain decoding (including packed mip tails) for compact 2D textures. ### What changed - **`Core/TtpfReader.cs`**: - Validates the 43-bit streaming metadata across `meta = c >> 21` and `d` (`TryDecodeChunkPages` / `TryValidateChunkSizes` / `ValidateCompactStreamingChunks`): four 5-bit zero-terminated chunk page-count codes checked against actual RDS5 chunk virtual sizes, plus `d >> 19` alignment-group padding checks for `nonTail == 3` chains (`alignGroup` 1: `c0 + pad = 16`, 2: `c0 + c1 + pad = 16`, 3: `c0 + c1 + pad = 8`). - Uses `(mode & 6) == 0 ? 65536 : 4096` for single-slice 2D tiling (`SW_64KB_D` for modes `0, 1, 32`; `SW_4KB_S` for modes `2, 4, 5, 6, 7, 34, 36, 38`). - Removes the `NonTailMipCount` cap so packed mip tails decode through standard `SurfaceLayout` whenever their chunks are raw/zlib. - Preserves `LegacyTopOnlyName` behavior (`297` entries) and keeps `SupportsNativeReplacement` strictly restricted to single-slice 2D non-compact `mode is 0 or 2` textures (`78,624` entries, unchanged). - **`Core/ArchiveReader.cs`**: - Updates the RDS5 limitation summary now that validated auxiliary compact profiles are decoded. - **`Tests/TtpfLayoutSmoke/`**: - Adds an asset-free `.NET 8` synthetic RDS5/ETPF634 smoke test verifying `mode=4` (`nt=1` and `nt=3`), `mode=6` (`nt=3`), `mode=1` (`SW_64KB_D`), packed mip-tail detiling, BCPack lower-mip fallback, and negative controls (mismatched chunk codes, bad alignment padding, reserved bits, all-BCPack rejection, `Rds5TextureWriter` rejection). ## Verification - **Synthetic smoke tests**: `dotnet build Tests/TtpfLayoutSmoke/TtpfLayoutSmoke.csproj -c Release` + run — passed (0 warnings, 0 errors). - **Builds (0 warnings, 0 errors)**: `App/RpfPreview.App.csproj` (.NET 10), `Tools/IndexBuilder/IndexBuilder.csproj` (.NET 8), and Leonida `tools/rpf9dump/rpf9dump.csproj` (.NET 8). - **Full local corpus (all 57 RDS5 pools, 357,115 descriptors, no game files committed)**: - Exported: `308,895` → `330,198` (`+21,303`) - Complete mip chains: `98,603` → `305,264` (`+206,661`) - Partial exports: `210,292` → `24,934` (`-185,358`) - Skipped: `48,220` → `26,917` (`26,215` all-BCPack, `678` array/volume, `24` unsupported format = 5 DXGI 11 + 19 2-slice arrays addressed in a follow-up PR). - Compact/packed-tail pixel continuity verified via mip-to-mip PSNR across all compact modes. 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:28 +00:00
github manually merged commit 28e4752d51 into gh-pr/5/base 2026-11-26 19:04:29 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.