Skip to content

packing/shader_split: read DrinkBox's whole-file SHADERS container - #2810

Open
Yodajr wants to merge 1 commit into
seedds:mainfrom
Yodajr:gfx/dbx-shader-reader
Open

Yodajr wants to merge 1 commit into
seedds:mainfrom
Yodajr:gfx/dbx-shader-reader

Conversation

@Yodajr

@Yodajr Yodajr commented Nov 16, 2026

Copy link
Copy Markdown

Guacamelee! STCE (0100BAE00B470000) and Guacamelee! 2 (01007E100456C000) both stop the NSP script at the split gate: no shaders in main or the RomFS. Their RomFS carries a single container, shaders.dat.nx, opening with SHADERS\0: a {u32 version, u16, u16} header, a name table of one NUL-terminated pair per shader (its .vsh/.psh source and its entry, main), uniform metadata, and one block per shader {code area, control section, 24-byte record}. The control sections are ordinary NVN (0x838 bytes here) and the code areas ordinary SPH, but the block stores the code before the control section (its +0x704 holds that code's length) — the opposite adjacency from the NVN dump the scan walks — and no known magic opens the file, so the generic prefilter never passed it to scan_blob and no reader ran.

dbx_shaders() walks the control sections (ctl_len at +0x20) and takes each code area at ctl - field(ctl+0x704), checked by its 78563412 header; the stage and the key come from the code area, as everywhere. The name table is not read: every block is self-checking. The file head SHADERS\0 dispatches it in scan_blob and scan_file_in. New reference entry and symptom index line, new fuzz seed.

Checked: test_split_dbx (new: a synthetic container read block by block in order with its stages, the file scanner's dispatch on the magic, and a control section whose code area is absent, wrong-sized or has no code header named in a red line); the fuzz harness with a dbx seed (1.67M runs, no finding) and test_fuzz_corpus; all test_split_*, test_docs, lint_python.py (no new finding); regress.py impact main..HEAD: 0 games use what the change touches, 3 only through the broad shader-table rule (shader:stage:*). End to end on the two real games (one cartridge holding both, via the NSP script's --title-id): 165/165 and 444/444 blocks well formed, both Mac apps built in under a minute each and boot to their launcher (163 and 425 unique shaders after dedup).

Not run: regress.py check — the reader runs only on files that open with this magic (as for the Blizzard and Criterion readers), neither game has a profile, and impact names no game the change reaches except through the shader-table rule; the iPhone; the games' own routes. On the machine this was written there is no Xcode 27.2 toolchain: the dm/gfx/tests and Swift-compiling tests fail identically at origin/main there, so they were checked as unchanged-against-baseline, not as passing.

Both games remain on provisional profiles: the reader makes the split pass and the apps boot; playtesting and a registered profile are someone's next step.

Guacamelee! STCE (0100BAE00B470000) and Guacamelee! 2 (01007E100456C000) both stop the NSP script at the split gate: no shaders in main or the RomFS. Their RomFS carries a single container, shaders.dat.nx, opening with SHADERS\0: a {version, u16, u16} header, a name table of one NUL-terminated pair per shader (its .vsh/.psh source and its entry, main), uniform metadata, and one block per shader {code area, control section, 24-byte record}. The control sections are ordinary NVN (0x838 bytes here) and the code areas ordinary SPH, but the block stores the CODE BEFORE the control section (its +0x704 holds that code's length) — the opposite adjacency from the NVN dump the scan walks — and no known magic opens the file, so the generic prefilter never passed it to scan_blob and no reader ran.

dbx_shaders() walks the control sections (ctl_len at +0x20) and takes each code area at ctl - field(ctl+0x704), checked by its 78563412 header; the stage and the key come from the code area, as everywhere. The name table is not read: every block is self-checking. The file head SHADERS\0 dispatches it in scan_blob and scan_file_in. New reference entry (DrinkBox's SHADERS container) and symptom index line.

Checked: test_split_dbx (new: a synthetic container read block by block in order with its stages, the file scanner's dispatch on the magic, and a control section whose code area is absent, wrong-sized or has no code header named in a red line); the fuzz harness with a dbx seed (1.67M runs, no finding) and test_fuzz_corpus; all test_split_*, test_docs, lint_python.py (no new finding); regress.py impact main..HEAD: 0 games use what the change touches, 3 only through the broad shader-table rule. End to end on the two real games: 165/165 and 444/444 blocks well formed, both Mac apps built in under a minute and boot to their launcher (163 and 425 unique shaders). Not run: regress.py check (the reader runs only on files that open with this magic, as for the Blizzard and Criterion readers; neither game has a profile); the iPhone. On this machine dm/gfx/tests and the Swift tests fail identically at origin/main (no Xcode toolchain), so they were not a gate.
@github-actions github-actions Bot added packing Building an IPA or a Mac app: the NSP script, extraction, the shader split, the packers tools Tools and scripts (dm/tools, scripts) docs Documentation labels Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation packing Building an IPA or a Mac app: the NSP script, extraction, the shader split, the packers tools Tools and scripts (dm/tools, scripts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant