fspx_unpack: test and document the 24-byte prologue (FSPX-SHORT-PROLOGUE) #583

Closed
github-bot wants to merge 1 commit from gh-pr/583/head into gh-pr/583/base
Owner

@⁠Tyrannys on GitHub · 2026-11-24 09:08 UTC · original
Tyrannys:fix/fspx-short-prologue → main · +22 −0 · 2 files · 1 commits · closed without merging

Claimed in the coordination issue as: FSPX-SHORT-PROLOGUE (claimed in #14)

Item: FSPX-SHORT-PROLOGUE (claimed in #14).

tools/fspx_unpack.py code_range only knew the 36-byte prologue (VOP3 opcode 0x180, bits 31..16 = 0xD580, at words 0, 3 and 6). Some programs of the pipeline library in shaders.rpf carry only words 0 and 3: a 24-byte prologue, with the code starting at word 6 (s_inst_prefetch in all of them). Read from word 0 they never decode.

Counted over the whole 1.0.2.1 library (2,684 programs): 50 have the 24-byte form; before this change 1 of the 50 translated. With it, all 50 disassemble with 0 invalid words, and 49 translate and pass spirv-val (the last stops at s_sethalt). A program whose words 0, 3 and 6 are all prologue words still takes the 36-byte form. shader_library.py writes "prologue": start > 0 for both forms. The runtime needs no change: the game passes these programs as FSPX payloads, which it reads by directory.

Found while booting the retail executable: four of the slot-67 compute pipelines the title creates were these programs.

Changes:

  • tools/fspx_unpack.py: SHORT_PROLOGUE_WORDS / SHORT_PROLOGUE_SIZE, code_range falls back to them.
  • tools/shader_library.py: the prologue flag covers both sizes.
  • tests/test_fspx_unpack.py: test_short_prologue (synthetic words, no game data).
  • docs/fspx.md: the 24-byte variant and the counts.

Tested (Windows 11, Python 3.12): python -I tests/test_fspx_unpack.py, tests/test_shader_library.py, tests/test_fspx_unpack_out.py, tests/test_fspx_shaders_stage.py, tests/test_text_write_line_endings.py, all OK. The corpus counts come from a local work folder on an RTX 4070 SUPER box; no GPU test involved.

AI-assisted (Claude Code).

GPUs tested: n/a (CPU-only Python tests)

AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

**@⁠Tyrannys** on GitHub · 2026-11-24 09:08 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/583) `Tyrannys:fix/fspx-short-prologue` → `main` · +22 −0 · 2 files · 1 commits · closed without merging Claimed in the coordination issue as: FSPX-SHORT-PROLOGUE (claimed in #14) Item: FSPX-SHORT-PROLOGUE (claimed in #14). `tools/fspx_unpack.py` `code_range` only knew the 36-byte prologue (VOP3 opcode 0x180, bits 31..16 = `0xD580`, at words 0, 3 and 6). Some programs of the pipeline library in `shaders.rpf` carry only words 0 and 3: a 24-byte prologue, with the code starting at word 6 (`s_inst_prefetch` in all of them). Read from word 0 they never decode. Counted over the whole 1.0.2.1 library (2,684 programs): 50 have the 24-byte form; before this change 1 of the 50 translated. With it, all 50 disassemble with 0 invalid words, and 49 translate and pass `spirv-val` (the last stops at `s_sethalt`). A program whose words 0, 3 and 6 are all prologue words still takes the 36-byte form. `shader_library.py` writes `"prologue": start > 0` for both forms. The runtime needs no change: the game passes these programs as FSPX payloads, which it reads by directory. Found while booting the retail executable: four of the slot-67 compute pipelines the title creates were these programs. Changes: - `tools/fspx_unpack.py`: `SHORT_PROLOGUE_WORDS` / `SHORT_PROLOGUE_SIZE`, `code_range` falls back to them. - `tools/shader_library.py`: the `prologue` flag covers both sizes. - `tests/test_fspx_unpack.py`: `test_short_prologue` (synthetic words, no game data). - `docs/fspx.md`: the 24-byte variant and the counts. Tested (Windows 11, Python 3.12): `python -I tests/test_fspx_unpack.py`, `tests/test_shader_library.py`, `tests/test_fspx_unpack_out.py`, `tests/test_fspx_shaders_stage.py`, `tests/test_text_write_line_endings.py`, all OK. The corpus counts come from a local work folder on an RTX 4070 SUPER box; no GPU test involved. AI-assisted (Claude Code). GPUs tested: n/a (CPU-only Python tests) AI-assisted: yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
main's code_range takes the 24-byte prologue with a stricter check than this PR
first proposed (both carriers must be literal-bearing VOP3 words), so the code
change is dropped. What is left: a unit test for the short form, its stricter
check and the 36-byte precedence, and the docs/fspx.md paragraph with the
library counts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:09:58 +00:00
github-bot closed this pull request 2026-11-26 09:09:58 +00:00
github-bot referenced this pull request from a commit 2026-11-26 10:19:35 +00:00
Author
Owner

@⁠Snooozs on GitHub · 2026-11-24 16:54 UTC · original

Independent check (Windows 10 19045, CPython 3.12.10, CPU only, no game files): merged cleanly onto main 82a2aabcc, tests/test_fspx_unpack.py 35 tests OK (1 skipped); with main's tools and this PR's test, 1 failure (the short prologue). I read the diff: the 36-byte form is still tried first, so a program with all three prologue words is unaffected, and both callers now use start > 0. I cannot check the 50-of-2,684 count. AI-assisted (Claude Code).

**@⁠Snooozs** on GitHub · 2026-11-24 16:54 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/583#issuecomment-7138399150) Independent check (Windows 10 19045, CPython 3.12.10, CPU only, no game files): merged cleanly onto `main` 82a2aabcc, `tests/test_fspx_unpack.py` 35 tests OK (1 skipped); with `main`'s tools and this PR's test, 1 failure (the short prologue). I read the diff: the 36-byte form is still tried first, so a program with all three prologue words is unaffected, and both callers now use `start > 0`. I cannot check the 50-of-2,684 count. AI-assisted (Claude Code).
Author
Owner

@⁠Tyrannys on GitHub · 2026-11-25 08:59 UTC · original

Rebased onto main 3f81d46ac and reduced. main's code_range already takes the 24-byte prologue (it came in with the #984 integration), with a stricter check than this PR first proposed: both carriers must be literal-bearing VOP3 words of the fspx_prologue_probe.py form. So the code change is dropped. What remains:

  • tests/test_fspx_unpack.py test_short_prologue: the short form, a single carrier (no prologue), opcode-0x180 words without the literal form (no prologue), and the 36-byte precedence.
  • The docs/fspx.md paragraph on the 24-byte variant and its library counts. Those counts were taken with this PR's earlier opcode-only check, and the paragraph says so.

python -I tests/test_fspx_unpack.py: 35 tests OK on Windows 11 (CPU only, no game files). check_no_game_data.py passes on both files. AI-assisted (Claude Code).

**@⁠Tyrannys** on GitHub · 2026-11-25 08:59 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/583#issuecomment-7157732502) Rebased onto `main` `3f81d46ac` and reduced. `main`'s `code_range` already takes the 24-byte prologue (it came in with the #984 integration), with a stricter check than this PR first proposed: both carriers must be literal-bearing VOP3 words of the `fspx_prologue_probe.py` form. So the code change is dropped. What remains: - `tests/test_fspx_unpack.py` `test_short_prologue`: the short form, a single carrier (no prologue), opcode-0x180 words without the literal form (no prologue), and the 36-byte precedence. - The `docs/fspx.md` paragraph on the 24-byte variant and its library counts. Those counts were taken with this PR's earlier opcode-only check, and the paragraph says so. `python -I tests/test_fspx_unpack.py`: 35 tests OK on Windows 11 (CPU only, no game files). `check_no_game_data.py` passes on both files. AI-assisted (Claude Code).
Author
Owner

@⁠kawaii-shakal on GitHub · 2026-11-25 10:16 UTC · original · reviewed

Heads-up: main now has this. tools/fspx_unpack.py::code_range on main (c7e82e26e) has the 24-byte form. When words 0 and 3 are literal-bearing 0xD580 VOP3 NOPs and word 6 is not, the code starts at byte 24. It came in with the integration merge 273b3bdf9 (#984).

Measured on the 1.0.2.1 pipeline library with main's shaders stage:

  • 50 programs list code 0x18.. (fspx);
  • 49 of them translate and pass spirv-val;
  • the 50th is the s_sethalt 1 program you mentioned, now handled by #1697.

So the code change here is superseded. If your tests cover cases main's version doesn't (for example the "all three prologue words still take the 36-byte form" check), they may be worth keeping as a small tests-only PR against main; otherwise this one can probably be closed.

AI-assisted review (Claude Code, Claude Opus 5.5).

**@⁠kawaii-shakal** on GitHub · 2026-11-25 10:16 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/583#pullrequestreview-6055667652) · **reviewed** Heads-up: main now has this. `tools/fspx_unpack.py::code_range` on main (c7e82e26e) has the 24-byte form. When words 0 and 3 are literal-bearing `0xD580` VOP3 NOPs and word 6 is not, the code starts at byte 24. It came in with the integration merge 273b3bdf9 (#984). Measured on the 1.0.2.1 pipeline library with main's shaders stage: - 50 programs list `code 0x18..` (fspx); - 49 of them translate and pass `spirv-val`; - the 50th is the `s_sethalt 1` program you mentioned, now handled by #1697. So the code change here is superseded. If your tests cover cases main's version doesn't (for example the "all three prologue words still take the 36-byte form" check), they may be worth keeping as a small tests-only PR against main; otherwise this one can probably be closed. AI-assisted review (Claude Code, Claude Opus 5.5).
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-26 03:09 UTC · original

Closing as included, thanks @⁠Tyrannys! #2138, merged as 0b11d86bc, has this PR's code_range check (main's literal-form check for the 24-byte prologue), its test and the docs/fspx.md paragraph from your head 3af97a1ec.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠aslan2142** on GitHub · 2026-11-26 03:09 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/583#issuecomment-7181441999) Closing as included, thanks @⁠Tyrannys! #2138, merged as `0b11d86bc`, has this PR's `code_range` check (`main`'s literal-form check for the 24-byte prologue), its test and the `docs/fspx.md` paragraph from your head `3af97a1ec`. AI-assisted (Claude Code, Claude Opus 5.5).

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.