fix(shader): isolate wave32 operations on 64-lane host subgroups #1293

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

@⁠carbonimax on GitHub · 2026-10-09 10:23 UTC · original
carbonimax:fix/wave32-host64-subgroups → main · +189 −12 · 7 files · 2 commits · closed without merging

When a wave32 workgroup runs in a 64-lane host subgroup, two guest waves share that subgroup. The emitted subgroup lane IDs, ballots and shuffle targets currently address the whole host subgroup, so readfirstlane in the upper guest wave can read a value from the lower guest wave.

Keep lane IDs relative to the 32-lane guest wave, select its 32-bit ballot word, and translate shuffle targets to the corresponding physical host lanes. Apply the same translation to DS lane reads, append/consume broadcasts and DS_PERMUTE_B32.

The mode is derived from the existing guest wave size and host subgroup size. The current NGG workgroup routing, allocation protocol and input assembly remain unchanged.

Two CPU regressions compile a mesh workgroup with wave32, 64 logical invocations and a 64-lane host subgroup. They validate the emitted SPIR-V and check guest-wave ballot selection and physical shuffle targets for readfirstlane and DS_PERMUTE_B32. Each regression fails without the fix and passes with it.

Validation against 7b9997baea0d385e9e8fc2bd3abeb02110bc4148: Release x86_64 build passes; both targeted regressions and the complete shader_cfg_tests suite pass. Runtime behavior on a 64-lane subgroup GPU has not been tested.

**@⁠carbonimax** on GitHub · 2026-10-09 10:23 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1293) `carbonimax:fix/wave32-host64-subgroups` → `main` · +189 −12 · 7 files · 2 commits · closed without merging When a wave32 workgroup runs in a 64-lane host subgroup, two guest waves share that subgroup. The emitted subgroup lane IDs, ballots and shuffle targets currently address the whole host subgroup, so `readfirstlane` in the upper guest wave can read a value from the lower guest wave. Keep lane IDs relative to the 32-lane guest wave, select its 32-bit ballot word, and translate shuffle targets to the corresponding physical host lanes. Apply the same translation to DS lane reads, append/consume broadcasts and `DS_PERMUTE_B32`. The mode is derived from the existing guest wave size and host subgroup size. The current NGG workgroup routing, allocation protocol and input assembly remain unchanged. Two CPU regressions compile a mesh workgroup with wave32, 64 logical invocations and a 64-lane host subgroup. They validate the emitted SPIR-V and check guest-wave ballot selection and physical shuffle targets for `readfirstlane` and `DS_PERMUTE_B32`. Each regression fails without the fix and passes with it. Validation against `7b9997baea0d385e9e8fc2bd3abeb02110bc4148`: Release x86_64 build passes; both targeted regressions and the complete `shader_cfg_tests` suite pass. Runtime behavior on a 64-lane subgroup GPU has not been tested.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:51:51 +00:00
github-bot closed this pull request 2026-11-26 09:51:51 +00:00
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-10-09 10:23 UTC · original · edited 2026-10-09 10:31 UTC

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-09T10:31:02.586334Z 664b34e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@⁠codex review" or "@⁠codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-10-09 10:23 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1293#issuecomment-6079014270) · edited 2026-10-09 10:31 UTC <!-- codex-pull-request-review-summary --> ## Codex Review Summary This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-10-09T10:31:02.586334Z">2026-10-09T10:31:02.586334Z</relative-time> | `664b34e` | PR opened | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@⁠codex review" or "@⁠codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details>
Author
Owner

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

Review in Change Stack →

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: e5386a9b-2af7-45f5-8504-89a175c0b7a5

📥 Commits

Reviewing files that changed from the base of the PR and between 7b9997baea and 664b34e72e.


📒 Files selected for processing (7)
  • src/graphics/shader/recompiler/backend/spirv/SpirvEmitter.cpp
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterHelpers.cpp
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterInternal.h
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cpp
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cpp
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterProgram.cpp
  • tests/shaderCfgTests.cpp

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



📝 Walkthrough

Walkthrough

The SPIR-V emitter now enables packed wave32 handling for workgroups with wave size 32 on a host subgroup of 64. It maps guest lanes to physical subgroup lanes and selects the ballot word for the active guest-wave half. Subgroup shuffle and ballot operations use these mappings. New mesh-shader regression tests inspect generated SPIR-V for read-first-lane and DS_PERMUTE cases.

Suggested reviewers: nmzik


Priority: ➖ Normal

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 664b3

The packed-wave mappings and targeted regression coverage present no identified blocker to merging after normal checks.

