shader: share indirect image query bodies inside the caller's wave #2142

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

@⁠theantipopau on GitHub · 2026-11-06 23:00 UTC · original
theantipopau:fix/indirect-image-query-wave → main · +431 −29 · 13 files · 7 commits · closed without merging

This is stacked on #2136 (fix/wave32-vote-reduce): the first two commits belong to that PR and drop out of this diff once it lands. The three new commits are the indirect-image work, its wave-local vote fix, and the test-contract update.

Upstream already supports dynamic indirect image tables and per-candidate query selection. What is still missing is the long-table path: a materialized image array can hold hundreds of candidates, and one static query body per candidate grows the module with the array.

  • Runs of consecutive descriptor slots now share one wave-uniform loop, so the per-lane answer is picked with a predicate and an iteration no lane asked for costs a compare and a vote instead of an image query.
  • On a wide wave32 host that vote now reads only the caller's ballot word, so the other wave sharing the native subgroup cannot keep a body alive for a descriptor this wave never selected. Native OpGroupNonUniformAny stays for every other host.
  • IndirectImageQueryDimensions asserts one body per candidate rather than one per type, checks that the dynamic query image needs no nonuniform decoration and still selects through the switch, and the long-table fixture asserts exactly one ballot and two query bodies at wave32 on a 64-lane host.

Local checks on this AMD machine: the filtered indirect-image compute group passes and shader_cfg_tests exits 0. The full compute suite stops earlier in GpuSelectedFormattedRgba16Store, a pre-existing failure of this branch's base on this driver.

