[PR #2142] [MERGED] rdna2spirv: take a v_fma_mix literal from the printed encoding when only the text is cut (SHADER-FMA-MIX-TEXT-CUT-LITERAL) #2146

Closed
opened 2026-11-26 21:20:12 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2142
Author: @DadaCap
Created: 11/25/2026
Status: ✅ Merged
Merged: 11/26/2026
Merged by: @aslan2142

Base: main ← Head: mix-literal-text-cut


📝 Commits (2)

  • a449806 rdna2spirv: take a v_fma_mix literal from the printed encoding when only the text is cut (SHADER-FMA-MIX-TEXT-CUT-LITERAL)
  • abcccef rdna2spirv: restore a text-cut v_fma_mix literal with no blob too; pin the low-half guard

📊 Changes

3 files changed (+31 additions, -1 deletions)

View changed files

📝 docs/design.md (+1 -1)
📝 tests/semantic/test_fma_mix_literal.py (+14 -0)
📝 tools/rdna2spirv.py (+16 -0)

📄 Description

Claimed in the coordination issue as: SHADER-FMA-MIX-TEXT-CUT-LITERAL (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7176772104)

Depends on: nothing

What and why

llvm-mc 21.1.8 can print a v_fma_mix* literal cut to its low 16 bits in the text only, while the printed encoding keeps all 32 bits. With the test's own values: the stored literal is 0x40004200 (low half 3.0, high half 2.0), the text says 0x4200, and the printed encoding ends in 00 42 00 40.

  • The printed-encoding check (same_encoding) passes, because the printed bytes are the stored ones.
  • So the existing repair, mix_literal (for an encoding that is cut too), never runs.
  • The text alone reads the high half as +0.0: an f16 source that should read 2.0 reads 0, and an f32 source reads a denormal instead of its value.

restore_text_cut_mix_literal takes the literal from the printed encoding when the text names only its low half and the high half is not zero. It runs on both the clean-listing path (check_printed_encodings) and the re-anchoring path (listings with undecodable words). The same restore_mix_literal as before gives the 32 bits to every source the bytes encode as the literal.

Counts over 1.0.2.1 (one work folder's listings, llvm-mc 21.1.8)

Listings Instructions Programs
Pipeline library 47,910 1,218
FidelityFX FSPX 6 1
The game's own shaders 0 0

The FSPX program is the upscaler's history pass: one resampling weight lost its high half, so the weights summed to more than 1 and the history grew each frame.

Measured in the game

That one upscaler program retranslated with this change; RTX 5080, NVIDIA 621.24, Windows 11, a local tree with other open work:

  • Before, the 1080p output saturated at 64,000 and its history filled with infinities (target dump), and every displayed frame turned white after about 12 world frames.
  • After, no white frame in 13 captures of the run.

That run had other local changes too, so it is not a clean A/B. The whole library retranslated with this change: 2,479 of 2,479 programs translate as before, none lost.

Tested

  • tests/semantic/test_fma_mix_literal.py: new test_text_cut_but_printed_encoding_whole (clean and re-anchoring paths). It fails without the change (6.0 instead of 8.0) and passes with it; the file's other 18 tests pass.
  • Whole translator suite: 493 files, 6,319 tests, 0 files failed (24 jobs, Windows 11).
  • tests/test_docs_*.py, scripts/check_no_game_data.py on the changed files.
  • The retranslated upscaler module holds the full literal and passes spirv-val.

GPUs tested: NVIDIA GeForce RTX 5080, driver 621.24, Windows 11 (the game run above; the hand-written GPU tests were not run)

AI-assisted: yes (Claude Code, Claude Opus 5.5 wrote the change, the test and this text)

Checklist

  • Based on current main and merges cleanly.
  • 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.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/2142 **Author:** [@DadaCap](https://github.com/DadaCap) **Created:** 11/25/2026 **Status:** ✅ Merged **Merged:** 11/26/2026 **Merged by:** [@aslan2142](https://github.com/aslan2142) **Base:** `main` ← **Head:** `mix-literal-text-cut` --- ### 📝 Commits (2) - [`a449806`](https://github.com/ubiquitarianism/leonida/commit/a449806dcfcd97b55e51a985244289bd2c945ca7) rdna2spirv: take a v_fma_mix literal from the printed encoding when only the text is cut (SHADER-FMA-MIX-TEXT-CUT-LITERAL) - [`abcccef`](https://github.com/ubiquitarianism/leonida/commit/abcccefd7d4ffd52cb252fbf76cabea383fc307c) rdna2spirv: restore a text-cut v_fma_mix literal with no blob too; pin the low-half guard ### 📊 Changes **3 files changed** (+31 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `docs/design.md` (+1 -1) 📝 `tests/semantic/test_fma_mix_literal.py` (+14 -0) 📝 `tools/rdna2spirv.py` (+16 -0) </details> ### 📄 Description Claimed in the coordination issue as: SHADER-FMA-MIX-TEXT-CUT-LITERAL (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7176772104) Depends on: nothing ### What and why llvm-mc 21.1.8 can print a `v_fma_mix*` literal cut to its low 16 bits **in the text only**, while the printed encoding keeps all 32 bits. With the test's own values: the stored literal is `0x40004200` (low half 3.0, high half 2.0), the text says `0x4200`, and the printed encoding ends in `00 42 00 40`. - The printed-encoding check (`same_encoding`) passes, because the printed bytes are the stored ones. - So the existing repair, `mix_literal` (for an encoding that is cut too), never runs. - The text alone reads the high half as +0.0: an f16 source that should read 2.0 reads 0, and an f32 source reads a denormal instead of its value. `restore_text_cut_mix_literal` takes the literal from the printed encoding when the text names only its low half and the high half is not zero. It runs on both the clean-listing path (`check_printed_encodings`) and the re-anchoring path (listings with undecodable words). The same `restore_mix_literal` as before gives the 32 bits to every source the bytes encode as the literal. ### Counts over 1.0.2.1 (one work folder's listings, llvm-mc 21.1.8) | Listings | Instructions | Programs | |---|---|---| | Pipeline library | 47,910 | 1,218 | | FidelityFX FSPX | 6 | 1 | | The game's own shaders | 0 | 0 | The FSPX program is the upscaler's history pass: one resampling weight lost its high half, so the weights summed to more than 1 and the history grew each frame. ### Measured in the game That one upscaler program retranslated with this change; RTX 5080, NVIDIA 621.24, Windows 11, a local tree with other open work: - Before, the 1080p output saturated at 64,000 and its history filled with infinities (target dump), and every displayed frame turned white after about 12 world frames. - After, no white frame in 13 captures of the run. That run had other local changes too, so it is not a clean A/B. The whole library retranslated with this change: 2,479 of 2,479 programs translate as before, none lost. ### Tested - `tests/semantic/test_fma_mix_literal.py`: new `test_text_cut_but_printed_encoding_whole` (clean and re-anchoring paths). It fails without the change (6.0 instead of 8.0) and passes with it; the file's other 18 tests pass. - Whole translator suite: 493 files, 6,319 tests, 0 files failed (24 jobs, Windows 11). - `tests/test_docs_*.py`, `scripts/check_no_game_data.py` on the changed files. - The retranslated upscaler module holds the full literal and passes `spirv-val`. GPUs tested: NVIDIA GeForce RTX 5080, driver 621.24, Windows 11 (the game run above; the hand-written GPU tests were not run) AI-assisted: yes (Claude Code, Claude Opus 5.5 wrote the change, the test and this text) ### Checklist - [x] Based on current `main` and merges cleanly. - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 21:20:12 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#2146
No description provided.