Skip to content

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

Closed
Tyrannys wants to merge 1 commit into
ProjectLeonida:mainfrom
Tyrannys:fix/fspx-short-prologue
Closed

Tyrannys wants to merge 1 commit into
ProjectLeonida:mainfrom
Tyrannys:fix/fspx-short-prologue

Conversation

@Tyrannys

@Tyrannys Tyrannys commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

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

@Snooozs

Snooozs commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Independent check (Windows 10 19045, CPython 3.12.10, CPU only, no game files): merged cleanly onto main 82a2aab, 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).

demoz53 added a commit to demoz53/leonida that referenced this pull request Nov 24, 2026
…e prologue of some pipeline-library programs (FSPX-SHORT-PROLOGUE)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
demoz53 added a commit to demoz53/leonida that referenced this pull request Nov 24, 2026
…te programs llvm-mc refuses

Conflicts with ProjectLeonida#583 (merged just before) in fspx_unpack.code_range and its
test: both handle the two-hash-word, 24-byte prologue of some pipeline-library
programs. ProjectLeonida#998's version counts the hash words (two or three) and covers
ProjectLeonida#583's case, so it is kept; ProjectLeonida#583's two constants, used only there, are
dropped and its measurement comment (50 of 2,684 programs) stays. Both PRs'
tests are kept and pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the needs rebase Conflicts with the base branch: rebase it on main label Nov 25, 2026
…s (FSPX-SHORT-PROLOGUE)

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 <noreply@anthropic.com>
@Tyrannys
Tyrannys force-pushed the fix/fspx-short-prologue branch from 4b9a891 to 3af97a1 Compare November 25, 2026 08:59
@Tyrannys Tyrannys changed the title fspx_unpack: code_range takes the 24-byte prologue of some pipeline-library programs (FSPX-SHORT-PROLOGUE) fspx_unpack: test and document the 24-byte prologue (FSPX-SHORT-PROLOGUE) Nov 25, 2026
@Tyrannys

Copy link
Copy Markdown
Contributor Author

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).

@kawaii-shakal kawaii-shakal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heads-up: main now has this. tools/fspx_unpack.py::code_range on main (c7e82e2) 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 273b3bd (#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).

@github-actions github-actions Bot removed the needs rebase Conflicts with the base branch: rebase it on main label Nov 25, 2026
aslan2142 added a commit that referenced this pull request Nov 26, 2026
…583 head)

The copy of #583 in this branch replaced main's check that both short
prologue words are literal-bearing VOP3 opcode-0x180 words
(words[k+1] & 0xFFFE0100 == 0x03FE0100, the shape fspx_prologue_probe.py
checks) with a looser SRC2 == 0xff test. Keep main's check, as #583's head
(3af97a1, by Tyrannys) does, with this branch's named constants, and take
that head's test_short_prologue (the stricter check refuses 0x03FF0000)
and its docs/fspx.md paragraph.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@aslan2142

Copy link
Copy Markdown
Collaborator

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 aslan2142 closed this Nov 26, 2026
milk4sale pushed a commit to milk4sale/leonida that referenced this pull request Nov 26, 2026
# Conflicts:
#	tools/fspx_unpack.py
#	tools/shader_library.py
Kokonotcu added a commit to Kokonotcu/leonida that referenced this pull request Nov 26, 2026
37 upstream commits after 86dc3d8: ProjectLeonida#2138 (integration/boot-combined), ProjectLeonida#2094 (geometry-view eviction on range
release, reaped after the replays that may name them), ProjectLeonida#998/ProjectLeonida#1317/ProjectLeonida#1281/ProjectLeonida#583 heads (pipeline-library compute
programs by code hash, shader_disasm prints the dot4 op_sel words llvm-mc rejects, FSPX short prologue with the
literal-form check), null-resource texture barriers and null-view RTV clears on the console list, and the removal
of the title's executable addresses from code (read from the environment).

Conflicts, on merit:
- d3d12_xs_device.cpp: both. Our title heap sync (LEONIDA_TITLE_HEAP_SYNC) and upstream's null-RTV marks sit side
  by side; heap_release unregisters the sync or the range as before and also drops the heap's null-RTV marks;
  CreateDescriptorHeap keeps our desc argument and takes upstream's RTV real range. Our value-op/upload-ring
  slots and upstream's slot 146 barrier conversion both stay.
- startup_trace.h: our thread and watchdog-table logging stays, and follows upstream's rule: the watchdog table's
  store and table RVAs come from LEONIDA_WATCHDOG_TABLE (off when unset, documented in runtime/README.md);
  upstream's environment-driven pool diagnostic replaces the fixed address.
- fspx_unpack.py: ours (the code end is found from one rdna2_decode pass, not an llvm-mc run per s_endpgm: the
  OOM and 15-minute fix). Its test takes upstream's short-prologue case, which checks the literal form our code
  also requires.
- rdna2spirv.py: ours (s_bitreplicate_b64_b32 into VCC in wave32 stays translated: 6 pipeline-library programs),
  plus the point behind upstream's refusal: in wave32 VCC's high word is data, so it is now written to vcc_hi as
  source bits 16..31 replicated (replicate_bits16, shared with the scalar form). Tests: ours kept, one added for
  the vcc_hi word; test_salu_flbit_64 keeps ours (this tree translates i64 of a lane mask).
- xs_proxy_mock_test.cpp: upstream's empty Barrier call, our chained-submission reference count.

Every line the merge removes from our side is upstream's own or one of the resolutions above (checked against the
merge base, D:\GTA6\analysis\lostlines.sh). The touched Python suites pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants