feat(tools): read raw-deflate shader entries in RPF9 archives #28

Manually merged
github merged 1 commit from gh-pr/28/head into gh-pr/28/base 2026-11-26 19:14:18 +00:00
Owner

@⁠Dark3581 on GitHub · 2026-11-22 02:05 UTC · original
Dark3581:feat/shader-scan-rpf9 → main · +139 −7 · 3 files · 1 commits · merged 2026-11-22 02:08 UTC

What

tools/shader_scan.py found no shaders in titles that keep them in RPF9 archives, because each entry is stored as raw deflate and the archive's table of contents is not readable. It now:

  • walks raw-deflate entries in RPF9 archives (file magic 9FPR) without the table of contents: <name> 00 <u8> <u32 stored> <u32> <u32 stored> <u32 size>, then stored bytes that must inflate to exactly size bytes of a valid DXBC container (same header and part-table checks as before);
  • classifies every DXIL part by the bitcode slot of its program header (DxilProgramHeader / DxilBitcodeHeader): bitcode, native (NOBC plus an XBCH block, so the GPU program is precompiled for the console), stub or unknown;
  • adds programs and stored counts to the summary; the JSON still holds names, offsets and part tags only.

This is the data the D3D12.X design (#4) needs: whether a title's shaders can go to a desktop driver as DXIL or need a native-code translator.

Tested

  • Windows 10, MinGW WinLibs GCC 15.2 UCRT, Ninja, Release, clean build directory: build without warnings, CTest 50/50.
  • python -m unittest discover -s tools/tests: 48/48, including 3 new tests (program classification, RPF9 entries with a size mismatch rejected, entries read only in RPF9 archives) on synthetic data.
  • check_conventions.py, debt_fold.py --check, progress.py --json pass.
  • On one title's decrypted package: the scan finds 26,503 containers in its shader archive in 44 s, all native, matching the count from an independent carve. No game data is in the PR.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • python tools/check_conventions.py passes (no comments in code, one declaration per export, Conventional Commit subjects)
  • Unimplemented paths stop (AbxNotImplemented / AbxUnsupported); silent stubs are listed under Silent stubs through a debt fragment
  • Known gaps added, changed or removed through docs/dev/debt/changes/<branch>.md
  • Generic behaviour, not specific to one title
  • No game files, keys, notes or logs added to the repository
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • Source of behaviour: DXIL program header layout from DirectXShaderCompiler's public DxilContainer.h; RPF9 entry layout measured on a package (also documented by Leonida, GPL-3.0; no code taken)
  • AI-assisted: yes
**@⁠Dark3581** on GitHub · 2026-11-22 02:05 UTC · [original](https://github.com/Dark3581/AnyBox/pull/28) `Dark3581:feat/shader-scan-rpf9` → `main` · +139 −7 · 3 files · 1 commits · merged 2026-11-22 02:08 UTC ### What `tools/shader_scan.py` found no shaders in titles that keep them in RPF9 archives, because each entry is stored as raw deflate and the archive's table of contents is not readable. It now: - walks raw-deflate entries in RPF9 archives (file magic `9FPR`) without the table of contents: `<name> 00 <u8> <u32 stored> <u32> <u32 stored> <u32 size>`, then `stored` bytes that must inflate to exactly `size` bytes of a valid DXBC container (same header and part-table checks as before); - classifies every `DXIL` part by the bitcode slot of its program header (`DxilProgramHeader` / `DxilBitcodeHeader`): `bitcode`, `native` (`NOBC` plus an `XBCH` block, so the GPU program is precompiled for the console), `stub` or `unknown`; - adds `programs` and `stored` counts to the summary; the JSON still holds names, offsets and part tags only. This is the data the D3D12.X design (#4) needs: whether a title's shaders can go to a desktop driver as DXIL or need a native-code translator. ### Tested - Windows 10, MinGW WinLibs GCC 15.2 UCRT, Ninja, Release, clean build directory: build without warnings, CTest 50/50. - `python -m unittest discover -s tools/tests`: 48/48, including 3 new tests (program classification, RPF9 entries with a size mismatch rejected, entries read only in RPF9 archives) on synthetic data. - `check_conventions.py`, `debt_fold.py --check`, `progress.py --json` pass. - On one title's decrypted package: the scan finds 26,503 containers in its shader archive in 44 s, all `native`, matching the count from an independent carve. No game data is in the PR. ### Checklist <!-- Rules behind each item: CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] `python tools/check_conventions.py` passes (no comments in code, one declaration per export, Conventional Commit subjects) - [x] Unimplemented paths stop (`AbxNotImplemented` / `AbxUnsupported`); silent stubs are listed under Silent stubs through a debt fragment - [x] Known gaps added, changed or removed through `docs/dev/debt/changes/<branch>.md` - [x] Generic behaviour, not specific to one title - [x] No game files, keys, notes or logs added to the repository - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] Source of behaviour: DXIL program header layout from DirectXShaderCompiler's public `DxilContainer.h`; RPF9 entry layout measured on a package (also documented by Leonida, GPL-3.0; no code taken) - [x] AI-assisted: yes
shader_scan.py now also walks entries stored as raw deflate in RPF9 archives (magic 9FPR), which it can read without the archive's table of contents, and classifies every DXIL part by its program header's bitcode slot: bitcode, native (NOBC with an XBCH block, a precompiled console GPU program), stub or unknown. The summary counts programs and how containers are stored. The format is documented under Shader formats in GAME_TESTING.md and covered by synthetic tests.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 19:14:17 +00:00
github manually merged commit 03af11f040 into gh-pr/28/base 2026-11-26 19:14:18 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.