shader: serve DS_ORDERED_COUNT waves in dispatch order #1199

Open
github-bot wants to merge 9 commits from github-bot/gh-1199 into main AGit
Owner

@⁠NeySlim on GitHub · 2026-10-08 10:09 UTC · original
NeySlim:fix/ordered-append → main · +456 −33 · 13 files · 9 commits · open

Problem

DS_ORDERED_COUNT is emulated as one unordered GDS atomic per wave. On hardware, the ordered-append unit serves the waves of a dispatch in dispatch order: each wave gets a term in TG_SIZE[16:6], waits until every earlier wave released, then does its GDS operation. Games build prefix sums on top of that.

God of War Ragnarök (PPSA08332, 05.005) simulates all particle emitters in one compute dispatch that shares a single GDS counter. Each wave adds its live particles, and the last group of each emitter swaps the counter to zero to write its draw count. With unordered atomics, waves of a later, larger emitter add to the counter before the small emitter's final swap. Small emitters then get inflated counts (17634 indices for an emitter of at most 448 particles in one capture) and draw thousands of stale records from neighbouring chunks. The result is huge triangles radiating across the screen.

Change

  • TranslateProgram: every compute shader that uses DS_ORDERED_COUNT is served in order, whether or not it loads TG_SIZE. When it does, TG_SIZE[16:6] carries the wave's position in dispatch order: flattened workgroup id times waves per group, plus the wave index, masked to 11 bits like the hardware term.
  • DS_ORDERED_COUNT first waits until a release counter reaches the wave's full dispatch rank (OrderedAppendWait), does the GDS add or swap as before, and increments the release counter when wave_release is set (OrderedAppendRelease). The rank is rebuilt from WorkgroupId, NumWorkgroups and LocalInvocationIndex, so waves 2048 apart do not share a slot; the game still sees the 11-bit term in TG_SIZE. The wait loop is bounded (2^22 polls), so a wave that never releases cannot hang the dispatch; past that bound the order for that wave is lost.
  • The release counter is a GDS dword past the 64 KiB the guest addresses. The GDS buffer grows by 16 bytes, and the counter is zeroed before each dispatch that uses ordered append.
  • The per-group dispatchBase split from d4465faa7 is removed: the in-shader order covers it, and the split serialized the GPU (6.9 to 18.5 fps in a God of War Ragnarök cutscene).
  • NumWorkgroups is accepted as a typed compute builtin by ShaderInfoCollection and declared as a shader input, so 2D and 3D dispatches get the right rank.

Test

New DsOrderedCountFollowsWaveLaunchOrder: 16 waves, where earlier waves spin longer before DS_ORDERED_COUNT (the iteration count is stored, so the delay is kept). Each wave must still read the counter value equal to its group index, and both the final count and the release counter must be 16. With the wait disabled, the waves are served in reverse order and the case fails. New DsOrderedCountRanksPastElevenBits: 2049 one-wave groups where only wave 0 is delayed, so wave 2048 (same 11-bit term) must still be served last. New DsOrderedCountFollowsWaveLaunchOrder2D runs the same check on 4x4 one-wave groups ranked y * 4 + x. All three also run under --ds-ordered-count-only. DsOrderedCountAddressAndExecWave32/64, DsOrderedCountPixelAddressWave32/64, DsAppendConsumeGdsRegionBounds and ComputeTgSizeSgprUsesWaveMetadata still pass.

Validation

Linux, AMD Radeon 8060S, Mesa RADV 26.2.3.

  • The cases above pass.
  • Full GPU suite, one case per process, after rebasing on 59183dbf: 605 of 615 cases pass; the 10 failures are the same as on main (602 of 612).
  • God of War Ragnarök: in a RenderDoc capture of a cutscene, 2 of 38 particle draws remain outside the screen bounds (none with non-finite positions), against 22 of 41 before, and the radiating triangles are gone from the final image.

Not tested: 3D dispatches using ordered append in a game (no case was seen; 2D is covered by the new test), and Windows/macOS (the change is platform-independent recompiler and renderer code).

AI use

I used Claude Code (AI agent) to capture and analyze the frames in RenderDoc, trace the particle counts back to the GDS prefix sum, write the change and the test, and run the tests above on my machine. I reviewed the diff and the results before opening this PR.

**@⁠NeySlim** on GitHub · 2026-10-08 10:09 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1199) `NeySlim:fix/ordered-append` → `main` · +456 −33 · 13 files · 9 commits · open ## Problem `DS_ORDERED_COUNT` is emulated as one unordered GDS atomic per wave. On hardware, the ordered-append unit serves the waves of a dispatch in dispatch order: each wave gets a term in `TG_SIZE[16:6]`, waits until every earlier wave released, then does its GDS operation. Games build prefix sums on top of that. God of War Ragnarök (PPSA08332, 05.005) simulates all particle emitters in one compute dispatch that shares a single GDS counter. Each wave adds its live particles, and the last group of each emitter swaps the counter to zero to write its draw count. With unordered atomics, waves of a later, larger emitter add to the counter before the small emitter's final swap. Small emitters then get inflated counts (17634 indices for an emitter of at most 448 particles in one capture) and draw thousands of stale records from neighbouring chunks. The result is huge triangles radiating across the screen. ## Change - `TranslateProgram`: every compute shader that uses `DS_ORDERED_COUNT` is served in order, whether or not it loads `TG_SIZE`. When it does, `TG_SIZE[16:6]` carries the wave's position in dispatch order: flattened workgroup id times waves per group, plus the wave index, masked to 11 bits like the hardware term. - `DS_ORDERED_COUNT` first waits until a release counter reaches the wave's full dispatch rank (`OrderedAppendWait`), does the GDS add or swap as before, and increments the release counter when `wave_release` is set (`OrderedAppendRelease`). The rank is rebuilt from `WorkgroupId`, `NumWorkgroups` and `LocalInvocationIndex`, so waves 2048 apart do not share a slot; the game still sees the 11-bit term in `TG_SIZE`. The wait loop is bounded (2^22 polls), so a wave that never releases cannot hang the dispatch; past that bound the order for that wave is lost. - The release counter is a GDS dword past the 64 KiB the guest addresses. The GDS buffer grows by 16 bytes, and the counter is zeroed before each dispatch that uses ordered append. - The per-group `dispatchBase` split from d4465faa7 is removed: the in-shader order covers it, and the split serialized the GPU (6.9 to 18.5 fps in a God of War Ragnarök cutscene). - `NumWorkgroups` is accepted as a typed compute builtin by `ShaderInfoCollection` and declared as a shader input, so 2D and 3D dispatches get the right rank. ## Test New `DsOrderedCountFollowsWaveLaunchOrder`: 16 waves, where earlier waves spin longer before `DS_ORDERED_COUNT` (the iteration count is stored, so the delay is kept). Each wave must still read the counter value equal to its group index, and both the final count and the release counter must be 16. With the wait disabled, the waves are served in reverse order and the case fails. New `DsOrderedCountRanksPastElevenBits`: 2049 one-wave groups where only wave 0 is delayed, so wave 2048 (same 11-bit term) must still be served last. New `DsOrderedCountFollowsWaveLaunchOrder2D` runs the same check on 4x4 one-wave groups ranked `y * 4 + x`. All three also run under `--ds-ordered-count-only`. `DsOrderedCountAddressAndExecWave32/64`, `DsOrderedCountPixelAddressWave32/64`, `DsAppendConsumeGdsRegionBounds` and `ComputeTgSizeSgprUsesWaveMetadata` still pass. ## Validation Linux, AMD Radeon 8060S, Mesa RADV 26.2.3. - The cases above pass. - Full GPU suite, one case per process, after rebasing on 59183dbf: 605 of 615 cases pass; the 10 failures are the same as on main (602 of 612). - God of War Ragnarök: in a RenderDoc capture of a cutscene, 2 of 38 particle draws remain outside the screen bounds (none with non-finite positions), against 22 of 41 before, and the radiating triangles are gone from the final image. Not tested: 3D dispatches using ordered append in a game (no case was seen; 2D is covered by the new test), and Windows/macOS (the change is platform-independent recompiler and renderer code). ## AI use I used Claude Code (AI agent) to capture and analyze the frames in RenderDoc, trace the particle counts back to the GDS prefix sum, write the change and the test, and run the tests above on my machine. I reviewed the diff and the results before opening this PR.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:47:26 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-08 10:14 UTC · original · edited 2026-10-20 14:31 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.

  • Last reviewed commit: ecb70d14279d69db85990b32d1310ddf30424f6a
  • Latest commit, not reviewed: 050386010c

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: e5a957b7-da15-4dff-9cd3-ae1d1c4fa176
📥 Commits

Reviewing files that changed from the base of the PR and between 7495ea8619e6438dd41df1fc0cd2acd5d707c652 and ecb70d14279d69db85990b32d1310ddf30424f6a.

📒 Files selected for processing (2)
  • src/graphics/shader/recompiler/ir/passes/ShaderInfoCollection.cpp
  • tests/ShaderRecompilerComputeTests.cpp
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/graphics/shader/recompiler/ir/passes/ShaderInfoCollection.cpp
  • tests/ShaderRecompilerComputeTests.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

Compute translation identifies programs that use DS_ORDERED_COUNT and encodes dispatch and wave order. The shader recompiler emits GDS wait and release operations around the shared atomic. The renderer clears ordered-append counters before direct and indirect compute dispatches. New compute tests check launch order and ranks across 2,049 waves.

Priority: ➖ Normal

Change: Bug fix

Merge Risk: ⚪ Minimal · up to ecb70

No confirmed issue blocks merging. The new 2D ordered-count test exercises the intended dispatch and rank order.

Pre-merge checks: Passed 4 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Docstring Coverage Inconclusive Docstring coverage is 15.79% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 19 functions across 10 files. (1 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
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.
Title check Passed The title clearly and concisely describes the main change: serving DS_ORDERED_COUNT waves in dispatch order.
Description check Passed The description directly explains the DS_ORDERED_COUNT ordering problem, implementation, tests, validation results, and known testing limits.
Full details: Docstring Coverage

Explanation

Docstring coverage is 15.79% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 19 functions across 10 files. (1 skipped: 1 too large.)

Resolution

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

  • Autopilot · 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-08 10:14 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1199#issuecomment-6057654857) · edited 2026-10-20 14:31 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/1199?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 --> <!-- 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: ecb70d14279d69db85990b32d1310ddf30424f6a > - Latest commit, not reviewed: 050386010c5e72572b01c83af346e7ba06309bbe > > 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**: `e5a957b7-da15-4dff-9cd3-ae1d1c4fa176` </dd> </dl> </details> <details> <summary><strong>📥 Commits</strong></summary> <dl> <dd> Reviewing files that changed from the base of the PR and between 7495ea8619e6438dd41df1fc0cd2acd5d707c652 and ecb70d14279d69db85990b32d1310ddf30424f6a. </dd> </dl> </details> <details> <summary><strong>📒 Files selected for processing (2)</strong></summary> <dl> <dd> * `src/graphics/shader/recompiler/ir/passes/ShaderInfoCollection.cpp` * `tests/ShaderRecompilerComputeTests.cpp` </dd> </dl> </details> <details> <summary><strong>🚧 Files skipped from review as they are similar to previous changes (2)</strong></summary> <dl> <dd> * src/graphics/shader/recompiler/ir/passes/ShaderInfoCollection.cpp * tests/ShaderRecompilerComputeTests.cpp </dd> </dl> </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. </dd> </dl> </details> <!-- recent_review_end --> <!-- walkthrough_start --> <details> <summary><strong>📝 Walkthrough</strong></summary> <dl> <dd> Compute translation identifies programs that use `DS_ORDERED_COUNT` and encodes dispatch and wave order. The shader recompiler emits GDS wait and release operations around the shared atomic. The renderer clears ordered-append counters before direct and indirect compute dispatches. New compute tests check launch order and ranks across 2,049 waves. </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ➖ Normal <!-- change_assessment_commit:"ecb70d14279d69db85990b32d1310ddf30424f6a" --> **Change:** Bug fix <!-- change_assessment_end --> <details> <summary><strong>Merge Risk:</strong> <strong>⚪ Minimal</strong> · up to <code>ecb70</code></summary> <dl> <dd> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **⚪ Minimal** · up to `ecb70` --> <!-- final_review_risk_coverage:{"sourceCommitId":"ecb70d14279d69db85990b32d1310ddf30424f6a","coveredCommitId":"ecb70d14279d69db85990b32d1310ddf30424f6a","kind":"reviewed"} --> No confirmed issue blocks merging. The new 2D ordered-count test exercises the intended dispatch and rank order. <!-- 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> <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 15.79% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 19 functions across 10 files. (1 skipped:… | 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> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------- | | 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. | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title clearly and concisely describes the main change: serving DS_ORDERED_COUNT waves in dispatch order. | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description directly explains the DS_ORDERED_COUNT ordering problem, implementation, tests, validation results, and known testing limits. | </dd> </dl> </details> <details> <summary><strong>Full details: Docstring Coverage</strong></summary> <dl> <dd> **Explanation** Docstring coverage is 15.79% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 19 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 --> <!-- autopilot:start --> - [ ] <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autopilot</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=1199)! 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 -->
@ -1428,0 +1505,4 @@
const auto expired = Binary(state, spv::OpUGreaterThanEqual, TypeBool(state), iteration,
ConstantU32(state, 1u << 22u));
const auto done = Binary(state, spv::OpLogicalOr, TypeBool(state), ready, expired);
state.builder.AddFunction(spv::OpBranchConditional, done, merge, cont);
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-08 10:14 UTC · original · edited 2026-10-08 10:43 UTC

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Do not treat an expired wait as permission to execute the ordered atomic.

If an earlier wave takes longer than this polling bound to release, expired sends the later wave to the same exit as ready. The later wave then performs its GDS atomic out of order. The bound prevents an indefinite wait, but it does not preserve the ordering promised by this path. Use a fallback that preserves ordering, or make the loss of ordering an explicit supported limitation. (docs.vulkan.org)

✅ Confirmed as addressed by @⁠NeySlim

**@⁠coderabbitai[bot]** on GitHub · 2026-10-08 10:14 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1199#discussion_r4217677734) · edited 2026-10-08 10:43 UTC **🎯 Functional Correctness** | **🟠 Major** | **🏗️ Heavy lift** **Do not treat an expired wait as permission to execute the ordered atomic.** If an earlier wave takes longer than this polling bound to release, `expired` sends the later wave to the same exit as `ready`. The later wave then performs its GDS atomic out of order. The bound prevents an indefinite wait, but it does not preserve the ordering promised by this path. Use a fallback that preserves ordering, or make the loss of ordering an explicit supported limitation. ([docs.vulkan.org](https://docs.vulkan.org/spec/latest/chapters/shaders.html?utm_source=openai)) <!-- fingerprinting:phantom:poseidon:wombat --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:118286c2f4ff31215a605f13 --> <!-- This is an auto-generated reply by CodeRabbit --> ✅ Confirmed as addressed by @⁠NeySlim <!-- This is an auto-generated comment by CodeRabbit -->
@ -1183,0 +1203,4 @@
builtin(IR::StageInputKind::WorkgroupId, 2)}));
const auto term = entry_ir.BitwiseAnd(
entry_ir.IAdd(entry_ir.IMul(group, u32(waves)), wave_id),
u32(IR::OrderedAppendWaveIdMask));
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-08 10:14 UTC · original · edited 2026-10-08 10:43 UTC

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Preserve distinct terms for all waves in a dispatch.

