Repository navigation
rdna2spirv: translate v_sat_pk_u8_i16 (SHADER-SATPK-U8) - #338
NolanCotter wants to merge 1 commit into
Conversation
The VOP1/VOP3 op saturates each signed i16 half of SRC0 to unsigned 8-bit and packs the pair into the low 16 bits of VDST, preserving the high half (GFX9+ partial write; LLVM VOP1Inst_t16, Mesa ACO instr_is_16bit). Neg/abs/clamp/omod are refused; _sdwa restricts to the documented source/destination selects; _e32 rejects all modifiers. Adds a hand-written fixture and a semantic test driving the SPIR-V through spirv_mini_interp against a plain-Python reference (lane edge values, SGPR/literal sources, sdwa selects, refused modifiers), the docs/design.md contract row, and drops the op from the fssm_crosscheck unhandled list. The two tests that used the mnemonic as the still-unsupported canary now use v_mullit_f32. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
Tested 6446e3c on NVIDIA GeForce RTX 3080 Ti Laptop (Ampere, subgroup 32..32), NVIDIA 621.24, Vulkan 1.4.357, Windows 11 Pro (build 26300): pass, regression check Runtime built at this head with
|
|
Follow-up for the One note on the references. The row and the test docstring cite Mesa ACO |
…alves partial-write code of ProjectLeonida#265 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ProjectLeonida#265 put v_sat_pk in _FULL32_V16_PREFIXES, so _preserves_dst took v_sat_pk_u8_i16 for a whole 32-bit write, and partial_write read its first type, u8, as an 8-bit result. The translator from ProjectLeonida#338 writes the two saturated bytes with write_lo16, which keeps the high half in the _e32, _e64 and DPP forms, so a high half that depends on the lane lost its taint: the shader passed as tier A (or tier B through readlane-uniform) although its export changes when the wave is cut in two. SDWA was already right (dst_sel/dst_unused decide). Neither Mesa ACO nor LLVM says the high half is kept on GFX10: ACO's instr_is_16bit is false for the op before GFX11 (only get_gfx11_true16_mask has it), and LLVM's zeroesHigh16BitsOfDest does not list it. The rule follows what the translator emits, and calling the op partial is the safe side if RDNA2 zeroes the high half. The RDNA2 behaviour is not measured. - tests/semantic/test_wave64_halves_sat_pk.py with the hand-written fixtures/w64_sat_pk_hi.asm: high half = lane id, 64 lanes against two waves of 32 on the wave interpreter, every encoding, the readlane-uniform case, operands()/partial_write per encoding. - runtime/test/shaders/ps_w64_a_sat_pk_hi (tier A, judged on 32-only GPUs) and ps_w64_c_sat_pk_hi (tier C, pinned in test_wave64_halves_fixtures). - docs/design.md contract row. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Checked 6446e3c merged into current +1 to @milk4sale's note on the ACO citation: on current Mesa One small test gap: the fixture's AI-assisted (Claude). |
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