tests: run the add_tid case in one wave instead of two #934
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!934
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/934/head"
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?
@theantipopau on GitHub · 2026-09-29 23:05 UTC · original
theantipopau:subgroup-lane-width→main· +7 −1 · 1 files · 1 commits · closed without mergingWhat
BufferStoreFormatXAddTidUsesLaneIndexdispatches a 64-thread workgroup withwave_size = 32andexpects only dwords 0–31 to be written, on the theory that
MUBUFadd_tidaddresses by thesubgroup lane. That expectation is only meaningful if the host subgroup is 32 wide — which nothing
in the pipeline guarantees.
On my machine (AMD,
subgroup_size == 64) the case fails:All 64 slots are written, i.e.
SubgroupLocalInvocationIdis coming back as the flat thread id.Dropping the workgroup to a single 32-lane wave makes it pass, which is what this change does.
The
required_spirv/forbidden_spirvassertions still pin the addressing choice — therecompiled module is still required to use
SubgroupLocalInvocationIdand must not useLocalInvocationIdor a reconstructed ballot — so nothing about what the case actually checks islost. Only the runtime pattern that was device-dependent is gone.
The underlying issue is bigger than this test
I do not think this should be closed as "just a test fix". What I found while isolating it:
state.lane_countis derived from the host subgroup size, but nothing ever declaresVK_SUBGROUP_SIZE_CONTROL.OpExecutionModenever carriesSubgroupSizeControl, andspirvEmitterModule.cpponly emitsExecutionModeLocalSize. The device already hasVkPhysicalDeviceVulkan13Features::subgroupSizeControlenabled at creation(
vulkanWindow.cpp:587), so the driver is free to pick any subgroup width it likes for a32-lane guest wave — and on my GPU it picks 64.
Wherever the recompiler assumes
SubgroupLocalInvocationIdis the wave lane, that assumptionbreaks together:
BufferLane(spirvEmitterMemory.cpp:76) masks with& 63unconditionally, so for a wave32shader on a 64-wide subgroup it yields the flat thread id — this is what the failing case saw.
ValueEmitContext::Ballot(spirvEmitterProgram.cpp) usesScopeSubgroup, which ballots acrossthe full 64 lanes rather than the guest's 32.
DsAppendAllocatesAcrossWaves32fails on the same machine and I believe it is the same rootcause: 256 threads with
wave_size = 32expects 8 waves, and the final LDS append counter doescome out right, but the per-lane allocation histogram collapses — bins 0–31 each get one hit,
bin 32 gets 32, everything after gets none. That is four 64-lane appends instead of eight 32-lane
ones. I have not touched that case, because confirming it needs hardware-truth I do not have
here.
A proper fix looks like emitting
SubgroupSizeControl = RequireSize 32for wave32 compute and64for wave64, gated on the device actually supportingVK_EXT_subgroup_size_control(thetest harness does not enable that feature today, so it would need that too). I have deliberately
not attempted it here — it touches device-capability plumbing and shader validity, and I cannot
validate it against a real game from this machine.
Testing
shader_recompiler_compute_testswith #930 and #933 merged in so the suite runs to completionhere. Failures on this machine go 5 → 4.
@theantipopau on GitHub · 2026-09-29 23:11 UTC · original
Superseded by #935, which fixes the underlying BufferLane wave-size mask.
@theantipopau on GitHub · 2026-09-29 23:12 UTC · original
Closing in favour of #935, which fixes the actual cause instead of working around it.
I had assumed here that the recompiler's choice of
SubgroupLocalInvocationIdwas right and the test's 64-thread workgroup was the problem. That was wrong.BufferLanemasks the lane id with a hardcoded63regardless of the guest wave size, so a wave32 shader running in a 64-wide subgroup gets the flat thread id and every per-lane buffer address is wrong.#935 masks by
state.program.wave_sizeinstead, and with itBufferStoreFormatXAddTidUsesLaneIndexpasses unchanged — the stricter 64-thread version this PR was relaxing. That is strictly better than what I proposed here: same coverage, one real defect fixed instead of one device dependency papered over.The underlying
VK_SUBGROUP_SIZE_CONTROLgap is documented in #935. The ballot half of it is still open, andDsAppendAllocatesAcrossWaves32still fails for that reason.Pull request closed