shader_disasm: print v_dot4_i32_i8 op_sel 2 / op_sel_hi 5 words llvm-mc rejects (OLD-10010) #1317

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

@⁠ambroseautomation on GitHub · 2026-11-24 21:48 UTC · original
ambroseautomation:carry/old-10010-fspx-dot4-op-sel → main · +224 −1 · 4 files · 1 commits · closed without merging

Summary

Coordination item: OLD-10010 (carry-forward of old-pr/10010, preserving original author tedin7).

Problem & Root Cause

llvm-mc rejects v_dot4_i32_i8 VOP3P words encoded with op_sel: 2 ([0,1,0]) and op_sel_hi: 5 ([1,0,1]), which appear in the FidelityFX upscaler's FSPX programs (docs/fspx.md), preventing those programs from disassembling and translating cleanly.

Implementation

  • Adds DOT4_I8_OPCODE, dot4_op_sel_words(), and with_dot4_op_sel() in tools/shader_disasm.py to patch rejected v_dot4_i32_i8 op_sel=2 / op_sel_hi=5 words to defaults (op_sel=0 / op_sel_hi=7) for llvm-mc disassembly and restore op_sel:[0,1,0] op_sel_hi:[1,0,1] and the original encoding bytes on the resulting instruction lines.
  • Preserves main's with_vopc_dpp() fallback pass cleanly alongside with_dot4_op_sel() in disasm().
  • Documents the behavior in docs/fspx.md and adds semantic/disassembly tests in tests/semantic/test_fspx_dot4_op_sel_disasm.py and tests/semantic/test_alu_dot4_i8.py.

Tests Run

Environment: Windows 11 Pro 64-bit, Python 3.12.10, synthetic fixtures only (no game data).

  • python -I -m py_compile tools/shader_disasm.py tests/semantic/test_fspx_dot4_op_sel_disasm.py tests/semantic/test_alu_dot4_i8.py — PASS
  • python -I tests/semantic/test_alu_dot4_i8.py — 12/12 PASS
  • python -I tests/semantic/test_fspx_dot4_op_sel_disasm.py — 4 skipped (no llvm-mc installed on this host); additionally verified shader_disasm.dot4_op_sel_words() and shader_disasm.disasm() fallback path with a mocked run_mc — PASS
  • pytest tests/test_docs_links.py tests/test_text_write_line_endings.py -v — 19/19 PASS
  • python -I scripts/check_no_game_data.py docs/fspx.md tests/semantic/test_alu_dot4_i8.py tests/semantic/test_fspx_dot4_op_sel_disasm.py tools/shader_disasm.py — PASS

Disclosure

AI-assisted: yes (carry-forward, rebase onto current main preserving with_vopc_dpp, and local verification; original implementation by tedin7).

**@⁠ambroseautomation** on GitHub · 2026-11-24 21:48 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1317) `ambroseautomation:carry/old-10010-fspx-dot4-op-sel` → `main` · +224 −1 · 4 files · 1 commits · closed without merging ## Summary Coordination item: `OLD-10010` (carry-forward of `old-pr/10010`, preserving original author `tedin7`). ### Problem & Root Cause `llvm-mc` rejects `v_dot4_i32_i8` VOP3P words encoded with `op_sel: 2` (`[0,1,0]`) and `op_sel_hi: 5` (`[1,0,1]`), which appear in the FidelityFX upscaler's FSPX programs (`docs/fspx.md`), preventing those programs from disassembling and translating cleanly. ### Implementation - Adds `DOT4_I8_OPCODE`, `dot4_op_sel_words()`, and `with_dot4_op_sel()` in `tools/shader_disasm.py` to patch rejected `v_dot4_i32_i8` `op_sel=2 / op_sel_hi=5` words to defaults (`op_sel=0 / op_sel_hi=7`) for `llvm-mc` disassembly and restore `op_sel:[0,1,0] op_sel_hi:[1,0,1]` and the original encoding bytes on the resulting instruction lines. - Preserves `main`'s `with_vopc_dpp()` fallback pass cleanly alongside `with_dot4_op_sel()` in `disasm()`. - Documents the behavior in `docs/fspx.md` and adds semantic/disassembly tests in `tests/semantic/test_fspx_dot4_op_sel_disasm.py` and `tests/semantic/test_alu_dot4_i8.py`. ## Tests Run Environment: Windows 11 Pro 64-bit, Python 3.12.10, synthetic fixtures only (no game data). - `python -I -m py_compile tools/shader_disasm.py tests/semantic/test_fspx_dot4_op_sel_disasm.py tests/semantic/test_alu_dot4_i8.py` — PASS - `python -I tests/semantic/test_alu_dot4_i8.py` — 12/12 PASS - `python -I tests/semantic/test_fspx_dot4_op_sel_disasm.py` — 4 skipped (no `llvm-mc` installed on this host); additionally verified `shader_disasm.dot4_op_sel_words()` and `shader_disasm.disasm()` fallback path with a mocked `run_mc` — PASS - `pytest tests/test_docs_links.py tests/test_text_write_line_endings.py -v` — 19/19 PASS - `python -I scripts/check_no_game_data.py docs/fspx.md tests/semantic/test_alu_dot4_i8.py tests/semantic/test_fspx_dot4_op_sel_disasm.py tools/shader_disasm.py` — PASS ## Disclosure AI-assisted: yes (carry-forward, rebase onto current `main` preserving `with_vopc_dpp`, and local verification; original implementation by tedin7).
The FidelityFX upscaler programs hold 89 such words in 8 programs (docs/fspx.md); the translator already models the form but the listing could not carry it, so the programs were refused as a fall-through into undecodable words.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:47:14 +00:00
github-bot closed this pull request 2026-11-26 09:47:14 +00:00
Author
Owner

