rdna2spirv: translate v_sat_pk_u8_i16 (SHADER-SATPK-U8) #338
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/338"
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?
Imported from ubiquitarianism/leonida. Originally posted by NolanCotter on 2026-11-24T03:24:44Z.
Claimed in #14 as SHADER-SATPK-U8.
Summary
tools/rdna2spirv.py: new rule forv_sat_pk_u8_i16(VOP1 0x62 / VOP3 0x1E2). Each signed i16 half of SRC0 is sign-extended,OpSClamped to [0, 255] and packed into the low 16 bits of VDST; the high half is preserved (GFX9+ partial 16-bit write — LLVM models the def asVOP1Inst_t16, Mesa ACOinstr_is_16bit, same class asv_cvt_f16_f32). Sourceneg/abs,clamp,omodandop_selraiseUnsupported;_sdwawhitelistssrc0_sel/dst_sel/dst_unused;_dppgoes throughnon_dpp_mods;_e32refuses all modifiers.tests/semantic/fixtures/sat_pk_u8_i16.asm+tests/semantic/test_alu_sat_pk_u8_i16.py: hand-written listing, runs the emitted SPIR-V throughspirv_mini_interpagainst a plain-Python reference — lane edge values (-0x8000/-1/0/255/256/0x7FFF), SGPR, literal and inline-constant sources,_sdwasource/destination selects, and refused modifiers.docs/design.md: contract-table row naming the confirmation (AMD machine-readable ISA semantics; LLVM/ACO partial-write reference; CPU-checked test; not GPU-verified).docs/fssm_crosscheck.md: removed from the unhandled-xbsc list.tests/test_translate.py,tests/test_f16_op_sel.py: the still-unsupported canary is repointed fromv_sat_pk_u8_i16tov_mullit_f32(still unhandled on this base).Heads-up for reviewers: PR #265's
_FULL32_V16_PREFIXESlistsv_sat_pkas a full-32-bit write for its wave64-halves liveness fix; this op writes only the low 16 bits and preserves the high half, so whichever of the two lands second should drop that prefix (noted as afinding:in #14).Test plan
python -m unittest discover -s tests/semantic -p test_alu_sat_pk_u8_i16.py— 5 tests passpython -m pytest tests/test_f16_op_sel.py— passespython -I scripts/run_semantic_tests.py tests/semantic— 444 files / 5894 tests; the only 4 failures (test_float_nan_fract,test_image_atomics_guard,test_image_store_d16,test_int32_to_f64) reproduce identically on cleanmain(the last is aspirv-optSIGSEGV in the test environment)python -I scripts/check_no_game_data.pyon both new files — cleanAI-assisted (Devin). No game files, no GPU, nothing online; semantics confirmed against AMD's ISA spec and the LLVM/ACO tables, not hardware. GPUs tested: none.
Generated with Devin
Imported from ubiquitarianism/leonida. Originally posted by Sangonapou on 2026-11-24T05:06:04Z.
Tested
6446e3ceon NVIDIA GeForce RTX 3080 Ti Laptop (Ampere, subgroup 32..32), NVIDIA 621.24, Vulkan 1.4.357, Windows 11 Pro (build 26300): pass, regression checkRuntime built at this head with
scripts\build_runtime.ps1(MSVC 19.51, VS Build Tools 2026);llvm-mc23.1.6 (conda-forge), SPIRV-Tools 2026.4, Vulkan SDK 1.4.363.0. No game files. This PR adds no GPU fixture, so this checks the translator change on the GPU suite.run_gpu_tests.py: 257 shaders, 257 translated, 257 pass spirv-val; native 197/248 passed, 49 skipped;LEONIDA_W64_EMULATE=1229/248 passed, 17 skipped, the same counts asmainece4ba5b. The only failures,cs_imgload_tfeandcs_imgload_d16_tfe, fail identically onmainece4ba5bon this card (main: native 197/248, emulated 229/248), the same pair as #31 / #336.tests/semantic/test_alu_sat_pk_u8_i16.py5 OK (unittest discover).tests/test_f16_op_sel.pyandtests/test_translate.pyneed pytest, which is not installed here, so they were not run.Imported from ubiquitarianism/leonida. Originally posted by milk4sale on 2026-11-24T06:39:03Z.
Follow-up for the
wave64_halvesside of this op is in #508 (SHADER-SATPK-HALVES,Depends on: #338). It takesv_sat_pkout of_FULL32_V16_PREFIXESso the halves analysis keeps the high half this PR'swrite_lo16keeps. #508 was stacked on this head plusmain, because #265 is not in this branch's base.One note on the references. The row and the test docstring cite Mesa ACO
instr_is_16bitfor the GFX10 high-half keep, butinstr_is_16bitreturns false forv_sat_pk_u8_i16before GFX11. The op is only inget_gfx11_true16_mask, whichcan_use_opselreads for GFX11+ (aco_ir.cpp, Mesa99abc485). LLVM'szeroesHigh16BitsOfDestdoes not list it either. So on RDNA2 the keep rests on the analogy withv_cvt_f16_f32until someone measures it on RDNA2 hardware. It might be worth saying that in the row rather than citing ACO for it.Imported from ubiquitarianism/leonida. Originally posted by tiguan26 on 2026-11-24T18:22:21Z.
Checked
6446e3cmerged into currentmain(3aa9754): it still merges cleanly. On Linux, Python 3.13, no GPU:tests/semantic/test_alu_sat_pk_u8_i16.py5/5 pass, andtests/test_f16_op_sel.py+tests/test_translate.pypass under pytest (40 passed, the rest skipped without llvm-mc). I recomputed the fixture's four words by hand from the ISA definition (each i16 half saturated to [0, 255], packed into D[15:0], D[31:16] kept):cafeff00 dead00ff 00008000 abcdffff, matching.+1 to @milk4sale's note on the ACO citation: on current Mesa
main,v_sat_pk_u8_i16is in neitherinstr_is_16bitnorcan_use_opsel, only inget_gfx11_true16_mask.One small test gap: the fixture's
_e64case writesv5, whose high half is already0x0000, so it cannot tell a kept high half from a zeroed one for the VOP3 encoding. Seedingv5with e.g.0x12340000(expected0x12348000) would check the VOP3 form the same way as the VOP1 ones, and would be the case to run when someone measures the high-half rule on RDNA2.AI-assisted (Claude).
Imported from ubiquitarianism/leonida. Originally posted by sodove on 2026-11-28T10:45:21Z.
#338 | head
6446e3ce76483c5c3ba2b539258ab5d80482369e|python3 -m unittest discover -s tests/semantic -p test_alu_sat_pk_u8_i16.py -v,python3 -m pytest -q -rA tests/test_f16_op_sel.py,python3 -m pytest -q -rA tests/test_translate.py| red: 759 run, 1 failure, 4 errors | green: 769 passed | Red → greenThe new packed saturation opcode failed on main. All three merged files passed, including the full PR-modified test_translate.py file.
Captured 17 distinct complete SPIR-V module(s) emitted while rerunning test_alu_sat_pk_u8_i16.py on the merged tree. All assembled and passed spirv-val for Vulkan 1.2 with --allow-offset-texture-operand.
tests/semantic/test_alu_sat_pk_u8_i16.pytests/test_f16_op_sel.pytests/test_translate.pyBase
3bd936ecd98995bca3e1da83d5e28d2343001aefwas merged into the recorded PR head for the second run. Ubuntu 26.04.1 (WSL2), Python 3.14.4. Counts include unittest subtest events where applicable. AI-assisted with OpenAI Codex. Batch claim.Imported from ubiquitarianism/leonida. Originally posted by DadaCap on 2026-11-28T11:51:18Z.
Merged, thank you @NolanCotter! This translator PR (rdna2spirv: translate v_sat_pk_u8_i16 (SHADER-SATPK-U8)) passed its own tests with main merged in during sodove's verification of this batch, so it went in with the batch.
AI-assisted (Claude Code, Claude Opus 5.5), posted for the maintainers.