feat(shader): decode DPP8 on VOP1 and VOP2 #513

Merged
adriadam10 merged 1 commit from upstream-pr/513 into main 2026-10-05 02:49:48 +00:00
adriadam10 commented 2026-10-04 14:15:52 +00:00 (Migrated from github.com)

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


What

The decoder threw on DPP8 (src0 = 233 dpp8, 234 dpp8 fi:1) for every VOP1/VOP2 opcode. Now it decodes them.

  • Decoder: the 24-bit lane selector goes into dppCtrl, plus a new dpp8 operand flag. fi:1 sets dppFetchInactive. DPP8 has no row/bank mask, bound_ctrl or neg/abs, so those keep their defaults.
  • IR: DppMoveFlags::control widens to 32 bits. Lanes8 marks a DPP8 selector, so the existing DppMoveU32/DppUpdateU32 ops and their LaneSource entries cover it unchanged.
  • SPIR-V: the quad_perm target lane helper now takes the group width (EmitDppGroupPermTargetLane): 2 bits per lane for quad_perm, 3 bits for DPP8 (8-lane groups).
  • Opcodes with no DPP8 encoding in llvm-mc -mcpu=gfx1013 (f64 VOP1, readfirstlane, swap/swaprel, madmk/madak/fmamk/fmaak, mac_legacy) throw DPP8 modifier is not supported for opcode.
  • Four more opcodes throw on purpose because the result would be wrong. The same bugs already exist with DPP16 on main, and I'll fix those in separate PRs:
    • v_movrels_b32, v_movrelsd_b32, v_movrelsd_2_b32: readRelativeVector reads the registers directly and drops the source permute. On HW the permute applies to the relatively indexed value.
    • v_pk_fmac_f16: the DPP16 form already disagrees with the same op on a pre-permuted source.

Behaviour measured on HW (RDNA2 gfx1035, wave32 and wave64)

  • lane l reads lane (l & ~7) | sel[l & 7]. The groups never cross 8 lanes, including across the wave64 halves.
  • fi:0: a lane whose source lane is inactive reads 0. fi:1: it reads the source lane's value anyway. Inactive lanes are not written.
  • A Python model of this matched HW on 6336 of 6336 cells (11–12 ops × wave32/wave64 × 6 random seeds).