With one wave per workgroup, workgroups 0 and 2,048 both receive term 0. If the later workgroup reaches DS_ORDERED_COUNT while the release counter is 0, OrderedAppendWait accepts it before the earlier workgroup. The ordered GDS atomic can then execute out of order. Use a dispatch-wide term and compare the full release count, or define an explicit limit for ordered dispatches. Vulkan permits dispatches larger than this 11-bit range. (docs.vulkan.org)

✅ Confirmed as addressed by @⁠NeySlim

**@⁠coderabbitai[bot]** on GitHub · 2026-10-08 10:14 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1199#discussion_r4217677743) · edited 2026-10-08 10:43 UTC **🎯 Functional Correctness** | **🟠 Major** | **🏗️ Heavy lift** **Preserve distinct terms for all waves in a dispatch.** With one wave per workgroup, workgroups 0 and 2,048 both receive term 0. If the later workgroup reaches `DS_ORDERED_COUNT` while the release counter is 0, `OrderedAppendWait` accepts it before the earlier workgroup. The ordered GDS atomic can then execute out of order. Use a dispatch-wide term and compare the full release count, or define an explicit limit for ordered dispatches. Vulkan permits dispatches larger than this 11-bit range. ([docs.vulkan.org](https://docs.vulkan.org/guide/latest/compute_shaders.html?utm_source=openai)) <!-- fingerprinting:phantom:poseidon:wombat --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:31871e1d744f964c576f8dcb --> <!-- This is an auto-generated reply by CodeRabbit --> ✅ Confirmed as addressed by @⁠NeySlim <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
tests/ShaderRecompilerComputeTests.cpp (2)

33270-33270: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Check the final release counter.

RunCase reads only expected_gds.size() words. With {waves}, this case checks GDS word zero but never checks OrderedAppendReleaseCounter. A release operation that increments the counter more than once can leave the recorded count sequence correct while this assertion passes. Copy gds_initial into expected_gds, then set the data counter and release counter to waves.


36634-36634: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Include the new case in the ordered-count selector.

--ds-ordered-count-only runs the four DsOrderedCountAddressAndExec variants directly. It does not use MakeCases. Add DsOrderedCountFollowsWaveLaunchOrder to that selector so the targeted command checks dispatch order rather than reporting success without running the new case.


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c6073b3d-0cce-4d9a-add6-a83f98a459bf
📥 Commits

Reviewing files that changed from the base of the PR and between 5a8808086a and 8604a92028deb92df0ee96237e33646b7ae6c1f4.

📒 Files selected for processing (12)
  • src/graphics/host_gpu/renderer/cache/bufferCache.cpp
  • src/graphics/host_gpu/renderer/render.h
  • src/graphics/host_gpu/renderer/renderCompute.cpp
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterInstructions.h
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cpp
  • src/graphics/shader/recompiler/frontend/translate/Memory.cpp
  • src/graphics/shader/recompiler/frontend/translate/Translate.cpp
  • src/graphics/shader/recompiler/ir/ShaderIR.h
  • src/graphics/shader/recompiler/ir/opcodes/ValueOpcodes.cpp
  • src/graphics/shader/recompiler/ir/opcodes/ValueOpcodes.inc
  • src/graphics/shader/recompiler/ir/passes/ShaderInfoCollection.cpp
  • tests/ShaderRecompilerComputeTests.cpp

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