@⁠whoalin1 on GitHub · 2026-11-24 22:28 UTC · original

Independent verification (AI-assisted, overnight shift worker):

Environment: Windows, py -3.14, LLVM_MC='wsl -d Ubuntu -e /usr/lib/llvm-21/bin/llvm-mc' (LLVM 21.1.8, AMDGPU target; needed MSYS_NO_PATHCONV=1 so the Linux path survives).

Commands & results:

  • pytest tests/semantic/test_alu_dot4_i8.py tests/semantic/test_fspx_dot4_op_sel_disasm.py -q → 16 passed, 36 subtests passed (3m06s). Without LLVM_MC the llvm-mc-gated cases skip (12 passed, 4 skipped) — with llvm-mc all run, so the emitted v_dot4_i32_i8 op_sel 2 / op_sel_hi 5 words are confirmed to disassemble through shader_disasm and translate end-to-end in the FSPX layout.
  • Regression neighbours: pytest tests/semantic/test_alu_dot4_u8.py tests/semantic/test_valu_dot4_int.py tests/semantic/test_valu_dot4acc_refused.py -q → 36 passed, 351 subtests passed.

The test assembles real instruction lines with llvm-mc, flips the op_sel/op_sel_hi fields in the two dwords, then checks shader_disasm prints and rdna2spirv translates the blob — this covers the claim that llvm-mc rejects these words while the patched disassembler path handles them. No game files or GPU needed; verified on this machine only.

— AI-assisted verification

**@⁠whoalin1** on GitHub · 2026-11-24 22:28 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1317#issuecomment-7146283026) Independent verification (AI-assisted, overnight shift worker): **Environment:** Windows, `py -3.14`, `LLVM_MC='wsl -d Ubuntu -e /usr/lib/llvm-21/bin/llvm-mc'` (LLVM 21.1.8, AMDGPU target; needed MSYS_NO_PATHCONV=1 so the Linux path survives). **Commands & results:** - `pytest tests/semantic/test_alu_dot4_i8.py tests/semantic/test_fspx_dot4_op_sel_disasm.py -q` → **16 passed, 36 subtests passed** (3m06s). Without LLVM_MC the llvm-mc-gated cases skip (12 passed, 4 skipped) — with llvm-mc all run, so the emitted `v_dot4_i32_i8` op_sel 2 / op_sel_hi 5 words are confirmed to disassemble through shader_disasm and translate end-to-end in the FSPX layout. - Regression neighbours: `pytest tests/semantic/test_alu_dot4_u8.py tests/semantic/test_valu_dot4_int.py tests/semantic/test_valu_dot4acc_refused.py -q` → **36 passed, 351 subtests passed**. The test assembles real instruction lines with llvm-mc, flips the op_sel/op_sel_hi fields in the two dwords, then checks shader_disasm prints and rdna2spirv translates the blob — this covers the claim that llvm-mc rejects these words while the patched disassembler path handles them. No game files or GPU needed; verified on this machine only. — AI-assisted verification
Author
Owner

@⁠Snooozs on GitHub · 2026-11-25 06:30 UTC · original

This is still needed: #281 (the same change from old PR 10010) shows as merged, and its merge b39899394 is an ancestor of main, but its content is not in the tree. At 42537e7b6, tools/shader_disasm.py has no op_sel handling and tests/semantic/test_fspx_dot4_op_sel_disasm.py doesn't exist; later merges kept main's side of the file.

Measured on Windows 10 19045 with native llvm-mc 23.1.6 and my own 1.0.2.1 copy:

fspx_unpack.py --disasm + rdna2spirv.py --wave64-emulate translated
main 42537e7b6 27 of 29 (2 refused: "reachable instruction with normalized encoding")
+ #281's dot4_op_sel_words / with_dot4_op_sel, called after with_vopc_dpp in disasm(), with wave32 passed to run_mc 29 of 29, all pass spirv-val

#281's 4 tests and tests/test_shader_disasm.py (31) pass with it.

It matters for the boot: on 42537e7b6 + #1558 + #1547 the retail run reaches the story load, then slot 67 and slot 62 find no translated compute shader for one FSPX program, and the title ends with 0xc0000005 in amd_fidelityfx_upscaler_xbox.dll+0x65ff (read of 0x10) at 152 s. The two refused programs are the only FSPX ones missing here. I have not shown yet that the run goes further with all 29; that is running now.