Tested

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

  • New agc_driver_dpp8_tests: v_mov (plain, fi:1), v_add_nc_u32, v_add_f32, v_fmac_f32, v_cndmask_b32, v_cvt_f32_i32 and v_add_co_ci_u32 with DPP8. A partial-exec block (exec = 0x5a5af0f3, wave64 hi 0xc3a5960f) checks fi:0/fi:1 and the zeroing of inactive sources. The source of mov_uniform_inactive is wave-uniform, which pins the two-half wave64 path. Expected values come from HW. It runs as wave32, as wave64 on one 64-lane subgroup, and as wave64 split into two 32-lane halves (ComputeTarget(32)). lavapipe skips the test (subgroup 8), as DsPermute does.
  • Without the fix, the test fails on each piece: VOP2 DPP8 not decoded, fi ignored, DPP8 neg/abs read like DPP16, lanes taken as quad_perm, destination losing dpp8, translator dropping Lanes8. Removing DppMoveU32/DppUpdateU32 from LaneSource also fails it on the split path. Forcing laneHalf to 0 fails it on lane 32.
  • A temporary differential sweep compared each of the 96 accepted opcodes against the same op on a source permuted with v_mov_b32_dpp. It is not committed. All passed except the four refused above and the *_co_ci forms, where the reference reads a vcc that the first op had already overwritten.
  • 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:4735016662 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/513). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-04T14:15:52Z. --- ### What The decoder threw on DPP8 (`src0` = 233 `dpp8`, 234 `dpp8 fi:1`) for every VOP1/VOP2 opcode. Now it decodes them. - Decoder: the 24-bit lane selector goes into `dppCtrl`, plus a new `dpp8` operand flag. `fi:1` sets `dppFetchInactive`. DPP8 has no row/bank mask, bound_ctrl or neg/abs, so those keep their defaults. - IR: `DppMoveFlags::control` widens to 32 bits. `Lanes8` marks a DPP8 selector, so the existing `DppMoveU32`/`DppUpdateU32` ops and their `LaneSource` entries cover it unchanged. - SPIR-V: the quad_perm target lane helper now takes the group width (`EmitDppGroupPermTargetLane`): 2 bits per lane for quad_perm, 3 bits for DPP8 (8-lane groups). - Opcodes with no DPP8 encoding in `llvm-mc -mcpu=gfx1013` (f64 VOP1, readfirstlane, swap/swaprel, madmk/madak/fmamk/fmaak, mac_legacy) throw `DPP8 modifier is not supported for opcode`. - Four more opcodes throw on purpose because the result would be wrong. The same bugs already exist with DPP16 on `main`, and I'll fix those in separate PRs: - `v_movrels_b32`, `v_movrelsd_b32`, `v_movrelsd_2_b32`: `readRelativeVector` reads the registers directly and drops the source permute. On HW the permute applies to the relatively indexed value. - `v_pk_fmac_f16`: the DPP16 form already disagrees with the same op on a pre-permuted source. #### Behaviour measured on HW (RDNA2 gfx1035, wave32 and wave64) - lane `l` reads lane `(l & ~7) | sel[l & 7]`. The groups never cross 8 lanes, including across the wave64 halves. - `fi:0`: a lane whose source lane is inactive reads 0. `fi:1`: it reads the source lane's value anyway. Inactive lanes are not written. - A Python model of this matched HW on 6336 of 6336 cells (11–12 ops × wave32/wave64 × 6 random seeds). ### Tested Arch Linux, RADV (RDNA2) and lavapipe; no title. - New `agc_driver_dpp8_tests`: v_mov (plain, `fi:1`), v_add_nc_u32, v_add_f32, v_fmac_f32, v_cndmask_b32, v_cvt_f32_i32 and v_add_co_ci_u32 with DPP8. A partial-exec block (`exec` = `0x5a5af0f3`, wave64 hi `0xc3a5960f`) checks `fi:0`/`fi:1` and the zeroing of inactive sources. The source of `mov_uniform_inactive` is wave-uniform, which pins the two-half wave64 path. Expected values come from HW. It runs as wave32, as wave64 on one 64-lane subgroup, and as wave64 split into two 32-lane halves (`ComputeTarget(32)`). lavapipe skips the test (subgroup 8), as DsPermute does. - Without the fix, the test fails on each piece: VOP2 DPP8 not decoded, `fi` ignored, DPP8 neg/abs read like DPP16, lanes taken as quad_perm, destination losing `dpp8`, translator dropping `Lanes8`. Removing `DppMoveU32`/`DppUpdateU32` from `LaneSource` also fails it on the split path. Forcing `laneHalf` to 0 fails it on lane 32. - A temporary differential sweep compared each of the 96 accepted opcodes against the same op on a source permuted with `v_mov_b32_dpp`. It is not committed. All passed except the four refused above and the `*_co_ci` forms, where the reference reads a vcc that the first op had already overwritten. - 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
oneandonlydean commented 2026-10-04 21:08:09 +00:00 (Migrated from github.com)

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