**@⁠coderabbitai[bot]** on GitHub · 2026-10-08 10:14 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1199#pullrequestreview-5455043815) · **reviewed** **Actionable comments posted: 2** <details> <summary>🧹 Nitpick comments (2)</summary><blockquote> <details> <summary>tests/ShaderRecompilerComputeTests.cpp (2)</summary><blockquote> `33270-33270`: **📐 Maintainability & Code Quality** | **🔵 Trivial** | **⚡ Quick win** **Check the final release counter.** `RunCase` reads only `expected_gds.size()` words. With `{waves}`, this case checks GDS word zero but never checks `OrderedAppendReleaseCounter`. A release operation that increments the counter more than once can leave the recorded count sequence correct while this assertion passes. Copy `gds_initial` into `expected_gds`, then set the data counter and release counter to `waves`. <!-- cr-comment:v1:0111bb2a6fbd3870da539abf --> --- `36634-36634`: **📐 Maintainability & Code Quality** | **🔵 Trivial** | **⚡ Quick win** **Include the new case in the ordered-count selector.** `--ds-ordered-count-only` runs the four `DsOrderedCountAddressAndExec` variants directly. It does not use `MakeCases`. Add `DsOrderedCountFollowsWaveLaunchOrder` to that selector so the targeted command checks dispatch order rather than reporting success without running the new case. <!-- cr-comment:v1:4abd9413f7b8f2118dc4e1d5 --> </blockquote></details> </blockquote></details> --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `c6073b3d-0cce-4d9a-add6-a83f98a459bf` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 5a8808086a9815b67d4822cd20cf1e8a7a05f002 and 8604a92028deb92df0ee96237e33646b7ae6c1f4. </details> <details> <summary>📒 Files selected for processing (12)</summary> * `src/graphics/host_gpu/renderer/cache/bufferCache.cpp` * `src/graphics/host_gpu/renderer/render.h` * `src/graphics/host_gpu/renderer/renderCompute.cpp` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterInstructions.h` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cpp` * `src/graphics/shader/recompiler/frontend/translate/Memory.cpp` * `src/graphics/shader/recompiler/frontend/translate/Translate.cpp` * `src/graphics/shader/recompiler/ir/ShaderIR.h` * `src/graphics/shader/recompiler/ir/opcodes/ValueOpcodes.cpp` * `src/graphics/shader/recompiler/ir/opcodes/ValueOpcodes.inc` * `src/graphics/shader/recompiler/ir/passes/ShaderInfoCollection.cpp` * `tests/ShaderRecompilerComputeTests.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=22c52e0b-4f59-47f4-8b23-bca4bfa54d48 attempt=46f975d2-4971-48f6-99ac-a92c005487c9 batch=1/1 -->
@ -1428,0 +1505,4 @@
const auto expired = Binary(state, spv::OpUGreaterThanEqual, TypeBool(state), iteration,
ConstantU32(state, 1u << 22u));
const auto done = Binary(state, spv::OpLogicalOr, TypeBool(state), ready, expired);
state.builder.AddFunction(spv::OpBranchConditional, done, merge, cont);
Author
Owner

@⁠NeySlim on GitHub · 2026-10-08 10:38 UTC · original

The bound is there to avoid a GPU hang when an earlier wave never releases, for example a wave that exits without reaching DS_ORDERED_COUNT. Hardware handles that case and Kyty cannot tell it apart from a slow wave. I kept it and made it an explicit, documented limitation in e86d3da: past 2^22 polls, the wave proceeds and the order for that wave is lost, but the dispatch completes. With the full-rank comparison, the only way to reach it is a wave that never releases.

**@⁠NeySlim** on GitHub · 2026-10-08 10:38 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1199#discussion_r4217888245) The bound is there to avoid a GPU hang when an earlier wave never releases, for example a wave that exits without reaching `DS_ORDERED_COUNT`. Hardware handles that case and Kyty cannot tell it apart from a slow wave. I kept it and made it an explicit, documented limitation in e86d3da: past 2^22 polls, the wave proceeds and the order for that wave is lost, but the dispatch completes. With the full-rank comparison, the only way to reach it is a wave that never releases.
@ -1183,0 +1203,4 @@
builtin(IR::StageInputKind::WorkgroupId, 2)}));
const auto term = entry_ir.BitwiseAnd(
entry_ir.IAdd(entry_ir.IMul(group, u32(waves)), wave_id),
u32(IR::OrderedAppendWaveIdMask));
Author
Owner

@⁠NeySlim on GitHub · 2026-10-08 10:38 UTC · original

Agreed, fixed in e86d3da. DS_ORDERED_COUNT no longer waits on the 11-bit term from M0. It rebuilds the wave's full dispatch rank from WorkgroupId, NumWorkgroups and LocalInvocationIndex (waves per group and wave size are recorded when the entry block writes TG_SIZE), and OrderedAppendWait compares it with the full 32-bit release counter. The game still gets the 11-bit term in TG_SIZE[16:6], as on hardware. New case DsOrderedCountRanksPastElevenBits: 2049 one-wave groups where only wave 0 is delayed, so wave 2048 (same 11-bit term) must still be served last. It passes. To be transparent: on this GPU it also passes with the old 11-bit comparison, because the waves past 2048 are not resident until earlier ones retire, so it guards the behavior rather than reproducing the race here.

**@⁠NeySlim** on GitHub · 2026-10-08 10:38 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1199#discussion_r4217888469) Agreed, fixed in e86d3da. `DS_ORDERED_COUNT` no longer waits on the 11-bit term from M0. It rebuilds the wave's full dispatch rank from `WorkgroupId`, `NumWorkgroups` and `LocalInvocationIndex` (waves per group and wave size are recorded when the entry block writes `TG_SIZE`), and `OrderedAppendWait` compares it with the full 32-bit release counter. The game still gets the 11-bit term in `TG_SIZE[16:6]`, as on hardware. New case `DsOrderedCountRanksPastElevenBits`: 2049 one-wave groups where only wave 0 is delayed, so wave 2048 (same 11-bit term) must still be served last. It passes. To be transparent: on this GPU it also passes with the old 11-bit comparison, because the waves past 2048 are not resident until earlier ones retire, so it guards the behavior rather than reproducing the race here.
@ -43229,1 +43476,4 @@
AddCase(DsAppendConsumeGdsRegionBounds);
AddCase(DsOrderedCountFollowsWaveLaunchOrder<false>);
AddCase(DsOrderedCountFollowsWaveLaunchOrder<true>);
AddCase(DsOrderedCountRanksPastElevenBits);
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-08 10:41 UTC · original · edited 2026-10-08 10:44 UTC

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Include the new order tests in the ordered-count test selector.

--ds-ordered-count-only runs four address tests directly. It does not use MakeCases(), so this registration does not make DsOrderedCountRanksPastElevenBits run under that selector. The selector also omits DsOrderedCountFollowsWaveLaunchOrder. Add both cases to the selector so the focused validation command checks the new ordering behavior.

✅ Confirmed as addressed by @⁠NeySlim

