Skip to content

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

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
adriadam10:fix/dpp16-movrels-pk-fmac
Oct 5, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
adriadam10:fix/dpp16-movrels-pk-fmac

Conversation

@adriadam10

Copy link
Copy Markdown
Collaborator

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

@github-actions github-actions Bot added shader core/shader agc libSceAgc* labels Oct 4, 2026
v_pk_fmac_f16 read its accumulator through the permuted destination and
wrote without the DPP write mask. v_movrels/movrelsd/movrelsd_2 dropped
the source permute, and the relative writes dropped the DPP write mask.

Co-Authored-By: Claude <noreply@anthropic.com>
@adriadam10
adriadam10 force-pushed the fix/dpp16-movrels-pk-fmac branch from 0857c9b to cebc1e8 Compare October 4, 2026 20:35
@adriadam10

Copy link
Copy Markdown
Collaborator Author

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

@oneandonlydean

Copy link
Copy Markdown
Collaborator

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

Copy link
Copy Markdown
Collaborator

Gated on PPSA21564: no visual or FPS change.

@oneandonlydean
oneandonlydean merged commit 1e37ed4 into boykopovar:main Oct 5, 2026
3 checks passed
oneandonlydean added a commit to oneandonlydean/AnyPS5 that referenced this pull request Oct 5, 2026
Takes upstream's merged versions of our boykopovar#586 boykopovar#611 boykopovar#612 boykopovar#505 boykopovar#490 boykopovar#619
boykopovar#503 boykopovar#627 boykopovar#628 boykopovar#618 and drops astrobot's local copies, plus gate-batch-3
(boykopovar#469 boykopovar#500 boykopovar#504 boykopovar#509 boykopovar#510 boykopovar#514 boykopovar#525 boykopovar#526 boykopovar#528), round o/p (boykopovar#617 boykopovar#620
boykopovar#621 boykopovar#622 boykopovar#623 boykopovar#624 boykopovar#501 boykopovar#508 boykopovar#629 boykopovar#630 boykopovar#631).

Conflicts:
- SpirvAnalysis.hpp/.cpp, SpirvBufferAccess.cpp: upstream's boykopovar#586/boykopovar#612.
  The 64-bit LDS atomics keep the full array (f27d6e5 no longer needed).
- SpirvMemoryInstructions.cpp: upstream's constant slot plus offset;
  astrobot's split-wave append/consume kept.
- GuestTextureResource.cpp, TextureTiling.cpp and their tests: upstream's
  boykopovar#490/boykopovar#503 (astrobot had no other change there).
- MaskedSelect.cpp test, ShaderMemory.cpp LDS test: upstream's.
- State.cpp: upstream's boykopovar#505 export count and boykopovar#469 null pixel program;
  astrobot's depth export rejection and depth target model kept.
- Pipeline.cpp: upstream's pipeline key; astrobot's depth attachment and
  blend check (a trailing unused attachment stays valid, as
  colorGapPipelineTests expects).
- Draw.cpp, Recorder.cpp, ShaderResources.cpp: astrobot's (renderPassKey
  with depth, moved sample functions, residency maintenance), which
  already hold the merged boykopovar#505/boykopovar#628/boykopovar#490 changes.
- ShaderInputState.cpp: both register sets.
- State.hpp: the duplicate exportIndex member from the auto-merge removed.
- CMakeLists.txt: astrobot's test list (a superset of upstream's).
- tests/Graphics.cpp: upstream's CompactedExportTests replaces astrobot's
  inline copy; tests/Recorder.cpp: upstream's viewPastLastMipTests added.
@adriadam10
adriadam10 deleted the fix/dpp16-movrels-pk-fmac branch October 6, 2026 20:22
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