feat(shader): f16 ldexp/frexp/norm/class, v_sat_pk_u8_i16, v_mul/mac_legacy_f32 #318
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/318"
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 adriadam10 on 2026-10-02T04:46:30Z.
What
These threw in the decoder:
v_ldexp_f16,v_mul_legacy_f32,v_mac_legacy_f32v_frexp_mant_f16,v_frexp_exp_i16_f16,v_cvt_norm_i16_f16,v_cvt_norm_u16_f16,v_sat_pk_u8_i16v_cvt_pknorm_i16_f16,v_cvt_pknorm_u16_f16v_cmp_class_f16,v_cmpx_class_f16The reference emulators don't cover these, so I measured them on an RDNA2 GPU (Radeon 660M, gfx1035; all exist on gfx1013 too) with raw kernels through the ROCm HSA runtime. A Python model of each matched 2048/2048 hardware results before I wrote the C++:
v_ldexp_f16: the exponent is src1 as an i16 (low 16 bits, sign-extended). The translation clamps it to ±64 and multiplies in f32, which is exact, then converts once.v_frexp_mant_f16/v_frexp_exp_i16_f16: zero and ±inf pass through with exponent 0; NaN is quieted.v_cvt_norm_*_f16andv_cvt_pknorm_*_f16: clamp, ×32767 or ×65535, round to nearest even; NaN gives 0. Done in integer arithmetic, becausex * 32767needs up to 26 significant bits and f32 could move a value onto a tie.v_cmp_class_f16: the 10 class bits ofv_cmp_class_f32, read from the f16 bits.v_sat_pk_u8_i16: both i16 halves saturated to[0, 255]and packed into the low 16 bits; the upper half is zeroed.v_mul_legacy_f32: if either factor is ±0 the result is +0, even when the other is inf or NaN.v_mac_legacy_f32adds that rounded product to D, likev_mac_f32. That one can't be checked on gfx10.3 hardware and is checked against the model.write16Bitsalready does.v_mad_legacy_f32is left out because #308 implements it (I left a note there about the legacy zero rule).Test
agc_driver_float16_misc: 256 input vectors with the expected results of all of the above, captured on the RDNA2 GPU, plusv_mac_legacy_f32from the model. They include f16 NaN/inf/zero/subnormal edges, exponent edges for ldexp, random class masks, and 0×inf/NaN for the legacy multiply. f16 NaNs are compared as NaN. The f32 legacy rows with denormals are skipped, since those follow the driver's float controls.Tested
Linux, full ctest (101) passes.
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)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-02T04:46:51Z.
Progress report (
709d7fe→8fd19cd)📈 GPU shader instructions: 53.69% (+1.03%, +12 implemented instructions)
✅ 12 implemented
V_CVT_NORM_I16_F16V_CVT_NORM_U16_F16V_FREXP_EXP_I16_F16V_FREXP_MANT_F16V_SAT_PK_U8_I16V_LDEXP_F16V_MAC_LEGACY_F32V_MUL_LEGACY_F32V_CVT_PKNORM_I16_F16V_CVT_PKNORM_U16_F16V_CMPX_CLASS_F16V_CMP_CLASS_F16Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-02T06:46:20Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/prx/libSceAgcDriver/tests/execution/FmaRounding.cppcore/libs/prx/libSceAgcDriver/tests/execution/Float16Rounding.cpp