**@⁠coderabbitai[bot]** on GitHub · 2026-10-08 10:41 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1199#discussion_r4217914509) · edited 2026-10-08 10:44 UTC **🎯 Functional Correctness** | **🟡 Minor** | **⚡ Quick win** **Include the new order tests in the ordered-count test selector.** `--ds-ordered-count-only` runs four address tests directly. It does not use `MakeCases()`, so this registration does not make `DsOrderedCountRanksPastElevenBits` run under that selector. The selector also omits `DsOrderedCountFollowsWaveLaunchOrder`. Add both cases to the selector so the focused validation command checks the new ordering behavior. <!-- fingerprinting:phantom:poseidon:wombat --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:842e664a8fa9dfd6d31cb2ac --> <!-- This is an auto-generated reply by CodeRabbit --> ✅ Confirmed as addressed by @⁠NeySlim <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-08 10:41 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: 0f0ced5d-545c-4ee0-b93b-678b6ecf7d4a
📥 Commits

Reviewing files that changed from the base of the PR and between 8604a92028deb92df0ee96237e33646b7ae6c1f4 and e86d3da18246a0ec9a7ca89f45ed4bd0564fb222.

📒 Files selected for processing (5)
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cpp
  • src/graphics/shader/recompiler/frontend/translate/Memory.cpp
  • src/graphics/shader/recompiler/frontend/translate/Translate.cpp
  • src/graphics/shader/recompiler/ir/ShaderIR.h
  • tests/ShaderRecompilerComputeTests.cpp

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

**@⁠coderabbitai[bot]** on GitHub · 2026-10-08 10:41 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1199#pullrequestreview-5455332177) · **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**: `0f0ced5d-545c-4ee0-b93b-678b6ecf7d4a` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 8604a92028deb92df0ee96237e33646b7ae6c1f4 and e86d3da18246a0ec9a7ca89f45ed4bd0564fb222. </details> <details> <summary>📒 Files selected for processing (5)</summary> * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cpp` * `src/graphics/shader/recompiler/frontend/translate/Memory.cpp` * `src/graphics/shader/recompiler/frontend/translate/Translate.cpp` * `src/graphics/shader/recompiler/ir/ShaderIR.h` * `tests/ShaderRecompilerComputeTests.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 4 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=fe4d0e7f-2460-402c-9c4d-1e9736ed7c14 attempt=15c0bcb6-773c-4f65-a91a-33fa2b9d4b25 batch=1/1 -->
@ -1183,0 +1203,4 @@
builtin(IR::StageInputKind::WorkgroupId, 2)}));
const auto term = entry_ir.BitwiseAnd(
entry_ir.IAdd(entry_ir.IMul(group, u32(waves)), wave_id),
u32(IR::OrderedAppendWaveIdMask));
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-08 10:43 UTC · original

@NeySlim, thanks for the fix and the test limitation details. Using the full dispatch rank for OrderedAppendWait addresses the aliasing concern. Keeping the 11-bit term in TG_SIZE[16:6] preserves the hardware-visible encoding.

DsOrderedCountRanksPastElevenBits checks the expected ordering beyond 2,048 waves. As you explained, its pass on this GPU does not demonstrate that it detects the original race.


✏️ Learnings added
Learnt from: NeySlim
Repo: KytyPS5/KytyPS5 PR: 1199
File: src/graphics/shader/recompiler/frontend/translate/Translate.cpp:1153-1155
Timestamp: 2026-10-08T10:43:03.272Z
Learning: In KytyPS5's C++ shader recompiler, the ordered-append term in TG_SIZE[16:6] intentionally uses an 11-bit hardware-visible encoding. This mask alone is not an ordering defect: evaluate the synchronization rank used by DS_ORDERED_COUNT and OrderedAppendWait separately from the guest-visible TG_SIZE term.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.


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-08 10:43 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1199#discussion_r4217926263) `@NeySlim`, thanks for the fix and the test limitation details. Using the full dispatch rank for `OrderedAppendWait` addresses the aliasing concern. Keeping the 11-bit term in `TG_SIZE[16:6]` preserves the hardware-visible encoding. `DsOrderedCountRanksPastElevenBits` checks the expected ordering beyond 2,048 waves. As you explained, its pass on this GPU does not demonstrate that it detects the original race. --- <details> <summary>✏️ Learnings added</summary> ``` Learnt from: NeySlim Repo: KytyPS5/KytyPS5 PR: 1199 File: src/graphics/shader/recompiler/frontend/translate/Translate.cpp:1153-1155 Timestamp: 2026-10-08T10:43:03.272Z Learning: In KytyPS5's C++ shader recompiler, the ordered-append term in TG_SIZE[16:6] intentionally uses an 11-bit hardware-visible encoding. This mask alone is not an ordering defect: evaluate the synchronization rank used by DS_ORDERED_COUNT and OrderedAppendWait separately from the guest-visible TG_SIZE term. ``` > Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure [review instructions](https://docs.coderabbit.ai/guides/review-instructions). You can manage existing learnings in the [app](https://app.coderabbit.ai/learnings). </details> --- <!-- 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=11-bit%20wave%20terms%20can%20wrap%2C%20letting%20ordered%20GPU%20atomics%20run%20out%20of%20order.%20%40coderabbitai%20flagged%20it%3B%20full%20dispatch-rank%20checks%20fix%20it.%20Try%20CodeRabbit%20for%20sharper%20reviews%20%F0%9F%9A%80&url=https%3A%2F%2Fgithub.com%2FKytyPS5%2FKytyPS5%2Fpull%2F1199%23discussion_r4217677743)? 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 -->
@ -1428,0 +1505,4 @@
const auto expired = Binary(state, spv::OpUGreaterThanEqual, TypeBool(state), iteration,
ConstantU32(state, 1u << 22u));
const auto done = Binary(state, spv::OpLogicalOr, TypeBool(state), ready, expired);
state.builder.AddFunction(spv::OpBranchConditional, done, merge, cont);
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-08 10:43 UTC · original

@NeySlim Thanks for the clarification. The comment in EmitOrderedAppendWait now makes the ordering loss explicit. This addresses the documented-limitation option in my finding.

One distinction remains: full-rank comparison prevents 11-bit aliasing. It does not prevent a slow wave from exceeding 2^22 polls. The bound remains a deliberate trade-off between ordering and avoiding an indefinite wait.


