fix(shader): keep v_permlane16 lanes whose source lane is inactive #606
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/606"
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-05T02:39:22Z.
What
On hardware, when a
v_permlane16_b32orv_permlanex16_b32lane reads from an inactive source lane, the result depends on the twoop_selbits:op_sel[0]) set: the lane reads the inactive lane's value anyway (mainalready did this).op_sel[1]) clear: the lane is not written and keeps its old value.mainwrote 0 here.maindecoded bound_ctrl intoPermlaneFlags::boundControlbut never used it. The translator now passes the old destination value toPermlane16U32, and the emitter picks the old value or 0 depending on bound_ctrl. The rule is the same as the one the hardware uses for DPP16 with an inactive source lane.Neither opcode had an execution test. This PR adds
agc_driver_permlane16(Permlane16.cpp), which runs in wave32, native wave64 and wave64 split into two wave32 halves (ComputeTarget(32)):v_permlane16_b32with identity, reverse and mixed selects, plus inline constant selects0and-1;v_permlanex16_b32with identity, reverse, mixed and broadcast selectsop_selcombination that matters (none, fi, bc, fi+bc), with the destination pre-filled so a lane that isn't written shows upBehaviour measured on HW
Measured on gfx1035 (RDNA2), wave32 and wave64, 3 random input sets per wave size, 0 mismatches against this model:
(lane & ~15) | sel, whereselis the nibblelane & 7of src1 for lanes 0-7 of the row and of src2 for lanes 8-15x16, the row is XORed with 16: rows 0↔1 and 2↔3 in wave64The expected values in the test come from the hardware output. Operand syntax
op_sel:[fi,bound_ctrl]followsllvm-mc -mcpu=gfx1013.Tested
Linux, RADV (Mesa 26.2): the new test passes in all three wave modes. On lavapipe it skips (8-lane subgroups), like the other cross-lane tests, so CI only builds it. Full Release ctest: everything passes except
agc_driver_pixel_helper_lanes, which also fails on local RADV onmain.Negative checks: the test fails when the code is mutated in any of these ways:
main's behaviour (inactive source writes 0): fails oninactive_permlane16Checklist
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-05T03:09:19Z.
Thanks, this checks out. I disassembled both kernels with
llvm-mc -mcpu=gfx1013:v_permlane16_b32andv_permlanex16_b32with the SGPR selects, the inline0and-1selects, and everyop_selcombination (none,[1,0],[0,1],[1,1]) under the partial EXEC.The change does what the table says: with fetch inactive set the shuffle is returned as before; otherwise an inactive source lane gives 0 when bound_ctrl is set and the old destination value (now passed in through
readRawU32of the destination) when it isn't. The extraPermlane16U32argument has no other users to update. The new test fails on main (inactive_permlane16 is 0x00000000, expected 0xdeaddead) and passes with the fix, and it merges cleanly with your other open shader PRs.One note for the merge order: PPSA21564 has 704
v_permlanex16_b32withop_sel:[0,1], whose output doesn't change, but also 56v_permlane16_b32with noop_selin two shaders, which is exactly the case that now keeps the old value. So I'll run it through my visual check of PPSA21564 before it goes in.Ready to merge from my side once that run is done.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-05T05:04:11Z.
Gated on PPSA21564: no visual or FPS change.