invalid_offsets is line based on main now (one dword per line), which the ported code needs, so a rebase is small. I am not opening a competing pull request.

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

**@⁠Snooozs** on GitHub · 2026-11-25 06:30 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1317#issuecomment-7154865162) This is still needed: #281 (the same change from old PR 10010) shows as merged, and its merge `b39899394` is an ancestor of `main`, but its content is not in the tree. At `42537e7b6`, `tools/shader_disasm.py` has no `op_sel` handling and `tests/semantic/test_fspx_dot4_op_sel_disasm.py` doesn't exist; later merges kept `main`'s side of the file. Measured on Windows 10 19045 with native `llvm-mc` 23.1.6 and my own 1.0.2.1 copy: | `fspx_unpack.py --disasm` + `rdna2spirv.py --wave64-emulate` | translated | |---|---| | `main` `42537e7b6` | 27 of 29 (2 refused: "reachable instruction with normalized encoding") | | + #281's `dot4_op_sel_words` / `with_dot4_op_sel`, called after `with_vopc_dpp` in `disasm()`, with `wave32` passed to `run_mc` | 29 of 29, all pass `spirv-val` | #281's 4 tests and `tests/test_shader_disasm.py` (31) pass with it. It matters for the boot: on `42537e7b6` + #1558 + #1547 the retail run reaches the story load, then slot 67 and slot 62 find no translated compute shader for one FSPX program, and the title ends with `0xc0000005` in `amd_fidelityfx_upscaler_xbox.dll+0x65ff` (read of `0x10`) at 152 s. The two refused programs are the only FSPX ones missing here. I have not shown yet that the run goes further with all 29; that is running now. `invalid_offsets` is line based on `main` now (one dword per line), which the ported code needs, so a rebase is small. I am not opening a competing pull request. AI-assisted (Claude Code, Claude Opus 5.5).
Author
Owner

@⁠ambroseautomation on GitHub · 2026-11-25 12:52 UTC · original

Rebased onto current main (98c2f7777): adapted with_dot4_op_sel to main's line-based invalid_offsets and forwarded wave32 to run_mc as noted by @⁠Snooozs, resolved the doc/comment conflicts in docs/fspx.md and tests/semantic/test_alu_dot4_i8.py, and added newline='\n' to the JSON write in test_fspx_dot4_op_sel_disasm.py. Re-verified test_shader_disasm.py (31/31), test_alu_dot4_i8.py (14/14), test_text_write_line_endings.py (3/3), and a mock wave32=False / line-offset check. AI-assisted.

**@⁠ambroseautomation** on GitHub · 2026-11-25 12:52 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1317#issuecomment-7162978108) Rebased onto current main (98c2f7777): adapted with_dot4_op_sel to main's line-based invalid_offsets and forwarded wave32 to run_mc as noted by @⁠Snooozs, resolved the doc/comment conflicts in docs/fspx.md and tests/semantic/test_alu_dot4_i8.py, and added newline='\n' to the JSON write in test_fspx_dot4_op_sel_disasm.py. Re-verified test_shader_disasm.py (31/31), test_alu_dot4_i8.py (14/14), test_text_write_line_endings.py (3/3), and a mock wave32=False / line-offset check. AI-assisted.
Author
Owner

@⁠MoonEyes on GitHub · 2026-11-25 17:14 UTC · original

Note for triage: #281 is shown as merged, but its shader_disasm change and tests/semantic/test_fspx_dot4_op_sel_disasm.py are not in current main (they were dropped in merge 154e4ec03 on the #939 branch). This PR still applies cleanly on main and would restore them.

AI-assisted: yes (Claude Code compared the diffs against origin/main; I reviewed it).

**@⁠MoonEyes** on GitHub · 2026-11-25 17:14 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1317#issuecomment-7169213835) Note for triage: #281 is shown as merged, but its shader_disasm change and tests/semantic/test_fspx_dot4_op_sel_disasm.py are not in current main (they were dropped in merge 154e4ec03 on the #939 branch). This PR still applies cleanly on main and would restore them. AI-assisted: yes (Claude Code compared the diffs against origin/main; I reviewed it).
Author
Owner

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

Closing as included, thanks @⁠ambroseautomation! #2138, merged as 0b11d86bc, has this PR's behaviour from your head 62237d0e5: wave32 is passed through with_dot4_op_sel and run_mc, so a wave64 program no longer prints vcc_lo, and only the measured op_sel 2 / op_sel_hi 5 form is printed. Only doc and test wording differ.

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

**@⁠aslan2142** on GitHub · 2026-11-26 03:09 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1317#issuecomment-7181441494) Closing as included, thanks @⁠ambroseautomation! #2138, merged as `0b11d86bc`, has this PR's behaviour from your head `62237d0e5`: `wave32` is passed through `with_dot4_op_sel` and `run_mc`, so a wave64 program no longer prints `vcc_lo`, and only the measured op_sel 2 / op_sel_hi 5 form is printed. Only doc and test wording differ. AI-assisted (Claude Code, Claude Opus 5.5).

Pull request closed

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