✏️ Learnings added
Learnt from: NeySlim
Repo: KytyPS5/KytyPS5 PR: 1199
File: src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cpp:1252-1255
Timestamp: 2026-10-08T10:43:18.148Z
Learning: In KytyPS5, src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cpp implements EmitOrderedAppendWait with a bounded polling loop as a deliberate GPU-hang safeguard when an earlier wave does not release. Timeout permits the ordered atomic to proceed and can lose ordering; this is an explicitly accepted limitation, not a guarantee of preserved ordering.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.


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-08 10:43 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1199#discussion_r4217928827) `@NeySlim` Thanks for the clarification. The comment in `EmitOrderedAppendWait` now makes the ordering loss explicit. This addresses the documented-limitation option in my finding. One distinction remains: full-rank comparison prevents 11-bit aliasing. It does not prevent a slow wave from exceeding `2^22` polls. The bound remains a deliberate trade-off between ordering and avoiding an indefinite wait. --- <details> <summary>✏️ Learnings added</summary> ``` Learnt from: NeySlim Repo: KytyPS5/KytyPS5 PR: 1199 File: src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cpp:1252-1255 Timestamp: 2026-10-08T10:43:18.148Z Learning: In KytyPS5, src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cpp implements EmitOrderedAppendWait with a bounded polling loop as a deliberate GPU-hang safeguard when an earlier wave does not release. Timeout permits the ordered atomic to proceed and can lose ordering; this is an explicitly accepted limitation, not a guarantee of preserved ordering. ``` > Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure [review instructions](https://docs.coderabbit.ai/guides/review-instructions). You can manage existing learnings in the [app](https://app.coderabbit.ai/learnings). </details> --- <!-- 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=An%20expired%20wait%20isn%E2%80%99t%20a%20safe%20signal%20to%20run%20an%20ordered%20atomic%E2%80%94it%20can%20break%20wave%20order.%20Use%20an%20ordering-preserving%20fallback%20or%20document%20the%20limitation.%20Try%20%40coderabbitai%20for%20sharp%20code%20reviews!%20%F0%9F%94%8D&url=https%3A%2F%2Fgithub.com%2FKytyPS5%2FKytyPS5%2Fpull%2F1199%23discussion_r4217677734)? 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 -->
@ -43229,1 +43476,4 @@
AddCase(DsAppendConsumeGdsRegionBounds);
AddCase(DsOrderedCountFollowsWaveLaunchOrder<false>);
AddCase(DsOrderedCountFollowsWaveLaunchOrder<true>);
AddCase(DsOrderedCountRanksPastElevenBits);
Author
Owner

@⁠NeySlim on GitHub · 2026-10-08 10:44 UTC · original

Fixed in 94a1031: --ds-ordered-count-only now also runs DsOrderedCountFollowsWaveLaunchOrder and DsOrderedCountRanksPastElevenBits, and all six cases pass.

**@⁠NeySlim** on GitHub · 2026-10-08 10:44 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1199#discussion_r4217935205) Fixed in 94a1031: `--ds-ordered-count-only` now also runs `DsOrderedCountFollowsWaveLaunchOrder` and `DsOrderedCountRanksPastElevenBits`, and all six cases pass.
@ -43229,1 +43476,4 @@
AddCase(DsAppendConsumeGdsRegionBounds);
AddCase(DsOrderedCountFollowsWaveLaunchOrder<false>);
AddCase(DsOrderedCountFollowsWaveLaunchOrder<true>);
AddCase(DsOrderedCountRanksPastElevenBits);
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-08 10:44 UTC · original

@NeySlim Thanks for the fix in 94a1031 and for confirming that all six cases pass. The selector now covers both new ordering tests.


🧠 Learnings used
Learnt from: NeySlim
Repo: KytyPS5/KytyPS5 PR: 1199
File: src/graphics/shader/recompiler/frontend/translate/Translate.cpp:1153-1155
Timestamp: 2026-10-08T10:43:07.336Z
Learning: In KytyPS5's C++ shader recompiler, the ordered-append term in TG_SIZE[16:6] intentionally uses an 11-bit hardware-visible encoding. This mask alone is not an ordering defect: evaluate the synchronization rank used by DS_ORDERED_COUNT and OrderedAppendWait separately from the guest-visible TG_SIZE term.

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-08 10:44 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1199#discussion_r4217939226) `@NeySlim` Thanks for the fix in `94a1031` and for confirming that all six cases pass. The selector now covers both new ordering tests. --- <details> <summary>🧠 Learnings used</summary> ``` Learnt from: NeySlim Repo: KytyPS5/KytyPS5 PR: 1199 File: src/graphics/shader/recompiler/frontend/translate/Translate.cpp:1153-1155 Timestamp: 2026-10-08T10:43:07.336Z Learning: In KytyPS5's C++ shader recompiler, the ordered-append term in TG_SIZE[16:6] intentionally uses an 11-bit hardware-visible encoding. This mask alone is not an ordering defect: evaluate the synchronization rank used by DS_ORDERED_COUNT and OrderedAppendWait separately from the guest-visible TG_SIZE term. ``` </details> --- <!-- 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=Add%20both%20ordering%20tests%20to%20%60--ds-ordered-count-only%60%20so%20focused%20validation%20covers%20wave%20launch%20order%20and%20ranks%20beyond%2011%20bits.%20Try%20%40coderabbitai%20for%20actionable%20code%20reviews!%20%F0%9F%90%87%E2%9C%85&url=https%3A%2F%2Fgithub.com%2FKytyPS5%2FKytyPS5%2Fpull%2F1199%23discussion_r4217914509)? 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

@⁠NeySlim on GitHub · 2026-10-09 19:22 UTC · original

Rebased on main (59183dbf). The conflicts in ShaderIR.h and ShaderInfoCollection.cpp came from the reworked ShaderInfo flags and the moved builtin validation; the change itself is unchanged. Also addressed the remaining nitpick from the first review: the two order cases now check the whole GDS readback, including OrderedAppendReleaseCounter (7495ea86), so a release that counts twice fails. Full GPU suite, one case per process: 604/614, same 10 failures as main (602/612).

