shader: keep lane reads and writes inside the guest wave #2135
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!2135
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2135/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-11-06 07:33 UTC · original
theantipopau:fix/wave32-lane-transfers→main· +94 −24 · 6 files · 2 commits · closed without mergingA 32-lane guest wave runs in one half of a 64-lane host subgroup on AMD. Lane transfers used the
native subgroup lane, so the wave in the upper half read and wrote the lower wave's registers:
V_READLANE_B32,V_READFIRSTLANE_B32and the DPP source lane passed the guest lane straightto
OpGroupNonUniformShuffle, and ballot lookups picked their word fromwave_sizeinstead offrom the caller's half, so the upper wave read the other wave's values.
V_WRITELANE_B32compared its lane against the native lane, which never matches in the upperhalf, so the write was dropped there.
EliminateReadLanefoldedV_READLANEof a written lane to that lane's own value operand.Hardware broadcasts the value the selected lane wrote, so this is only equivalent when that
value is wave-uniform; with a per-lane value every thread read its own register instead of the
writer's.
Lane numbers are now relative to the guest wave, ballot words are selected by the caller's lanes,
and the fold is guarded by
ValidateWaveUniformValue. The scalar capture pattern(
s_mov+v_writelane+v_readlane) still folds, whichVectorReadlaneInactiveWrittenLanecontinues to cover.
Testing on an RX 9070 XT (RADV, subgroup size 64),
shader_recompiler_compute:register, and a readlane of the written lane; all three cover both halves of the subgroup
ctestreports 82/82Existing 32-thread lane cases always landed in the lower half, which is why this stayed green
there. I could not test NVIDIA or Intel hardware.
@coderabbitai[bot] on GitHub · 2026-11-06 07:38 UTC · original
Walkthrough
The SPIR-V backend now maps wave32 lane operations to the caller’s native subgroup half. Shader info collection requests subgroup-local invocation IDs for
DppMoveU32,ReadFirstLane, andReadLane. ReadLane elimination now substitutes matchedWriteLanevalues only when they are wave-uniform. A compute test checks lane writes and reads across two 32-lane waves.Suggested reviewers:
nmzikChange: Bug fix
Merge Risk:
Moderate · up to
b77fbOn hosts with a 64-lane subgroup, DPP operations in the upper half of a 32-lane guest wave can return zero instead of the real source value, which gives wrong shader results. Fix the ballot range check before merging.
Pre-merge checks:
4 ·
1
Full details: Docstring Coverage
Explanation
Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 6 functions across 5 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
@ -208,0 +196,4 @@// emulated half both live in word one.const auto word = EmitNative<spv::OpVectorExtractDynamic, IR::Type::U32>(state, active_ballot,Binary(state, spv::OpShiftRightLogical, TypeU32(state), lane, ConstantU32(state, 5)));@coderabbitai[bot] on GitHub · 2026-11-06 07:38 UTC · original
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 3037
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 8568
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 20209
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 9852
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 11214
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 9454
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 4448
Check the guest-relative lane in the range test.
For a wave32 in native lanes 32–63,
EmitDppMoveU32passes a physical source lane to the ballot check. The range test rejects that lane, so DPP can return zero for an active source whenfetch_inactiveis false.Keep the physical lane for ballot-word selection. Use
lane_lowfor the wave32 range check and retainlanefor wave64.Suggested fix
@coderabbitai[bot] on GitHub · 2026-11-06 07:38 UTC · original · reviewed
Actionable comments posted: 1
db09292b-8c02-422b-9390-1ef1dcb6b59dReviewing files that changed from the base of the PR and between
b6cc1fff27andb77fb9e155.src/graphics/shader/recompiler/backend/spirv/spirvEmitterFlow.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterHelpers.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterProgram.cppsrc/graphics/shader/recompiler/ir/passes/ReadLaneElimination.cppsrc/graphics/shader/recompiler/ir/passes/ShaderInfoCollection.cpptests/ShaderRecompilerComputeTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Pull request closed