shader: exclude fragment helpers from ballots #761

Closed
github-bot wants to merge 4 commits from gh-pr/761/head into gh-pr/761/base
Owner

@⁠carbonimax on GitHub · 2026-09-21 23:17 UTC · original
carbonimax:codex/fragment-helper-ballots → main · +617 −222 · 6 files · 4 commits · closed without merging

Summary

  • exclude fragment helper invocations from guest ballots
  • apply the same exclusion to the internal lane-activity ballot used by swizzle and bpermute
  • add a portable Vulkan fragment regression and register it with CTest

Validation

  • shader_recompiler_compute_tests --wave64-append-index-only
  • shader_recompiler_compute_tests --ds-append-helper-quad-only
    • uncovered pixel absent
    • ranks 0/1/2
    • indices 10/11/12
    • GDS[5] = 13
  • ctest -R '^shader_recompiler_helper_quad$' --output-on-failure
  • negative control without the four SPIR-V changes: CTest fails with GDS[5] = 10, delta 0
  • fresh macOS x86-64 integration build at f22c188, equivalent to PR head 1540c77
    • the intro video started and stopped
    • the game progressed from frame 80 to 1293, then 1983
    • the last two measurements were above the former frame-948 stall and increasing

Validation boundaries

  • The end-to-end run used MoltenVK 9525fe1 with pinned SPIRV-Cross aaeadbdf; no MoltenVK change is included here.
  • The run used the control MoltenVK build without the experimental quad_is_helper_thread() substitution.
  • The focused tests pass with the reference MoltenVK 1.4.2 build.
  • The clean local Xcode 27 build needs an unrelated one-line test compatibility fix already present in #640; it was applied only for local validation and is not part of this commit.
  • The Mac was locked during the integration run. Frame progression is confirmed, but visual correctness, an interactive menu, and playability are not.
**@⁠carbonimax** on GitHub · 2026-09-21 23:17 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/761) `carbonimax:codex/fragment-helper-ballots` → `main` · +617 −222 · 6 files · 4 commits · closed without merging ## Summary - exclude fragment helper invocations from guest ballots - apply the same exclusion to the internal lane-activity ballot used by swizzle and bpermute - add a portable Vulkan fragment regression and register it with CTest ## Validation - `shader_recompiler_compute_tests --wave64-append-index-only` - `shader_recompiler_compute_tests --ds-append-helper-quad-only` - uncovered pixel absent - ranks `0/1/2` - indices `10/11/12` - `GDS[5] = 13` - `ctest -R '^shader_recompiler_helper_quad$' --output-on-failure` - negative control without the four SPIR-V changes: CTest fails with `GDS[5] = 10`, delta `0` - fresh macOS x86-64 integration build at `f22c188`, equivalent to PR head `1540c77` - the intro video started and stopped - the game progressed from frame `80` to `1293`, then `1983` - the last two measurements were above the former frame-948 stall and increasing ## Validation boundaries - The end-to-end run used MoltenVK `9525fe1` with pinned SPIRV-Cross `aaeadbdf`; no MoltenVK change is included here. - The run used the control MoltenVK build without the experimental `quad_is_helper_thread()` substitution. - The focused tests pass with the reference MoltenVK 1.4.2 build. - The clean local Xcode 27 build needs an unrelated one-line test compatibility fix already present in #640; it was applied only for local validation and is not part of this commit. - The Mac was locked during the integration run. Frame progression is confirmed, but visual correctness, an interactive menu, and playability are not.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Apply the repository's pinned clang-format 22.1.3 hook to the source files modified by this pull request.

Assisted-by: OpenAI GPT-6.1 Sol
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:31:52 +00:00
github-bot closed this pull request 2026-11-26 09:31:52 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-09-21 23:22 UTC · original · edited 2026-10-13 22:44 UTC

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 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.cpp
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterInternal.h
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cpp
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterProgram.cpp
  • tests/ShaderRecompilerComputeTests.cpp
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cpp

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_APPEND indexing and helper-quad behavior for DS_APPEND and DS_SWIZZLE. CTest and command-line entries select the tests.

