shader: exclude fragment helpers from ballots #761
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!761
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/761/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?
@carbonimax on GitHub · 2026-09-21 23:17 UTC · original
carbonimax:codex/fragment-helper-ballots→main· +617 −222 · 6 files · 4 commits · closed without mergingSummary
Validation
shader_recompiler_compute_tests --wave64-append-index-onlyshader_recompiler_compute_tests --ds-append-helper-quad-only0/1/210/11/12GDS[5] = 13ctest -R '^shader_recompiler_helper_quad$' --output-on-failureGDS[5] = 10, delta0f22c188, equivalent to PR head1540c7780to1293, then1983Validation boundaries
9525fe1with pinned SPIRV-Crossaaeadbdf; no MoltenVK change is included here.quad_is_helper_thread()substitution.@coderabbitai[bot] on GitHub · 2026-09-21 23:22 UTC · original · edited 2026-10-13 22:44 UTC
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
cf6eb82b-9a7c-4b46-bb5d-5ddc453be21d📥 Commits
Reviewing files that changed from the base of the PR and between 22b5a691bbca569beaf303841808904d07a68e45 and 1613cbc78f1d8bf6f6dd8071bf0e1c1ea5ce259b.
📒 Files selected for processing (5)
src/graphics/shader/recompiler/backend/spirv/spirvEmitterHelpers.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterInternal.hsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterProgram.cpptests/ShaderRecompilerComputeTests.cpp🚧 Files skipped from review as they are similar to previous changes (1)
Included 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 SPIR-V backend now filters helper invocations from subgroup ballot predicates when the helper-invocation input is available. The Vulkan test harness supports portable compute and graphics modes, configurable render dimensions, and optional GDS storage-buffer readback. New tests cover wave64
DS_APPENDindexing and helper-quad behavior forDS_APPENDandDS_SWIZZLE. CTest and command-line entries select the tests.Suggested reviewers:
nmzikPriority: ➖ Normal
Change: Bug fix
Merge Risk: 🟡 Moderate · up to
1613cThe GPU regressions can fail or validate the wrong behavior. Correct the test fixtures before merging.
Security Architecture Review
Security architecture risk: 🔵 Low · up to
b7e71The change restricts participation rather than widening access. No security vulnerability was established, but empty-participant behavior and the reported validation remain incompletely verified.
Retained concerns
No architecture-level concerns identified.
Security review details
Security Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Pre-merge checks |
4 |
1
❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
Full details: Docstring Coverage
Explanation
Docstring coverage is 3.85% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 26 functions across 4 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.@carbonimax on GitHub · 2026-09-21 23:53 UTC · original · edited 2026-09-21 23:56 UTC
Runtime validation on macOS (Apple M4 Pro), using source build
f22c188(the integration-stack equivalent of PR head1540c77):macgaming/mesh-shaderat9525fe1with pinned SPIRV-Crossaaeadbdfand no localquad_is_helper_thread()patch; the rebuilt library emitssimd_is_helper_thread();0/1/2, indices10/11/12, andGDS[5] = 13;Visual validation was unavailable because the Mac was locked. This result shows that the experimental SPIRV-Cross quad-helper substitution is not required for progression past frame 948.
@ -38662,0 +38879,4 @@0xbf800000u, 0x3f000000u, 0, 0, 0, 0x3f800000u,0x3f800000u, 0x3f800000u, 0, 0, 0, 0x3f800000u};test.gds_initial = {0, 0, 0, 0, 0, 10}; // GDS[5] countertest.expected_gds = {0, 0, 0, 0, 0, 0}; // sizes the GDS readback only@coderabbitai[bot] on GitHub · 2026-09-22 22:45 UTC · original · edited 2026-10-01 17:36 UTC
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 20501
Add a fragment helper test for masked lane reads.
GraphicsDsAppendHelperQuadchecks helper exclusion throughDS_APPEND’s execution-mask ballot. It does not exerciseEmitSubgroupLaneActiveBool, which the swizzle and bpermute masked-read paths call. The inspected swizzle and bpermute regressions are compute cases without helper invocations. A regression in fragment helper filtering on this path can therefore pass the helper-quad test. Add a fragment case that reads from a helper lane through swizzle or bpermute and asserts that the helper lane is excluded.✅ Confirmed as addressed by @carbonimax
@coderabbitai[bot] on GitHub · 2026-09-22 22:45 UTC · original · reviewed
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
b2bf7df6-ee0a-4ae2-a312-2e74aaa6b899📥 Commits
Reviewing files that changed from the base of the PR and between 1540c77ee0935c6be19dcef1bc2a8b2458e55a4f and bd57f5cab0c13398d4c2dce2703fa734ea7938f7.
📒 Files selected for processing (1)
tests/ShaderRecompilerComputeTests.cppIncluded review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.
@ -38662,0 +38879,4 @@0xbf800000u, 0x3f000000u, 0, 0, 0, 0x3f800000u,0x3f800000u, 0x3f800000u, 0, 0, 0, 0x3f800000u};test.gds_initial = {0, 0, 0, 0, 0, 10}; // GDS[5] countertest.expected_gds = {0, 0, 0, 0, 0, 0}; // sizes the GDS readback only@carbonimax on GitHub · 2026-10-01 17:27 UTC · original
Added GraphicsSwizzleHelperQuad: a 2x2 fragment quad with three covered pixels, a DS_SWIZZLE masked lane read, and an oracle derived from the covered lanes. It checks that a read from a helper source is excluded and that covered sources retain their value. The --fragment-helper-host-only selector compiles and validates SPIR-V without creating a Vulkan device, and checks the swizzle select dataflow through a !HelperInvocation ballot. That host check passes, fails (exit 134) when helper filtering is removed specifically from EmitSubgroupLaneActiveBool, and passes after restoration. The emulator, shader_cfg_tests and compute-test binary build on current main
44798085. The --swizzle-helper-quad-only GPU case is added and compiled but has not been executed during this update; no new GPU result is claimed.@ -38662,0 +38879,4 @@0xbf800000u, 0x3f000000u, 0, 0, 0, 0x3f800000u,0x3f800000u, 0x3f800000u, 0, 0, 0, 0x3f800000u};test.gds_initial = {0, 0, 0, 0, 0, 10}; // GDS[5] countertest.expected_gds = {0, 0, 0, 0, 0, 0}; // sizes the GDS readback only@coderabbitai[bot] on GitHub · 2026-10-01 17:36 UTC · original
@carbonimax, thanks for addingGraphicsSwizzleHelperQuad. The helper-source exclusion and covered-source checks address this finding.The reported host negative control targets
EmitSubgroupLaneActiveBool, which was the missing coverage. GPU execution remains unverified, as you stated.If you found this review helpful, would you consider giving us a shout-out on X?
Thank you for using CodeRabbit!
✅ Review thread resolved.
You are interacting with an AI system.
@carbonimax on GitHub · 2026-10-02 15:16 UTC · original · edited 2026-10-02 15:18 UTC
GPU tests on Apple M4 Pro / MoltenVK 1.4.3: DS_APPEND vs. the GDS region bounds check from #883, and the swizzle helper quad
DS_APPEND. At this PR's head (b7e7135),
GraphicsDsAppendHelperQuad(--ds-append-helper-quad-only, ctestshader_recompiler_helper_quad) fails:The emitted SPIR-V shows why. The test sets
M0 = 8(GDS region base 0, size 8 bytes) and appends at GDS offset 20. The GDS region bounds check that reached this branch from main with #883 (0791f92, merged here in b7e7135) requiresoffset + 3 < size, that is23 < 8. The atomic is skipped and the shader returns 0, while the per-pixel ranks (0/1/2) stay correct. As they stand, the test and the bounds check are incompatible.readfirstlane(not pushed). The DS_APPEND SPIR-V is byte-identical in both builds.Wave64AppendIndexFromExecRankuses the sameM0 = 8with offset 20, so its SPIR-V carries the same23 < 8guard. It has not run on GPU here.Swizzle. In the invocations above, the DS_APPEND abort stopped the process before
GraphicsSwizzleHelperQuadran; only its host predicate check (--fragment-helper-host-only) ran, and it passes. In a later invocation that ran it before DS_APPEND, it failed on GPU:Its guest code, SPIR-V and check are identical to b7e7135. The test does not print the values, so the following is read from the code, not from GPU output. The check uses the green channel as a lane ID, but that channel holds
v_mbcnt_lo_u32_b32(exec_lo, 0), the rank among EXEC lanes. On this GPU the uncovered pixel (0,0) is lane 0 (seen in other cases with the same vertices), so the ranks 0/1/2 differ from the lane IDs 1/2/3. The check then expects 7 where the source is the helper and 0 where it is a covered lane.The GPU coverage of this PR is not green on this setup at the moment.
@carbonimax on GitHub · 2026-10-02 15:50 UTC · original
Correction to my previous comment: the swizzle helper quad failure
My previous comment explained the
GraphicsSwizzleHelperQuadfailure with quad-permute semantics (each lane reading lane ^ 1). That mechanism was wrong. I have since logged the per-pixel values on the same setup (Apple M4 Pro, MoltenVK 1.4.3).The test encodes DS_SWIZZLE offset
0x00b1, documented as the quad selector [1,0,3,2]. Without offset[15], the ISA reads that offset in bitmask mode: and 0x11, or 0x05, xor 0. Every lane of the 2x2 quad then reads lane 5, which does not exist in that draw, so every covered pixel receives 0:The check also used the green channel,
v_mbcnt_lo_u32_b32(exec_lo, 0), which is the EXEC rank (0/1/2), as a lane number (1/2/3). So the failure came from both the encoding and the oracle. The emitted SPIR-V and the masked swizzle read itself were not at fault.With the quad-permute encoding the comment describes (
0x80b1), and an oracle taken from the guest code (EXEC rank and lane number exported separately), the helper source reads 0 and the covered sources read 7:In the same single invocation, the DS_APPEND helper quad and
Wave64AppendIndexFromExecRankpass with a GDS region covering their counter (M0 = 24: base 0, 24 bytes). The production bounds check from #883 is unchanged.@ -34123,0 +34265,4 @@TestCase Wave64AppendIndexFromExecRank() {using O = ShaderOpcode;std::vector<u32> code;AppendSMovLiteral(&code, 124, 8);@coderabbitai[bot] on GitHub · 2026-10-09 09:39 UTC · original
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Set
M0to 24 in both append fixtures.Both fixtures set
M0 = 8and use append offset 20. Under the reported GDS bounds check,offset + 3 < sizefails. The atomic is skipped, so the counter remains 10 and both GPU regressions fail despite correct helper filtering.Change both
AppendSMovLiteralcalls to use 24. The supplied validation report describes this correction, but the reviewed source still uses 8.This finding uses the GDS bounds-check and corrected-fixture evidence in the PR objectives.
Also applies to: 36331-36331
@ -38662,0 +38931,4 @@std::vector<u32> code;AppendVMovU32(&code, 2, 7);AppendVop3(&code, 0x365, 4, 126u, InlineU32(0));code.push_back(EncodeDs0(0x35, 0x00b1)); // quad selector [1,0,3,2]@coderabbitai[bot] on GitHub · 2026-10-09 09:39 UTC · original
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Correct the swizzle encoding and export lane identity separately from EXEC rank.
The fixture uses
0x00b1, but the runner expects the quad permutationlane ^ 1u. The supplied validation report identifies0x00b1as bitmask mode selecting lane 5 and reports that quad mode requires0x80b1.The fixture also exports
MBCNT(EXEC)as lane identity. With a helper lane excluded, EXEC rank does not identify the source lane. The runner therefore derives its expected result from the wrong identity.Use
0x80b1. Export lane identity separately from EXEC rank, and use lane identity for the covered-source lookup. The reported correction is not present in this source.This finding uses the encoding and rank-versus-lane correction evidence in the PR objectives.
@coderabbitai[bot] on GitHub · 2026-10-09 09:39 UTC · original · reviewed
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
d65b734b-de32-488a-97de-ac28273120c6📥 Commits
Reviewing files that changed from the base of the PR and between b7e713559dba7245228a68ad77dec1dc2eb4f179 and 22b5a691bbca569beaf303841808904d07a68e45.
📒 Files selected for processing (5)
CMakeLists.txtsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterInternal.hsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterProgram.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.
Pull request closed