feat(shader): implement v_div_fixup_f16 #438

Merged
adriadam10 merged 1 commit from upstream-pr/438 into main 2026-10-04 02:41:12 +00:00
adriadam10 commented 2026-10-03 07:21:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-03T07:21:18Z.


What

v_div_fixup_f16 (VOP3 0x35f) threw "VOP3 opcode is not implemented". Found by the ISA coverage sweep.

It is translated on the raw half bits (no f32 round trip), with this behaviour measured on RDNA2 hardware:

  • sign = sign(src1) ^ sign(src2).
  • NaN src2, else NaN src1: returned quieted (bit 9 set, sign and payload kept).
  • 0/0 and inf/inf: 0xfe00 (the default NaN has the sign bit set).
  • src1 == 0 or |src2| == inf: signed infinity. |src1| == inf or src2 == 0: signed zero.
  • Otherwise sign | |src0|, except a NaN src0, which gives a signed infinity.
  • Denormals are not flushed. op_sel (sources and destination half), abs and neg work as for the other f16 ternary
    ops; the other half of the destination is kept.

Tested

  • New execution test DivFixupF16 (32 lanes, expected values captured on an RDNA2 GPU, Radeon 660M): eight forms
    covering low/high source halves, high destination half, abs/neg, swapped operands and literal operands, with
    inputs drawn from zeros, infinities, quiet and signalling NaNs, denormals and random halves. A Python model matched
    the 256 test values and a further 16384 random values on hardware before the C++ was written.
  • Passes on Linux with RADV and lavapipe.
  • Negative checks, each fails the test: NaN src0 passed through ("mixed halves"), default NaN 0x7e00
    ("mixed halves"), NaN not quieted ("neg denominator").
  • Full Release build + ctest: 129/130. The failure is agc_driver_pixel_helper_lanes (wave64 case) on this
    machine's RADV, and it fails the same way on main without this change.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4724860113 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/438). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-03T07:21:18Z. --- ### What `v_div_fixup_f16` (VOP3 0x35f) threw "VOP3 opcode is not implemented". Found by the ISA coverage sweep. It is translated on the raw half bits (no f32 round trip), with this behaviour measured on RDNA2 hardware: - `sign = sign(src1) ^ sign(src2)`. - NaN `src2`, else NaN `src1`: returned quieted (bit 9 set, sign and payload kept). - 0/0 and inf/inf: `0xfe00` (the default NaN has the sign bit set). - `src1 == 0` or `|src2| == inf`: signed infinity. `|src1| == inf` or `src2 == 0`: signed zero. - Otherwise `sign | |src0|`, except a NaN `src0`, which gives a signed infinity. - Denormals are not flushed. `op_sel` (sources and destination half), `abs` and `neg` work as for the other f16 ternary ops; the other half of the destination is kept. ### Tested - New execution test `DivFixupF16` (32 lanes, expected values captured on an RDNA2 GPU, Radeon 660M): eight forms covering low/high source halves, high destination half, abs/neg, swapped operands and literal operands, with inputs drawn from zeros, infinities, quiet and signalling NaNs, denormals and random halves. A Python model matched the 256 test values and a further 16384 random values on hardware before the C++ was written. - Passes on Linux with RADV and lavapipe. - Negative checks, each fails the test: NaN `src0` passed through ("mixed halves"), default NaN `0x7e00` ("mixed halves"), NaN not quieted ("neg denominator"). - Full Release build + `ctest`: 129/130. The failure is `agc_driver_pixel_helper_lanes` (wave64 case) on this machine's RADV, and it fails the same way on `main` without this change. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-03 07:21:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-03T07:21:41Z.


Progress report (926906e → c23ead6)

📈 GPU shader instructions: 65.78% (+0.09%, +1 implemented instructions)

✅ 1 implemented
Encoding Name
VOP3 V_DIV_FIXUP_F16
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5966722019 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/438#issuecomment-5966722019). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-03T07:21:41Z. --- <!-- progress-report --> ### Progress report (926906e → c23ead6) 📈 **GPU shader instructions**: 65.78% (+0.09%, +1 implemented instructions) <details> <summary>✅ 1 implemented</summary> | Encoding | Name | | - | - | | VOP3 | `V_DIV_FIXUP_F16` | </details>
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!438
No description provided.