🚥 Pre-merge checks | ✅ 4 | ❓ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage Inconclusive Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 6 files. (1 skipped: … 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 identifies the main change: isolating wave32 operations on 64-lane host subgroups.
Description check Passed The description directly explains the wave32 subgroup isolation problem, the implementation changes, regression coverage, and validation results.
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 12.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 6 files. (1 skipped: 1 too large.)



  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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-10-09 10:29 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1293#issuecomment-6079098793) <!-- 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/1293?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=2" alt="Review in Change Stack →" width="220" height="32"></a> <!-- review_stack_entry_end --> <!-- recent_review_start --> No actionable comments were generated in the recent review. 🎉 <details> <summary>ℹ️ Recent review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `e5386a9b-2af7-45f5-8504-89a175c0b7a5` <hr> </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 7b9997baea0d385e9e8fc2bd3abeb02110bc4148 and 664b34e72e7ecc5e55883a121c938eb75233bb8e. <hr> </details> <details> <summary>📒 Files selected for processing (7)</summary> * `src/graphics/shader/recompiler/backend/spirv/SpirvEmitter.cpp` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterHelpers.cpp` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterInternal.h` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cpp` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cpp` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterProgram.cpp` * `tests/shaderCfgTests.cpp` <hr> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 2 remain after this review. <hr> </details> --- <!-- recent_review_end --> <!-- walkthrough_start --> <details> <summary>📝 Walkthrough</summary> ## Walkthrough The SPIR-V emitter now enables packed wave32 handling for workgroups with wave size 32 on a host subgroup of 64. It maps guest lanes to physical subgroup lanes and selects the ballot word for the active guest-wave half. Subgroup shuffle and ballot operations use these mappings. New mesh-shader regression tests inspect generated SPIR-V for read-first-lane and DS_PERMUTE cases. **Suggested reviewers:** `nmzik` <hr> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ➖ Normal <!-- change_assessment_commit:"664b34e72e7ecc5e55883a121c938eb75233bb8e" --> **Change:** Bug fix <!-- change_assessment_end --> <!-- final_review_risk_start --> **Merge Risk:** **⚪ Minimal** · up to `664b3` <!-- final_review_risk_coverage:{"sourceCommitId":"664b34e72e7ecc5e55883a121c938eb75233bb8e","coveredCommitId":"664b34e72e7ecc5e55883a121c938eb75233bb8e","kind":"reviewed"} --> The packed-wave mappings and targeted regression coverage present no identified blocker to merging after normal checks. <!-- final_review_risk_end --> <!-- pre_merge_checks_walkthrough_start --> <details> <summary>🚥 Pre-merge checks | ✅ 4 | ❓ 1</summary> ### ❌ 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 12.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 6 files. (1 skipped: … | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary>✅ Passed checks (4 passed)</summary> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------ | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title clearly and concisely identifies the main change: isolating wave32 operations on 64-lane host subgroups. | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description directly explains the wave32 subgroup isolation problem, the implementation changes, regression coverage, and validation results. | | 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. | <hr> </details> <details> <summary>Full details: Docstring Coverage</summary> **Explanation** Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 6 files. (1 skipped: 1 too large.) <hr> </details> <hr> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- autopilot:start --> - [ ] <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autofix</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts <!-- autopilot:end --> <!-- tips_start --> --- Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=1293)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary>❤️ Share</summary> - [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) <hr> </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
Author
Owner

@⁠carbonimax on GitHub · 2026-10-10 21:04 UTC · original

Hi, was this closed under the AI policy, or because you consider it a duplicate? I checked #985, #935, #1143 and a8beac19: they handle branch decisions and one buffer-lane mask, not the lane IDs, ballots, shuffles and DS permutes this PR keeps inside each 32-lane guest wave.

AI disclosure: the patch and its two regressions were written by AI agents (Claude and Codex) and run on my M4 Pro; I reviewed the change and the test results. Happy to rebase or reopen as a fresh PR with this note in the description if that works better for you.

**@⁠carbonimax** on GitHub · 2026-10-10 21:04 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1293#issuecomment-6102157006) Hi, was this closed under the AI policy, or because you consider it a duplicate? I checked #985, #935, #1143 and a8beac19: they handle branch decisions and one buffer-lane mask, not the lane IDs, ballots, shuffles and DS permutes this PR keeps inside each 32-lane guest wave. AI disclosure: the patch and its two regressions were written by AI agents (Claude and Codex) and run on my M4 Pro; I reviewed the change and the test results. Happy to rebase or reopen as a fresh PR with this note in the description if that works better for you.

Pull request closed

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