Suggested reviewers: nmzik

Priority: ➖ Normal

Change: Bug fix

Merge Risk: 🟡 Moderate · up to 1613c

The GPU regressions can fail or validate the wrong behavior. Correct the test fixtures before merging.

Security Architecture Review

Security architecture risk: 🔵 Low · up to b7e71

The 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

  • inferred — The identified security-relevant effect is within guest shader subgroup participation and existing shared-memory or GDS reservations. The inspected predicate change narrows eligibility rather than adding resource targets or memory authority.

Trust Boundaries and Controls

  • observed — The exclusion uses a StorageClassInput variable decorated BuiltInHelperInvocation. The original guest execution predicate remains an input to the restricted ballot rather than being replaced by a new authority source.

Resilience and Maintainability Implications

  • observed — The two-half reservation path requires a nonzero filtered count. The one-half path instead checks the original execution predicate, then unconditionally shuffles from the selected lane. This leaves empty-ballot result handling unresolved, not a demonstrated unauthorized write.
Pre-merge checks | Passed 4 | Inconclusive 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage Inconclusive 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… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check Passed The title clearly and concisely summarizes the primary change: excluding fragment helper invocations from ballots.
Description check Passed The description directly explains the ballot changes, regression tests, validation results, and known validation boundaries.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
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 help to get the list of available commands.

