Skip to content

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

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
adriadam10:feat/dpp8
Oct 5, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
adriadam10:feat/dpp8

Conversation

@adriadam10

Copy link
Copy Markdown
Collaborator

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 fix(recompiler): start pixel waves without their helper invocations in EXEC #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

@oneandonlydean

Copy link
Copy Markdown
Collaborator

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.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 5, 2026
Co-Authored-By: Claude <noreply@anthropic.com>
@adriadam10

Copy link
Copy Markdown
Collaborator Author

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).

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 5, 2026
@oneandonlydean

Copy link
Copy Markdown
Collaborator

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.

@oneandonlydean
oneandonlydean merged commit 6d23390 into boykopovar:main Oct 5, 2026
3 checks passed
@adriadam10
adriadam10 deleted the feat/dpp8 branch October 5, 2026 06:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* shader core/shader

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants