mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 21:50:52 +01:00
[PR #985] [MERGED] rdna2spirv: re-anchor from llvm-mc's own offsets of the rejected words (SHADER-REANCHOR-LLVM-OFFSETS) #1020
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1020
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/985
Author: @Tyrannys
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/25/2026
Merged by: @QemmHD
Base:
main← Head:fix/reanchor-from-llvm-offsets📝 Commits (1)
2f5b49crdna2spirv: re-anchor from llvm-mc's own offsets of the rejected words📊 Changes
4 files changed (+115 additions, -1 deletions)
View changed files
📝
docs/design.md(+1 -1)➕
tests/semantic/test_reanchor_llvm_offsets.py(+84 -0)📝
tools/rdna2spirv.py(+26 -0)📝
tools/shader_ir.py(+4 -0)📄 Description
Item: SHADER-REANCHOR-LLVM-OFFSETS (claimed in #14).
Problem. After undecodable words,
translate()puts each printed instruction back at its offset in the blob by searching forward for its printed bytes. A data word that llvm-mc printed as a copy of a later instruction (its printed bytes are not the bytes it read) matches that later instruction, takes its place, and every instruction after it loses its place. The shader then fails withundecodable words (cannot re-anchor).Fix. llvm-mc already says where it rejected each word.
tools/shader_disasm.pyfeeds it one line of0xNNbytes (5 characters a byte), so the message column gives the byte offset.tools/shader_ir.py:parse_filereturnsinvalid_at, the sorted offsets (code_start + (column - 1) // 5).tools/rdna2spirv.py: when there is one offset per rejected word, re-anchoring skips exactly those words and never searches forward. The literal-restoring paths (mix_literal,mix_inline_literal) are kept. A listed offset whose bytes are the next instruction is not skipped, so a listing whose messages do not match its blob (or hand-written tests with a placeholder message) reads as before. Without offsets, the old search runs unchanged.Effect. On the 1.0.2.1 pipeline library (2,684 compute programs), with #327 / #596's vcc-tuple decoding applied: 36 programs that stopped at "cannot re-anchor" now translate and pass
spirv-val, and none that translated before is lost. With #596 and #647 as well, the library goes from 2,396 to 2,560 translated in our runs (that total includes #583's 49). Several of these are compute programs the retail boot creates through slot 67.Tests (synthetic, no game data):
tests/semantic/test_reanchor_llvm_offsets.py:parse_filereads the offset; a data word printed as a copy of the next real instruction (behind a branch) no longer displaces it, and the pixel shader writes the expected value (the old search raisescannot re-anchoron the same listing); a message that names the instruction's own bytes falls back to the old behaviour.docs/design.md: the "Code-embedded data" row says how re-anchoring uses the offsets, with the count.python -I scripts/run_semantic_tests.py tests/semantic: 465 files, 6,108 tests; 1 file fails,test_image_cube_store_glc, which fails the same onmainwithout this change.AI-assisted (Claude Code). Windows 11, RTX 4070 SUPER; CPU-only checks.
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.