Skip to content

packing/shader_split: read Phyre shaders from split KIT archives - #1939

Closed
JS-banana wants to merge 1 commit into
seedds:mainfrom
JS-banana:fix/kit-phyre-shaders
Closed

JS-banana wants to merge 1 commit into
seedds:mainfrom
JS-banana:fix/kit-phyre-shaders

Conversation

@JS-banana

@JS-banana JS-banana commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Unravel TWO's shader split finds no programs: its effects are in indexed .kit.N parts with chained LZ4 blocks, and some Phyre compute programs lack the graphics code header.

Read the KIT index and members with bounds, decoded-length and SHA1 checks. Recognize headerless compute programs only inside bounded Phyre effects, while preserving existing graphics rules, reader precedence and archive scan budgets. Nonzero high offset words remain unsupported. The shader entry describes the format and checks.

Validation

Rechecked on upstream main 38521863 (2026-11-13), preserving its GLSLC section-header reader, archive readers and shared-DLC shader-key merge.

  • 117 targeted tests pass: KIT/VBF, Phyre, PG records, Sumo, split progress, every test_split_* suite, docs and environment-switch consistency. This includes a new KIT integration regression: a DLC copy of an effect leaves the game rows unchanged, in either scan order and with or without the DLC.
  • Python lint: 321 baseline findings, zero new. The symptom index is current and git diff --check passes.
  • The headerless Phyre effect fixture still fails against unmodified 38521863; that revision has no KIT reader.
  • regress.py impact upstream/main..HEAD: Breath of the Wild, Pokémon Scarlet and Tears of the Kingdom match the broad shader rule; Hades is not affected; 161 profiles have no usage manifest. No game route or Metal GPU regression was run on this revision. A fresh FINAL FANTASY X/X-2 build remains unchecked. shader_split.py is not a chain-version input.
  • Latest-head CI is pending; previous-head CI results do not validate this revision.

Earlier local repair: Unravel TWO (0100E5D00CC0C000) 1.0.1 yielded 2,629 shaders (438 vertex, 1,793 pixel, 398 compute), all built on the Mac. Two-player gameplay was reported working on November 8. This rebased revision has not been played.

Docs

  • General finding in docs/reference/shaders.md; symptom index regenerated.
  • Synthetic fixtures only. No game files, keys or extracted game data in the change or attachments.

@github-actions github-actions Bot added nvn NVN on Metal and its tests (dm/gfx/nvn, dm/gfx/tests) packing Building an IPA or a Mac app: the NSP script, extraction, the shader split, the packers docs Documentation labels Nov 9, 2026
@JS-banana
JS-banana force-pushed the fix/kit-phyre-shaders branch from a06eb2c to 4504379 Compare November 12, 2026 03:57
Unravel TWO stores its effects in indexed KIT parts with chained LZ4
blocks. Read those members with length and SHA1 checks, then recognize
headerless compute programs within bounded Phyre effects. Keep existing
graphics acceptance rules and archive scan budgets.

Rechecked on main 3852186 with its GLSLC section reader and shared-DLC
shader key merge. A synthetic KIT regression verifies that a repeated
DLC effect leaves the game rows unchanged in either scan order.
117 targeted tests pass. Python lint reports no new findings.
Game routes and Metal GPU regression remain untested on this revision.
@JS-banana
JS-banana force-pushed the fix/kit-phyre-shaders branch from 4504379 to a535695 Compare November 13, 2026 07:16
@JS-banana JS-banana changed the title Read Phyre shaders from split KIT archives packing/shader_split: read Phyre shaders from split KIT archives Nov 13, 2026
seedds added a commit that referenced this pull request Nov 16, 2026
…1939)

Unravel TWO's shader split found nothing: its effects are in KIT archives, an index ('kit!') naming hashed members whose data sits in numbered .kit.N parts, compressed as 64 KB LZ4 blocks whose matches reach into the block before. Some of its Phyre effects also hold compute programs without the graphics code header phyre_shaders required.

- dm/gfx/tools/kit.py reads the format, beside vbf.py and through romfs like it (the NSP script hands the split a RomFS image): the index and part ranges checked, each block decoded with the previous 64 KB as its dictionary, decoded lengths, complete input use and the member's SHA1 verified, ValueError naming the archive or member otherwise. Nonzero high offset words are rejected.
- kit_jobs scans the members in ranges through scan_blob and leaves the parts out of the loose-file scan; a damaged index stops the split, a damaged member leaves its range out with a red line.
- phyre_shaders takes the stage from glslc_stage (graphics programs as before); a headerless compute program must lie inside a RYHP effect, fit its bounds and overlap no control section. scan_blob takes Phyre effects and FFX/X-2's loose programs wherever it meets them, and a loose file in either form goes to it: one rule where the loose-file path had its own.

Checked: the PR reports 2,629 shaders on Unravel TWO 1.0.1 (438 vertex, 1,793 pixel, 398 compute; zero before), all built on the Mac, and two-player play on an earlier head; neither was rerun here (the game is not on hand). FINAL FANTASY X/X-2 (base and both DLC, 5,752 shaders) and Mario Golf: Super Rush (25,270) split byte-identically to main, tables and red lines, and match their profiles. FINAL FANTASY XII was not run: its tables have no compute rows, so no change is expected. test_kit.py (new) covers the dictionary chaining, raw members, missing and truncated parts, bad lengths and hashes, parts inside a RomFS image, DLC copies leaving the game rows alone and the split's red line; test_vbf.py the Phyre rules; test_pg_shader.py that a binding-table record still reaches its reader.

Co-authored-by: Panionk <42017491+JS-banana@users.noreply.github.com>
@seedds

seedds commented Nov 16, 2026

Copy link
Copy Markdown
Owner

Landed on main as b4b1c8d, with you as co-author. Thank you: the format work, the reader logic and the tests are yours.

Changes on landing:

  • Rebased onto current main. The conflicts were with Larian's LSPK jobs, the ARH1 → ARH job tag rename and FFXII's docs.
  • The KIT reader moved into its own module, dm/gfx/tools/kit.py (entries, read), beside vbf.py. It reads through romfs as vbf.py does, raises ValueError, and the split turns that into a red line. kit_jobs stays in the split.
  • The loose-file Phyre check is now part of the existing rule that sends loose files to scan_blob, so there is one Phyre rule instead of two.
  • The KIT tests moved to dm/gfx/tests/test_kit.py, with two new ones: parts inside a RomFS image, and the split's red line for a damaged member.

Checked: FINAL FANTASY X/X-2 (base and both DLC, 5,752 shaders) and Mario Golf: Super Rush (25,270) split byte-identically to main and match their profiles. FFXII wasn't run here (no game files).

Not checked: Unravel TWO itself. The game isn't on hand here, so neither the 2,629-shader split nor two-player play was rerun on the landed head. Could you run the NSP script on Unravel TWO 1.0.1 at b4b1c8d and confirm the shader count and a short play session? A profile and game note for Unravel TWO would be welcome as a follow-up PR.

@seedds seedds closed this Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation nvn NVN on Metal and its tests (dm/gfx/nvn, dm/gfx/tests) packing Building an IPA or a Mac app: the NSP script, extraction, the shader split, the packers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants