Repository navigation
rdna2spirv: fix v_fma_mix* f16 literals and replace remaining PackHalf2x16 sites - #711
Conversation
|
Tested I translated a synthetic fragment listing with binary16-selected float literals and ran the resulting Vulkan shader on the RTX 5090. Both shader modules passed spirv-val. Every pixel of the 64×64 raw RGBA32F readback matched the same four expected words:
This was a direct translator-listing test (4,096/4,096 pixels exact). It covers the three mixed-FMA forms and destination-half preservation. Buffer and image D16 conversion paths were outside this draw. AI-assisted verification. |
|
Tested f93afca on Windows 11, Python 3.12 (conda-forge), llvm-mc 23.1.6 (AMDGPU), spirv-tools from conda-forge, CPU only: pass
|
|
Independent RDNA2 round-trip and GPU test — RTX 3090 Tested
I assembled and disassembled two hand-written
The FMA probe used 32 lanes and checked both destination-half writes and two f32 results. For each lane the base returned Both D16 buffer results were AI-assisted verification using synthetic shaders only. No game files were used. |
|
GPU check of #711 on AMD and NVIDIA. The GPU runs are at f93afca. The new head c53e06b only changes Setup: Windows 11. AMD Radeon Graphics (Ryzen 7 7800X3D iGPU, RDNA2), driver 32.0.21043.5001, subgroup 32..64. RTX 4070 Ti SUPER, driver 610.88, subgroup 32. Test programs from main 67204bf (llvm-mingw clang), llvm-mc 23.1.6.
No failures, the same counts as main. Code read (a second model, read-only): no emitted (AI-assisted run, counts only.) |
|
Tested c53e06b (merged with main 67204bf, no conflicts) on NVIDIA GeForce RTX 3060, driver 620.73.04, Linux (llvm-mc 23.1.5): pass.
AI-assisted (Claude Code). |
Summary
Rebased onto
origin/main(762893f, after #641 mergedf16_bitsforv_interp_p2_f16andv_fma_mix*_f16output packing). This PR fixes binary16 inline literal decoding inv_fma_mix*and replaces the remainingPackHalf2x16sites intools/rdna2spirv.pyso zeroPackHalf2x16instructions remain emitted:v_fma_mix_f32,v_fma_mixlo_f16, andv_fma_mixhi_f16source decoding (op_sel_hi=1):fma_mix_srcs(a, mods)usingself.f16_in(src, sb[i])whenhb[i] == 1andself.src_f(src)otherwise. Previously,self.src_u(...)encodedfimminline float constants (such as1.5,-2.0) as 32-bit float bit patterns instead of binary16 viaself.src_h(...).v_fma_mixlo_f16/v_fma_mixhi_f16output packing toself.f16_out(a[0], r, hi=(op == "v_fma_mixhi_f16")), reusingf16_bits(r)while preserving the unwritten half of the destination VGPR.PackHalf2x16sites (encode_format,buffer_load_formatd16, andimage_sample_c_lzd16):encode_format()(kind == "f16"): replacedPackHalf2x16withself.f16_bits(self.tof(fcomps[c])).buffer_load_format()(d16path): replacedPackHalf2x16withself.f16_pack2(self.tof(lo), self.tof(hi)).image_sample(kind == "_c_lz"withd16): replacedPackHalf2x16withself.f16_bits(d).Commits
rdna2spirv: fix v_fma_mix* f16 literals and replace remaining PackHalf2x16 sitestests/test_translate.py: test v_fma_mix* fimm literals and remaining f16_bits pack sitesTests & Verification
Added 16 synthetic test cases at the end of
tests/test_translate.py(translated viardna2spirv.translate, validated withspirv-val --target-env vulkan1.2, and executed viaspirv_mini_interp):test_fma_mix_decodes_fimm_as_binary16_and_preserves_other_half: verifies1.5and-2.0fimmoperands onv_fma_mixlo_f16,v_fma_mixhi_f16, andv_fma_mix_f32(op_sel_hi:[1,0,0]/[1,1,0]), destination half preservation,spirv-val, and noPackHalf2x16.test_fma_mix_f16_rte_edge_cases_and_half_preservation(12 cases): verifies ties-to-even, subnormals and subnormal ties,+-Infoverflow,-0.0, and quiet NaN on bothv_fma_mixlo_f16andv_fma_mixhi_f16with sentinel half preservation.test_encode_format_f16_uses_f16_bits_rte(xyformat 29 andxformat 13): verifies RTE tie-to-even stores,spirv-val, and noPackHalf2x16.test_remaining_d16_paths_avoid_packhalf2x16: verifiesbuffer_load_format_d16_xyandimage_sample_c_lz d16emit noPackHalf2x16and passspirv-val.Observed locally against
wt_f16mix(Windows, Python 3.13,spirv-as/spirv-valVulkan SDK 1.4.341.1, straight-line synthetic listings withoutllvm-mc):tests/test_translate.pyharness: 16 passed, 0 failed.origin/main(762893f): 12 passed, 4 failed (failing onfimmdecoding inv_fma_mix*,encode_formatxy/xemittingPackHalf2x16, andd16buffer_load_format/image_sample_c_lzemittingPackHalf2x16; the 12 RTE edge cases already pass on762893fafter make_game.py: --jobs reaches vk_pipeline_check in the pipelines stage (BUILD-105) #641).AI-assisted