feat(shader): VOP3 v_max/min_f16, v_cvt_f32_f16/ubyte and abs/neg on f16 binaries #252

Merged
adriadam10 merged 2 commits from upstream-pr/252 into main 2026-10-02 07:49:58 +00:00
adriadam10 commented 2026-10-01 19:42:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-01T19:42:10Z.


What

The VOP1/VOP2 forms of these already translate, but their VOP3 encodings threw "VOP3 opcode is not implemented":

  • v_max_f16_e64, v_min_f16_e64 (were explicitly excluded as VOP3 aliases)
  • v_cvt_f32_f16_e64, v_cvt_f32_ubyte0..3_e64 (missing from the VOP3-encoded VOP1 table)

VOP3 f16 binaries (add/sub/subrev/mul/min/max_f16) also rejected abs/neg ("VOP3 source modifiers are not implemented") although readF16AsF32 already applies them, so they are now accepted. clamp/omod stay rejected for f16 results: writeF16 does not apply result modifiers (separate fix).

Found with an ISA sweep: every gfx1013 opcode from llvm-mc fed to DecodeRdnaInstruction + TranslateInstruction; these were the VOP3 forms whose short form already works.

Test agc_driver_vop3_aliases: hand-assembled compute shader (words from llvm-mc -mcpu=gfx1013 -show-encoding, same harness as MixPrecision), 64 lanes compared with a CPU model: v_max_f16 -a,|b|, v_min_f16 |a|,-b, v_mul_f16 -|a|,b, v_cvt_f32_f16 b mul:4, v_cvt_f32_f16 -|a|, v_cvt_f32_ubyte0..3 with mul:2, div:2, clamp. Only the written f16 half is checked.

Tested

Linux: test passes on RADV (Radeon 660M) and lavapipe; without the decoder change it fails with "VOP3 opcode is not implemented". CI runs it on lavapipe through #251.

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: #251 (test helper VulkanTestDevice.hpp + lavapipe in CI); review only the last commit
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4708706425 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/252). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-01T19:42:10Z. --- ### What The VOP1/VOP2 forms of these already translate, but their VOP3 encodings threw "VOP3 opcode is not implemented": - `v_max_f16_e64`, `v_min_f16_e64` (were explicitly excluded as VOP3 aliases) - `v_cvt_f32_f16_e64`, `v_cvt_f32_ubyte0..3_e64` (missing from the VOP3-encoded VOP1 table) VOP3 f16 binaries (`add/sub/subrev/mul/min/max_f16`) also rejected `abs`/`neg` ("VOP3 source modifiers are not implemented") although `readF16AsF32` already applies them, so they are now accepted. `clamp`/`omod` stay rejected for f16 results: `writeF16` does not apply result modifiers (separate fix). Found with an ISA sweep: every gfx1013 opcode from `llvm-mc` fed to `DecodeRdnaInstruction` + `TranslateInstruction`; these were the VOP3 forms whose short form already works. Test `agc_driver_vop3_aliases`: hand-assembled compute shader (words from `llvm-mc -mcpu=gfx1013 -show-encoding`, same harness as `MixPrecision`), 64 lanes compared with a CPU model: `v_max_f16 -a,|b|`, `v_min_f16 |a|,-b`, `v_mul_f16 -|a|,b`, `v_cvt_f32_f16 b mul:4`, `v_cvt_f32_f16 -|a|`, `v_cvt_f32_ubyte0..3` with `mul:2`, `div:2`, `clamp`. Only the written f16 half is checked. ### Tested Linux: test passes on RADV (Radeon 660M) and lavapipe; without the decoder change it fails with "VOP3 opcode is not implemented". CI runs it on lavapipe through #251. ### Checklist - [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: #251 (test helper `VulkanTestDevice.hpp` + lavapipe in CI); review only the last commit - [x] AI-assisted: yes
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!252
No description provided.