**@⁠coderabbitai[bot]** on GitHub · 2026-09-21 23:22 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/761#issuecomment-5768891346) · edited 2026-10-13 22:44 UTC <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/761?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=3"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3" alt="Review in Change Stack →" height="32"></picture></a> <!-- review_stack_entry_end --> <!-- This is an auto-generated comment: review paused by coderabbit.ai --> > [!NOTE] > ## Reviews paused > > It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the `reviews.auto_review.auto_pause_after_reviewed_commits` setting. > > Use the following commands to manage reviews: > - `@coderabbitai resume` to resume automatic reviews. > - `@coderabbitai review` to trigger a single review. > > Use the checkboxes below for quick actions: > - [ ] <!-- {"checkboxId":"7f6cc2e2-2e4e-497a-8c31-c9e4573e93d1"} --> ▶️ Resume reviews > - [ ] <!-- {"checkboxId":"e9bb8d72-00e8-4f67-9cb2-caf3b22574fe"} --> 🔍 Trigger review <!-- end of auto-generated comment: review paused by coderabbit.ai --> <!-- recent_review_start --> No actionable comments were generated in the recent review. 🎉 <details> <summary><strong>ℹ️ Recent review info</strong></summary> <dl> <dd> <details> <summary><strong>⚙️ Run configuration</strong></summary> <dl> <dd> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `cf6eb82b-9a7c-4b46-bb5d-5ddc453be21d` </dd> </dl> </details> <details> <summary><strong>📥 Commits</strong></summary> <dl> <dd> Reviewing files that changed from the base of the PR and between 22b5a691bbca569beaf303841808904d07a68e45 and 1613cbc78f1d8bf6f6dd8071bf0e1c1ea5ce259b. </dd> </dl> </details> <details> <summary><strong>📒 Files selected for processing (5)</strong></summary> <dl> <dd> * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterHelpers.cpp` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterInternal.h` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cpp` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterProgram.cpp` * `tests/ShaderRecompilerComputeTests.cpp` </dd> </dl> </details> <details> <summary><strong>🚧 Files skipped from review as they are similar to previous changes (1)</strong></summary> <dl> <dd> * src/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cpp </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. </dd> </dl> </details> <!-- recent_review_end --> <!-- walkthrough_start --> <details> <summary><strong>📝 Walkthrough</strong></summary> <dl> <dd> 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_APPEND` indexing and helper-quad behavior for `DS_APPEND` and `DS_SWIZZLE`. CTest and command-line entries select the tests. **Suggested reviewers:** `nmzik` </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ➖ Normal <!-- change_assessment_commit:"1613cbc78f1d8bf6f6dd8071bf0e1c1ea5ce259b" --> **Change:** Bug fix <!-- change_assessment_end --> <details> <summary><strong>Merge Risk:</strong> <strong>🟡 Moderate</strong> · up to <code>1613c</code></summary> <dl> <dd> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **🟡 Moderate** · up to `1613c` --> <!-- final_review_risk_coverage:{"sourceCommitId":"1613cbc78f1d8bf6f6dd8071bf0e1c1ea5ce259b","coveredCommitId":"1613cbc78f1d8bf6f6dd8071bf0e1c1ea5ce259b","kind":"reviewed"} --> The GPU regressions can fail or validate the wrong behavior. Correct the test fixtures before merging. <!-- final_review_risk_end --> </dd> </dl> </details> <!-- architecture_review_start --> <details> <summary><strong>Security Architecture Review</strong></summary> <dl> <dd> **Security architecture risk:** _🔵 Low_ · up to `b7e71` The 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. <details> <summary><h4><strong>Security review details</strong></h4></summary> <dl> <dd> **Security Blast Radius** - _inferred_ — The identified security-relevant effect is within guest shader subgroup participation and existing shared-memory or GDS reservations. The inspected predicate change narrows eligibility rather than adding resource targets or memory authority. **Trust Boundaries and Controls** - _observed_ — The exclusion uses a StorageClassInput variable decorated BuiltInHelperInvocation. The original guest execution predicate remains an input to the restricted ballot rather than being replaced by a new authority source. **Resilience and Maintainability Implications** - _observed_ — The two-half reservation path requires a nonzero filtered count. The one-half path instead checks the original execution predicate, then unconditionally shuffles from the selected lane. This leaves empty-ballot result handling unresolved, not a demonstrated unauthorized write. </dd> </dl> </details> </dd> </dl> </details> <!-- architecture_review_end --> <!-- pre_merge_checks_walkthrough_start --> <details> <summary><strong>Pre-merge checks | <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v1.svg" width="14" height="17" align="middle" alt="Passed" title="Passed"></picture></sup> 4 | <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-inconclusive-14-v1.svg" width="14" height="17" align="middle" alt="Inconclusive" title="Inconclusive"></picture></sup> 1</strong></summary> <dl> <dd> ### ❌ Failed checks (1 inconclusive) | Check name | Status | Explanation | Resolution | | :---------------- | :--------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ![Inconclusive](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-inconclusive.svg) | 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… | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary><strong>✅ Passed checks (4 passed)</strong></summary> <dl> <dd> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------- | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title clearly and concisely summarizes the primary change: excluding fragment helper invocations from ballots. | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description directly explains the ballot changes, regression tests, validation results, and known validation boundaries. | | Linked Issues check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | </dd> </dl> </details> <details> <summary><strong>Full details: Docstring Coverage</strong></summary> <dl> <dd> **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.) </dd> </dl> </details> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- tips_start --> Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=761)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary><strong>❤️ Share</strong></summary> <dl> <dd> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </dd> </dl> </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
Author
Owner

@⁠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 head 1540c77):

  • rebuilt MoltenVK macgaming/mesh-shader at 9525fe1 with pinned SPIRV-Cross aaeadbdf and no local quad_is_helper_thread() patch; the rebuilt library emits simd_is_helper_thread();
  • strict fragment regression passed: uncovered pixel absent, ranks 0/1/2, indices 10/11/12, and GDS[5] = 13;
  • compute wave64 regression passed;
  • one process of the game advanced from frame 78 to 790, then 1166 and 1498 at 10-62 fps. The final two measurements were both above the previous frame-948 stall and increasing;
  • the process was stopped cleanly after the criterion was met.

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.

