feat(shader): accept every SDWA selector on VOP2 integer ops #509
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/509"
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-04T11:29:55Z.
What
VOP2 SDWA on integer ops threw for most selector combinations:
v_min_i32,v_max_i32,v_sub_co_ci_u32,v_subrev_co_ci_u32had no SDWA rule, so any non-DWORD selector threwVOP2 SDWA modifier is not supported for opcode.v_mul_{i32_i24,hi_i32_i24,u32_u24,hi_u32_u24},v_max_u32,v_lshrrev_b32,v_ashrrev_i32,v_lshlrev_b32,v_add_co_ci_u32andv_subrev_nc_u32, anydst_selother than DWORD threw. Onv_and/or/xor/xnor_b32, bytedst_selthrew.All of them now take every
src0_sel/src1_sel(withsext) and everydst_selwithUNUSED_PAD,UNUSED_SEXTorUNUSED_PRESERVE, likev_add_nc_u32andv_min_u32already did. The five integer profiles in the decoder are merged into one. The translator needed no change: these ops already read their sources throughapplyBitSourceModifiersand write throughwriteRawU32, which apply the selectors. On the carry ops, the carry is computed from the selected 32-bit operands. Only the VGPR write depends ondst_sel.clampon these ops and the reserveddst_unusedvalue 3 still throw.Behaviour measured on HW (RDNA2, gfx1035)
I ran the 13 forms in the test (all 13 ops, with byte and word selectors,
sexton either source, and all threedst_unusedmodes, plus the carry-out of the three carry ops) on 2048 rows of edge words and random values. The Python model matches all 32768 results. The model zero- or sign-extends the selected source field, computes the 32-bit op, then writes the destination field: zero the rest, sign-extend upward with the lower bits zero, or keep the rest.Tested
New execution test
agc_driver_sdwa_integer_selectors_tests: 32 rows with expected values from the hardware (the model matches every cell). Rows are picked so each op gets both signs of each selected source, both values of the carry and the top bit of the written field. For min/max both comparison outcomes are covered, and for shifts the counts 0, 1-15 and 16-31.It passes on RADV and lavapipe. It fails without each part of the change: no rule for
v_min_i32, no rule forv_sub_co_ci_u32and a DWORD-only destination for the integer profile all throw again, and droppingsexton the sources gives wrong values (4 mutations). The full Release ctest passes exceptagc_driver_pixel_helper_lanes, which also fails onmainon local RADV.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 oneandonlydean on 2026-10-04T21:08:03Z.
Thanks, checked against the RDNA2 ISA SDWA description: the source field is extracted (sign-extended with
sext), the op runs at 32 bits, anddst_sel/dst_unusedplace the low bits of the result. The translator already reads these ops throughapplyBitSourceModifiersand writes throughwriteRawU32, so the decoder change is all that was missing, and forms main already accepted decode the same way. I disassembled the test with llvm-mc and wrote my own model of it; it matches all 512 expected values, including the carry-outs. The new test fails on main and the full ctest passes with it on my machine. Ready to merge from my side; I'll run it through my PPSA21564 check before merging, together with #510.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-05T08:31:20Z.
Gated on PPSA21564 with #510 on top: no visual or FPS change.