Thanks, this checks out. The encoding matches LLVM (DPP8_FI_0 = 0xE9, DPP8_FI_1 = 0xEA, eight 3-bit selectors in bits 31:8), and the decoder correctly leaves the row/bank masks, bound_ctrl and neg/abs at their defaults. (l & ~7) | sel[l & 7] never crosses a 32-lane half, so wave64 on a 32-wide host subgroup is safe, and with fi:0 an inactive source reads 0 while the write condition is just EXEC. I swept every VOP1/VOP2 opcode through llvm-mc with a DPP8 word: every op the decoder knows without a DPP8 form is either in your refuse list or isn't a gfx1013 opcode at all. The new test fails on main and passes on NVIDIA in my run. Ready to merge from my side. It reshapes the quad_perm lane helper every DPP16 quad_perm goes through, so I'll run it through my PPSA21564 check before merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5984397390 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/513#issuecomment-5984397390). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-04T21:08:09Z. --- Thanks, this checks out. The encoding matches LLVM (`DPP8_FI_0 = 0xE9`, `DPP8_FI_1 = 0xEA`, eight 3-bit selectors in bits 31:8), and the decoder correctly leaves the row/bank masks, `bound_ctrl` and neg/abs at their defaults. `(l & ~7) | sel[l & 7]` never crosses a 32-lane half, so wave64 on a 32-wide host subgroup is safe, and with `fi:0` an inactive source reads 0 while the write condition is just EXEC. I swept every VOP1/VOP2 opcode through llvm-mc with a DPP8 word: every op the decoder knows without a DPP8 form is either in your refuse list or isn't a gfx1013 opcode at all. The new test fails on main and passes on NVIDIA in my run. Ready to merge from my side. It reshapes the quad_perm lane helper every DPP16 quad_perm goes through, so I'll run it through my PPSA21564 check before merging.
adriadam10 commented 2026-10-05 01:32:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-05T01:32:37Z.


Rebased on current main (after #587). Conflict in SpirvSubgroup.{hpp,cpp}: kept #587's EmitHostSubgroupLane/EmitWaveBallot next to EmitDppGroupPermTargetLane, and updated #587's Wave32WideSubgroup.cpp call from EmitDppQuadPermTargetLane(state, id, 0x1b) to EmitDppGroupPermTargetLane(state, id, 0x1b, 2) (same lane math). agc_driver_dpp8_tests, wave32_wide_subgroup_tests and the rest of ctest pass on RADV (only the known agc_driver_pixel_helper_lanes, red on main locally since #305).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5986597891 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/513#issuecomment-5986597891). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-05T01:32:37Z. --- Rebased on current main (after #587). Conflict in `SpirvSubgroup.{hpp,cpp}`: kept #587's `EmitHostSubgroupLane`/`EmitWaveBallot` next to `EmitDppGroupPermTargetLane`, and updated #587's `Wave32WideSubgroup.cpp` call from `EmitDppQuadPermTargetLane(state, id, 0x1b)` to `EmitDppGroupPermTargetLane(state, id, 0x1b, 2)` (same lane math). `agc_driver_dpp8_tests`, `wave32_wide_subgroup_tests` and the rest of ctest pass on RADV (only the known `agc_driver_pixel_helper_lanes`, red on main locally since #305).
oneandonlydean commented 2026-10-05 02:47:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-05T02:47:09Z.


Thanks, the conflict resolution is right. EmitDppGroupPermTargetLane(state, id, 0x1b, 2) emits the same instructions as #587's EmitDppQuadPermTargetLane(state, id, 0x1b), so wave32_wide_subgroup checks the same lane math as before, and #587's EmitHostSubgroupLane/EmitWaveBallot are kept. agc_driver_dpp8 and wave32_wide_subgroup pass here on the merged branch.

PPSA21564 has no DPP8, and with 2 lane bits the quad_perm path generates the same SPIR-V as main, so this doesn't need my PPSA21564 check. Ready to merge from my side.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5987227911 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/513#issuecomment-5987227911). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-05T02:47:09Z. --- Thanks, the conflict resolution is right. `EmitDppGroupPermTargetLane(state, id, 0x1b, 2)` emits the same instructions as #587's `EmitDppQuadPermTargetLane(state, id, 0x1b)`, so `wave32_wide_subgroup` checks the same lane math as before, and #587's `EmitHostSubgroupLane`/`EmitWaveBallot` are kept. `agc_driver_dpp8` and `wave32_wide_subgroup` pass here on the merged branch. PPSA21564 has no DPP8, and with 2 lane bits the quad_perm path generates the same SPIR-V as main, so this doesn't need my PPSA21564 check. Ready to merge from my side.
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!513
No description provided.