**@⁠carbonimax** on GitHub · 2026-09-21 23:53 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/761#issuecomment-5769238455) · edited 2026-09-21 23:56 UTC Runtime validation on macOS (Apple M4 Pro), using source build `f22c188` (the integration-stack equivalent of PR head `1540c77`): - rebuilt MoltenVK `macgaming/mesh-shader` at `9525fe1` with pinned SPIRV-Cross `aaeadbdf` and no local `quad_is_helper_thread()` patch; the rebuilt library emits `simd_is_helper_thread()`; - strict fragment regression passed: uncovered pixel absent, ranks `0/1/2`, indices `10/11/12`, and `GDS[5] = 13`; - compute wave64 regression passed; - one process of the game advanced from frame 78 to 790, then 1166 and 1498 at 10-62 fps. The final two measurements were both above the previous frame-948 stall and increasing; - the process was stopped cleanly after the criterion was met. 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] counter
test.expected_gds = {0, 0, 0, 0, 0, 0}; // sizes the GDS readback only
Author
Owner

@⁠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:

rg -ni 'swizzle|bpermute|EmitSubgroupLaneActiveBool|helper.?quad|HelperQuad' tests
sed -n '27430,27512p' tests/ShaderRecompilerComputeTests.cpp

Repository: KytyPS5/KytyPS5

Length of output: 20501


Add a fragment helper test for masked lane reads.

GraphicsDsAppendHelperQuad checks helper exclusion through DS_APPEND’s execution-mask ballot. It does not exercise EmitSubgroupLaneActiveBool, 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](https://github.com/KytyPS5/KytyPS5/pull/761#discussion_r4077307695) · edited 2026-10-01 17:36 UTC _📐 Maintainability & Code Quality_ | _🟡 Minor_ | _⚡ Quick win_ <details> <summary>🔎 Supported by static analysis</summary> 🏁 Script executed: ```bash rg -ni 'swizzle|bpermute|EmitSubgroupLaneActiveBool|helper.?quad|HelperQuad' tests sed -n '27430,27512p' tests/ShaderRecompilerComputeTests.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 20501 --- </details> **Add a fragment helper test for masked lane reads.** `GraphicsDsAppendHelperQuad` checks helper exclusion through `DS_APPEND`’s execution-mask ballot. It does not exercise `EmitSubgroupLaneActiveBool`, 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. <!-- fingerprinting:phantom:medusa:serval --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:b08ca7508e1ac5ee1b8ff2e7 --> <!-- This is an auto-generated reply by CodeRabbit --> ✅ Confirmed as addressed by @⁠carbonimax <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠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.cpp

Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-09-22 22:45 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/761#pullrequestreview-5284760626) · **reviewed** **Actionable comments posted: 1** --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml **Review profile**: CHILL **Plan**: Advanced **Run ID**: `b2bf7df6-ee0a-4ae2-a312-2e74aaa6b899` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 1540c77ee0935c6be19dcef1bc2a8b2458e55a4f and bd57f5cab0c13398d4c2dce2703fa734ea7938f7. </details> <details> <summary>📒 Files selected for processing (1)</summary> * `tests/ShaderRecompilerComputeTests.cpp` </details> **Included review availability:** Your plan provides up to 10 included reviews per hour; 5 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
@ -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] counter
test.expected_gds = {0, 0, 0, 0, 0, 0}; // sizes the GDS readback only
Author
Owner

@⁠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.

**@⁠carbonimax** on GitHub · 2026-10-01 17:27 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/761#discussion_r4158418344) 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] counter
test.expected_gds = {0, 0, 0, 0, 0, 0}; // sizes the GDS readback only
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-01 17:36 UTC · original

