fix(agc): run wave32 compute programs on 32-wide subgroups #316
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/316"
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-02T04:29:14Z.
What
On devices whose default subgroup is 64 lanes (RADV; AMD on Windows reports 64 too), a wave32 compute program was compiled for a 64-wide host subgroup. With more than 32 threads per workgroup, two guest waves then share one host subgroup, so everything wave-wide in the second wave sees the first one:
v_mbcntlane ids, ballots/VCC, EXEC saved or changed byv_cmpx,v_readlane. On RADV, a 64-thread wave32 dispatch givesv_mbcnt_lo= 32..63 in the second wave instead of 0..31.Fix, with
VK_EXT_subgroup_size_control:VulkanDeviceenablessubgroupSizeControlwhen the default subgroup is wider than 32, 32 lies in[minSubgroupSize, maxSubgroupSize]and compute is inrequiredSubgroupSizeStages.VulkanDevice::ComputeTarget(waveSize)returnsTarget()withsubgroupSize = 32for wave32 programs on such devices.Dispatch.cppuses it, so the program is recompiled for a 32-wide host subgroup, the path NVIDIA already takes.RecompileResult::hostSubgroupSizerecords the width the program was laid out for. It is stored in the disk cache and fills existing padding, so the struct size is unchanged. The compute pipeline addsVkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT{32}when it is 32 and the device's default is not.Wave64 programs and devices whose default is already 32 (NVIDIA) are unchanged. The cache key already includes
target.subgroupSize.Not in this PR: graphics stages. RADV can require 32 for fragment/mesh/task, but not vertex. That needs per-stage widths in
Pipeline.cppand its own tests, so it is a follow-up.Test
agc_driver_wave32_subgroup: one 64-thread wave32 dispatch, hand-assembled (words fromllvm-mc -mcpu=gfx1013). Each lane checksv_mbcnt_lo(lane in its wave),s_bcnt1of a VCC compare (8 per wave),v_readlane_b32 lane 3(its own wave's lane 3), and the EXEC save →v_cmpx→ restore pattern. It is skipped when the device cannot run wave32 on 32-wide subgroups (lavapipe: 8).Tested
Linux, full ctest (99) passes.
device->Target()(the old path):thread 32 v_mbcnt_lo_u32_b32 is 32, expected 0.VulkanDevice/Recompiler/ShaderDiskCache(#218 #261 #278 #282 #290 #291).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)