fix(shader): accept clamp and omod on every f16 VOP3 result op #664
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/664"
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-05T12:39:18Z.
What
Closes the clamp/omod modifiers of the f16 VOP3 result ops in one go (follow-up of #323, which made f16 results honour clamp). Before, each op either refused the modifier or the decoder dropped it:
v_add/sub/subrev/mul/min/max_f16writeF16, #323)v_fma_f16,v_max3/min3/med3_f16writeF16)v_div_fixup_f16v_ldexp_f16,v_frexp_mant_f16v_cvt_norm_i16/u16_f16Not touched, still throw:
v_pack_b32_f16,v_cvt_pknorm_*_f16,v_fmac_f16in VOP3,v_cvt_i16/u16_f16forms and the VOP3P packed ops keep their current behaviour.clampF16Bits, used byv_div_fixup_f16,v_ldexp_f16andv_frexp_mant_f16.omodis accepted and ignored, as the existing TechnicalDebt entry for the output modifier already says (the hardware ignores it while f16 denormals are enabled; with them flushed it applies it, not modelled).Behaviour measured on HW
gfx1035 (Radeon 660M). 2048 rows per op, special values plus random bits,
IEEE=0/1,DENORM16=3:clamp= the f16 clamp above applied to the unmodified result: 0 mismatches on every op of the table exceptv_cvt_norm_*_f16.mul:2,mul:4,div:2= the unmodified result, 0 mismatches. WithDENORM16=0andIEEE=0the hardware applies them (506/2048 equal forv_add_f16), already documented.v_cvt_norm_i16/u16_f16:clampandomodboth ignored (2048/2048 equal to unmodified).Tested
Linux (CachyOS), RADV and lavapipe.
Float16Modifiers.cppexecution test: 16 instructions (clamp, omod and both on 14 ops), 32 rows, expected values from the hardware. NaN results are compared as "any NaN".main.Float16TernaryClamp.cpp(same PR, first commit's scope) keeps covering the ternary forms with op_sel/neg/abs.ctest: all pass exceptagc_driver_pixel_helper_lanes,agc_driver_pixel_ldsandagc_driver_pixel_lds_lane_slots, which fail on RADV onmaintoo (wave32 pixel tests, no f16 ops).v_min_f16/v_max_f16/v_max3_f16return the other operand where the hardware returns the quiet NaN. The new test avoids sNaN inputs.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 adriadam10 on 2026-10-05T17:07:41Z.
Rebased on main (conflict with #501, which grouped
v_cvt_pk_u8_f32withv_ldexp_f16:v_cvt_pk_u8_f32keeps rejecting clamp/omod,v_ldexp_f16accepts them as in this PR). Float16Modifiers, Float16TernaryClamp and Vop3LegacySourceModifiers pass on RADV and lavapipe.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-05T18:31:27Z.
Rebased on main after #507 (
usesSignedSaturateClamprenamed tousesIntegerSaturateClamp); execution tests pass again.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-05T19:45:38Z.
Thanks. #507 landed and renamed
usesSignedSaturateClamptousesIntegerSaturateClamp, so this now conflicts on the return line ofsupportsNativeVop3Clamp. Keeping your early return and main's new name resolves it:I tested that resolution with the rest of the batch:
agc_driver_float16_modifiersandagc_driver_float16_ternary_clampfail on main's code, pass with the change, and pass 20 times in a row. The full ctest passes apart from one unrelated test. Ready to merge after the rebase.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-05T20:07:56Z.
Sorry, please ignore my rebase note above: this branch is already on top of #507 and uses
usesIntegerSaturateClamp, and I was looking at an older head. It merges cleanly with main as it is.