**@⁠NeySlim** on GitHub · 2026-10-09 19:22 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1199#issuecomment-6087710251) Rebased on main (59183dbf). The conflicts in `ShaderIR.h` and `ShaderInfoCollection.cpp` came from the reworked `ShaderInfo` flags and the moved builtin validation; the change itself is unchanged. Also addressed the remaining nitpick from the first review: the two order cases now check the whole GDS readback, including `OrderedAppendReleaseCounter` (7495ea86), so a release that counts twice fails. Full GPU suite, one case per process: 604/614, same 10 failures as main (602/612).
@ -454,6 +455,7 @@ void Visit(Program& program, ShaderStageInputInfo input_info, InputUsage& inputs
break;
case StageInputKind::TessCoord:
case StageInputKind::WorkgroupId:
case StageInputKind::NumWorkgroups:
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-09 19:27 UTC · original · edited 2026-10-09 19:49 UTC

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Declare NumWorkgroups when accepting the builtin.

An ordered-append compute shader reads NumWorkgroups to calculate its wave rank. Visit now accepts that read, but AddBuiltinInput has no NumWorkgroups case. The SPIR-V emitter therefore has no input binding for a GDS-only shader; its separate insertion applies only to LDS stored in a storage buffer. Add the gl_NumWorkGroups input in AddBuiltinInput so ordered-append shader compilation can resolve the read. (raw.githubusercontent.com)

✅ Addressed in commit ecb70d1

**@⁠coderabbitai[bot]** on GitHub · 2026-10-09 19:27 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1199#discussion_r4233808802) · edited 2026-10-09 19:49 UTC **🩺 Stability & Availability** | **🟠 Major** | **⚡ Quick win** **Declare `NumWorkgroups` when accepting the builtin.** An ordered-append compute shader reads `NumWorkgroups` to calculate its wave rank. `Visit` now accepts that read, but `AddBuiltinInput` has no `NumWorkgroups` case. The SPIR-V emitter therefore has no input binding for a GDS-only shader; its separate insertion applies only to LDS stored in a storage buffer. Add the `gl_NumWorkGroups` input in `AddBuiltinInput` so ordered-append shader compilation can resolve the read. ([raw.githubusercontent.com](https://raw.githubusercontent.com/KytyPS5/KytyPS5/refs/pull/1199/head/src/graphics/shader/recompiler/ir/passes/ShaderInfoCollection.cpp)) <!-- fingerprinting:phantom:poseidon:wombat --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:c57af5af6c42db3096a7acb6 --> <!-- This is an auto-generated reply by CodeRabbit --> ✅ Addressed in commit ecb70d1
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-09 19:27 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: 9a68b42f-7fa4-41f0-b940-bf22efbe1934
📥 Commits

Reviewing files that changed from the base of the PR and between 94a1031d0c4b10bcee1d0885e471387214f4b6ac and 7495ea8619e6438dd41df1fc0cd2acd5d707c652.

📒 Files selected for processing (9)
  • src/graphics/host_gpu/renderer/render.h
  • src/graphics/host_gpu/renderer/renderCompute.cpp
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterInstructions.h
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cpp
  • src/graphics/shader/recompiler/frontend/translate/Translate.cpp
  • src/graphics/shader/recompiler/ir/ShaderIR.h
  • src/graphics/shader/recompiler/ir/opcodes/ValueOpcodes.inc
  • src/graphics/shader/recompiler/ir/passes/ShaderInfoCollection.cpp
  • tests/ShaderRecompilerComputeTests.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.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-09 19:27 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1199#pullrequestreview-5474475354) · **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**: `9a68b42f-7fa4-41f0-b940-bf22efbe1934` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 94a1031d0c4b10bcee1d0885e471387214f4b6ac and 7495ea8619e6438dd41df1fc0cd2acd5d707c652. </details> <details> <summary>📒 Files selected for processing (9)</summary> * `src/graphics/host_gpu/renderer/render.h` * `src/graphics/host_gpu/renderer/renderCompute.cpp` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterInstructions.h` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterMemory.cpp` * `src/graphics/shader/recompiler/frontend/translate/Translate.cpp` * `src/graphics/shader/recompiler/ir/ShaderIR.h` * `src/graphics/shader/recompiler/ir/opcodes/ValueOpcodes.inc` * `src/graphics/shader/recompiler/ir/passes/ShaderInfoCollection.cpp` * `tests/ShaderRecompilerComputeTests.cpp` </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. </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=ecd499ba-73b8-4285-9fce-180505034c04 attempt=8033b49d-7c40-49be-a7fe-64c4e20ec192 batch=1/1 -->
@ -454,6 +455,7 @@ void Visit(Program& program, ShaderStageInputInfo input_info, InputUsage& inputs
break;
case StageInputKind::TessCoord:
case StageInputKind::WorkgroupId:
case StageInputKind::NumWorkgroups:
Author
Owner

@⁠NeySlim on GitHub · 2026-10-09 19:41 UTC · original

Confirmed and fixed in ecb70d14: AddBuiltinInput now declares gl_NumWorkGroups. Without it the read fell back to 0, so the rank collapsed to WorkgroupId.x; 1D dispatches still came out right, which is why the existing cases passed. New case DsOrderedCountFollowsWaveLaunchOrder2D (4x4 one-wave groups, ranked y * 4 + x) fails without the fix and passes with it; it also runs under --ds-ordered-count-only. Full GPU suite: 605/615, same 10 failures as main.

**@⁠NeySlim** on GitHub · 2026-10-09 19:41 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1199#discussion_r4233917044) Confirmed and fixed in ecb70d14: `AddBuiltinInput` now declares `gl_NumWorkGroups`. Without it the read fell back to 0, so the rank collapsed to `WorkgroupId.x`; 1D dispatches still came out right, which is why the existing cases passed. New case `DsOrderedCountFollowsWaveLaunchOrder2D` (4x4 one-wave groups, ranked `y * 4 + x`) fails without the fix and passes with it; it also runs under `--ds-ordered-count-only`. Full GPU suite: 605/615, same 10 failures as main.
@ -454,6 +455,7 @@ void Visit(Program& program, ShaderStageInputInfo input_info, InputUsage& inputs
break;
case StageInputKind::TessCoord:
case StageInputKind::WorkgroupId:
case StageInputKind::NumWorkgroups:
Author
Owner

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

@NeySlim Thanks for the fix and the explanation. The supplied AddBuiltinInput code now declares gl_NumWorkGroups with three components. The reported DsOrderedCountFollowsWaveLaunchOrder2D regression test covers the rank error that 1D dispatches did not expose.


✏️ Learnings added
Learnt from: NeySlim
Repo: KytyPS5/KytyPS5 PR: 1199
File: src/graphics/shader/recompiler/ir/passes/ShaderInfoCollection.cpp:459-459
Timestamp: 2026-10-09T19:49:38.211Z
Learning: In KytyPS5's C++ shader recompiler, accepting StageInputKind::NumWorkgroups in ShaderInfoCollection.cpp::Visit is not sufficient: AddBuiltinInput must also declare the three-component gl_NumWorkGroups input. The author explains that an undeclared read falls back to zero, which can collapse ordered-append ranks to WorkgroupId.x and leave 1D tests passing. Multidimensional dispatch tests are needed to expose this rank error.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.


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-09 19:49 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1199#discussion_r4233983281) `@NeySlim` Thanks for the fix and the explanation. The supplied `AddBuiltinInput` code now declares `gl_NumWorkGroups` with three components. The reported `DsOrderedCountFollowsWaveLaunchOrder2D` regression test covers the rank error that 1D dispatches did not expose. --- <details> <summary>✏️ Learnings added</summary> ``` Learnt from: NeySlim Repo: KytyPS5/KytyPS5 PR: 1199 File: src/graphics/shader/recompiler/ir/passes/ShaderInfoCollection.cpp:459-459 Timestamp: 2026-10-09T19:49:38.211Z Learning: In KytyPS5's C++ shader recompiler, accepting StageInputKind::NumWorkgroups in ShaderInfoCollection.cpp::Visit is not sufficient: AddBuiltinInput must also declare the three-component gl_NumWorkGroups input. The author explains that an undeclared read falls back to zero, which can collapse ordered-append ranks to WorkgroupId.x and leave 1D tests passing. Multidimensional dispatch tests are needed to expose this rank error. ``` > Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure [review instructions](https://docs.coderabbit.ai/guides/review-instructions). You can manage existing learnings in the [app](https://app.coderabbit.ai/learnings). </details> --- <!-- 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=Missing%20%60gl_NumWorkGroups%60%20made%20ordered-append%20ranks%20wrong%20for%202D%20dispatches.%20Adding%20the%20builtin%20fixes%20it%E2%80%94and%20a%20new%20regression%20test%20proves%20it.%20Try%20%40coderabbitai%20%F0%9F%A9%BA%E2%9C%85&url=https%3A%2F%2Fgithub.com%2FKytyPS5%2FKytyPS5%2Fpull%2F1199%23discussion_r4233808802)? 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

@⁠NeySlim on GitHub · 2026-10-19 14:02 UTC · original

Rebased on cd4eab9d. With d4465faa7 a single-wave ordered-append dispatch is now split into one dispatchBase per group, so NumWorkgroups is 1x1x1 inside each piece and the ranks this PR derived from it collapsed to x+y+z: on a 2x2x2 grid the waits ran into their bound instead of being served. The ranks now come from the group counts the host writes next to the release counter (filled for direct dispatches, copied from the arguments for indirect ones), so they are the same whether or not the dispatch is split. New CheckOrderedAppendRanks (in --ordered-dispatch-only) goes through the real direct and indirect paths with TG_SIZE on, wave32 and wave64, and fails without the change.

**@⁠NeySlim** on GitHub · 2026-10-19 14:02 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1199#issuecomment-6269063023) Rebased on cd4eab9d. With d4465faa7 a single-wave ordered-append dispatch is now split into one `dispatchBase` per group, so `NumWorkgroups` is 1x1x1 inside each piece and the ranks this PR derived from it collapsed to x+y+z: on a 2x2x2 grid the waits ran into their bound instead of being served. The ranks now come from the group counts the host writes next to the release counter (filled for direct dispatches, copied from the arguments for indirect ones), so they are the same whether or not the dispatch is split. New `CheckOrderedAppendRanks` (in `--ordered-dispatch-only`) goes through the real direct and indirect paths with TG_SIZE on, wave32 and wave64, and fails without the change.
Author
Owner

@⁠NeySlim on GitHub · 2026-10-20 14:30 UTC · original

@⁠shadowbeat070 d4465faa7 splits every single-wave ordered-append dispatch into one dispatchBase per group with a barrier in between. In God of War Ragnarök that is around 1300 groups per dispatch, a few dispatches per frame, and the GPU ends up busy most of the frame on those barriers. With my other open PRs applied, on a Radeon 8060S:

fps cutscene sled Freya
with the split 6.9 6.8 12.6
without the split (this PR) 18.5 16.2 14.4

This PR already serves DS_ORDERED_COUNT in dispatch order inside the shader (each wave waits for its rank in a GDS release counter), so the split isn't needed for ordering. It only did that when the shader loads TG_SIZE though, and your CheckOrderedDispatch doesn't, so without the split that case failed here. The hardware orders ordered-append waves from the dispatch initiator bit, not from TG_SIZE, so:

  • shader: serve ordered-append waves in order without TG_SIZE: every compute shader with DS_ORDERED_COUNT waits for its rank; only the TG_SIZE term stays tied to TG_SIZE.
  • gpu: drop the per-group ordered-append dispatch split: back to one dispatch, and the pipelines no longer need eDispatchBase.

CheckOrderedDispatch passes without the split (20 of 20 runs), and fails with the split removed but without the first commit. The other ordered-append cases still pass. Full GPU suite, one case per process: same failures as main.

The wait is still bounded, so a wave that is never released can't hang the dispatch. If you had a game where the split fixed something the in-shader order doesn't cover, tell me which one and I'll check it.

**@⁠NeySlim** on GitHub · 2026-10-20 14:30 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1199#issuecomment-6293280637) @⁠shadowbeat070 d4465faa7 splits every single-wave ordered-append dispatch into one `dispatchBase` per group with a barrier in between. In God of War Ragnarök that is around 1300 groups per dispatch, a few dispatches per frame, and the GPU ends up busy most of the frame on those barriers. With my other open PRs applied, on a Radeon 8060S: | fps | cutscene | sled | Freya | |---|---|---|---| | with the split | 6.9 | 6.8 | 12.6 | | without the split (this PR) | 18.5 | 16.2 | 14.4 | This PR already serves `DS_ORDERED_COUNT` in dispatch order inside the shader (each wave waits for its rank in a GDS release counter), so the split isn't needed for ordering. It only did that when the shader loads TG_SIZE though, and your `CheckOrderedDispatch` doesn't, so without the split that case failed here. The hardware orders ordered-append waves from the dispatch initiator bit, not from TG_SIZE, so: - `shader: serve ordered-append waves in order without TG_SIZE`: every compute shader with `DS_ORDERED_COUNT` waits for its rank; only the TG_SIZE term stays tied to TG_SIZE. - `gpu: drop the per-group ordered-append dispatch split`: back to one `dispatch`, and the pipelines no longer need `eDispatchBase`. `CheckOrderedDispatch` passes without the split (20 of 20 runs), and fails with the split removed but without the first commit. The other ordered-append cases still pass. Full GPU suite, one case per process: same failures as main. The wait is still bounded, so a wave that is never released can't hang the dispatch. If you had a game where the split fixed something the in-shader order doesn't cover, tell me which one and I'll check it.
This pull request has changes conflicting with the target branch.
  • src/graphics/host_gpu/renderer/cache/bufferCache.cpp
  • src/graphics/host_gpu/renderer/pipeline/shaders.cpp
  • src/graphics/host_gpu/renderer/render.h
  • src/graphics/host_gpu/renderer/renderCompute.cpp
  • src/graphics/shader/recompiler/ir/ShaderIR.h
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1199/head:github-bot/gh-1199'
git switch 'github-bot/gh-1199'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1199'
git switch 'github-bot/gh-1199'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1199'
git switch 'github-bot/gh-1199'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1199'
git switch 'main'
git merge --squash 'github-bot/gh-1199'
git switch 'main'
git merge --ff-only 'github-bot/gh-1199'
git switch 'main'
git merge 'github-bot/gh-1199'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.