mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 21:30:53 +01:00
[PR #1301] [CLOSED] rdna2spirv: keep the stored op_sel_hi of a signed-byte dot with an inline integer (SHADER-FFX-PACKED-DOT) #1331
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#1331
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/1301
Author: @Moriz82
Created: 11/24/2026
Status: ❌ Closed
Base:
main← Head:split/shader-ffx-packed-dot📝 Commits (1)
62e1245rdna2spirv: keep the stored op_sel_hi of a signed-byte dot with an inline integer (SHADER-FFX-PACKED-DOT)📊 Changes
3 files changed (+55 additions, -2 deletions)
View changed files
📝
docs/design.md(+3 -0)📝
tests/semantic/test_printed_encoding.py(+50 -2)📝
tools/rdna2spirv.py(+2 -0)📄 Description
Rebased onto
bfef489cat62e1245f. Main already restores the stored selector. This diff limits that recovery to a plain four-operand listing and preserves the encoding regression tests. Nine focused tests passed.Claimed in the coordination issue as: SHADER-FFX-PACKED-DOT (claim).
Part of the split of #984 into small pull requests.
Depends on: none
Overlaps: #984 is the parent integration. #281 (open, draft) makes
tools/shader_disasm.pyprint thev_dot4_i32_i8words withop_sel2 /op_sel_hi5 that llvm-mc rejects; that half of the integration's packed-dot work is left to #281 and is not repeated here. This pull request is about the words llvm-mc does decode (op_sel0) and prints without theirop_sel_hi, which #281 leaves alone ("a pair llvm-mc accepted is never touched"). The two change different files (#281:tools/shader_disasm.py,docs/fspx.md, two test files; this:tools/rdna2spirv.py,docs/design.md,tests/semantic/test_printed_encoding.py).What and why
llvm-mc prints no
op_sel_hionv_dot4_i32_i8and re-encodes the instruction with the default 7. Measured with llvm-mc 23.1.5 forgfx1030andgfx1036, everyop_selxop_sel_hicombination, with a VGPR, an SGPR, an inline integer and a 32-bit literal as S1:op_sel0,op_sel_hi7op_sel0,op_sel_hi0..6op_sel_hi7op_sel1..7op_sel2 /op_sel_hi5 one)So for a stored
op_sel_hiother than 7 the listing shows an instruction the bytes do not hold. The translator already notices: the printed-encoding check refuses it, on a clean listing (a field the disassembler dropped) and on a listing with invalid words (reachable instruction with normalized encoding). That is the right default, because the selector changes the result (docs/design.md, "Signed-byte dot products":op_sel_hi[k]picks the 16-bit half of source k for byte pairs 2..3).One of these forms is the one #984 repairs, in its notes on the FidelityFX upscaler's FSPX programs (
docs/fspx.md): an inline integer S1 withop_sel_hi5, that isop_sel_hi[1]clear, so byte pairs 2..3 read the low half of S1 again. An inline 10 is then the bytes 10, 0, 10, 0 instead of 10, 0, 0, 0. This pull request repairs exactly that form instead of refusing it (restore_dot4_inline_sel, called from both listing paths):clamp, noneg,op_sel0,op_sel_hi5 and an inline integer in SRC1 (0..64, −1..−16);The instruction then takes
op_sel_hi:[1,0,1]and goes through the lowering that is already there. Every other dropped selector staysUnsupported, a register S1 with the same selector included.Not measured on hardware. The half selection on this instruction was measured with a register S1 (
op_sel2 /op_sel_hi5, the table intests/semantic/test_alu_dot4_i8.py). That an inline integer is selected from as its 32-bit word is an assumption; the new contract row says so. One raw kernel throughtools/hw_oracle(0xCC164008 0x0C0D1501, S0 = 0x00010001, S2 = 0: 20 if the assumption holds, 10 if the selector is ignored) would settle it. How many such words the real programs hold was not counted for this pull request.Tested
Linux (CachyOS, kernel 7.3.5), Python 3.14, LLVM
llvm-mc23.1.5, SPIRV-Tools v2026.4. One commit on6293c1c4f.python3 -I tests/semantic/test_printed_encoding.py: 9 tests pass. The new test gives 20 for the stored selector and 10 for the default one (S0 = 0x00010001, S1 = 10, S2 = 0) on a clean listing and on one with an invalid word, and expectsUnsupportedfor a changed S0, storedop_sel_hi1, 3 and 4,clamp,neg_lo,neg_hi, a register S1 withop_sel_hi5, and a listing text withclampor without S2.LEONIDA_TOOLS_DIR=<export of 6293c1c4f>/tools): 2 errors, the two stored-selector subtests (Unsupported, the two messages quoted above). Everything else in the file passes there too.python3 -I tests/semantic/test_alu_dot4_i8.py: 12 tests pass.tools/shader_disasm.disasm(llvm-mc,gfx1030) made the listing of a five-instruction program with the dot stored withop_sel_hi5 and with 7, once clean and once followed by an invalid word; each listing was translated against its bytes, run in the interpreter, assembled and validated withspirv-val. 324 of 324 give the expected word here. With the base translator the 162 default-selector listings do and the 162 withop_sel_hi5 are refused.ci.ymlon the committed tree (compileall; eachtests/test_*.pyoutsidetests/semanticwithpython3 -I <file>, or pytest where it has no__main__;python3 -I scripts/run_semantic_tests.py tests/semantic -j 2; the tracked-file guard): one failing file,tests/test_imhex_patterns.py, which fails on the base commit too. Semantic suite: 470 files, 6,169 tests, 0 files failed (base: 470 files, 6,168 tests, 0 failed).python3 -I scripts/check_no_game_data.py: passes.Not run: a GPU, the hardware oracle, the real FSPX programs, native Windows or macOS, the runtime build (no C++ or build file changes).
GPUs tested: none (CPU interpreter and SPIRV-Tools only).
AI-assisted: yes (Claude Code). The numbers above come from runs on the machine named.
Checklist
6293c1c4f, one commit.docs/design.md("Signed-byte dot with an inline integer S1"), with how it was checked and what is not measured.🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.