shader: read lane 0 in V_READFIRSTLANE_B32 when EXEC is empty #1573
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!1573
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1573/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?
@Nawid3333 on GitHub · 2026-10-16 23:23 UTC · original
Nawid3333:shader/readfirstlane-empty-exec→main· +49 −1 · 2 files · 1 commits · closed without mergingWith EXEC = 0, V_READFIRSTLANE_B32 reads lane 0 (RDNA2 guide: "Lane# = 0 if exec is zero. Ignores exec mask for the access."; RDNA4: "Force lane 0 if all lanes are disabled"). The native path took the lane from
OpGroupNonUniformBallotFindLSB, which is undefined on an empty ballot. The two-half path tookFindILsb(0) + 32, which is lane 31.Change (
EmitReadFirstLane): an empty ballot reads lane 0. A ReadFirstLane whose EXEC is the constant true keeps the old code.FirstLaneis unchanged, so this combines with #983.Test:
VectorReadFirstLaneEmptyExec(wave32 and wave64):v_readfirstlaneruns with EXEC emptied bys_mov_b64 exec, 0and byv_cmpx, then once with only lanes 33-63 active;After the change, all of these read lane 0.
If lane 0 is not a live invocation on the host (for example a culled pixel), the shuffle from it stays undefined (poison in SPIR-V), as for any lane the host doesn't have.
The same lane-0 rule is in shadowbeat070's f2d9a2bdb (part of the RE Engine bring-up #1495, where the old lane 31 left black pixels along character edges) and in ClGratton's port b164d6e4e3. This PR keeps only that part, without their
v_readlanechange.If you'd like this done differently, tell me and I'll change it.
Written with Claude Code (AI): it wrote the change and the test and ran them on my PC (driver 26.8.1, Windows 11). I reviewed the diff and this description before opening the PR.
🤖 Generated with Claude Code
RDNA2 reads lane 0 when EXEC is zero ("Lane# = 0 if exec is zero"). OpGroupNonUniformBallotFindLSB is undefined on an empty ballot, and the two-half path's FindILsb(0) + 32 named lane 31. With an empty EXEC the lane is now 0; a full EXEC keeps the old code.@coderabbitai[bot] on GitHub · 2026-10-16 23:26 UTC · original
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
8386232b-61a5-4bbf-ac2e-bbb473ba6753📥 Commits
Reviewing files that changed from the base of the PR and between
42bb0da520ande25853617e.📒 Files selected for processing: 2
src/graphics/shader/recompiler/backend/spirv/spirvEmitterFlow.cpptests/ShaderRecompilerComputeTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
📝 Walkthrough
When EXEC is not an immediate true value,
EmitReadFirstLanechecks whether the ballot is empty and selects lane 0 if it is. Otherwise, it uses the first lane as before. New compute tests cover wave32 and wave64 with empty EXEC and after comparisons.Suggested reviewers:
nmzikPriority: ➖ Normal
Change: Bug fix
Merge Risk: ⚪ Minimal · up to
e2585The empty-EXEC change appears ready to merge after normal checks; no outstanding issue was identified.
Pre-merge checks:
4 ·
1
Full details: Docstring Coverage
Explanation
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 1 files. (1 skipped: 1 too large.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
Comment
@coderabbitai helpto get the list of available commands.@NeySlim on GitHub · 2026-10-17 23:09 UTC · original
RADV data point: Radeon 8060S (RDNA 3.5), Mesa 26.2.4, against
763d3be3. On main both new tests fail here: with EXEC emptied bys_mov_b64 exec, 0or byv_cmpx, every lane gets its own value (lane + 64) instead of lane 0's, in wave32 and wave64; the wave64 pass with lanes 33-63 active gives 97 as expected. With the PR both pass and the rest of the suite is unchanged.@Nmzik on GitHub · 2026-10-21 23:42 UTC · original
Sole credited
Pull request closed