fix(shader): name the per-invocation value behind a spanned-wave fallback #22432
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/22432"
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 milescoviello on 2026-11-17T15:24:50Z.
What
When the spanned-wave uniformity check finds a barrier in divergent flow, the recompiler falls back to two lanes per invocation and logs the reason:
The line named the barrier's block, not the value. MXGP 26 (PPSA30839) logs 100 such fallbacks in one run and Borderlands 4 (PPSA01494) 168, and the log cannot tell which kind of value causes them. That decides what could keep those programs spanned.
The check now keeps a root for each per-invocation value it finds. A value derived from others takes the root of its first per-invocation operand. The roots are:
VaryingBuiltinlists);For each divergent construct it also keeps the branch that split it. The report appends that branch, its condition and the condition's root, for example:
The decision itself is unchanged: the same programs are rejected and accepted as on
main.Second commit. A private variable's load had one merged reason. Each variable now keeps the first of three reasons, which a fix would treat differently: a per-invocation value stored to it (with that value's root), a store through a per-invocation pointer, or a store in divergent flow (with the store's block).
MXGP 26 with the first commit (
maine7988a85b0+ #22052 + #22401 + #20827 + this PR's first commit, 600 s): 84 fallbacks in 42 distinct programs. The roots:Tested
spanned_uniformity(core/shader/recompiler/tests/SpannedUniformityTests.cpp) gains four cases that require the report to name the root: a lane comparison (the LocalInvocationIndex built-in, with the deciding branch and condition), a phi joining a per-lane selection, an atomic result, and a workgroup word read after a store with no barrier before the load. The existing cases, which check only whether a program is rejected, are unchanged.main'sSpirvSpannedUniformity.cppwith this PR's tests, on both: the four new cases fail, each with the old line, for exampleexpected a rejection naming "the branch at the end of block %100 on %102 decides it, and %102 comes from a load of the LocalInvocationIndex built-in", got an OpControlBarrier in block %103 of function %16 sits in control flow a per-invocation value decides.is stored in divergent flow in block %103for a store on one side of a per-lane selection, andis stored %101, which comes from a load of the LocalInvocationIndex built-infor a stored lane value. Linux: 3 of 3 pass; withmain'sSpirvSpannedUniformity.cppthe new cases fail.700f58b981merged ontomainaa11bb9111(WinLibs GCC 15.2, Release):spanned_uniformitypasses 3 of 3, and with only this PR's test onmainall six new reason cases fail with the old message. Their extra GPU check,agc_driver_spanned_ballot_sequenceon an AMD Radeon AI PRO R9700 with the Khronos validation layer, passes with 0VUID-lines. That device has no full 32-lane subgroups, so it skipped the spanned mode, ran only the two-lane path, and does not exercise this change.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T07:44:51Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the review is complete, and the inspected source and tests support merging.
What I ran
Reviewed head
700f58b9817c6685525db02283f164516e4fe460. No commands or tests were run in this review; the reported Linux and Windows runs are author supplied.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
No tests were run independently. The reported platform runs and negative control were not independently confirmed. Read
core/shader/recompiler/SpirvBackend/src/SpirvSpannedUniformity.cppandcore/shader/recompiler/tests/SpannedUniformityTests.cpp; both changed files listed as reviewed were included and read. No changed files were excluded.To get this to a good state
Nothing is required.