Repository navigation
feat(shader): accept float modifiers on v_cndmask_b32, v_mul_legacy_f32 and v_ldexp_f16 - #498
Conversation
|
Rebased on current main (conflict with the f64 entries of #446 in the VOP3 float-modifier list; both kept). Vop2ModifierForms and F64Arithmetic pass on RADV and lavapipe. |
e0d6cb3 to
0e94b46
Compare
|
Thanks. I checked the 15 forms in the test kernel with llvm-mc, and they are the DPP, SDWA and VOP3 forms the table lists. The decoder changes do what the table says: src1 modifiers are still refused on
The
|
…32 and v_ldexp_f16 - v_cndmask_b32: neg/abs on DPP; neg/abs applied on the bits, as the hardware does - v_mul_legacy_f32: neg/abs on DPP and SDWA, clamp/omod on SDWA and VOP3 - v_ldexp_f16: neg/abs on src0 for VOP3, DPP and SDWA; NaN result chosen on the bits Co-Authored-By: Claude <noreply@anthropic.com>
0e94b46 to
e58e2f0
Compare
|
Gated on PPSA21564: no visual or FPS change. |
What
v_cndmask_b32,v_mul_legacy_f32andv_ldexp_f16now accept the float modifiers thatllvm-mc -mcpu=gfx1013accepts for them and that were still rejected. The modifier sweep over decoded opcodes found them:v_cndmask_b32v_mul_legacy_f32v_ldexp_f16Translation changes:
v_cndmask_b32applies neg/abs on the bits (sign flip and clear). Before this, when a modifier was set, the operands went throughOpFNegate/FAbsandSelectF32. RADV flushes the denormal there (-0x00000001came out as0x80000000). On hardware the select keeps every bit, denormals and NaN payloads included, in every float mode.v_ldexp_f16reads src0 withreadF16Bits(bit modifiers, asv_frexp_*_f16already does). A NaN input now returns the NaN chosen on the bits (input with modifiers applied, quiet bit set) instead of whatever the driver's f16→f32→f16 path gives.v_mul_legacy_f32keeps its translation. Clamp and omod go throughapplyF32ResultModifiers, the same asv_mul_f32.v_ldexp_f16clamp/omod stays rejected: f16 result modifiers are what #323 changes.v_mac_legacy_f32is unchanged because gfx1035 doesn't have it, so I can't measure it.Behaviour measured on HW
Ran on a Radeon 660M (gfx1035; same VOP2/VOP3 encodings as gfx1013 for these ops) with the 15 forms in the test, over 1836 (a, b, condition) rows: zeros of both signs, denormals, infinities, quiet and signalling NaNs, values around 1.0, overflow, f16 values in the low half with garbage in the high half, and f16 exponents up to ±64 and beyond. 17624 checked cells match the model, 0 mismatches:
v_cndmask_b32neg/abs on DPP, SDWA and VOP3 are bit operations. They keep denormals and NaN payloads, with f32 denormals both on and flushed.v_mul_legacy_f32: either source ±0 after modifiers → +0, otherwise IEEE multiply, then omod, then clamp. omod only applies with IEEE=0 and f32 denormals flushed (default compute mode ignores it, as for every f32 op). The recompiler already models omod as applied, so the omod rows come from that mode.v_ldexp_f16: modifiers on the f16 bits, result rounded once to f16, NaN → input bits with quiet bit set (IEEE mode). VOP3/DPP keep the high half of the destination; SDWAdst_sel:DWORDzeroes it.v_mul_f32), f16 denormal and signalling NaN ldexp inputs, and clamp of −0/NaN.FPSaturate32is GLSLFClamp, which leaves those unspecified, the same as every f32 clamp today.Side finding while picking this batch:
tfeon MUBUF/MTBUF loads leaves the extra status VGPR unchanged on hardware, both in bounds and out of bounds, so the current decode (ignore it) is already right for non-sparse buffers.Tested
Arch Linux, RADV (Radeon 660M) plus lavapipe (local Mesa and the CI version, Ubuntu Mesa 25.2.8). New execution test
Vop2ModifierFormsruns the 15 forms on 32 HW rows (382 checked cells, the rest are the excluded classes above).Negative checks, each making the test fail: the old float select in
v_cndmask_b32(RADV), dropping src0 modifiers inv_ldexp_f16, dropping omod or clamp inv_mul_legacy_f32, and removingv_mul_legacy_f32from the VOP2 float list (decoder error). Taking the NaN result from the driver inv_ldexp_f16still passes on RADV and lavapipe, because they keep the payload. The bit-level NaN is there for drivers that return a canonical NaN.Full Release build plus
ctest: everything passes exceptagc_driver_pixel_helper_lanes, which also fails onmainon local RADV since #305.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)