rdna2spirv: the exact re-anchor keeps a signed-byte dot's stored op_sel_hi (SHADER-DOT4-SEL-EXACT-ANCHOR) #1662

Manually merged
github merged 1 commit from gh-pr/1662/head into gh-pr/1662/base 2026-11-26 09:59:52 +00:00
Owner

@⁠Tyrannys on GitHub · 2026-11-25 07:29 UTC · original
Tyrannys:dot4-sel-exact-anchor → main · +108 −2 · 3 files · 1 commits · merged 2026-11-26 01:57 UTC

Claimed in the coordination issue as: SHADER-DOT4-SEL-EXACT-ANCHOR (#1608)

What and why

translate() re-anchors a listing that reports rejected words. When llvm-mc's messages give one offset per rejected word, it re-anchors exactly, from those offsets (invalid_at). That exact path tried mix_literal and mix_inline_literal, but not restore_dot4_inline_sel. The forward search and check_printed_encodings already try that repair. So a v_dot4_i32_i8 with an inline-integer S1 and a stored op_sel_hi of 5 (llvm-mc prints it as the default, 7) got marked normalized, and its whole program was refused with "reachable instruction with normalized encoding".

One of the FidelityFX DLL's programs has this form, plus rejected words. Without it, the title's slot-67 pipeline creation fails. In a retail boot, the upscaler then crashes on a null read a few seconds later.

The fix: the exact path tries restore_dot4_inline_sel first, in the same order as the forward search. Other mismatches are refused as before. The change is one line. It doesn't touch #1301's lines in restore_dot4_inline_sel itself.

docs/design.md (the "Code-embedded data" row) records the rule and the count.

Tested

No game files in the test. Windows 11, CPU only for the suite.

  • New tests/semantic/test_reanchor_dot4_inline_sel.py, hand-built encodings:
    • the exact path now translates the form, with the same result as the clean-listing path;
    • that result is the stored op_sel_hi, not the printed one;
    • a register-S1 mismatch is still refused.
    • Before the fix, the first two fail with the error above.
  • python -I scripts/run_semantic_tests.py tests/semantic: 488 files, 6,282 tests, 0 failed (292 s, 16 jobs).
  • Counted on my own 1.0.2.1 copy (LLVM 21.1.8, --wave64-emulate), the FidelityFX DLL's 29 programs:
    • main: 22 translated;
    • this PR: 24;
    • this PR with #674 (SHADER-VCC-TUPLE-RESYNC) on top: 29 of 29, all pass spirv-val;
    • #674 alone: 28.
    • So the two PRs are independent, and both are needed for the whole DLL.
  • Retail boot with all 29 programs (RTX 4070 SUPER, NVIDIA 621.01; LEONIDA_SKIP_INT3=1 LEONIDA_TITLE_WATCHDOG=0, plus #1631): the upscaler crash that ended the runs before is gone, and the run lasted its full 485 s. A device loss on a library compute dispatch came late in the run. That's a separate matter.

AI-assisted (Claude Code).

GPUs tested: NVIDIA GeForce RTX 4070 SUPER, driver 621.01, Windows 11 (retail boot only; the translator tests need no GPU)

AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

**@⁠Tyrannys** on GitHub · 2026-11-25 07:29 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1662) `Tyrannys:dot4-sel-exact-anchor` → `main` · +108 −2 · 3 files · 1 commits · merged 2026-11-26 01:57 UTC Claimed in the coordination issue as: SHADER-DOT4-SEL-EXACT-ANCHOR (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608) ### What and why `translate()` re-anchors a listing that reports rejected words. When llvm-mc's messages give one offset per rejected word, it re-anchors exactly, from those offsets (`invalid_at`). That exact path tried `mix_literal` and `mix_inline_literal`, but not `restore_dot4_inline_sel`. The forward search and `check_printed_encodings` already try that repair. So a `v_dot4_i32_i8` with an inline-integer S1 and a stored op_sel_hi of 5 (llvm-mc prints it as the default, 7) got marked normalized, and its whole program was refused with "reachable instruction with normalized encoding". One of the FidelityFX DLL's programs has this form, plus rejected words. Without it, the title's slot-67 pipeline creation fails. In a retail boot, the upscaler then crashes on a null read a few seconds later. The fix: the exact path tries `restore_dot4_inline_sel` first, in the same order as the forward search. Other mismatches are refused as before. The change is one line. It doesn't touch #1301's lines in `restore_dot4_inline_sel` itself. `docs/design.md` (the "Code-embedded data" row) records the rule and the count. ### Tested No game files in the test. Windows 11, CPU only for the suite. - New `tests/semantic/test_reanchor_dot4_inline_sel.py`, hand-built encodings: - the exact path now translates the form, with the same result as the clean-listing path; - that result is the stored op_sel_hi, not the printed one; - a register-S1 mismatch is still refused. - Before the fix, the first two fail with the error above. - `python -I scripts/run_semantic_tests.py tests/semantic`: 488 files, 6,282 tests, 0 failed (292 s, 16 jobs). - Counted on my own 1.0.2.1 copy (LLVM 21.1.8, `--wave64-emulate`), the FidelityFX DLL's 29 programs: - `main`: 22 translated; - this PR: 24; - this PR with #674 (SHADER-VCC-TUPLE-RESYNC) on top: **29 of 29**, all pass `spirv-val`; - #674 alone: 28. - So the two PRs are independent, and both are needed for the whole DLL. - Retail boot with all 29 programs (RTX 4070 SUPER, NVIDIA 621.01; `LEONIDA_SKIP_INT3=1 LEONIDA_TITLE_WATCHDOG=0`, plus #1631): the upscaler crash that ended the runs before is gone, and the run lasted its full 485 s. A device loss on a library compute dispatch came late in the run. That's a separate matter. AI-assisted (Claude Code). GPUs tested: NVIDIA GeForce RTX 4070 SUPER, driver 621.01, Windows 11 (retail boot only; the translator tests need no GPU) AI-assisted: yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A listing that reports rejected words with llvm-mc's own offsets is
re-anchored exactly, and that path never tried restore_dot4_inline_sel,
which the forward search and check_printed_encodings already use. A
v_dot4_i32_i8 with an inline-integer S1 and stored op_sel_hi 5 (printed
as the default 7) was marked normalized and its whole program refused
("reachable instruction with normalized encoding"). One FidelityFX DLL
program has that form; without it the title's slot 67 fails and the
run crashes inside the upscaler.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:59:51 +00:00
github manually merged commit b3ce84b33f into gh-pr/1662/base 2026-11-26 09:59:52 +00:00
Author
Owner

@⁠GeorgiyDemo on GitHub · 2026-11-25 07:51 UTC · original

Tested b3ce84b33 on Apple M5 Pro (16-core GPU), macOS 26.7.3 (25G342), against main 3f81d46ac (translator-only PR; binaries from the build at 66d4f5aa3):

  • tests/semantic/test_reanchor_dot4_inline_sel.py: OK at this head; copied onto main it errors 2 — the exact re-anchor path without restore_dot4_inline_sel fails as described.
  • No v_dot4 GPU fixture exists, so the GPU smoke is on the neighbouring integer VALU set: --filter ps_vint 5/5 PASS on MoltenVK 1.4.2 (ps_vint_bits, ps_vint_logic3, ps_vint_minmax, ps_vint_minmax3, ps_vint_mul24).
  • Not run: the re-anchor path against a real rejected-word listing / corpus; the semantic fixture is the evidence.

AI-assisted; synthetic fixtures only, no game data.

**@⁠GeorgiyDemo** on GitHub · 2026-11-25 07:51 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1662#issuecomment-7156327957) Tested `b3ce84b33` on Apple M5 Pro (16-core GPU), macOS 26.7.3 (25G342), against `main` `3f81d46ac` (translator-only PR; binaries from the build at `66d4f5aa3`): - `tests/semantic/test_reanchor_dot4_inline_sel.py`: **OK** at this head; copied onto `main` it errors **2** — the exact re-anchor path without `restore_dot4_inline_sel` fails as described. - No `v_dot4` GPU fixture exists, so the GPU smoke is on the neighbouring integer VALU set: `--filter ps_vint` **5/5 PASS** on **MoltenVK 1.4.2** (`ps_vint_bits`, `ps_vint_logic3`, `ps_vint_minmax`, `ps_vint_minmax3`, `ps_vint_mul24`). - Not run: the re-anchor path against a real rejected-word listing / corpus; the semantic fixture is the evidence. AI-assisted; synthetic fixtures only, no game data.
Author
Owner

@⁠whoalin1 on GitHub · 2026-11-25 08:31 UTC · original

Independent verification (native Windows): minimal one-condition fix in the exact re-anchor path (restore_dot4_inline_sel tried before marking normalized), mirrors the forward-search path at rdna2spirv.py:17783; contract row extended; new test_reanchor_dot4_inline_sel.py 3/3 OK, neighbor reanchor/fma-mix tests all OK; FULL semantic suite 488 files / 6,282 tests / 0 failed. Game-file claims unverifiable, fix itself is clean. AI-assisted verification.

**@⁠whoalin1** on GitHub · 2026-11-25 08:31 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1662#issuecomment-7157131938) Independent verification (native Windows): minimal one-condition fix in the exact re-anchor path (`restore_dot4_inline_sel` tried before marking normalized), mirrors the forward-search path at rdna2spirv.py:17783; contract row extended; new `test_reanchor_dot4_inline_sel.py` 3/3 OK, neighbor reanchor/fma-mix tests all OK; FULL semantic suite 488 files / 6,282 tests / 0 failed. Game-file claims unverifiable, fix itself is clean. AI-assisted verification.
Author
Owner

@⁠kawaii-shakal on GitHub · 2026-11-25 10:15 UTC · original · reviewed

Independent confirmation on the full shaders stage of current main (c7e82e26e). The disassembly comes from make_game's own stage, so the LLVM differs from your 21.1.8 run. The two FidelityFX DLL programs that fail are exactly the ones this PR is about:

  • Without the change, amd_fidelityfx_upscaler_xbox_03 and _18 are refused as reachable instruction with normalized encoding, and 27 of 29 translate.
  • The refused words are a v_dot4_i32_i8 with an inline-integer S1 (10 and -6). The stored op_sel_hi is [1,0,1] and the printed one [1,1,1]: the stored word has bit 60 clear and the printed word has it set (0x0c vs 0x1c in byte 7), both in listings with llvm-mc offsets, so the exact path.
  • With the same one-line change (try restore_dot4_inline_sel on the exact path before marking the word), both translate and pass spirv-val: 29 of 29.

So with this PR the FSPX set is complete on main. I made the same change locally before I found this PR and dropped mine in its favour. The code change matches; I did not run your new test.

Tested on Windows 11 Pro 26300, Python 3.13, rdna2spirv.py --no-asm --wave64-emulate on the stage's own listings.

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

**@⁠kawaii-shakal** on GitHub · 2026-11-25 10:15 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1662#pullrequestreview-6055658152) · **reviewed** Independent confirmation on the full shaders stage of current main (c7e82e26e). The disassembly comes from `make_game`'s own stage, so the LLVM differs from your 21.1.8 run. The two FidelityFX DLL programs that fail are exactly the ones this PR is about: - Without the change, `amd_fidelityfx_upscaler_xbox_03` and `_18` are refused as `reachable instruction with normalized encoding`, and 27 of 29 translate. - The refused words are a `v_dot4_i32_i8` with an inline-integer S1 (10 and -6). The stored op_sel_hi is `[1,0,1]` and the printed one `[1,1,1]`: the stored word has bit 60 clear and the printed word has it set (`0x0c` vs `0x1c` in byte 7), both in listings with llvm-mc offsets, so the exact path. - With the same one-line change (try `restore_dot4_inline_sel` on the exact path before marking the word), both translate and pass `spirv-val`: 29 of 29. So with this PR the FSPX set is complete on main. I made the same change locally before I found this PR and dropped mine in its favour. The code change matches; I did not run your new test. Tested on Windows 11 Pro 26300, Python 3.13, `rdna2spirv.py --no-asm --wave64-emulate` on the stage's own listings. AI-assisted review (Claude Code, Claude Opus 5.5).
Author
Owner

@⁠Tyrannys on GitHub · 2026-11-25 18:12 UTC · original · edited 2026-11-25 18:55 UTC

Test report from a combined build on a second NVIDIA machine. Counts only.

Machine: Windows 11, RTX 4070 SUPER, NVIDIA 621.01, 64 GB, own 1.0.2.1 copy.

Build: main fe1553456 (already contains #1827 and #1893), plus #674, #1662, #1851, #1849, #1905, #1957, #1950, #1886 and #1894. All of them merged without conflicts.

Shaders: translated on 3de22a190 + #674 + #1662 with --wave64-emulate. 29,279 of 29,280 translated, and all 29,279 pass spirv-val. That is 2,683 library programs and 29 of 29 FSPX. main's translator changes since then are correctness fixes only.

Pipeline cache: warm and complete, 26,503 of 26,503 (9.6 GB).

  • Three library compute programs took 30 to 32 minutes each to build alone: the ScreenProbes ActivateRays, ActivateProbes and ActivateProbesTarget programs of indirect diffuse lighting.
  • Building all three at once crashed the NVIDIA compiler ("NVVM compilation failed: 3", after 22 minutes).

Recipe: scripts/windows-boot/boot.ps1 -Seconds 480, LEONIDA_KEYBOARD_PAD=1 LEONIDA_SKIP_INT3=1 LEONIDA_TITLE_WINDOWS_MB=1024 LEONIDA_MAP_READBACK=1, LEONIDA_PIPELINE_CACHE_DIR pointing at the offline cache. Host image copy: off (auto: NVIDIA) from #1851. One run per row.

run 1 run 2 (+ LEONIDA_TITLE_WATCHDOG=0)
end 344 s: the title's hang watchdog (null write at game_scarlett_master.exe+0x23cf683) full 484 s, stopped by the script
device loss / fault report none none
D3D12 calls 330,487 375,686
ExecuteCommandLists 5,490 6,017
Dispatch / DrawIndexedInstanced 2,435 / 2,726 2,779 / 6,026
PresentX 1,358 ok, 0 failed 1,465 ok, 0 failed
captures 23, all non-black 25, all non-black
indirect draws recorded / emitted / skipped 64 / 0 / 5,092 128 / 34 / 9,244 (#429 not included)
  • WRITE_INVALID: the world-start WRITE_INVALID did not happen in either run. On this machine it ended an earlier run with host image copies on (main 42537e7b6 + #1631; my run table of 07:54 in #1608).
  • #1950 / #1886: in run 1 the exit filter ran on the title's fatal exception: "1 pipeline build(s) still running at exit; writing the pipelines finished so far". It then refused the write: "pipeline cache is 9722912321 bytes, over the 4294967296-byte write limit". With a seeded offline cache, the union is past 4 GiB, so nothing from the session was kept. This is the seeded case raised on #1886. No session file was written in either run.

AI-assisted (Claude Code).

**@⁠Tyrannys** on GitHub · 2026-11-25 18:12 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1662#issuecomment-7170583484) · edited 2026-11-25 18:55 UTC Test report from a combined build on a second NVIDIA machine. Counts only. **Machine:** Windows 11, RTX 4070 SUPER, NVIDIA 621.01, 64 GB, own 1.0.2.1 copy. **Build:** `main` `fe1553456` (already contains #1827 and #1893), plus #674, #1662, #1851, #1849, #1905, #1957, #1950, #1886 and #1894. All of them merged without conflicts. **Shaders:** translated on `3de22a190` + #674 + #1662 with `--wave64-emulate`. 29,279 of 29,280 translated, and all 29,279 pass `spirv-val`. That is 2,683 library programs and 29 of 29 FSPX. `main`'s translator changes since then are correctness fixes only. **Pipeline cache:** warm and complete, 26,503 of 26,503 (9.6 GB). - Three library compute programs took 30 to 32 minutes each to build alone: the ScreenProbes `ActivateRays`, `ActivateProbes` and `ActivateProbesTarget` programs of indirect diffuse lighting. - Building all three at once crashed the NVIDIA compiler ("NVVM compilation failed: 3", after 22 minutes). **Recipe:** `scripts/windows-boot/boot.ps1 -Seconds 480`, `LEONIDA_KEYBOARD_PAD=1 LEONIDA_SKIP_INT3=1 LEONIDA_TITLE_WINDOWS_MB=1024 LEONIDA_MAP_READBACK=1`, `LEONIDA_PIPELINE_CACHE_DIR` pointing at the offline cache. Host image copy: `off (auto: NVIDIA)` from #1851. One run per row. | | run 1 | run 2 (+ `LEONIDA_TITLE_WATCHDOG=0`) | |---|---|---| | end | 344 s: the title's hang watchdog (null write at `game_scarlett_master.exe+0x23cf683`) | full 484 s, stopped by the script | | device loss / fault report | none | none | | D3D12 calls | 330,487 | 375,686 | | ExecuteCommandLists | 5,490 | 6,017 | | Dispatch / DrawIndexedInstanced | 2,435 / 2,726 | 2,779 / 6,026 | | PresentX | 1,358 ok, 0 failed | 1,465 ok, 0 failed | | captures | 23, all non-black | 25, all non-black | | indirect draws recorded / emitted / skipped | 64 / 0 / 5,092 | 128 / 34 / 9,244 (#429 not included) | - **WRITE_INVALID:** the world-start WRITE_INVALID did not happen in either run. On this machine it ended an earlier run with host image copies on (`main` `42537e7b6` + #1631; my run table of 07:54 in #1608). - **#1950 / #1886:** in run 1 the exit filter ran on the title's fatal exception: "1 pipeline build(s) still running at exit; writing the pipelines finished so far". It then refused the write: "pipeline cache is 9722912321 bytes, over the 4294967296-byte write limit". With a seeded offline cache, the union is past 4 GiB, so nothing from the session was kept. This is the seeded case raised on #1886. No session file was written in either run. AI-assisted (Claude Code).
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-26 01:57 UTC · original

Merged, thanks! The exact re-anchor's window check now tries the same repair as the normal pass and the forward search: a signed-byte dot's stored op_sel_hi with a replicated inline integer is restored there too, instead of the instruction being refused as normalized.

  • Why it mattered: with llvm-mc 23 naming undecodable words at known offsets, a listing reaches that check, and an FSPX v_dot4_i32_i8 was refused there while the same instruction was repaired everywhere else.
  • Same fix as #1862 (Coderlord), which I'm closing as a duplicate.
  • Checked on main ef3493186 + b3ce84b33: the semantic suite passes (496 files, 6,336 tests, 0 files failed); the 15 docs and writer tests pass; check_no_game_data.py is clean on the 3 changed files.

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

**@⁠aslan2142** on GitHub · 2026-11-26 01:57 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1662#issuecomment-7180319671) Merged, thanks! The exact re-anchor's window check now tries the same repair as the normal pass and the forward search: a signed-byte dot's stored `op_sel_hi` with a replicated inline integer is restored there too, instead of the instruction being refused as normalized. - **Why it mattered:** with `llvm-mc` 23 naming undecodable words at known offsets, a listing reaches that check, and an FSPX `v_dot4_i32_i8` was refused there while the same instruction was repaired everywhere else. - **Same fix as #1862** (Coderlord), which I'm closing as a duplicate. - **Checked on `main` `ef3493186` + `b3ce84b33`:** the semantic suite passes (496 files, 6,336 tests, 0 files failed); the 15 docs and writer tests pass; `check_no_game_data.py` is clean on the 3 changed files. AI-assisted (Claude Code, Claude Opus 5.5).
This discussion has been locked. Commenting is limited to contributors.
No description provided.