fix(shader): DPP16 operands of v_pk_fmac_f16 and the relative moves #514

Merged
adriadam10 merged 1 commit from upstream-pr/514 into main 2026-10-05 08:33:49 +00:00
adriadam10 commented 2026-10-04 14:25:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-04T14:25:27Z.


What

Four VOP1/VOP2 opcodes gave wrong results with a DPP16 modifier on main. #513 found them with its differential sweep and refuses them for DPP8.

  • v_pk_fmac_f16: the accumulator was read through the destination, which destinationOperand gives the source DPP, so the accumulator was permuted too. The result was then written through plainOperand, which dropped the DPP write mask (row/bank mask, out-of-range lanes). It now reads the accumulator with accumulatorOperand like v_fmac_f32 does and writes with the destination's DPP.
  • v_movrels_b32, v_movrelsd_b32, v_movrelsd_2_b32: readRelativeVector read the registers directly and ignored the source DPP. It now applies the source modifiers to the relatively indexed value. The decoder already refuses SDWA on these opcodes, so in practice this only adds the permute.
  • v_movrelsd_b32, v_movrelsd_2_b32, v_movreld_b32: writeRelativeVector wrote through plainOperand, which dropped the DPP write mask. Now it keeps it.

Behaviour measured on HW (RDNA2 gfx1035, wave32)

  • v_pk_fmac_f16_dpp: the DPP permutes only src0. The accumulator is the lane's own vdst.
  • v_movrels*_dpp: lane l gets the relatively indexed register of the DPP source lane, i.e. v[base + m0] permuted.
  • All five opcodes use the same write rule as v_mov_b32_dpp: row_mask, bank_mask, exec, and no write for an out-of-range source without bound_ctrl. The relative destination is vdst + m0 (or m0[25:16] for _2).
  • A Python model of this matched HW on 3072 of 3072 cells (16 results × 32 lanes × 6 random seeds). It covers quad_perm, row_shr with invalid lanes, and row/bank masks with partial exec.

Tested

Arch Linux, RADV (RDNA2) and lavapipe; no title.

  • New agc_driver_dpp16_operands_tests: the five opcodes under three DPP16 controls. quad_perm with full exec; row_shr:1 without bound_ctrl, so the first lane of each row is not written; quad_perm with row_mask:0x5 bank_mask:0xa and partial exec. Expected values come from HW. One extra row checks that the relative base registers stay untouched. lavapipe skips it (subgroup size 8 can't hold a 16-lane row), the same way DsPermute does.
  • The test fails without each piece of the fix: unpermuted relative source, relative write without DPP, permuted accumulator, pk write without DPP.
  • Release ctest: all pass except agc_driver_pixel_helper_lanes, which also fails on main on local RADV since #305.

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:4735071510 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/514). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-04T14:25:27Z. --- ### What Four VOP1/VOP2 opcodes gave wrong results with a DPP16 modifier on `main`. #513 found them with its differential sweep and refuses them for DPP8. - `v_pk_fmac_f16`: the accumulator was read through the destination, which `destinationOperand` gives the source DPP, so the accumulator was permuted too. The result was then written through `plainOperand`, which dropped the DPP write mask (row/bank mask, out-of-range lanes). It now reads the accumulator with `accumulatorOperand` like `v_fmac_f32` does and writes with the destination's DPP. - `v_movrels_b32`, `v_movrelsd_b32`, `v_movrelsd_2_b32`: `readRelativeVector` read the registers directly and ignored the source DPP. It now applies the source modifiers to the relatively indexed value. The decoder already refuses SDWA on these opcodes, so in practice this only adds the permute. - `v_movrelsd_b32`, `v_movrelsd_2_b32`, `v_movreld_b32`: `writeRelativeVector` wrote through `plainOperand`, which dropped the DPP write mask. Now it keeps it. #### Behaviour measured on HW (RDNA2 gfx1035, wave32) - `v_pk_fmac_f16_dpp`: the DPP permutes only src0. The accumulator is the lane's own `vdst`. - `v_movrels*_dpp`: lane `l` gets the relatively indexed register of the DPP source lane, i.e. `v[base + m0]` permuted. - All five opcodes use the same write rule as `v_mov_b32_dpp`: row_mask, bank_mask, exec, and no write for an out-of-range source without `bound_ctrl`. The relative destination is `vdst + m0` (or `m0[25:16]` for `_2`). - A Python model of this matched HW on 3072 of 3072 cells (16 results × 32 lanes × 6 random seeds). It covers quad_perm, row_shr with invalid lanes, and row/bank masks with partial exec. ### Tested Arch Linux, RADV (RDNA2) and lavapipe; no title. - New `agc_driver_dpp16_operands_tests`: the five opcodes under three DPP16 controls. quad_perm with full exec; `row_shr:1` without `bound_ctrl`, so the first lane of each row is not written; quad_perm with `row_mask:0x5 bank_mask:0xa` and partial exec. Expected values come from HW. One extra row checks that the relative base registers stay untouched. lavapipe skips it (subgroup size 8 can't hold a 16-lane row), the same way DsPermute does. - The test fails without each piece of the fix: unpermuted relative source, relative write without DPP, permuted accumulator, pk write without DPP. - Release ctest: all pass except `agc_driver_pixel_helper_lanes`, which also fails on `main` on local RADV since #305. ### 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
adriadam10 commented 2026-10-04 20:36:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-04T20:36:23Z.


