fix(shader): throw for constant lane reads outside the host subgroup #997
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/997"
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 Celegans12 on 2026-10-06T22:29:37Z.
What
On a 32-lane host, the pixel, vertex and tessellation stages of a wave64 program run one guest lane per invocation (compute and mesh hold two), so lanes 32-63 have no invocation, yet
v_readlane_b32still shuffled from them.EmitReadLanethrows for a constant lane at or above the subgroup size, andEmitPermlane16U32throws forv_permlanex16_b32on subgroups of 16 lanes or fewer.s_ff1_i32_b64waterfalls are unaffected.mainthey stop earlier, at image-table descriptors (#920). Running them exactly needs lane reads across subgroups, which is a design question.Tested
mainc1241ad0: configure-DBUILD_TESTING=ON, full build,--target libs,ctest:ctest --output-on-failure)VK_DRIVER_FILES): 364/364 pass;agc_driver_flat_storeis left out there because it takes several minutes on Windows llvmpipeverifyLanesOutsideHostSubgroupinagc_shader_memory(CPU only): lane 63 throws on 32 and 8 lanes but builds on 64 and as compute on 32 and 8, lane 31 throws only on 8, ans_ff1_i32_b64waterfall builds,v_permlanex16_b32throws on 8; the four throws fail onmain.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 NahuelGenchi on 2026-10-06T23:58:47Z.
Since this was only tested on 32 and 8 lane hosts, here's a run on a native 64 lane subgroup: R9 380 (Tonga, GFX8, RADV, Mesa 26.0.8), Ubuntu 26.04, GCC 15.2, Release build of
a40fe0b4.The full suite passes, 367 tests with lod_clamp skipped as on main (no shaderResourceMinLod on this card). That includes the read_lane, write_lane, read_first_lane, permlane16, wave32_subgroup and pixel lane tests, so the 64 lane path still builds and gives correct results here. All agc_driver_* binaries are also clean under the Khronos validation layer with VK_KHRONOS_VALIDATION_VALIDATE_SYNC=true, same as main at
ab9437e3.Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-07T00:03:02Z.
Thanks for running it on a real 64-lane card. That was the case I couldn't check here, and it's good to see the read_lane, permlane16 and pixel lane tests come out right on GCN as well.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-07T12:08:52Z.
Checked on RADV (build + full ctest on current main, 393/393;
agc_shader_memoryfails without the change). Measured on RDNA2 (gfx1035) with the HW oracle: with an inactive source lane,v_permlane16_b32/v_permlanex16_b32keep the old value without fetch-inactive (0 with bound_ctrl) and read the lane's VGPR with fetch-inactive, andv_readlane_b32of an inactive lane reads its VGPR. That matches the ballot-based source EXEC and both TechnicalDebt lines. Merging.