Skip to content

rdna2spirv: restore the dot4 inline op_sel_hi under exact re-anchoring too (SHADER-FSPX-DOT4-EXACT) - #1862

Closed
Coderlord wants to merge 1 commit into
ProjectLeonida:mainfrom
Coderlord:fspx-dot4-exact
Closed

Coderlord wants to merge 1 commit into
ProjectLeonida:mainfrom
Coderlord:fspx-dot4-exact

Conversation

@Coderlord

Copy link
Copy Markdown

Claimed in the coordination issue as: SHADER-FSPX-DOT4-EXACT (#1608 (comment))

What and why

A listing whose undecodable words sit at offsets its llvm-mc messages name is re-anchored exactly
(invalid_at, from #984). That branch of translate tried the v_fma_mix literal restores but not
restore_dot4_inline_sel, which the forward-search branch and check_printed_encodings both try. So a
v_dot4_i32_i8 whose src1 is a replicated inline integer (llvm-mc prints op_sel_hi[1] set where the program's
word has it clear) was marked normalized, and the whole program was refused as "reachable instruction with
normalized encoding".

llvm-mc 23.1.6 names every word it rejects, so two of the 29 FSPX programs of the FidelityFX DLL take that branch and
did not translate. The title then has no pipeline for one of them, and the DLL reads through the missing object
(an access violation at amd_fidelityfx_upscaler_xbox.dll+0x65ff, about 50 s after the first-run setup is
confirmed, native Windows). The fix is one condition: the exact branch tries restore_dot4_inline_sel before the
literal restores, as the other two paths do.

Tested

  • FSPX step (rdna2spirv.py <work>/shaders/fspx/disasm --no-asm --wave64-emulate) with llvm-mc 23.1.6 (conda-forge
    llvm-tools): 27 of 29 translated and passing spirv-val on main 98c2f77, 29 of 29 with this change.
    The other 6 FSPX programs with rejected words (the dot4 forms [integration] Linux/Proton and native Windows: boot through the story load (RT-PROTON-STORY-LOAD) #984 recovers) translate either way.
  • python -I tests/test_rdna2spirv_decode.py: 26 tests OK. The new
    test_exact_anchoring_restores_dot4_inline_sel (one rejected word at a known offset after s_endpgm, a dot4
    printed with the default op_sel_hi) passes with the change and fails without it with "reachable instruction with
    normalized encoding".
  • Retail boots on this card (native Windows, ubiq main ed94fbe + d3d12: import a slot-133 buffer at any offset in its page (RT-SLOT133-IMPORT-OFFSET) #1768): without this change the process
    died 50 s after the first-run setup was confirmed, in amd_fidelityfx_upscaler_xbox.dll+0x65ff (a read at
    0x10), right after the runtime logged "no translated compute shader for FSPX" for one of the two programs and
    refused its pipeline (E_INVALIDARG). With the 29 retranslated, the next boot logged no missing FSPX program
    and did not fault in the DLL; it went on to a later, unrelated stop (a lost device about 75 s into the session).

GPUs tested: NVIDIA GeForce RTX 5080, driver 621.24, Windows 11 Pro 26300

AI-assisted: yes (Claude Code)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: an
    existing restore applied in one more branch, no new rule)

…g too (SHADER-FSPX-DOT4-EXACT)

A listing whose undecodable words sit at offsets its llvm-mc messages name is re-anchored exactly (ProjectLeonida#984's
invalid_at). That branch tried the v_fma_mix literal restores but not restore_dot4_inline_sel, which the search
branch and check_printed_encodings both try, so a v_dot4_i32_i8 whose src1 is a replicated inline integer (llvm-mc
prints op_sel_hi[1] set where the program's word has it clear) was marked normalized and the program refused as
"reachable instruction with normalized encoding".

llvm-mc 23.1.6 names every rejected word, so two of the 29 FSPX programs of the FidelityFX DLL took that branch and
did not translate (27 of 29). The title then had no pipeline for one of them at the start of the story, and the DLL
read through the missing object (an access violation at amd_fidelityfx_upscaler_xbox.dll+0x65ff, 50 s after the
first-run setup, native Windows, RTX 5080). With the restore the FSPX step translates 29 of 29, all passing
spirv-val.

test_rdna2spirv_decode: a listing with one rejected word at a known offset after s_endpgm and a dot4 printed with the
default op_sel_hi translates (it raised before).

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

Copy link
Copy Markdown
Contributor

Tested merged onto main 384abe5 (Linux, Python 3.13): tests/test_rdna2spirv_decode.py passes, and the whole tests/semantic suite gives 489 files, 6288 tests, with only test_int32_to_f64 failing (Ubuntu's spirv-opt segfaults, same on main). The new call matches the two existing restore_dot4_inline_sel call sites, and the helper only accepts the case it describes (v_dot4_i32_i8, inline-integer src1, printed bytes equal to the stored ones plus op_sel_hi bit 28), so I don't see it widening anything else.

AI-assisted (Claude).

@Snooozs

Snooozs commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Confirmed on a second machine, tools of main 71a769d with and without this change, FSPX step run on its own (fspx_unpack.py --disasm, then rdna2spirv.py --no-asm --wave64-emulate), Windows 10 Pro 19045, Python 3.12.10:

llvm-mc main with #1862
23.1.6 27 of 29, 27 pass spirv-val 29 of 29, 29 pass spirv-val
21.1.8 22 of 29 (2 normalized, 5 fall-through) 24 of 29 (5 fall-through)
  • With 23.1.6 the 27 programs that already translated are byte-identical with and without the change.
  • All 29 are also byte-identical to a set I made earlier with another local fix (the shader_disasm op_sel listing of old fix: shader_disasm prints the v_dot4_i32_i8 op_sel 2 / op_sel_hi 5 words llvm-mc rejects, so the FSR4 FSPX programs translate #281), so the two routes agree.
  • That earlier set is what removed the amd_fidelityfx_upscaler_xbox.dll+0x65ff fault in my retail boots (RTX 5060 Ti, NVIDIA 621.01): the boot with 27 of 29 stopped there at 152 s, the next one with 29 of 29 went past it and stopped later at the world-start device loss. I have not booted with this branch itself.
  • With llvm-mc 21.1.8 the 5 "fall-through into undecodable words" programs remain, which is outside this change; 23.1.6 decodes them.

Counts only, no game data. AI-assisted (Claude Code).

@BubsMcgee

Copy link
Copy Markdown
Contributor

Tested on RTX 3080 Ti / Windows 11 / NVIDIA 616.64: this takes the FidelityFX FSPX set from 27 to 29 (rdna2spirv.py <fspx>/disasm --out <spirv>/fspx --no-asm --wave64-emulate), 29/29 pass spirv-val. On a retail boot with the 29, no translated compute shader for FSPX and the amd_fidelityfx_upscaler_xbox.dll+0x65ff AV are gone; the run stays at session d to t=195 s and the next stop is the known world-start device loss (#1537/#1602, lib_cs_01725/01726/01728). AI-assisted.

@DeadlyChirp

Copy link
Copy Markdown

Tested on Windows 11, Python 3.12.10, with this PR merged onto current upstream main.

python -m pytest -q tests/test_rdna2spirv_decode.py:

  • PR: 26 passed, 102 subtests passed. main: 25 passed, 102 subtests passed. The new test passes on Windows.

(AI-assisted test run; output checked by hand.)

@BubsMcgee

Copy link
Copy Markdown
Contributor

Independent check on this PR — RTX 3080 Ti (616.64), Windows 11, LLVM 23.1.5 (the repo's documented llvm-mc; MSYS2).

The next stop is not this PR: after ~216 s, VK_ERROR_DEVICE_LOST on pipeline-library compute (library/lib_cs_02996), the 0x380 / 63,632-page XMem pool window with no GPU mapping (QemmHD's finding in #1608), then a title breakpoint. Snooozs' run 2 in #1608 has the same order (29/29 → device lost). This PR is the FSR4 unlock; the pool-window mapping (RT-GPU-WINDOW-SPARSE / title-memory) is the next one.

AI-assisted.

@Tyrannys

Copy link
Copy Markdown
Contributor

Heads-up for review: this overlaps #1662 (SHADER-DOT4-SEL-EXACT-ANCHOR, claimed in #1608 at 07:3x today, opened 07:29). Both add the same repair: restore_dot4_inline_sel tried in the exact re-anchor path before the word is marked normalized. #1662 also adds a semantic fixture (tests/semantic/test_reanchor_dot4_inline_sel.py, which fails on main and passes with the fix) and extends the contract row in docs/design.md; this PR adds a unit test in tests/test_rdna2spirv_decode.py. Only one of the two should land, so a maintainer only has to review one. If your test covers a case #1662's doesn't, I'm happy to take it into #1662 with credit, or to close #1662 if this one is preferred.

AI-assisted (Claude Code).

@MoonEyes

Copy link
Copy Markdown
Collaborator

Small addition for llvm-mc 21.1.8 users (Windows 11, llvm-mc 21.1.8 under WSL): the 22 -> 24 reported above for 21.1.8 was on an older main. On current main (db1a22d29) 21.1.8 gives 27 of 29, and main with this PR merged gives 29 of 29 (all pass spirv-val; the 27 that already translated are byte-identical). The PR head alone (e88177e53, based on 384abe5b0) still gives 24 of 29 with 21.1.8, so with that llvm-mc test it merged into main.

  • Mutation: with the added not restore_dot4_inline_sel(ins, window, enc) condition replaced by True, the PR's new test in tests/test_rdna2spirv_decode.py fails (1 failed, 25 passed), so the test covers the change.

Counts only, no game data.

AI-assisted: yes (Claude Code ran the translation and the tests)

@Coderlord

Copy link
Copy Markdown
Author

Note: #2138 (RT-BOOT-COMBINED, open) carries #1495's restore_dot4_op_sel, which replaces restore_dot4_inline_sel and is already tried in the exact re-anchoring branch. On #2138's head the 29 FSPX programs translate 29 of 29 with llvm-mc 23.1.6 (RTX 5080, Windows 11), and this PR's new test test_exact_anchoring_restores_dot4_inline_sel passes there without this PR's code change. So if #2138 lands first, this PR reduces to that regression test, and I'm happy to close it or trim it to the test, whichever you prefer.

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

@aslan2142

Copy link
Copy Markdown
Collaborator

Thanks for this! Closing as a duplicate of #1662, merged as 88b290fcb: it adds the same restore_dot4_inline_sel repair to the exact re-anchor's window check, so the FSPX v_dot4_i32_i8 with a replicated inline integer is no longer refused there.

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

@aslan2142 aslan2142 closed this Nov 26, 2026
aslan2142 added a commit that referenced this pull request Nov 26, 2026
…re_dot4_inline_sel

The general rule from #1495 (dot4_op_sel_fields / restore_dot4_op_sel,
ported from luizwidmer/palmetto) took the stored op_sel/op_sel_hi of any
v_dot4_i32_i8 that llvm-mc printed with the defaults. That translated
op_sel 0 / op_sel_hi 5 with a VGPR second source, a word #1317's
test_fspx_dot4_op_sel_disasm.py (case (0, 5)) requires to stay refused:
only op_sel 2 / op_sel_hi 5 was measured on gfx1036. The translator suite
failed there.

Resolve it on the measured side:
- drop dot4_op_sel_fields and restore_dot4_op_sel;
- keep main's restore_dot4_inline_sel (#984) and its three call sites:
  the clean-listing check, the forward re-anchor search, and the exact
  re-anchor window #1662 added today. The general rule does not cover
  only those cases, so it cannot replace them;
- tests/semantic/test_dot4_printed_op_sel.py now checks that the
  inline-integer form is restored in a clean listing and on re-anchoring,
  and that op_sel_hi 5 with a VGPR S1, op_sel 1 / op_sel_hi 6,
  op_sel_hi 4 and a non-default S2 half stay refused;
- docs/design.md "Signed-byte dot products" states how each form was
  confirmed (hardware for op_sel 2 / op_sel_hi 5, a corpus count for the
  inline-integer form, refused otherwise); docs/fspx.md follows.

This also settles the #1662 / #1862 overlap: #1662's call site stays.

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.

8 participants