shader: test a wave-wide zero branch as no lane failing #985
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!985
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/985/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?
@wuboo on GitHub · 2026-10-02 21:01 UTC · original
wuboo:pr/zero-branch-ballot→main· +59 −14 · 4 files · 2 commits · closed without mergingProblem
s_cbranch_execz,s_cbranch_vcczands_cbranch_scc0are taken when the condition holds on every lane.EmitConditionRefon current main implements that as an all-ones ballot: AND the two wave halves and compare with~0.A ballot does not set bits for lanes that have no work. A per-vertex capture wave past the vertex count, or a wave64 shader run as two wave32 halves, therefore never sees all-ones. Every such loop stays taken and runs until an iteration cap, or forever if there is no cap.
On Astro Bot's world scene that was about 50 seconds per frame at a cap of 65536 iterations, once per vertex.
35759e48(wave32 guards) andf29bd0fe(ballot reuse) do not change this compare.EmitConditionRefstill usesOpBitwiseAndandOpIEqualagainst~0for a*Zerobranch. The split itself is still there:lane_countis 2 when the guest wave is 64 and the host subgroup is 32.Change
For a
*Zerobranch the ballot is of the inverted condition, the two halves are OR-ed, and the branch is taken when that word is 0: no lane fails the condition. Lanes that never vote do not keep the wave in the loop. When every lane is active the result matches the old all-ones test.Other branches stay "any lane is true" (
OpINotEqualagainst 0), without the invert.Tests
shader_cfg_tests, Release, macOS,KYTY_VS_LANE_FROM_INDEX=0: exit 0.TestZeroBranchBallotIgnoresInactiveLanescompiles the same small loop ass_cbranch_execzand ass_cbranch_execnz, withwave_size64 andhost_subgroup_size32. Both binaries validate. The execz binary contains moreOpLogicalNot(opcode 168) than the execnz binary, which is the inverted ballot.Release
kyty_emulatorfrom this branch links.Limits
The test checks the opcode, not a rendered frame.
@coderabbitai[bot] on GitHub · 2026-10-02 21:06 UTC · original · edited 2026-10-02 21:29 UTC
Navigate logical layers of code changes, visualize relationships, and explore their blast radius.
📝 Walkthrough
Walkthrough
The SPIR-V emitter now negates ballot predicates for
ExecZero,VccZero, andSccZero, then checks whether the combined ballot words are zero. Other branch conditions retain the nonzero comparison. A regression test compiles and validates EXECZ and EXECNZ shaders with host subgroup size 32 and wave size 64, then compares their opcode 168 counts.Suggested reviewers:
nmzikPriority: ⬇️ Low
Change: Bug fix
Merge Risk: 🔵 Low · up to
139a2The zero-branch change is mergeable with a bounded testing gap: the new test does not check that EXECZ takes the intended reduction direction.
🚥 Pre-merge checks | ✅ 4 | ❓ 1
❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
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 3 functions across 3 files. (1 skipped: 1 too large.)
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-02 21:06 UTC · original · reviewed
🧹 Nitpick comments (1)
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
0fbb8d96-f80b-4ea0-bf34-904cecbfe60c📥 Commits
Reviewing files that changed from the base of the PR and between
e317465d8aand139a260e49.📒 Files selected for processing (4)
src/graphics/shader/recompiler/backend/spirv/spirvEmitterFlow.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterInternal.hsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterProgram.cpptests/shaderCfgTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 4 remain after this review.
@wuboo on GitHub · 2026-10-02 21:29 UTC · original
Re the nitpick on the reduction direction:
daff547eadds direct checks. The EXECZ fixture must have moreOpIEqual(170) and the EXECNZ fixture moreOpINotEqual(171). The fixtures contain no other integer compares (EXECZ 170=1/171=0, EXECNZ 170=0/171=1), so the comparison is exact. Swapping the two opcodes in the emitter makes the test abort.@Nmzik on GitHub · 2026-10-21 19:41 UTC · original
Superseded by
bb2d6dbeb.Pull request closed