Skip to content

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

Merged
aslan2142 merged 1 commit into
ProjectLeonida:mainfrom
Tyrannys:dot4-sel-exact-anchor
Nov 26, 2026
Merged

aslan2142 merged 1 commit into
ProjectLeonida:mainfrom
Tyrannys:dot4-sel-exact-anchor

Conversation

@Tyrannys

@Tyrannys Tyrannys commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

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

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.

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

…el_hi (SHADER-DOT4-SEL-EXACT-ANCHOR)

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 <noreply@anthropic.com>
@GeorgiyDemo

Copy link
Copy Markdown
Contributor

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.

@whoalin1

Copy link
Copy Markdown
Contributor

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.

@kawaii-shakal kawaii-shakal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent confirmation on the full shaders stage of current main (c7e82e2). 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).

@Tyrannys

Tyrannys commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor Author

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)

AI-assisted (Claude Code).

@aslan2142
aslan2142 merged commit 88b290f into ProjectLeonida:main Nov 26, 2026
5 of 12 checks passed
@aslan2142

Copy link
Copy Markdown
Collaborator

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 rdna2spirv: restore the dot4 inline op_sel_hi under exact re-anchoring too (SHADER-FSPX-DOT4-EXACT) #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 added a commit that referenced this pull request Nov 26, 2026
Conflict in runtime/shims/d3d12_xs_device.cpp, proxy_copy_descriptors_simple:
keep this branch's copy_null_rtv_marks call and main's fsdraw::enabled()
gate for the descriptor-copy diagnostic.

tools/rdna2spirv.py merged without a textual conflict, but #1662 on main
calls restore_dot4_inline_sel in the exact re-anchoring path, which this
branch had deleted. The merge puts main's function back so that call
resolves; the next commits reconcile it with the dot4 op_sel rule.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
Kokonotcu added a commit to Kokonotcu/leonida that referenced this pull request Nov 26, 2026
12 upstream commits after ad41fd5, all taken: ProjectLeonida#2123 (D16S8 as D24S8: castable widening only for format 118,
CreatePlacedResource takes its clear value, the depth-UAV copy path in vulkan_replay.h reworked, with its
xbox_depth_storage tests), ProjectLeonida#1662 (rdna2spirv: the backward re-anchor also restores a signed-byte dot4's stored
op_sel_hi, as the forward search does), ProjectLeonida#2160 and ProjectLeonida#2177 (typed image-load and texture-array test models), ProjectLeonida#2159
(gameinput test reads the pad before expecting a scripted press to end). No conflict; every line the merge removes
from our side is one of upstream's own (checked against the merge base, D:\GTA6\analysis\lostlines.sh).

The corpus is to be translated again with this rdna2spirv.

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.

5 participants