@carbonimax, thanks for adding GraphicsSwizzleHelperQuad. 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.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-01 17:36 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/761#discussion_r4158498589) `@carbonimax`, thanks for adding `GraphicsSwizzleHelperQuad`. 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. --- <!-- This is an auto-generated comment: tweet message by coderabbit.ai --> If you found this review helpful, would you consider giving us a shout-out on [X](https://twitter.com/intent/tweet?related=CodeRabbitAI&text=A%20helper-lane%20gap%20is%20now%20covered%3A%20a%202%C3%972%20fragment%20swizzle%20test%20checks%20masked%20reads%20exclude%20helpers%2C%20with%20host%20validation%20catching%20regressions.%20Try%20%40coderabbitai!%20%F0%9F%A7%AA&url=https%3A%2F%2Fgithub.com%2FKytyPS5%2FKytyPS5%2Fpull%2F761%23discussion_r4077307695)? Thank you for using CodeRabbit! <!-- end of auto-generated comment: tweet message by coderabbit.ai --> ✅ Review thread resolved. _You are interacting with an AI system._ <!-- This is an auto-generated reply by CodeRabbit -->
Author
Owner

@⁠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, ctest shader_recompiler_helper_quad) fails:

[graphics] GraphicsDsAppendHelperQuad GDS[5]=10 delta=0 covered=3
GraphicsDsAppendHelperQuad failed at graphics DS_APPEND quad: DS_APPEND base is not 10

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) requires offset + 3 < size, that is 23 < 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.

  • The failure is identical with and without a local follow-up change to readfirstlane (not pushed). The DS_APPEND SPIR-V is byte-identical in both builds.
  • Wave64AppendIndexFromExecRank uses the same M0 = 8 with offset 20, so its SPIR-V carries the same 23 < 8 guard. It has not run on GPU here.

Swizzle. In the invocations above, the DS_APPEND abort stopped the process before GraphicsSwizzleHelperQuad ran; 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:

GraphicsSwizzleHelperQuad failed at graphics: swizzle read a helper lane or dropped a covered lane

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:16 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/761#issuecomment-5955463614) · 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`, ctest `shader_recompiler_helper_quad`) fails: ``` [graphics] GraphicsDsAppendHelperQuad GDS[5]=10 delta=0 covered=3 GraphicsDsAppendHelperQuad failed at graphics DS_APPEND quad: DS_APPEND base is not 10 ``` 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) requires `offset + 3 < size`, that is `23 < 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. - The failure is identical with and without a local follow-up change to `readfirstlane` (not pushed). The DS_APPEND SPIR-V is byte-identical in both builds. - `Wave64AppendIndexFromExecRank` uses the same `M0 = 8` with offset 20, so its SPIR-V carries the same `23 < 8` guard. It has not run on GPU here. **Swizzle.** In the invocations above, the DS_APPEND abort stopped the process before `GraphicsSwizzleHelperQuad` ran; 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: ``` GraphicsSwizzleHelperQuad failed at graphics: swizzle read a helper lane or dropped a covered lane ``` 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.
Author
Owner

@⁠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 GraphicsSwizzleHelperQuad failure 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:

GraphicsSwizzleHelperQuad offset=0x000000b1 pixel(1,0) lane=1 rank=0 source=5(absent) value=0 expected_rank=0 expected_value=0 ok
GraphicsSwizzleHelperQuad offset=0x000000b1 pixel(0,1) lane=2 rank=1 source=5(absent) value=0 expected_rank=1 expected_value=0 ok
GraphicsSwizzleHelperQuad offset=0x000000b1 pixel(1,1) lane=3 rank=2 source=5(absent) value=0 expected_rank=2 expected_value=0 ok

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:

GraphicsSwizzleHelperQuadPerm offset=0x000080b1 pixel(1,0) lane=1 rank=0 source=0(helper) value=0 expected_rank=0 expected_value=0 ok
GraphicsSwizzleHelperQuadPerm offset=0x000080b1 pixel(0,1) lane=2 rank=1 source=3(live) value=7 expected_rank=1 expected_value=7 ok
GraphicsSwizzleHelperQuadPerm offset=0x000080b1 pixel(1,1) lane=3 rank=2 source=2(live) value=7 expected_rank=2 expected_value=7 ok

In the same single invocation, the DS_APPEND helper quad and Wave64AppendIndexFromExecRank pass with a GDS region covering their counter (M0 = 24: base 0, 24 bytes). The production bounds check from #883 is unchanged.