Rebased on current main: the only Windows failure was guest_audio_in_no_device, fixed by #532. No other changes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5984141679 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/514#issuecomment-5984141679). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-04T20:36:23Z. --- Rebased on current main: the only Windows failure was `guest_audio_in_no_device`, fixed by #532. No other changes.
oneandonlydean commented 2026-10-04 21:30:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-04T21:30:39Z.


Thanks, good catch. I re-checked the rebased head: the commit is unchanged from the one I first looked at, and it still merges cleanly onto current main.

On main the source DPP is copied into inst.destination, so v_pk_fmac_f16 read a permuted accumulator. I ran your test against main's code on NVIDIA and it fails with a value ("lane 0 quad_perm_pk_fmac_f16 is 0x3f013c00, expected 0x4a3d4000"), so this fixes a silent wrong result. accumulatorOperand plus writeRawU32(inst.destination) is right, and for the non-DPP VOP2 and VOP3P forms the write is the same as before. For the relative moves, M0 is uniform, so permuting after the M0 select equals permuting v[base + m0]. The full ctest passes with it on my machine, and CI is green now.

Ready to merge from my side. packedFloat16 is the path for every packed f16 op, so I'll run it through my PPSA21564 check before merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5984595643 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/514#issuecomment-5984595643). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-04T21:30:39Z. --- Thanks, good catch. I re-checked the rebased head: the commit is unchanged from the one I first looked at, and it still merges cleanly onto current main. On main the source DPP is copied into `inst.destination`, so `v_pk_fmac_f16` read a permuted accumulator. I ran your test against main's code on NVIDIA and it fails with a value ("lane 0 quad_perm_pk_fmac_f16 is 0x3f013c00, expected 0x4a3d4000"), so this fixes a silent wrong result. `accumulatorOperand` plus `writeRawU32(inst.destination)` is right, and for the non-DPP VOP2 and VOP3P forms the write is the same as before. For the relative moves, M0 is uniform, so permuting after the M0 select equals permuting `v[base + m0]`. The full ctest passes with it on my machine, and CI is green now. Ready to merge from my side. `packedFloat16` is the path for every packed f16 op, so I'll run it through my PPSA21564 check before merging.
oneandonlydean commented 2026-10-05 08:31:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-05T08:31:22Z.


Gated on PPSA21564: no visual or FPS change.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5990922346 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/514#issuecomment-5990922346). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-05T08:31:22Z. --- Gated on PPSA21564: no visual or FPS change.
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!514
No description provided.