Repository navigation
shader_stage_manifest: read a carve or unpack index saved with a UTF-8 BOM (EGEN-STAGEMANIFEST-BOM) - #6922
shader_stage_manifest: read a carve or unpack index saved with a UTF-8 BOM (EGEN-STAGEMANIFEST-BOM)#6922evilclanker9000 wants to merge 2 commits into
Conversation
…8 BOM shader_stems() opened the index as utf-8, so a BOM (Notepad, PowerShell 5.1 '>' redirection) reached json.load as U+FEFF and the caller got 'invalid JSON'. json.load itself names the fix: decode with utf-8-sig. Every other index reader in tools/ (hashdict, world_index, classify_carve, user_sgpr_census, spirv_stubs) already does this, and fssm_unpack.py --carve-index and shader_disasm.py --unpack-index are the two callers that read that index.
…lformed JSON The new case fails on main with 'invalid JSON: Unexpected UTF-8 BOM (decode using utf-8-sig)' and passes with the fix. The malformed index behind a BOM keeps failing, so only the BOM is tolerated.
shayderrr
left a comment
There was a problem hiding this comment.
Summary
tools/shader_stage_manifest.py:shader_stems() opens carve/unpack index JSON with encoding="utf-8-sig" instead of "utf-8". tests/test_shader_stage_manifest.py adds a case writing BOM-prefixed carve and unpack indexes (asserting both are read) plus a BOM + [{bad case that must still raise invalid JSON.
Why merge
fssm_unpack.py --carve-index and shader_disasm.py --unpack-index share this reader, so a BOM written by Notepad or PowerShell > previously read as invalid JSON; make_game.py swallowed it and needlessly re-ran the unpack. This fixes both callers in one place and matches every other index reader under tools/. Malformed content still errors; no game data or GPU needed.
Summary
Why merge
|
|
Tested dab31cf on Windows 11 (NTFS), Python 3.12.10 (CPU only, no GPU, no game files): pass. The branch now conflicts with What I ran:
Corrections, none blocking:
Overlap:
AI-assisted (Claude Code). |
|
This PR is approved but no longer merges cleanly with main: merging upstream/main conflicts in tools/shader_stage_manifest.py. Please merge main into the branch (no rebase) and resolve the conflict; the CI check should then go green on the new head. AI-assisted. |
|
Tested dab31cf on Windows 11, Python 3.15.2, NVIDIA RTX 4060 Ti (driver 621.24; CPU-only checks, no game files, no GPU/llvm-mc/MSVC used): pass. Ran the test files this PR adds or changes, from a clean checkout of the PR head: AI-assisted (Claude Code). |
tools/shader_stage_manifest.shader_stems()is the readertools/fssm_unpack.py --carve-indexandtools/shader_disasm.py --unpack-indexuse for a carve'sindex.jsonand an unpack'sfssm_index.json. It opened thefile as
utf-8, so an index saved by a Windows editor (Notepad, PowerShell 5.1>redirection) stopped at the firstcharacter:
json.loadrefuses the BOM as U+FEFF and the tool reportedinvalid JSON, which reads like a broken indexrather than an encoding the reader can handle. Every other index reader in
tools/(hashdict,world_index,classify_carve,user_sgpr_census,spirv_stubs,root_spill_census) already decodes withutf-8-sig, so the samefile that works for one tool failed for these two.
make_game.py'sunpacked_shader_stems()swallowed the error andre-ran the unpack, which is the same defect without the message.
The change is one line: read the index as
utf-8-sig. It tolerates a BOM and nothing else; a malformed index behind aBOM still raises
ValueError.Test
Before (test added, tool unchanged):
After:
python -m compileall -q make_game.py tools testsexits 0.The new case writes two hand-built indexes with a
EF BB BFprefix (a carve index withfile, an unpack index withname), asserts both are read, and asserts thatBOM + "[{bad"is stillinvalid JSON.GPU: none needed; nothing on this path touches a GPU or game data.
Notes
the same BOM bit
make_game.pyin a second place (unpacked_shader_stems()), which now fails over to "unpack again"instead of returning
None.AI-assisted.