**@⁠carbonimax** on GitHub · 2026-10-02 15:50 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/761#issuecomment-5956051839) **Correction to my previous comment: the swizzle helper quad failure** My previous comment explained the `GraphicsSwizzleHelperQuad` failure 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: ``` GraphicsSwizzleHelperQuad offset=0x000000b1 pixel(1,0) lane=1 rank=0 source=5(absent) value=0 expected_rank=0 expected_value=0 ok GraphicsSwizzleHelperQuad offset=0x000000b1 pixel(0,1) lane=2 rank=1 source=5(absent) value=0 expected_rank=1 expected_value=0 ok GraphicsSwizzleHelperQuad offset=0x000000b1 pixel(1,1) lane=3 rank=2 source=5(absent) value=0 expected_rank=2 expected_value=0 ok ``` 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: ``` GraphicsSwizzleHelperQuadPerm offset=0x000080b1 pixel(1,0) lane=1 rank=0 source=0(helper) value=0 expected_rank=0 expected_value=0 ok GraphicsSwizzleHelperQuadPerm offset=0x000080b1 pixel(0,1) lane=2 rank=1 source=3(live) value=7 expected_rank=1 expected_value=7 ok GraphicsSwizzleHelperQuadPerm offset=0x000080b1 pixel(1,1) lane=3 rank=2 source=2(live) value=7 expected_rank=2 expected_value=7 ok ``` In the same single invocation, the DS_APPEND helper quad and `Wave64AppendIndexFromExecRank` pass 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);
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-09 09:39 UTC · original

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Set M0 to 24 in both append fixtures.

Both fixtures set M0 = 8 and use append offset 20. Under the reported GDS bounds check, offset + 3 &lt; size fails. The atomic is skipped, so the counter remains 10 and both GPU regressions fail despite correct helper filtering.

Change both AppendSMovLiteral calls 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

**@⁠coderabbitai[bot]** on GitHub · 2026-10-09 09:39 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/761#discussion_r4228747299) **🎯 Functional Correctness** | **🟠 Major** | **⚡ Quick win** **Set `M0` to 24 in both append fixtures.** Both fixtures set `M0 = 8` and use append offset 20. Under the reported GDS bounds check, `offset + 3 &lt; size` fails. The atomic is skipped, so the counter remains 10 and both GPU regressions fail despite correct helper filtering. Change both `AppendSMovLiteral` calls 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 <!-- fingerprinting:phantom:medusa:wombat61 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:876cc6fd89f4928ea055a3bd --> <!-- This is an auto-generated comment by CodeRabbit -->
@ -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]
Author
Owner

@⁠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 permutation lane ^ 1u. The supplied validation report identifies 0x00b1 as bitmask mode selecting lane 5 and reports that quad mode requires 0x80b1.

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](https://github.com/KytyPS5/KytyPS5/pull/761#discussion_r4228747321) **🎯 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 permutation `lane ^ 1u`. The supplied validation report identifies `0x00b1` as bitmask mode selecting lane 5 and reports that quad mode requires `0x80b1`. 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. <!-- fingerprinting:phantom:medusa:wombat61 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:72061a5513e8eef4f0655d1e --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-09 09:39 UTC · original · reviewed

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 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.txt
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterInternal.h
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cpp
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterProgram.cpp
  • tests/ShaderRecompilerComputeTests.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-09 09:39 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/761#pullrequestreview-5468378958) · **reviewed** **Actionable comments posted: 2** --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `d65b734b-de32-488a-97de-ac28273120c6` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between b7e713559dba7245228a68ad77dec1dc2eb4f179 and 22b5a691bbca569beaf303841808904d07a68e45. </details> <details> <summary>📒 Files selected for processing (5)</summary> * `CMakeLists.txt` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterInternal.h` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cpp` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterProgram.cpp` * `tests/ShaderRecompilerComputeTests.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=74efa382-e2a6-4ea0-a3d5-99b7a0f6d4af attempt=2a21a0af-47fe-471b-9e19-8463bdfba2e9 batch=1/1 -->

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.