fspx_unpack: --backend auto, used by the FSPX stage (FSPX-UNPACK-AUTO-BACKEND) #1984

Closed
ImLele69 wants to merge 2 commits from upstream-pr/1984 into main
ImLele69 commented 2026-11-25 17:25:46 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by ImLele69 on 2026-11-25T17:25:46Z.


Claimed in the coordination issue as FSPX-UNPACK-AUTO-BACKEND (#1608). Depends on #1712, which adds backend="auto" to tools/shader_disasm.py. This branch is #1712 plus one commit.

What and why

With llvm-mc 21 or 22, five of the 29 FSPX programs of amd_fidelityfx_upscaler_xbox.dll (05, 06, 08, 09, 28) are disassembled with invalid words, and the translator refuses them. The title then reads through the missing pipeline: the access violation at amd_fidelityfx_upscaler_xbox.dll+0x65ff (read of 0x10) reported in #1608 by CLHelper, kurrutako and Snooozs. Here it showed up as soon as the boot ran with LEONIDA_DEVICE_TYPE=6. #1862 fixes the two programs that llvm-mc 23 leaves out; it doesn't help older llvm-mc builds. The Linux packages and scripts/build_llvm_mc.ps1's default are 21.1.8.

#1712's auto backend decodes those five with the pure-Python decoder and no invalid words. This change:

  • tools/fspx_unpack.py: a --backend {llvm-mc,python,auto} option for --disasm, passed to shader_disasm.disasm. The default stays llvm-mc, so direct uses and the existing tests are unchanged.
  • make_game.py: the FSPX stage runs fspx_unpack.py ... --disasm --backend auto, as #1712 does for the pipeline library. fspx_unpack.py is already in FSPX_TOOLS, so a cached FSPX set is rebuilt once.

Tested

  • Real DLL: the FidelityFX DLL of a 1.0.2.1 package, llvm-mc 22.1.8 (Fedora), rdna2spirv.py --no-asm --wave64-emulate.
    • Before: 24 of 29 translated.
    • After: 29 of 29 translated, 29 pass spirv-val. The five listings report 0 invalid words.
  • Retail boot, Linux/Wine (RTX 2070 SUPER, LEONIDA_DEVICE_TYPE=6):
    • With 24 of 29: the process died at amd_fidelityfx_upscaler_xbox.dll+0x65ff right at the world start.
    • With 29 of 29: the next boot went past it, with 0 no translated compute shader for FSPX lines, to a later and unrelated stop.
  • Unit tests: python -I tests/test_fspx_unpack.py (35, including the new test_auto_backend_replaces_a_listing_with_invalid_words, which fails without the change), test_fspx_shaders_stage.py, test_fspx_unpack_out.py, test_shader_disasm.py and test_shader_library.py pass.
  • test_fspx_shaders_stage.py changes in two places:
    • It now expects --backend auto on the unpack command line.
    • The "failed disassembly leaves no marker" test runs the unpack with llvm-mc alone. With auto, the Python decoder would read its program and the stage would not fail, which is the point of the change but not what that test checks.

No game files in the change or the tests.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5495989481 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1984). Originally posted by [ImLele69](https://github.com/ImLele69) on 2026-11-25T17:25:46Z. --- Claimed in the coordination issue as FSPX-UNPACK-AUTO-BACKEND ([#1608](https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7169483079)). **Depends on #1712**, which adds `backend="auto"` to `tools/shader_disasm.py`. This branch is #1712 plus one commit. ### What and why With llvm-mc 21 or 22, five of the 29 FSPX programs of `amd_fidelityfx_upscaler_xbox.dll` (05, 06, 08, 09, 28) are disassembled with invalid words, and the translator refuses them. The title then reads through the missing pipeline: the access violation at `amd_fidelityfx_upscaler_xbox.dll+0x65ff` (read of 0x10) reported in #1608 by CLHelper, kurrutako and Snooozs. Here it showed up as soon as the boot ran with `LEONIDA_DEVICE_TYPE=6`. #1862 fixes the two programs that llvm-mc 23 leaves out; it doesn't help older llvm-mc builds. The Linux packages and `scripts/build_llvm_mc.ps1`'s default are 21.1.8. #1712's `auto` backend decodes those five with the pure-Python decoder and no invalid words. This change: - `tools/fspx_unpack.py`: a `--backend {llvm-mc,python,auto}` option for `--disasm`, passed to `shader_disasm.disasm`. The default stays `llvm-mc`, so direct uses and the existing tests are unchanged. - `make_game.py`: the FSPX stage runs `fspx_unpack.py ... --disasm --backend auto`, as #1712 does for the pipeline library. `fspx_unpack.py` is already in `FSPX_TOOLS`, so a cached FSPX set is rebuilt once. ### Tested - **Real DLL:** the FidelityFX DLL of a 1.0.2.1 package, llvm-mc 22.1.8 (Fedora), `rdna2spirv.py --no-asm --wave64-emulate`. - Before: 24 of 29 translated. - After: **29 of 29 translated, 29 pass spirv-val**. The five listings report `0 invalid words`. - **Retail boot, Linux/Wine** (RTX 2070 SUPER, `LEONIDA_DEVICE_TYPE=6`): - With 24 of 29: the process died at `amd_fidelityfx_upscaler_xbox.dll+0x65ff` right at the world start. - With 29 of 29: the next boot went past it, with 0 `no translated compute shader for FSPX` lines, to a later and unrelated stop. - **Unit tests:** `python -I tests/test_fspx_unpack.py` (35, including the new `test_auto_backend_replaces_a_listing_with_invalid_words`, which fails without the change), `test_fspx_shaders_stage.py`, `test_fspx_unpack_out.py`, `test_shader_disasm.py` and `test_shader_library.py` pass. - `test_fspx_shaders_stage.py` changes in two places: - It now expects `--backend auto` on the unpack command line. - The "failed disassembly leaves no marker" test runs the unpack with `llvm-mc` alone. With `auto`, the Python decoder would read its program and the stage would not fail, which is the point of the change but not what that test checks. No game files in the change or the tests. AI-assisted (Claude Code).
qhukz13 commented 2026-11-25 22:23:50 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by qhukz13 on 2026-11-25T22:23:50Z.


Independent run of the tests at 64ac9de08 (this PR on top of #1712), Linux, Python 3, no game files and no llvm-mc on this machine:

  • tests/test_fspx_unpack.py 35 (1 skipped: the Windows-only exclusive-lock case), test_fspx_shaders_stage.py 24, test_fspx_unpack_out.py 5, test_shader_disasm.py 34, test_shader_library.py 23: all pass.
  • With tools/fspx_unpack.py put back to #1712's version and the tests left at this head, test_auto_backend_replaces_a_listing_with_invalid_words fails and the other 34 pass, so the new test does check the change.
  • The branch merges into current main without conflicts.

The real-DLL numbers (29 of 29 FSPX programs) need a package; I can repeat them on Windows 10 / GTX 1050 Ti once mine is unpacked.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7176310425 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1984#issuecomment-7176310425). Originally posted by [qhukz13](https://github.com/qhukz13) on 2026-11-25T22:23:50Z. --- Independent run of the tests at `64ac9de08` (this PR on top of #1712), Linux, Python 3, no game files and no llvm-mc on this machine: - `tests/test_fspx_unpack.py` 35 (1 skipped: the Windows-only exclusive-lock case), `test_fspx_shaders_stage.py` 24, `test_fspx_unpack_out.py` 5, `test_shader_disasm.py` 34, `test_shader_library.py` 23: all pass. - With `tools/fspx_unpack.py` put back to #1712's version and the tests left at this head, `test_auto_backend_replaces_a_listing_with_invalid_words` fails and the other 34 pass, so the new test does check the change. - The branch merges into current main without conflicts. The real-DLL numbers (29 of 29 FSPX programs) need a package; I can repeat them on Windows 10 / GTX 1050 Ti once mine is unpacked. AI-assisted (Claude Code).
MoonEyes commented 2026-11-28 02:52:10 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T02:52:10Z.


Hi @ImLele69, thanks for this pull request. It currently conflicts with main (conflicting file(s): tools/fspx_unpack.py, tools/shader_disasm.py, tools/shader_library.py), so it carries the needs rebase label. CONTRIBUTING.md asks authors to rebase their branch on main; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here.

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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7232645633 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1984#issuecomment-7232645633). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T02:52:10Z. --- Hi @ImLele69, thanks for this pull request. It currently conflicts with `main` (conflicting file(s): `tools/fspx_unpack.py`, `tools/shader_disasm.py`, `tools/shader_library.py`), so it carries the `needs rebase` label. CONTRIBUTING.md asks authors to rebase their branch on `main`; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here. AI-assisted (Claude Code, Claude Opus 5.5).
TheGeogeo commented 2026-11-29 04:50:33 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-29T04:50:33Z.


Checked 64ac9de08 against main ef3299584 on Windows 11 10.0.26300: it does not merge (git merge-tree --write-tree), so I ran no tests.

  • Conflicts: tools/fspx_unpack.py, tools/shader_disasm.py, tools/shader_library.py.
  • Already in main in another form (ALREADY-IN-MAIN):
    • ebcb0acad and bec14f225 (2026-11-24) made fspx_unpack.py disassemble with compute=True. With that, shader_disasm.disasm takes the rdna2_decode listing when llvm-mc leaves more invalid words.
    • #1712, which this branch builds on, was merged on 2026-11-28 (15c34d797).
    • So the FSPX stage (make_game.py, fspx_unpack.py ... --disasm) already falls back without a flag, and the --backend auto option this PR adds would duplicate it.
    • If something is still missing, a short note on which FSPX program still fails on main would show it.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7250893636 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1984#issuecomment-7250893636). Originally posted by [TheGeogeo](https://github.com/TheGeogeo) on 2026-11-29T04:50:33Z. --- Checked `64ac9de08` against `main` `ef3299584` on Windows 11 10.0.26300: it does not merge (`git merge-tree --write-tree`), so I ran no tests. - Conflicts: `tools/fspx_unpack.py`, `tools/shader_disasm.py`, `tools/shader_library.py`. - Already in `main` in another form (ALREADY-IN-MAIN): - `ebcb0acad` and `bec14f225` (2026-11-24) made `fspx_unpack.py` disassemble with `compute=True`. With that, `shader_disasm.disasm` takes the `rdna2_decode` listing when llvm-mc leaves more invalid words. - #1712, which this branch builds on, was merged on 2026-11-28 (`15c34d797`). - So the FSPX stage (`make_game.py`, `fspx_unpack.py ... --disasm`) already falls back without a flag, and the `--backend auto` option this PR adds would duplicate it. - If something is still missing, a short note on which FSPX program still fails on `main` would show it. AI-assisted (Claude Code).
ImLele69 commented 2026-11-29 21:16:42 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by ImLele69 on 2026-11-29T21:16:42Z.


Closing this because main already covers it. #1712 is merged, and the FSPX stage already disassembles with compute=True (ebcb0acad, bec14f225), so shader_disasm.disasm takes the rdna2_decode listing when it has fewer invalid words than the llvm-mc one. A --backend auto option on fspx_unpack.py would duplicate that.

I checked this in the code at 060c47160. I did not rerun programs 05, 06, 08, 09 and 28 from the FidelityFX DLL, because I no longer have the game package. If one of them still fails on main, it needs a new fix.

Thanks @qhukz13 and @TheGeogeo for checking this.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7262747718 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1984#issuecomment-7262747718). Originally posted by [ImLele69](https://github.com/ImLele69) on 2026-11-29T21:16:42Z. --- Closing this because `main` already covers it. #1712 is merged, and the FSPX stage already disassembles with `compute=True` (`ebcb0acad`, `bec14f225`), so `shader_disasm.disasm` takes the `rdna2_decode` listing when it has fewer invalid words than the `llvm-mc` one. A `--backend auto` option on `fspx_unpack.py` would duplicate that. I checked this in the code at `060c47160`. I did not rerun programs 05, 06, 08, 09 and 28 from the FidelityFX DLL, because I no longer have the game package. If one of them still fails on `main`, it needs a new fix. Thanks @qhukz13 and @TheGeogeo for checking this. AI-assisted (Claude Code).

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!1984
No description provided.