[PR #998] [MERGED] tools: decode the pipeline-library compute programs llvm-mc refuses #1037

Closed
opened 2026-11-26 20:19:52 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/998
Author: @Kokonotcu
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/26/2026
Merged by: @aslan2142

Base: main ← Head: fix/library-compute-decode


📝 Commits (3)

  • ebcb0ac tools: decode the pipeline-library compute programs llvm-mc refuses
  • bf0c4d9 tests: fspx_unpack takes the decoder listing when llvm-mc reports invalid words
  • bec14f2 tools: the last pipeline-library compute programs of 1.0.2.1

📊 Changes

8 files changed (+190 additions, -25 deletions)

View changed files

📝 tests/semantic/test_salu_flbit_64.py (+4 -2)
📝 tests/semantic/test_salu_quadmask_bitreplicate.py (+9 -0)
📝 tests/test_fspx_unpack.py (+28 -4)
📝 tools/fspx_unpack.py (+70 -6)
📝 tools/rdna2_decode.py (+26 -0)
📝 tools/rdna2spirv.py (+38 -10)
📝 tools/shader_disasm.py (+13 -1)
📝 tools/shader_library.py (+2 -2)

📄 Description

llvm-mc 21 cannot decode SMEM loads whose SOFFSET is null (0x7D). Because of that, whole pipeline-library compute programs of 1.0.2.1 disassembled with invalid words and failed to translate. A retail boot also reached 50 more library programs that had no translation; dumped from the running game, all 50 now translate and pass spirv-val.

Changes

  • shader_disasm: for compute programs (compute=True, passed by shader_library and fspx_unpack), it falls back to rdna2_decode.disasm_bytes when that leaves fewer invalid words than llvm-mc.
  • rdna2_decode: VOPC with DPP16/DPP8 is decoded as the 8-byte form it is.
  • fspx_unpack.code_range:
    • some programs carry a 24-byte hash prologue (two VOP3 words, then s_inst_prefetch) instead of 36 bytes; two or three hash words now count (shader_library uses the same range);
    • --last-endpgm: early exits branch past the first s_endpgm, and data after the code can hold s_endpgm words, so a program ends at the first s_endpgm whose listing keeps every branch inside the code.
  • rdna2spirv:
    • SMEM with vcc as its base reads the vcc_lo/vcc_hi pair.
    • s_flbit_i32_b64 of a lane mask reads the wave's 64-bit mask (18 library programs), as s_ff1_i32_b64 already does.
    • s_bitreplicate_b64_b32 of a lane mask into plain scalar data replicates the wave's mask word (6 library programs). From a constant into vcc it sets each lane's bit as the exec form does (6 programs).
    • v_cmp_*_dpp into vcc (12 compares in reductions) is taken when every lane writes (full row/bank masks with bound_ctrl:1, or DPP8).
  • Tests:
    • test_salu_flbit_64: the lane-mask case now translates; the subgroup op is outside the single-invocation interpreter, so the test checks that.
    • test_fspx_unpack: the invalid-word case takes the decoder's listing; new cases cover the two-word prologue, code_range_last and branch checks.
    • test_salu_quadmask_bitreplicate: new case for bitreplicate into vcc.

Result

Library programs: 2633 of 2684 translated after the first commit; the 50 the retail boot then dumped as missing all translate after the second.

Testing

These pass:

  • tests/semantic/test_salu_flbit_64.py
  • tests/semantic/test_salu_quadmask_bitreplicate.py
  • tests/test_fspx_unpack.py
  • tests/test_shader_library.py
  • tests/test_rdna2_decode.py
  • tests/test_shader_disasm.py
  • tests/test_rdna2spirv_decode.py

The VOPC-DPP path is checked only by spirv-val, since the interpreter runs no subgroup ops. Tested on an RTX 3080 Laptop, i7-11800H, Windows 10.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/998 **Author:** [@Kokonotcu](https://github.com/Kokonotcu) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/26/2026 **Merged by:** [@aslan2142](https://github.com/aslan2142) **Base:** `main` ← **Head:** `fix/library-compute-decode` --- ### 📝 Commits (3) - [`ebcb0ac`](https://github.com/ubiquitarianism/leonida/commit/ebcb0acad599f0199b827a7ebc8008585aaa5dd6) tools: decode the pipeline-library compute programs llvm-mc refuses - [`bf0c4d9`](https://github.com/ubiquitarianism/leonida/commit/bf0c4d99ce4fca375a89538d200efdd7cb70f84d) tests: fspx_unpack takes the decoder listing when llvm-mc reports invalid words - [`bec14f2`](https://github.com/ubiquitarianism/leonida/commit/bec14f22599924c9d6d98b76714e00b6e0cc798a) tools: the last pipeline-library compute programs of 1.0.2.1 ### 📊 Changes **8 files changed** (+190 additions, -25 deletions) <details> <summary>View changed files</summary> 📝 `tests/semantic/test_salu_flbit_64.py` (+4 -2) 📝 `tests/semantic/test_salu_quadmask_bitreplicate.py` (+9 -0) 📝 `tests/test_fspx_unpack.py` (+28 -4) 📝 `tools/fspx_unpack.py` (+70 -6) 📝 `tools/rdna2_decode.py` (+26 -0) 📝 `tools/rdna2spirv.py` (+38 -10) 📝 `tools/shader_disasm.py` (+13 -1) 📝 `tools/shader_library.py` (+2 -2) </details> ### 📄 Description llvm-mc 21 cannot decode SMEM loads whose SOFFSET is null (0x7D). Because of that, whole pipeline-library compute programs of 1.0.2.1 disassembled with invalid words and failed to translate. A retail boot also reached 50 more library programs that had no translation; dumped from the running game, all 50 now translate and pass spirv-val. ## Changes - **shader_disasm**: for compute programs (`compute=True`, passed by shader_library and fspx_unpack), it falls back to `rdna2_decode.disasm_bytes` when that leaves fewer invalid words than llvm-mc. - **rdna2_decode**: VOPC with DPP16/DPP8 is decoded as the 8-byte form it is. - **fspx_unpack.code_range**: - some programs carry a 24-byte hash prologue (two VOP3 words, then s_inst_prefetch) instead of 36 bytes; two or three hash words now count (shader_library uses the same range); - `--last-endpgm`: early exits branch past the first s_endpgm, and data after the code can hold s_endpgm words, so a program ends at the first s_endpgm whose listing keeps every branch inside the code. - **rdna2spirv**: - SMEM with `vcc` as its base reads the vcc_lo/vcc_hi pair. - `s_flbit_i32_b64` of a lane mask reads the wave's 64-bit mask (18 library programs), as `s_ff1_i32_b64` already does. - `s_bitreplicate_b64_b32` of a lane mask into plain scalar data replicates the wave's mask word (6 library programs). From a constant into vcc it sets each lane's bit as the exec form does (6 programs). - `v_cmp_*_dpp` into vcc (12 compares in reductions) is taken when every lane writes (full row/bank masks with bound_ctrl:1, or DPP8). - **Tests**: - `test_salu_flbit_64`: the lane-mask case now translates; the subgroup op is outside the single-invocation interpreter, so the test checks that. - `test_fspx_unpack`: the invalid-word case takes the decoder's listing; new cases cover the two-word prologue, `code_range_last` and branch checks. - `test_salu_quadmask_bitreplicate`: new case for bitreplicate into vcc. ## Result Library programs: 2633 of 2684 translated after the first commit; the 50 the retail boot then dumped as missing all translate after the second. ## Testing These pass: - `tests/semantic/test_salu_flbit_64.py` - `tests/semantic/test_salu_quadmask_bitreplicate.py` - `tests/test_fspx_unpack.py` - `tests/test_shader_library.py` - `tests/test_rdna2_decode.py` - `tests/test_shader_disasm.py` - `tests/test_rdna2spirv_decode.py` The VOPC-DPP path is checked only by spirv-val, since the interpreter runs no subgroup ops. Tested on an RTX 3080 Laptop, i7-11800H, Windows 10. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:19:52 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#1037
No description provided.