feat(shader): implement legacy float multiply-add ops #308
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/308"
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 boykopovar/AnyPS5. Originally posted by asimplestray on 2026-10-02T03:12:10Z.
What
Implements 2 VOP3 opcodes:
V_MAD_LEGACY_F32(0x140) reuses the FMA translation;V_MULLIT_F32(0x150) reuses the multiply translation.Note: the integer multiply-add family from the original revision (
V_MAD_I16/U16,V_MAD_I32_I16/U32_U16,V_MUL_LO_U16,V_ADD/SUB_NC_I32,V_ASHRREV_I64) has since landed inmainvia other work, so this PR keeps only the two remaining float ops.Tested
Linux (GCC,
BUILD_TESTING=ON,ANYPS5_ENABLE_SPIRV_TOOLS=OFF): full build,ctest110/110 pass, including the newvector_mad_legacytest (decode opcode + family + ALU classification plus translation emitting the expected IR op for both encodings).Checklist
main; no other open PR implements the same opcodes (checked open shader PRs).mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-02T03:12:35Z.
Progress report (
313de1c→20f12cc)📈 GPU shader instructions: 59.78% (+0.17%, +2 implemented instructions)
✅ 2 implemented
V_MAD_LEGACY_F32V_MULLIT_F32Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-02T04:44:54Z.
Heads-up on overlap: #257 (opened 2026-10-01) already implements
v_add_nc_i32/v_sub_nc_i32(including clamp as signed saturation),v_mul_lo_u16,v_mad_u16,v_mad_i16,v_mad_u32_u16,v_mad_i32_i16andv_ashrrev_i64. It has an execution test comparing every lane on RADV/lavapipe. One thing it caught: theu32_u16/i32_i16forms must not take the 16-bit destination select inapplyNativeVop3I16TernarySelectors, or the result gets truncated to 16 bits. Worth checking here too.On
v_mad_legacy_f32, two semantic details thatFPFma32misses:v_mul_legacy_f32on an RDNA2 GPU, and it's the defining property of the legacy family.v_mad_f32. #263 adds an unfusedFPMad32for exactly that.I had
v_mad_legacy_f32in an upcoming PR next tov_mul/mac_legacy_f32, and I've dropped it there since yours came first.