Skip to content

fix(engine): Valkyria Chronicles 4 builds: read Fenrir's gzip streams of BNSH shaders - #1280

Open
XeresRazor wants to merge 1 commit into
LNPANDY:mainfrom
XeresRazor:vc4-gzip-bnsh-shaders
Open

XeresRazor wants to merge 1 commit into
LNPANDY:mainfrom
XeresRazor:vc4-gzip-bnsh-shaders

Conversation

@XeresRazor

Copy link
Copy Markdown

Fix or feature

  • Fix
  • Feature

Feature from outside: not applicable, this is a fix.

What and why

Problem. Valkyria Chronicles 4 stops at the shader split ("found no shaders"). Fixes #1279.
Cause. Its shaders are gzip streams of BNSH files, 6,712 in FENRIR_SHADER_NEW_NX64_.HSG and 158 in main. No reader decompresses them.
Change. 0046 adds a reader for them. The split then finds all 6,870, the same set the game creates at boot.

Details
  • Every stream has the same ten header bytes (1f 8b 08 00 00 00 00 00 00 0b). The reader takes a stream only with that header, complete and with BNSH inside, and bounds the decoded size. scan_blob calls it for an HSPK file, main() for each version's main.
  • Each BNSH holds one stage, so the shaders are single-stage programs (3,435 vertex, 3,435 pixel).
  • A temporary host change dumped every program the game creates in its first 60 seconds: the same 6,870 keys as the split, none missing or extra. The change is not in this PR.
  • 16 other games' main have no stream with that header, so no other game's tables change.
  • The patch is pending: the same change goes to seedds/nxnative as its own PR. The game has no registered profile yet.

Checked

  • Tests: python3 tools/engine.py check passes (45 patches apply to upstream 0c078130f6db). The reader has 7 tests. 204 of 206 test files in dm/tools/tests, dm/gfx/tests and dm/ios/tests pass (the other two need .NET in my test shell). The generated doc indexes are current.
  • Test for a fix: dm/tools/tests/test_gzip_bnsh.py (synthetic packages and images, no game files).
  • Visual QA: not applicable.
  • Run on a device or Mac: Valkyria Chronicles 4 01005C600AC68000 1.0.0 (base, 8 DLC), MacBook Pro M1 Max, macOS 27.2. A build from this branch with try-local was installed on the connected iPad Pro 13-inch (M5) from the launcher and reached gameplay (reported by the tester, not measured). Also, the Mac build passes all steps (6,870 of 6,870 shaders translate), and a headless run reached the opening scenes and the first map screen at about 30 fps. iOS shaders: 6,870 of 6,870 compile.
  • Not checked: an iPhone, frame rate or memory on the iPad, and how far into gameplay it went.

Screenshots

None, no visible change.

Scope

  • No engine file (dm/, scripts/, docs/, ref/) is added to the repository: the change is one patch in patches/, and tools/engine.py check passes.
  • 0046 says pending until its seedds/nxnative PR is open.
  • No launcher view is changed.
  • No keys, game files or data extracted from a game in the change or the attachments.

… of BNSH shaders

Valkyria Chronicles 4 stops at the shader split ("found no shaders"). Fixes LNPANDY#1279.

- 0046 adds a reader for the gzip streams of BNSH files that hold its shaders:
  6,712 in the HSPK package FENRIR_SHADER_NEW_NX64_.HSG and 158 in main

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the patch-queue Changes the patch queue or the upstream pin label Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch-queue Changes the patch queue or the upstream pin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Build Failure] Shader split found no shaders in Valkyria Chronicles 4 (v0)

1 participant