**@⁠theantipopau** on GitHub · 2026-11-06 23:00 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2142) `theantipopau:fix/indirect-image-query-wave` → `main` · +431 −29 · 13 files · 7 commits · closed without merging This is stacked on #2136 (fix/wave32-vote-reduce): the first two commits belong to that PR and drop out of this diff once it lands. The three new commits are the indirect-image work, its wave-local vote fix, and the test-contract update. Upstream already supports dynamic indirect image tables and per-candidate query selection. What is still missing is the long-table path: a materialized image array can hold hundreds of candidates, and one static query body per candidate grows the module with the array. - Runs of consecutive descriptor slots now share one wave-uniform loop, so the per-lane answer is picked with a predicate and an iteration no lane asked for costs a compare and a vote instead of an image query. - On a wide wave32 host that vote now reads only the caller's ballot word, so the other wave sharing the native subgroup cannot keep a body alive for a descriptor this wave never selected. Native OpGroupNonUniformAny stays for every other host. - IndirectImageQueryDimensions asserts one body per candidate rather than one per type, checks that the dynamic query image needs no nonuniform decoration and still selects through the switch, and the long-table fixture asserts exactly one ballot and two query bodies at wave32 on a 64-lane host. Local checks on this AMD machine: the filtered indirect-image compute group passes and shader_cfg_tests exits 0. The full compute suite stops earlier in GpuSelectedFormattedRgba16Store, a pre-existing failure of this branch's base on this driver.
A wave32 guest wave occupies one half of a 64-lane native subgroup, so
subgroup-wide Any/All and UMin/UMax/BitwiseOr also saw the neighbouring
wave's EXEC and values. Votes now compare the caller's ballot word (All
against that word's active lanes), and reductions lower to a five-step
shuffle-xor butterfly over the half's lane bits. Wave64 waves and 32-lane
host subgroups keep their existing paths.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <[email protected]>
The wave32 vote cases asserted the ballot-word lowering even when the harness compiles at the device's own subgroup size, so a 32-lane host was required to emit the opcode it must not. Split the contract into plain and wide lists chosen from the compiled host size, and cover both ConditionRef lowerings in the CPU vote test.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <[email protected]>
A materialized image array can hold hundreds of candidates, and one query body per candidate grows the module with the array. Runs of consecutive descriptor slots now share one wave-uniform loop, the per-lane answer is picked with a predicate, and iterations no lane asked for cost only a compare and a vote instead of an image query.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <[email protected]>
An indirect image table long enough to share one query body per descriptor run voted with OpGroupNonUniformAny over the whole native subgroup, so the wave in the other half could keep a body alive for a descriptor this wave never selected. Wide wave32 now compares the caller's ballot word, with the subgroup-id builtin and ballot capability gated for image-only programs, and the native vote stays for every other host. The long-run fixture asserts both lowerings.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <[email protected]>
The query-dimension case still asserted one body per image type, so the per-candidate switch the emitter builds for a lane-selected descriptor tripped the body budget. Count the specialized candidates and keep the module-size limit per wave half.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <[email protected]>
The emitter assumed every stage without workgroup metadata ran on a 64-lane subgroup, so a wave32 pixel shader on a 32-lane host took the split-wave shuffle path, where inactive invocations make shuffle results undefined. Carry the device subgroup size through CompileOptions and pass it from the pipeline cache.

🤖 Generated with Codebuff

Co-Authored-By: Codebuff <[email protected]>
The emitted wave32 fallback depends on the native subgroup size and on
whether compute subgroup control is available. Include both in the shader
store header so a cache written on one GPU is not warmed up on another.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:15:58 +00:00
github-bot closed this pull request 2026-11-26 10:15:58 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-06 23:08 UTC · original · edited 2026-11-08 22:15 UTC

Explain Change →

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.

  • Last reviewed commit: 6b923372ae53dff81b70d9c64461d0f2b62611da
  • Latest commit, not reviewed: d992f09f83

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
Walkthrough

The SPIR-V emitter now tracks host subgroup size. For wave32 guest execution on a wider host subgroup, it uses ballot-based condition votes and XOR shuffle reductions. Large indirect image-dimension queries use shared loops over compatible candidate groups, while smaller lists use an index switch. Tests cover wide-host and matching-size subgroup cases, query instruction counts, and emitted SPIR-V.

Suggested reviewers: nmzik

Change: Refactor

Merge Risk: Moderate · previous review 6b923

After switching to a GPU with a different subgroup size, stale cached shaders can produce wrong results for wave32 votes or reductions. Include the subgroup size in the shader-store header before merging.

Pre-merge checks: Passed 4 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Docstring Coverage Inconclusive Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed

Check name Status Explanation
Title check Passed The title names the main change: indirect image query bodies are shared in a wave-uniform loop. The changeset adds EmitSharedIndirectImageQuery, which groups consecutive descriptor slots into shared l…
Description check Passed The description states the purpose of the change: a long-table path for indirect image queries, where consecutive descriptor slots share a wave-uniform loop. It also explains the wave32 ballot-word vo…
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: Title check

Explanation

The title names the main change: indirect image query bodies are shared in a wave-uniform loop. The changeset adds EmitSharedIndirectImageQuery, which groups consecutive descriptor slots into shared loops, and the wave-local ballot handling matches the 'inside the caller's wave' part. It is specific and single-sentence, though it uses internal jargon. This is a PASS.

Full details: Description check

Explanation

The description states the purpose of the change: a long-table path for indirect image queries, where consecutive descriptor slots share a wave-uniform loop. It also explains the wave32 ballot-word vote fix, the test updates, and the local test results. It relates directly to the changeset, so this is a PASS.

Full details: Docstring Coverage

Explanation

Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 12 functions across 10 files. (1 skipped: 1 too large.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Tip

🎯 Customize your risk assessments

Guide how CodeRabbit assesses merge risk and security architecture risk. Highlight sensitive changes and explain your security boundaries using Merge Risk Instructions and Security Risk Instructions in your review settings. Security architecture risk assessments require the Advanced plan or above.

✅ Automatic approvals, with your rules

Let CodeRabbit approve pull requests once required threads are resolved, pre-merge checks pass, and your risk limits are met. Enable Automatic approvals in review settings, with overrides for teams or file paths.

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

**@⁠coderabbitai[bot]** on GitHub · 2026-11-06 23:08 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2142#issuecomment-6698053408) · edited 2026-11-08 22:15 UTC <!-- coderabbit-ai-generated:v1 --> <!-- 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/2142?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-buttons-v1/explain-change-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change.svg" alt="Explain Change →" 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. > > - Last reviewed commit: 6b923372ae53dff81b70d9c64461d0f2b62611da > - Latest commit, not reviewed: d992f09f83bc00f5d7945177822a350930ab6759 > > 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 --> <!-- walkthrough_start --> <details> <summary><strong>Walkthrough</strong></summary> <dl> <dd> <br> The SPIR-V emitter now tracks host subgroup size. For wave32 guest execution on a wider host subgroup, it uses ballot-based condition votes and XOR shuffle reductions. Large indirect image-dimension queries use shared loops over compatible candidate groups, while smaller lists use an index switch. Tests cover wide-host and matching-size subgroup cases, query instruction counts, and emitted SPIR-V. **Suggested reviewers:** `nmzik` </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> <!-- change_assessment_commit:"6b923372ae53dff81b70d9c64461d0f2b62611da" --> <!-- change_assessment_priority:{"version":1,"urgency":"p3","manual":false} --> **Change:** Refactor <!-- change_assessment_end --> <details> <summary><strong>Merge Risk:</strong> <strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/risk-normal-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Moderate</strong> · previous review <code>6b923</code></summary> <dl> <dd> <br> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **🟡 Moderate** · up to `6b923` --> <!-- final_review_risk_coverage:{"sourceCommitId":"6b923372ae53dff81b70d9c64461d0f2b62611da","coveredCommitId":"6b923372ae53dff81b70d9c64461d0f2b62611da","kind":"reviewed"} --> After switching to a GPU with a different subgroup size, stale cached shaders can produce wrong results for wave32 votes or reductions. Include the subgroup size in the shader-store header before merging. <!-- final_review_risk_end --> </dd> </dl> </details> <!-- 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-v2.svg" width="14" height="14" 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-v2.svg" width="14" height="14" align="middle" alt="Inconclusive" title="Inconclusive"></picture></sup> 1</strong></summary> <dl> <dd> <br> <strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> Failed checks: 1 inconclusive</strong> | Check name | Status | Explanation | Resolution | | :---------------- | :--------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ![Inconclusive](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-inconclusive.svg) | Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary><strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> Passed checks: 4 passed</strong></summary> <dl> <dd> <br> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title names the main change: indirect image query bodies are shared in a wave-uniform loop. The changeset adds EmitSharedIndirectImageQuery, which groups consecutive descriptor slots into shared l… | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description states the purpose of the change: a long-table path for indirect image queries, where consecutive descriptor slots share a wave-uniform loop. It also explains the wave32 ballot-word vo… | | 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. | <details> <summary><strong>Full details: Title check</strong></summary> <dl> <dd> <br> **Explanation** The title names the main change: indirect image query bodies are shared in a wave-uniform loop. The changeset adds EmitSharedIndirectImageQuery, which groups consecutive descriptor slots into shared loops, and the wave-local ballot handling matches the 'inside the caller's wave' part. It is specific and single-sentence, though it uses internal jargon. This is a PASS. </dd> </dl> </details> <details> <summary><strong>Full details: Description check</strong></summary> <dl> <dd> <br> **Explanation** The description states the purpose of the change: a long-table path for indirect image queries, where consecutive descriptor slots share a wave-uniform loop. It also explains the wave32 ballot-word vote fix, the test updates, and the local test results. It relates directly to the changeset, so this is a PASS. </dd> </dl> </details> </dd> </dl> </details> <details> <summary><strong>Full details: Docstring Coverage</strong></summary> <dl> <dd> <br> **Explanation** Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 12 functions across 10 files. (1 skipped: 1 too large.) **Resolution** Write docstrings for the functions missing them to satisfy the coverage threshold. </dd> </dl> </details> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- announcements_start --> > [!TIP] > <details> > <summary><strong>🎯 Customize your risk assessments</strong></summary> > <dl> > <dd> > <br> > > Guide how CodeRabbit assesses merge risk and security architecture risk. Highlight sensitive changes and explain your security boundaries using **Merge Risk Instructions** and **Security Risk Instructions** in your review settings. Security architecture risk assessments require the **Advanced plan or above**. > > </dd> > </dl> > </details> > > <details> > <summary><strong>✅ Automatic approvals, with your rules</strong></summary> > <dl> > <dd> > <br> > > Let CodeRabbit approve pull requests once required threads are resolved, pre-merge checks pass, and your risk limits are met. Enable **Automatic approvals** in review settings, with overrides for teams or file paths. > > </dd> > </dl> > </details> <!-- announcements_end --> <!-- tips_start --> Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=2142)! 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> <br> - [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> <!-- tips_end -->
@ -466,0 +466,4 @@
// A 32-lane guest wave that shares its native subgroup with a second guest wave.
bool WideWave32(const EmitterState& state) {
return state.program.wave_size == 32u && state.host_subgroup_size != 32u;
}
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-06 23:08 UTC · original · edited 2026-11-07 04:25 UTC

Major · Functional Correctness · Heavy lift

Supported by static analysis

Script executed:

git diff 182161eb3e31439d97433607a8aa95463c56a9cc c01de550add44cf736725b4398bd7de183b8f689 -- src/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cpp
rg -n -F -e 'WideWave32' -e 'host_subgroup_size' -e 'ShaderWorkgroupInput' -e 'lane_count' -e 'SubgroupInvocationID' -- src/graphics/shader | cat

Repository: KytyPS5/KytyPS5

Length of output: 10079


Script executed:

for spec in \
 'src/graphics/shader/shader.h:60:95' \
 'src/graphics/shader/shader.h:210:260' \
 'src/graphics/shader/recompiler/backend/spirv/SpirvEmitter.cpp:20:80' \
 'src/graphics/shader/recompiler/backend/spirv/spirvEmitterFlow.cpp:780:900' \
 'src/graphics/shader/recompiler/backend/spirv/spirvEmitterImage.cpp:680:790' \
 'src/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cpp:575:600'; do
 IFS=: read -r f a b <<< "$spec"; echo "=== $f:$a-$b"; nl -ba "$f" | sed -n "${a},${b}p"
done
echo '=== Graphics host subgroup and wave assignments'
rg -n -F -e 'host_subgroup_size' -e 'subgroupSize' -e 'wave_size =' -e 'wave_size{' -- src/graphics/host_gpu src/graphics/shader | cat

Repository: KytyPS5/KytyPS5

Length of output: 27054


Script executed:

for spec in \
 'src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp:330:410' \
 'src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp:675:740' \
 'src/graphics/shader/shader.cpp:300:355' \
 'src/graphics/shader/shader.cpp:520:565' \
 'src/graphics/shader/recompiler/backend/spirv/spirvEmitterHelpers.cpp:130:230' \
 'src/graphics/shader/recompiler/backend/spirv/spirvEmitterProgram.cpp:450:545'; do
 IFS=: read -r f a b <<< "$spec"; echo "=== $f:$a-$b"; nl -ba "$f" | sed -n "${a},${b}p"
done
echo '=== Definitions and pipeline size configuration'
rg -n -F -e 'HalfBallotWord' -e 'BallotOf(' -e 'subgroup_size' -e 'requiredSubgroupSize' -e 'REQUIRE_FULL_SUBGROUPS' -- src/graphics/host_gpu/renderer/pipeline src/graphics/shader/recompiler/backend/spirv src/graphics/host_gpu | cat

Repository: KytyPS5/KytyPS5

Length of output: 29963


Script executed:

rg -n -F -e 'EmitSubgroupLocalInvocationId(' -e 'SubgroupUMinU32' -e 'SubgroupUMaxU32' -e 'SubgroupOrU32' -e 'helper_invocation' -e 'demote' -- src/graphics/shader/recompiler | cat
rg -n -F -e 'subgroup_size =' -e 'subgroupSize' -e 'ShaderStageRequiredSubgroupSize' -- src/graphics/host_gpu src/graphics/presentation | cat
git diff 182161eb3e31439d97433607a8aa95463c56a9cc c01de550add44cf736725b4398bd7de183b8f689 -- src/graphics/shader/recompiler/backend/spirv/spirvEmitterFlow.cpp src/graphics/shader/recompiler/backend/spirv/spirvEmitterProgram.cpp

Repository: KytyPS5/KytyPS5

Length of output: 10812


Web query:

Vulkan SPIR-V SubgroupLocalInvocationId fragment helper invocations ballot helper invocations undefined OpGroupNonUniformShuffleXor inactive invocation

Result:

Sources consulted:
- Shader Interfaces :: Vulkan Documentation Project — https://docs.vulkan.org/spec/latest/chapters/interfaces.html
- SPIR-V Specification — https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.pdf
- Vulkan® 1.4.351 - A Specification (with all ratified extensions) — https://registry.khronos.org/vulkan/specs/latest-ratified/pdf/vkspec.pdf
- Vulkan® SC 1.0.20 - A Specification (with all registered Vulkan SC extensions) : Based on Vulkan 1.2.330 — https://registry.khronos.org/VulkanSC/specs/1.0-extensions/pdf/vkspec.pdf
- …and 28 more

Script executed:

for spec in \
 'src/graphics/shader/recompiler/ir/passes/ReadLaneElimination.cpp:140:260' \
 'src/graphics/shader/recompiler/backend/spirv/spirvEmitterProgram.cpp:210:260' \
 'src/graphics/shader/recompiler/backend/spirv/spirvEmitterHelpers.cpp:50:120' \
 'src/graphics/host_gpu/renderer/pipeline/shaders.cpp:1:190' \
 'src/graphics/presentation/window/vulkanWindow.cpp:460:490'; do
 IFS=: read -r f a b <<< "$spec"; echo "=== $f:$a-$b"; nl -ba "$f" | sed -n "${a},${b}p"
done
rg -n -F -e 'ReadLaneEliminationPass' -e 'ReadLaneElimination' -- src/graphics/shader/recompiler

Repository: KytyPS5/KytyPS5

Length of output: 24586


Web query:

Vulkan SPIR-V OpGroupNonUniformShuffleXor resulting value undefined inactive invocation mask subgroup current invocation specification

Result:

Sources consulted:
- SPIR-V Specification — https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.pdf
- # Non-uniform Group Operations — https://vulkan.org/user/pages/09.events/vulkanised-2025/T08-Hugo-Devillers-SaarlandUniversity.pdf
- Khronos Template 2015 — https://www.khronos.org/assets/uploads/developers/library/2018-vulkan-devday/06-subgroups.pdf
- SPIR-V Specification — https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html
- SPIR-V Specification — https://registry.khronos.org/SPIR-V/specs/1.0/SPIRV.pdf
- …and 24 more

Script executed:

for spec in \
 'src/graphics/shader/recompiler/ir/passes/ShaderInfoCollection.cpp:490:545' \
 'src/graphics/shader/recompiler/ShaderRecompiler.cpp:250:340' \
 'src/graphics/shader/recompiler/ir/passes/ReadLaneElimination.cpp:95:145' \
 'src/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cpp:810:845'; do
 IFS=: read -r f a b <<< "$spec"; echo "=== $f:$a-$b"; nl -ba "$f" | sed -n "${a},${b}p"
done
rg -n -F -e 'subgroup_vote' -e 'EliminateReadLane(' -e 'ConditionRef' -- src/graphics/shader/recompiler/ir src/graphics/shader/recompiler/ShaderRecompiler.cpp | cat

Repository: KytyPS5/KytyPS5

Length of output: 13869


Use the host subgroup size for non-workgroup stages.

On a 32-lane host, a wave32 pixel shader still takes the wide-wave reduction path. If an invocation is inactive, the shuffle reduction can produce an undefined result. Pass the host subgroup size to these stages so they use the native reduction on 32-lane hosts.

✅ Addressed in commit 9fe7cc0

**@⁠coderabbitai[bot]** on GitHub · 2026-11-06 23:08 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2142#discussion_r4498575304) · edited 2026-11-07 04:25 UTC <!-- coderabbit-ai-generated:v1 --> **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/major-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Major** · **Functional Correctness** · **Heavy lift** <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/review-details-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/review-details.svg" width="16" height="16" align="absmiddle" alt=""></picture> Supported by static analysis</summary> <dl> <dd> <br> Script executed: ```bash git diff 182161eb3e31439d97433607a8aa95463c56a9cc c01de550add44cf736725b4398bd7de183b8f689 -- src/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cpp rg -n -F -e 'WideWave32' -e 'host_subgroup_size' -e 'ShaderWorkgroupInput' -e 'lane_count' -e 'SubgroupInvocationID' -- src/graphics/shader | cat ``` Repository: KytyPS5/KytyPS5 Length of output: 10079 --- Script executed: ```bash for spec in \ 'src/graphics/shader/shader.h:60:95' \ 'src/graphics/shader/shader.h:210:260' \ 'src/graphics/shader/recompiler/backend/spirv/SpirvEmitter.cpp:20:80' \ 'src/graphics/shader/recompiler/backend/spirv/spirvEmitterFlow.cpp:780:900' \ 'src/graphics/shader/recompiler/backend/spirv/spirvEmitterImage.cpp:680:790' \ 'src/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cpp:575:600'; do IFS=: read -r f a b <<< "$spec"; echo "=== $f:$a-$b"; nl -ba "$f" | sed -n "${a},${b}p" done echo '=== Graphics host subgroup and wave assignments' rg -n -F -e 'host_subgroup_size' -e 'subgroupSize' -e 'wave_size =' -e 'wave_size{' -- src/graphics/host_gpu src/graphics/shader | cat ``` Repository: KytyPS5/KytyPS5 Length of output: 27054 --- Script executed: ```bash for spec in \ 'src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp:330:410' \ 'src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp:675:740' \ 'src/graphics/shader/shader.cpp:300:355' \ 'src/graphics/shader/shader.cpp:520:565' \ 'src/graphics/shader/recompiler/backend/spirv/spirvEmitterHelpers.cpp:130:230' \ 'src/graphics/shader/recompiler/backend/spirv/spirvEmitterProgram.cpp:450:545'; do IFS=: read -r f a b <<< "$spec"; echo "=== $f:$a-$b"; nl -ba "$f" | sed -n "${a},${b}p" done echo '=== Definitions and pipeline size configuration' rg -n -F -e 'HalfBallotWord' -e 'BallotOf(' -e 'subgroup_size' -e 'requiredSubgroupSize' -e 'REQUIRE_FULL_SUBGROUPS' -- src/graphics/host_gpu/renderer/pipeline src/graphics/shader/recompiler/backend/spirv src/graphics/host_gpu | cat ``` Repository: KytyPS5/KytyPS5 Length of output: 29963 --- Script executed: ```bash rg -n -F -e 'EmitSubgroupLocalInvocationId(' -e 'SubgroupUMinU32' -e 'SubgroupUMaxU32' -e 'SubgroupOrU32' -e 'helper_invocation' -e 'demote' -- src/graphics/shader/recompiler | cat rg -n -F -e 'subgroup_size =' -e 'subgroupSize' -e 'ShaderStageRequiredSubgroupSize' -- src/graphics/host_gpu src/graphics/presentation | cat git diff 182161eb3e31439d97433607a8aa95463c56a9cc c01de550add44cf736725b4398bd7de183b8f689 -- src/graphics/shader/recompiler/backend/spirv/spirvEmitterFlow.cpp src/graphics/shader/recompiler/backend/spirv/spirvEmitterProgram.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 10812 --- Web query: `Vulkan SPIR-V SubgroupLocalInvocationId fragment helper invocations ballot helper invocations undefined OpGroupNonUniformShuffleXor inactive invocation` Result: ``` Sources consulted: - Shader Interfaces :: Vulkan Documentation Project — https://docs.vulkan.org/spec/latest/chapters/interfaces.html - SPIR-V Specification — https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.pdf - Vulkan® 1.4.351 - A Specification (with all ratified extensions) — https://registry.khronos.org/vulkan/specs/latest-ratified/pdf/vkspec.pdf - Vulkan® SC 1.0.20 - A Specification (with all registered Vulkan SC extensions) : Based on Vulkan 1.2.330 — https://registry.khronos.org/VulkanSC/specs/1.0-extensions/pdf/vkspec.pdf - …and 28 more ``` --- Script executed: ```bash for spec in \ 'src/graphics/shader/recompiler/ir/passes/ReadLaneElimination.cpp:140:260' \ 'src/graphics/shader/recompiler/backend/spirv/spirvEmitterProgram.cpp:210:260' \ 'src/graphics/shader/recompiler/backend/spirv/spirvEmitterHelpers.cpp:50:120' \ 'src/graphics/host_gpu/renderer/pipeline/shaders.cpp:1:190' \ 'src/graphics/presentation/window/vulkanWindow.cpp:460:490'; do IFS=: read -r f a b <<< "$spec"; echo "=== $f:$a-$b"; nl -ba "$f" | sed -n "${a},${b}p" done rg -n -F -e 'ReadLaneEliminationPass' -e 'ReadLaneElimination' -- src/graphics/shader/recompiler ``` Repository: KytyPS5/KytyPS5 Length of output: 24586 --- Web query: `Vulkan SPIR-V OpGroupNonUniformShuffleXor resulting value undefined inactive invocation mask subgroup current invocation specification` Result: ``` Sources consulted: - SPIR-V Specification — https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.pdf - # Non-uniform Group Operations — https://vulkan.org/user/pages/09.events/vulkanised-2025/T08-Hugo-Devillers-SaarlandUniversity.pdf - Khronos Template 2015 — https://www.khronos.org/assets/uploads/developers/library/2018-vulkan-devday/06-subgroups.pdf - SPIR-V Specification — https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html - SPIR-V Specification — https://registry.khronos.org/SPIR-V/specs/1.0/SPIRV.pdf - …and 24 more ``` --- Script executed: ```bash for spec in \ 'src/graphics/shader/recompiler/ir/passes/ShaderInfoCollection.cpp:490:545' \ 'src/graphics/shader/recompiler/ShaderRecompiler.cpp:250:340' \ 'src/graphics/shader/recompiler/ir/passes/ReadLaneElimination.cpp:95:145' \ 'src/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cpp:810:845'; do IFS=: read -r f a b <<< "$spec"; echo "=== $f:$a-$b"; nl -ba "$f" | sed -n "${a},${b}p" done rg -n -F -e 'subgroup_vote' -e 'EliminateReadLane(' -e 'ConditionRef' -- src/graphics/shader/recompiler/ir src/graphics/shader/recompiler/ShaderRecompiler.cpp | cat ``` Repository: KytyPS5/KytyPS5 Length of output: 13869 --- </dd> </dl> </details> **Use the host subgroup size for non-workgroup stages.** On a 32-lane host, a wave32 pixel shader still takes the wide-wave reduction path. If an invocation is inactive, the shuffle reduction can produce an undefined result. Pass the host subgroup size to these stages so they use the native reduction on 32-lane hosts. <!-- fingerprinting:phantom:poseidon:beignet55 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:b660b4d81caee24b217dfbf3 --> <!-- This is an auto-generated reply by CodeRabbit --> ✅ Addressed in commit 9fe7cc0 <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-06 23:08 UTC · original · reviewed

Actionable comments posted: 1

Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 182161eb3e and c01de550add44cf736725b4398bd7de183b8f689.

Files selected for processing: 8

  • src/graphics/shader/recompiler/backend/spirv/SpirvEmitter.cpp
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterFlow.cpp
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterImage.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
  • tests/shaderCfgTests.cpp

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

**@⁠coderabbitai[bot]** on GitHub · 2026-11-06 23:08 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2142#pullrequestreview-5808232060) · **reviewed** <!-- coderabbit-ai-generated:v1 --> **Actionable comments posted: 1** <h6> <details> <summary><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/info.svg" width="12" height="12" align="absmiddle" alt=""></picture> Review info</summary> <dl> <dd> <br> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog.svg" width="16" height="16" align="absmiddle" alt=""></picture> Run configuration</summary> <dl> <dd> <br> - **Source mode**: Auto - **Repository**: [KytyPS5/KytyPS5](<https://github.com/KytyPS5/KytyPS5>) - **Branch**: [main](<https://github.com/KytyPS5/KytyPS5/tree/main>) - **File**: [.coderabbit.yaml](<https://github.com/KytyPS5/KytyPS5/blob/182161eb3e31439d97433607a8aa95463c56a9cc/.coderabbit.yaml>) - **Commit**: [182161e](<https://github.com/KytyPS5/KytyPS5/commit/182161eb3e31439d97433607a8aa95463c56a9cc>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `2df24dc6-7819-40b8-be78-fabec9b71ef5` </dd> </dl> </details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal.svg" width="16" height="16" align="absmiddle" alt=""></picture> Commits</summary> <dl> <dd> <br> Reviewing files that changed from the base of the PR and between 182161eb3e31439d97433607a8aa95463c56a9cc and c01de550add44cf736725b4398bd7de183b8f689. </dd> </dl> </details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner.svg" width="16" height="16" align="absmiddle" alt=""></picture> Files selected for processing: 8</summary> <dl> <dd> <br> * `src/graphics/shader/recompiler/backend/spirv/SpirvEmitter.cpp` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterFlow.cpp` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterImage.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` * `tests/shaderCfgTests.cpp` </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. </dd> </dl> </details> </h6> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=623204cf-8b8c-40be-8041-e636f7d35cde attempt=9d15ad74-66cb-4bb1-9f2a-148fb71df71b batch=1/1 -->
@ -466,0 +466,4 @@
// A 32-lane guest wave that shares its native subgroup with a second guest wave.
bool WideWave32(const EmitterState& state) {
return state.program.wave_size == 32u && state.host_subgroup_size != 32u;
}
Author
Owner

@⁠theantipopau on GitHub · 2026-11-07 04:24 UTC · original

Fixed in 9fe7cc04: the pipeline cache now passes the device subgroup size for non-workgroup stages, so wave32 pixel shaders use native subgroup reductions on 32-lane hosts. Added a pixel-stage regression test that fails without the emitter change.

**@⁠theantipopau** on GitHub · 2026-11-07 04:24 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2142#discussion_r4500079322) Fixed in 9fe7cc04: the pipeline cache now passes the device subgroup size for non-workgroup stages, so wave32 pixel shaders use native subgroup reductions on 32-lane hosts. Added a pixel-stage regression test that fails without the emitter change.
@ -466,0 +466,4 @@
// A 32-lane guest wave that shares its native subgroup with a second guest wave.
bool WideWave32(const EmitterState& state) {
return state.program.wave_size == 32u && state.host_subgroup_size != 32u;
}
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-07 04:24 UTC · original

@⁠theantipopau Thanks for fixing this and adding the pixel-stage regression test.


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-11-07 04:24 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2142#discussion_r4500081040) <!-- coderabbit-ai-generated:v1 --> @⁠theantipopau Thanks for fixing this and adding the pixel-stage regression test. --- <!-- 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=%40coderabbitai%20caught%20a%20subtle%20shader%20bug%3A%20wave32%20pixel%20shaders%20used%20unsafe%20wide-wave%20reductions%20on%2032-lane%20hosts.%20Passing%20the%20host%20subgroup%20size%20enables%20native%20reductions%E2%80%94and%20a%20regression%20test%20guards%20the%20fix.%20Try%20CodeRabbit%20%F0%9F%90%87&url=https%3A%2F%2Fgithub.com%2FKytyPS5%2FKytyPS5%2Fpull%2F2142%23discussion_r4498575304)? Thank you for using CodeRabbit! <!-- end of auto-generated comment: tweet message by coderabbit.ai --> Review thread resolved. <sub><i>You are interacting with an AI system.</i></sub> <!-- This is an auto-generated reply by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-07 11:57 UTC · original · reviewed

Nitpick comments: 1

tests/ShaderRecompilerComputeTests.cpp: 1

45893-45943: Trivial · Maintainability & Code Quality · Quick win

Check the reduction shuffle masks.

TestSpirvWave32HalfReductions checks opcode counts but not shuffle masks. A repeated mask can leave a lane bit out without failing the test. Assert masks 1, 2, 4, 8, 16 for each reduction.

Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 9fe7cc040dda2d3a60e5ad8dd41e7da18697a662 and 8cf6a47642f1f59ebc2f89b82438123fcbc70263.

Files selected for processing: 1

  • tests/ShaderRecompilerComputeTests.cpp

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

**@⁠coderabbitai[bot]** on GitHub · 2026-11-07 11:57 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2142#pullrequestreview-5812053379) · **reviewed** <!-- coderabbit-ai-generated:v1 --> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/brush-cleaning-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/brush-cleaning.svg" width="16" height="16" align="absmiddle" alt=""></picture> Nitpick comments: 1</summary><blockquote> <dl> <dd> <br> <details> <summary>tests/ShaderRecompilerComputeTests.cpp: 1</summary><blockquote> <dl> <dd> <br> `45893-45943`: **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/neutral-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Trivial** · **Maintainability & Code Quality** · **Quick win** **Check the reduction shuffle masks.** `TestSpirvWave32HalfReductions` checks opcode counts but not shuffle masks. A repeated mask can leave a lane bit out without failing the test. Assert masks `1, 2, 4, 8, 16` for each reduction. <!-- cr-comment:v1:b61d898ba708ecf5dda6a702 --> </dd> </dl> </blockquote></details> </dd> </dl> </blockquote></details> <h6> <details> <summary><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/info.svg" width="12" height="12" align="absmiddle" alt=""></picture> Review info</summary> <dl> <dd> <br> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog.svg" width="16" height="16" align="absmiddle" alt=""></picture> Run configuration</summary> <dl> <dd> <br> - **Source mode**: Auto - **Repository**: [KytyPS5/KytyPS5](<https://github.com/KytyPS5/KytyPS5>) - **Branch**: [main](<https://github.com/KytyPS5/KytyPS5/tree/main>) - **File**: [.coderabbit.yaml](<https://github.com/KytyPS5/KytyPS5/blob/589bd14a9b8934a85e951d1aaa8112a05d62354c/.coderabbit.yaml>) - **Commit**: [589bd14](<https://github.com/KytyPS5/KytyPS5/commit/589bd14a9b8934a85e951d1aaa8112a05d62354c>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `089fe69a-2df6-4627-aa68-675b61590881` </dd> </dl> </details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal.svg" width="16" height="16" align="absmiddle" alt=""></picture> Commits</summary> <dl> <dd> <br> Reviewing files that changed from the base of the PR and between 9fe7cc040dda2d3a60e5ad8dd41e7da18697a662 and 8cf6a47642f1f59ebc2f89b82438123fcbc70263. </dd> </dl> </details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner.svg" width="16" height="16" align="absmiddle" alt=""></picture> Files selected for processing: 1</summary> <dl> <dd> <br> * `tests/ShaderRecompilerComputeTests.cpp` </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. </dd> </dl> </details> </h6> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=98253bb4-e76d-4c5a-828b-6c8b5580ced4 attempt=9fab0251-4dba-46c4-8bf1-cb992d128d5f batch=1/1 -->
@ -390,1 +390,4 @@
}
if (ShaderWorkgroupInput(options.stage, options.input_info) == nullptr) {
// Graphics stages have no workgroup metadata; their native subgroups are the device's.
options.host_subgroup_size = m_graphics.subgroup_size;
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-07 20:11 UTC · original · edited 2026-11-07 21:24 UTC

Major · Data Integrity & Integration · Quick win

Include the subgroup size in shader-store invalidation.

If a user switches GPUs with different subgroup sizes but matching shader-store headers, WarmUp reloads graphics SPIR-V compiled for the old size. The graphics stage keys also omit this value, so GetProgram can reuse that module and produce incorrect wave32 votes or reductions. Include m_graphics.subgroup_size in the shader-store header so incompatible records are discarded before warm-up. (raw.githubusercontent.com)

✅ Addressed in commits e3c2f9f to 444395a

**@⁠coderabbitai[bot]** on GitHub · 2026-11-07 20:11 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2142#discussion_r4503554155) · edited 2026-11-07 21:24 UTC <!-- coderabbit-ai-generated:v1 --> **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/major-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Major** · **Data Integrity & Integration** · **Quick win** **Include the subgroup size in shader-store invalidation.** If a user switches GPUs with different subgroup sizes but matching shader-store headers, `WarmUp` reloads graphics SPIR-V compiled for the old size. The graphics stage keys also omit this value, so `GetProgram` can reuse that module and produce incorrect wave32 votes or reductions. Include `m_graphics.subgroup_size` in the shader-store header so incompatible records are discarded before warm-up. ([raw.githubusercontent.com](https://raw.githubusercontent.com/KytyPS5/KytyPS5/6b923372ae53dff81b70d9c64461d0f2b62611da/src/graphics/host_gpu/renderer/pipeline/pipelineSerialization.cpp)) <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:3176ede6ca9012c1d0e442b1 --> <!-- This is an auto-generated reply by CodeRabbit --> ✅ Addressed in commits e3c2f9f to 444395a
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-07 20:11 UTC · original · reviewed

Actionable comments posted: 1

Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between bd6391f45405caabb956a740074dd506d5983ae9 and 6b923372ae53dff81b70d9c64461d0f2b62611da.

Files selected for processing: 2

  • src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp
  • tests/ShaderRecompilerComputeTests.cpp

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

**@⁠coderabbitai[bot]** on GitHub · 2026-11-07 20:11 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2142#pullrequestreview-5814714229) · **reviewed** <!-- coderabbit-ai-generated:v1 --> **Actionable comments posted: 1** <h6> <details> <summary><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/info.svg" width="12" height="12" align="absmiddle" alt=""></picture> Review info</summary> <dl> <dd> <br> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog.svg" width="16" height="16" align="absmiddle" alt=""></picture> Run configuration</summary> <dl> <dd> <br> - **Source mode**: Auto - **Repository**: [KytyPS5/KytyPS5](<https://github.com/KytyPS5/KytyPS5>) - **Branch**: [main](<https://github.com/KytyPS5/KytyPS5/tree/main>) - **File**: [.coderabbit.yaml](<https://github.com/KytyPS5/KytyPS5/blob/27f290e9573ed19c7fd0f4bc35467b8dea82140c/.coderabbit.yaml>) - **Commit**: [27f290e](<https://github.com/KytyPS5/KytyPS5/commit/27f290e9573ed19c7fd0f4bc35467b8dea82140c>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `a5639657-8abd-4917-92c5-81c5306d033c` </dd> </dl> </details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal.svg" width="16" height="16" align="absmiddle" alt=""></picture> Commits</summary> <dl> <dd> <br> Reviewing files that changed from the base of the PR and between bd6391f45405caabb956a740074dd506d5983ae9 and 6b923372ae53dff81b70d9c64461d0f2b62611da. </dd> </dl> </details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner.svg" width="16" height="16" align="absmiddle" alt=""></picture> Files selected for processing: 2</summary> <dl> <dd> <br> * `src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp` * `tests/ShaderRecompilerComputeTests.cpp` </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review. </dd> </dl> </details> </h6> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=a03ee3c2-f1bf-4d7f-909f-7cad61888d8c attempt=60c60713-5aec-461e-bfcd-850ed1db93ca batch=1/1 -->
@ -390,1 +390,4 @@
}
if (ShaderWorkgroupInput(options.stage, options.input_info) == nullptr) {
// Graphics stages have no workgroup metadata; their native subgroups are the device's.
options.host_subgroup_size = m_graphics.subgroup_size;
Author
Owner

@⁠theantipopau on GitHub · 2026-11-07 21:23 UTC · original

Fixed in 444395a: the shader store header now records the host subgroup size and the compute subgroup-control flag, so records compiled for different wave behaviour are discarded before WarmUp.

**@⁠theantipopau** on GitHub · 2026-11-07 21:23 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2142#discussion_r4503798108) Fixed in 444395a: the shader store header now records the host subgroup size and the compute subgroup-control flag, so records compiled for different wave behaviour are discarded before WarmUp.
@ -390,1 +390,4 @@
}
if (ShaderWorkgroupInput(options.stage, options.input_info) == nullptr) {
// Graphics stages have no workgroup metadata; their native subgroups are the device's.
options.host_subgroup_size = m_graphics.subgroup_size;
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-07 21:25 UTC · original

Analysis chain

Script executed:

#!/bin/bash
set -u
printf '%s\n' '=== Current revision and reported commit ==='
git rev-parse HEAD
git show -s --format='%h %s' 444395a 2>&1 || true
printf '%s\n' '=== Serialization outline ==='
ast-grep outline src/graphics/host_gpu/renderer/pipeline/pipelineSerialization.cpp --items all 2>&1 || true
printf '%s\n' '=== Header and warm-up references ==='
rg -n -C 5 'subgroup_size|subgroup.*control|SupportsComputeWave64|WarmUp|StoreHeader|ShaderStore|shader.store' src/graphics/host_gpu/renderer/pipeline/pipelineSerialization.cpp src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp
printf '%s\n' '=== Relevant test references ==='
rg -n -i -C 3 'shader.store|subgroup.*(header|cache|store)|warm.?up' tests || true

Length of output: 22271


Script executed:

#!/bin/bash
set -u
printf '%s\n' '=== WarmUp header validation ==='
sed -n '143,206p' src/graphics/host_gpu/renderer/pipeline/pipelineSerialization.cpp
printf '%s\n' '=== Shader-store test outline ==='
ast-grep outline tests/ShaderRecompilerComputeTests.cpp --match CheckShaderStore --view expanded 2>&1 || true
printf '%s\n' '=== Shader-store test ==='
sed -n '49257,49430p' tests/ShaderRecompilerComputeTests.cpp

Length of output: 12598


@theantipopau Verified in 444395a: StoreHeader includes both values, and WarmUp loads records only when the header matches. I did not run tests.


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-11-07 21:25 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2142#discussion_r4503802576) <!-- coderabbit-ai-generated:v1 --> <details> <summary>Analysis chain</summary> <dl> <dd> <br> Script executed: ```shell #!/bin/bash set -u printf '%s\n' '=== Current revision and reported commit ===' git rev-parse HEAD git show -s --format='%h %s' 444395a 2>&1 || true printf '%s\n' '=== Serialization outline ===' ast-grep outline src/graphics/host_gpu/renderer/pipeline/pipelineSerialization.cpp --items all 2>&1 || true printf '%s\n' '=== Header and warm-up references ===' rg -n -C 5 'subgroup_size|subgroup.*control|SupportsComputeWave64|WarmUp|StoreHeader|ShaderStore|shader.store' src/graphics/host_gpu/renderer/pipeline/pipelineSerialization.cpp src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp printf '%s\n' '=== Relevant test references ===' rg -n -i -C 3 'shader.store|subgroup.*(header|cache|store)|warm.?up' tests || true ``` Length of output: 22271 --- Script executed: ```shell #!/bin/bash set -u printf '%s\n' '=== WarmUp header validation ===' sed -n '143,206p' src/graphics/host_gpu/renderer/pipeline/pipelineSerialization.cpp printf '%s\n' '=== Shader-store test outline ===' ast-grep outline tests/ShaderRecompilerComputeTests.cpp --match CheckShaderStore --view expanded 2>&1 || true printf '%s\n' '=== Shader-store test ===' sed -n '49257,49430p' tests/ShaderRecompilerComputeTests.cpp ``` Length of output: 12598 --- </dd> </dl> </details> `@theantipopau` Verified in `444395a`: `StoreHeader` includes both values, and `WarmUp` loads records only when the header matches. I did not run tests. --- <!-- 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=GPU%20subgroup%20mismatches%20can%20reuse%20stale%20SPIR-V%20and%20break%20wave32%20operations.%20%40coderabbitai%20caught%20it%3A%20cache%20subgroup%20settings%20to%20invalidate%20incompatible%20records%20before%20WarmUp.%20Try%20CodeRabbit!%20%F0%9F%90%87&url=https%3A%2F%2Fgithub.com%2FKytyPS5%2FKytyPS5%2Fpull%2F2142%23discussion_r4503554155)? Thank you for using CodeRabbit! <!-- end of auto-generated comment: tweet message by coderabbit.ai --> Review thread resolved. <sub><i>You are interacting with an AI system.</i></sub> <!-- This is an auto-generated reply by CodeRabbit -->
Author
Owner

@⁠Nawid3333 on GitHub · 2026-11-10 00:36 UTC · original

@⁠theantipopau I ran d992f09f8 against its base 9ffbe8550 on an RX 9070 XT (Windows). The run was shader_recompiler_compute_tests with the graphics cases enabled, using our lab overlays: keep-going, and VectorMinMaxF64CapturedAndEdges skipped because it crashes this driver. I also ran shader_cfg_tests.

  • No new failures. shader_cfg_tests exits 0 on both.
  • IndirectImageQueryDimensions fails on the base and on upstream main (6fd43ac65) and passes with this PR. On the base, lane 1 gets {1,1,0,2} instead of {2,1,0,3}. That is the driver behaviour reported in #1624: on this GPU a NonUniform image size/levels query takes the descriptor of the subgroup's first lane, while the Ryzen 7600X iGPU passes the same standalone repro. So the static per-candidate bodies are what make this query correct on the RX 9070 XT. The shared loop also uses a wave-uniform slot index, which should avoid this descriptor-selection bug, but these runs do not execute that path.

Two points:

  1. In a pixel shader, wanted comes from a ballot or OpGroupNonUniformAny, and Vulkan allows helper invocations to be inactive for those. A candidate that only a helper lane selects can then be skipped, and that lane keeps the carried value. Live fragments are affected when that result feeds derivatives or quad operations. Running the body unconditionally in pixel shaders, or always using the per-candidate switch in pixel shaders whatever the candidate count, would avoid it.
  2. The long-table fixture validates the SPIR-V and counts the query bodies, but it is never dispatched. So the loop's per-lane results and the upper-word vote on a 64-lane host have no executed check. A dispatched case would cover them if it has more than 16 candidates with a consecutive descriptor run, selections in both halves and a partial upper wave.
**@⁠Nawid3333** on GitHub · 2026-11-10 00:36 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2142#issuecomment-6755441958) @⁠theantipopau I ran d992f09f8 against its base 9ffbe8550 on an RX 9070 XT (Windows). The run was `shader_recompiler_compute_tests` with the graphics cases enabled, using our lab overlays: keep-going, and `VectorMinMaxF64CapturedAndEdges` skipped because it crashes this driver. I also ran `shader_cfg_tests`. - No new failures. `shader_cfg_tests` exits 0 on both. - `IndirectImageQueryDimensions` fails on the base and on upstream main (6fd43ac65) and passes with this PR. On the base, lane 1 gets `{1,1,0,2}` instead of `{2,1,0,3}`. That is the driver behaviour reported in https://git.gtahub.st/github/KytyPS5--KytyPS5/issues/1624: on this GPU a `NonUniform` image size/levels query takes the descriptor of the subgroup's first lane, while the Ryzen 7600X iGPU passes the same standalone repro. So the static per-candidate bodies are what make this query correct on the RX 9070 XT. The shared loop also uses a wave-uniform slot index, which should avoid this descriptor-selection bug, but these runs do not execute that path. Two points: 1. In a pixel shader, `wanted` comes from a ballot or `OpGroupNonUniformAny`, and Vulkan allows helper invocations to be inactive for those. A candidate that only a helper lane selects can then be skipped, and that lane keeps the carried value. Live fragments are affected when that result feeds derivatives or quad operations. Running the body unconditionally in pixel shaders, or always using the per-candidate switch in pixel shaders whatever the candidate count, would avoid it. 2. The long-table fixture validates the SPIR-V and counts the query bodies, but it is never dispatched. So the loop's per-lane results and the upper-word vote on a 64-lane host have no executed check. A dispatched case would cover them if it has more than 16 candidates with a consecutive descriptor run, selections in both halves and a partial upper wave.

Pull request closed

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