feat(shader): implement v_qsad_pk_u16_u8, v_mqsad_pk_u16_u8 and v_mqsad_u32_u8 #437
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/437"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-03T07:11:23Z.
What
v_qsad_pk_u16_u8(VOP3 0x172),v_mqsad_pk_u16_u8(0x173) andv_mqsad_u32_u8(0x175) threw "VOP3 opcode is notimplemented". Found by the ISA coverage sweep.
src0(window k =src0 >> 8k, k = 0..3) and compute a byte SADagainst
src1. Themqsadforms skip bytes where thesrc1(reference) byte is 0, likev_msad_u8._pk_u16_u8: each SAD is added to the matching 16-bit half of the 64-bitsrc2and packed into a 64-bit result.mqsad_u32_u8: each SAD is added to the matching dword of the 128-bitsrc2, 128-bit result.subwordSadmoved to a helper (byteSad) shared by the existing SAD ops and the new ones.Tested
Vop3QuadSad(32 lanes, expected values captured on an RDNA2 GPU, Radeon 660M): the three opswith VGPR accumulators,
qsadwith an inline 0 accumulator, and accumulators chosen to wrap. A Python model of thesemantics above matched all 512 measured values before the C++ was written.
main("VOP3 opcode is not implemented"); passes on Linux with RADV and lavapipe.128-bit accumulator not offset ("mqsad_u32 2"),
mqsad_pkwithout the mask ("mqsad_pk lo").ctest: 128/129. The failure isagc_driver_pixel_helper_lanes(wave64 case) on thismachine's RADV, and it fails the same way on
mainwithout this change.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-03T07:11:45Z.
Progress report (
870bdd8→01bae4d)📈 GPU shader instructions: 73.41% (+0.25%, +3 implemented instructions)
✅ 3 implemented
V_MQSAD_PK_U16_U8V_MQSAD_U32_U8V_QSAD_PK_U16_U8Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-04T05:44:50Z.
The quad SAD maths checks out for me, including the per-field wrap. One small thing:
embeddedFetchDstSizein EmbeddedVertexFetch.cpp still reports one register for these, butv_qsad_pk_u16_u8/v_mqsad_pk_u16_u8write two andv_mqsad_u32_u8writes four. The vertex fetch analysis then only clears the first register's tracked lanes, so a vertex shader that reuses v[d+1..] after one of these could keep a stale fetch. #435 adds its op to the same function; could you add these three the same way? Then it's ready from my side.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-04T06:23:42Z.
Good catch, thanks.
embeddedFetchDstSizeis now a switch:v_qsad_pk_u16_u8andv_mqsad_pk_u16_u8report 2 registers next tov_mad_u64_u32, andv_mqsad_u32_u8reports 4. #435 changes the same line, so whichever lands second needs a one-line rebase (I'll handle it on #435). Rebased onto main;agc_driver_vop3_quad_sadpasses on RADV and lavapipe, andagc_driver_graphicspasses.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-04T06:29:22Z.
Thanks for the quick update, that covers it. I'll test it here and merge once CI is green.