shader: fix black eyes from wave64 OR scans #1503
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!1503
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1503"
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?
@NeySlim on GitHub · 2026-10-14 05:59 UTC · original
NeySlim:fix/gow-black-eyes→main· +748 −3 · 14 files · 1 commits · openTested in God of War Ragnarok (PPSA08332, 05.005).
In the opening cutscene the eyes of Atreus and of the deer are drawn as black blocks. The eye draws write NaN into the scene target and the half resolution passes (DOF, blur) spread it into squares. There were two causes. The first one, the f32 clamp modifier on NaN, is fixed on main now (
4f1f3b1bb, thenNClampin3c4124daf), so this PR only keeps the second one.Whole-wave OR of light masks. The pixel shader of the eyes ORs the light masks of its tile across the whole wave:
s_orn2_saveexec_b64with S = EXEC (all 64 lanes on),v_cndmask_b32 x, 0, v, s[34:35]with a mask taken from EXEC,v_or_b32_dppwith row_shr:1/2/4/8,v_permlanex16_b32,v_or_b32, thenv_readlane_b32of lanes 31 and 63. On the hardware the 64 lanes always exist and the lanes that were not launched contribute 0 through the cndmask. On the host a pixel wave only has the launched quads. For a small object (the eyes, the deer far away) lanes 31/63 often do not exist, and the shuffle behindv_permlanex16andv_readlanereads an invocation that is not there: the light mask is garbage, the shader reads random lights with zero matrices andrcp(0) * 0gives NaN.The fix recognizes this exact idiom in the translator and lowers it to a subgroup OR over the launched invocations:
v_cndmask x, 0, v, mwith m proven, followed by exactly row_shr 1, 2, 4, 8, permlanex16 with -1/-1 selects and the final or. Any other write to x, to the permlane result or to EXEC drops the match;v_readlaneof an immediate lane on it becomes a reduction over the lanes that feed that lane, emitted asOpGroupNonUniformBitwiseOr(Reduce / InclusiveScan, GroupNonUniformArithmetic). When the host subgroup is 32 wide (each half emitted separately), both halves are handled.Outside this proven pattern nothing changes. Other DPP, permlane or readlane reads of a lane the host did not launch keep the old behavior.
Testing (Linux, Radeon 8060S, RADV 26.2.3):
VectorWholeWaveOrReduction{4,20,32,40,64}(--whole-wave-reduction-only): two reductions like the game, readlane of lanes 15/31/47/63 and the per-lane values of x and of the permlane result, with 4 to 64 launched lanes. Without the second commit the readlane values are garbage (for 4 lanes 0x21be634c instead of 0xf). Variants with a literal mask, a broken chain and partial EXEC check that the pattern is not matched.Not tested on Windows. Recompiler and SPIR-V emitter code only. The 32-wide path is the one a 32-lane host subgroup (NVIDIA) takes.
Before (left, clamp fix only) and after (right, with this change):
AI use
I used Claude Code to write the change and the test and to run the measurements above. I reviewed the code and the results before opening the PR.
@coderabbitai[bot] on GitHub · 2026-10-14 06:02 UTC · original · edited 2026-10-21 06:55 UTC
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
ed52248f-068a-4c17-bfd3-4f969fc3a263📥 Commits
Reviewing files that changed from the base of the PR and between 49efdadb8a38ab9e61b6e9cff248b304ad3e4562 and
1861e4362c.📒 Files selected for processing: 6
src/graphics/shader/recompiler/backend/spirv/spirvEmitterFlow.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterInstructions.hsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterProgram.cppsrc/graphics/shader/recompiler/frontend/translate/Translate.cppsrc/graphics/shader/recompiler/ir/passes/ShaderInfoCollection.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
The translator now computes and tracks launched-lane masks for wave64 programs. It recognizes specified wave OR-scan instruction sequences and emits corresponding IR pattern operations. IR processing rewrites eligible lane reads, and the SPIR-V backend emits subgroup reductions for the patterns. Compute tests cover multiple thread counts and reduction variants.
Suggested reviewers:
nmzikPriority: ⚪ Not assessed
Change: Bug fix
Merge Risk: ⚪ Minimal · up to
1861eThis change adds subgroup-based lowering of wave64 OR reductions and a NaN-safe clamp to fix black eye artifacts. No concrete defect was found in the changed recompiler or SPIR-V paths, and the reduction tests cover the key thread-count boundaries. The change looks ready to merge.
Pre-merge checks:
4 ·
1
Full details: Docstring Coverage
Explanation
Docstring coverage is 23.40% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 47 functions across 15 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.@coderabbitai[bot] on GitHub · 2026-10-16 00:47 UTC · original · reviewed
🧹 Nitpick comments: 1
ℹ️ Review info
⚙️ Run configuration
fe8a8850-047d-407a-a129-07628b429beb📥 Commits
Reviewing files that changed from the base of the PR and between 83a848b5e47fb6a081513e97518186339a4146a7 and c871731f3631563bcad0cdba893945ed4356be42.
📒 Files selected for processing: 7
src/graphics/shader/recompiler/backend/spirv/spirvEmitterFlow.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterInstructions.hsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterProgram.cppsrc/graphics/shader/recompiler/ir/opcodes/ValueOpcodes.incsrc/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 8 included reviews per hour; 7 remain after this review.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.