Skip to content

rdna2spirv: reject contradictory packed FMA literal text during repair - #8877

Closed
coenflict wants to merge 1 commit into
ProjectLeonida:mainfrom
coenflict:orchestrator/packed-fma-encoding
Closed

coenflict wants to merge 1 commit into
ProjectLeonida:mainfrom
coenflict:orchestrator/packed-fma-encoding

Conversation

@coenflict

Copy link
Copy Markdown
Contributor

FMA-MIX-LITERAL-TEXT (coordination claim).

Depends on: #2977
Depends on: #6808
Depends on: #3372 (shared reconciliation call sites need a rebase when either change lands).

Summary

LLVM 23.1.6 on gfx1030 prints synthetic lit(0x40400000) and lit(0x40800000) operands with the same zero literal dword in the encoding annotation. On main, a listing for 4.0 paired with a blob holding 3.0 silently translated as 3.0 on both listing paths.

During the existing low-half reconstruction, check that each encoded literal source names either the low half in the annotation or the full dword in the blob before updating any operands. The regression covers both paths. This is a synthetic listing consistency fix. The FSPX report in #8683 remains unverified.

Tests

  • The new regression failed on both listing paths on 867d922f0 and passes on this head. The targeted literal, packed FMA, printed encoding, decoder and parser tests passed (107 tests).
  • LLVM 23.1.6 under WSL, gfx1013 and gfx1030. All 21,594 cut-literal cases in a sweep of 24,000 synthetic instructions across the three mix opcodes restored successfully and agreed with the repository's direct decoder on operand values and modifiers.
  • Six repaired synthetic fragment modules returned the expected output and passed spirv-val --target-env vulkan1.3 with SPIRV-Tools 2026.4.
  • Full semantic suite on Windows 11 build 26340 with CPython 3.14.7. Main ran 5,957 tests, this head ran 5,958. Both had the same three failing files documented in tests/semantic: three image test files red on main (stale after #4473 and #6805; LLVM_MC on Windows) #7284. The line-ending check reports the existing leonida_tui, wave_diff: pin LF on the two writers no scan reaches; test them #7819 failures and the design-row check reports duplicate entries in the unchanged docs index. Compilation, game-data scan and diff hygiene passed.
  • CPU only. The host has a GeForce RTX 5090 on driver 621.24. All shader inputs were synthetic.

AI-assisted (Codex).

@catminou4

Copy link
Copy Markdown
Contributor

Tested on Apple M1 Max, macOS 27.2.1 arm64, Python 3.12.16: python -m unittest test_fma_mix_literal (tests/semantic) → 12 tests OK. No game files. AI-assisted (Devin).

@Grimkaaah Grimkaaah 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 Linux CPU review (589bee9b)

What changed: rdna2spirv rejects contradictory packed FMA literal text during repair.

Checked: focused tests 12 OK.

Looks correct; no game files.

@gut0to gut0to left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Reviewed the literal repair paths. restore_mix_literal now compares instruction bytes exactly, requires all three sources, and verifies every encoded literal operand agrees with either the annotation low half or the stored full word before mutating operands. The regression covers both clean-listing and re-anchoring paths for contradictory annotations. No blocking issue found. AI-assisted.

@Kev-Ball

Copy link
Copy Markdown

Checked 589bee9b8 against its direct parent 867d922f0 on the manifest-verified Xbox 1.0.2.1 FidelityFX DLL. I extracted all 29 FSPX programs with fspx_unpack.py --disasm (default gfx1030, llvm-mc 23.1.5) and ran both translators on the same fresh listings.

Both revisions translated 21/29, all 21 passed spirv-val, and the complete indexes and all 21 SPIR-V binaries matched. I also counted successful calls to the revised restore_mix_literal: six repairs in one listing, and that listing produced one of the validated modules. The stricter text check therefore preserves a real repair path on this input.

The other eight listings all stopped at fall-through into undecodable words on both revisions. This setup did not reproduce the 26/29 run or its specific FMA refusal in #8683. The LLVM version and disassembly options from that run would help compare the two results. CPU-only, CachyOS, AI-assisted.

@eizispark

Copy link
Copy Markdown

Tested 589bee9 merged onto main (867d922) on AMD Radeon RX 9070 XT, Adrenalin 26.11.1 (LLPC / Vulkan 1.4.359), Windows 11:

  • python -I -X utf8 -m unittest discover -s tests/semantic -p test_*fma*.py (including tests/semantic/test_fma_mix_literal.py): 208/208 passed (exit 0)
  • python -I -X utf8 scripts/run_gpu_tests.py --build runtime/build --filter fma --require-pass: 4/4 translated & spirv-val valid, 4/4 GPU tests passed (cs_div_fmas_f64, cs_fma_fused, ps_fma_literal, ps_fmac_f16_mods, exit 0)

@WALID1618Y

Copy link
Copy Markdown
Contributor

Tested 589bee9b8 on NVIDIA GeForce RTX 3050 (driver 621.24 / 32.0.16.2124, Vulkan 1.4.357, Windows x64, Python 3.13.14): pass

Environment notes: pre-built runtime-windows CI binaries from e68c5c9c9 (tools/rdna2spirv.py unchanged between e68c5c9c9 and 867d922f0), --assembler python (tools/spirv_asm.py), --disasm-dir tests/semantic/fixtures/disasm (no llvm-mc), spirv-val skipped (--no-validate). Synthetic/fixture shaders only, no game files. AI-assisted.

Semantic tests:

  • Red-before (LEONIDA_TOOLS_DIR -> base tools/): tests/semantic/test_fma_mix_literal.py -> test_llvm23_full_literal_with_the_same_low_half_is_refused FAILED on both invalid=False and invalid=True (11 ok, 2 subtest failures).
  • Green-after (589bee9b8):
    • python -I tests/semantic/test_fma_mix_literal.py -v: 12/12 OK
    • python -I tests/semantic/test_printed_encoding.py -v: 7/7 OK

RTX 3050 GPU suite (589bee9b8):

  • python -I scripts/run_gpu_tests.py --build runtime-windows --disasm-dir tests/semantic/fixtures/disasm --assembler python --filter fma --require-pass: 2/2 passed (ps_fma_literal 4096/4096 pixels exact, ps_fmac_f16_mods 4096/4096 pixels exact)
  • Full pre-disassembled suite (native): 81/96 passed, 15 skipped (32-wide device wave64 compute skips; matches baseline)
  • LEONIDA_W64_EMULATE=1 with --filter cs_w --require-pass: 30/30 passed

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