Repository navigation
Translator: apply VOP3 output modifiers on v_fmac_f16 and v_interp_p2/mov_f32 - #956
Conversation
…/mov_f32 Apply clamp_mods (mul:2/mul:4/div:2 then clamp to [0, 1]) in v_fmac_f16_e64 (before f16 narrowing, matching v_fma_f16 and keeping the high half intact) and in v_interp_p2_f32_e64 / v_interp_mov_f32_e64 (zero-instruction no-op when mods has none). Confirmed against LLVM gfx10_asm_vop2.s (v_fmac_f16_e64 clamp/mul:2/mul:4/div:2) and gfx10_asm_vop3.s (v_interp_p2_f32_e64, v_interp_mov_f32_e64). Verified on CPU with tests/semantic/test_f16_fma_rounding.py, tests/semantic/test_interp_f32_mods.py, tests/semantic/test_interp_f16.py and tests/semantic/test_value_semantics.py.
|
The f32 interpolation part of I assembled the synthetic VS/PS with LLVM for gfx1013 and ran
Each control also matched its own predicted raw RGBA32F values across the whole frame. These measurements cover translated Vulkan execution. AI-assisted, synthetic inputs only. |
|
Tested 643f9d0 on Windows 11 (Python 3.12, llvm-mc 23.1.6 with AMDGPU, spirv-tools): pass
|
IAmNotSiob
left a comment
There was a problem hiding this comment.
lgtm. scaling by a power of two and clamping to [0,1] both commute with the later f16 rounding of the round-to-odd value (barring overflow and denormals), so the order works. tests pass with main ^^ AI-assisted review (Claude Code).
|
GPU check of
|
Claimed in the coordination issue as: #634 (comment)
What and why
Three VOP3 floating-point handlers in
tools/rdna2spirv.pysilently dropped VOP3 output modifiers (mul:2,mul:4,div:2, andclampto[0, 1]):v_fmac_f16_e64(line 3363): computedr = self.fma_f16_odd(*vals)and passedrstraight tof16_outwithoutself.clamp_mods(r, mods), unlikev_fma_f16and every other f16 arithmetic op in the translator. Confirmed against LLVMllvm/test/MC/AMDGPU/gfx10_asm_vop2.s(lines 12044–12054:v_fmac_f16_e64 v5, v1, v2 clamp / mul:2 / mul:4 / div:2) andVOP2Instructions.td(VOP_MAC_F16 : VOP_MAC<f16>).v_interp_p2_f32_e64andv_interp_mov_f32_e64(line 4102): passedfstraight todstwithoutself.clamp_mods(f, mods)(sibling tov_interp_p2_f16clamp). Confirmed against LLVMllvm/test/MC/AMDGPU/gfx10_asm_vop3.s(lines 13210–13261). Whenmodshas no output modifiers,clamp_modsis a zero-instruction no-op, leaving plainv_interp_*_f32output byte-identical.Added semantic tests in
tests/semantic/test_f16_fma_rounding.py(test_fmac_output_modifiers, including high-half preservation) andtests/semantic/test_interp_f32_mods.py, plus a contract row indocs/design.md.Tested
CPU-only on Windows 11, Python 3.11.9 (no GPU run, no
spirv-val/llvm-mc, no game files):python -m compileall -q make_game.py tools tests— exit 0python -I -W error::ResourceWarning tests/semantic/test_f16_fma_rounding.py -q— 5/5 OKpython -I -W error::ResourceWarning tests/semantic/test_interp_f32_mods.py -q— 3/3 OKpython -m unittest discover -s tests/semantic -p 'test_interp*.py' -q— 79/79 OKpython -m unittest discover -s tests/semantic -p 'test_value_semantics.py' -q— 16/16 OKpython -m unittest discover -s tests/semantic -p 'test_f16*.py' -q— 10/10 OKAI-assisted.
Checklist
docs/design.md, with how it was confirmed.