gpu: allow compute dispatches to read buffers they write through scalar loads #1403

Open
github-bot wants to merge 4 commits from github-bot/gh-1403 into main AGit
Owner

@⁠ReverendOzmund on GitHub · 2026-10-11 07:02 UTC · original
ReverendOzmund:fix/compute-self-overlap → main · +13 −2 · 1 files · 4 commits · open

Halo: Campaign Evolved (PPSA28038) stops at scalar resource reads overlap a shader buffer write (descriptors.cpp) right when the menu narration prompt comes up. added logging to see what was overlapping and its a single compute shader overlapping itself:

reader stage=Compute hash=cff4569b849942cd read=[1051830018 +4]
writer stage=Compute hash=cff4569b849942cd same_stage=1 buffer=4 written=[1051830000 +100]

so its one dispatch reading a dword at offset 0x18 of a 256 byte buffer it also writes (looks like a small control/counter block)

this skips the check only when the writer is the same compute stage as the reader. reasoning: on hardware those scalar loads go through the scalar cache which isnt coherent with the dispatch's own vector writes, so the value at dispatch start (what the specialization captured) is a valid result, and the next dispatch re-materializes from memory anyway. cross stage overlaps, image writes and address writes all still EXIT like before

i know this check is there on purpose so if youd rather handle it differently (narrower write ranges, per-dword tracking etc) happy to change it

testing

  • with this + #1365 halo gets past the narration prompt, renders the title screen correctly at ~29fps (screenshot below), takes input, and reaches its online login screen which fails since theres no PSN (separate thing)
  • no visual corruption on the title screen, which id expect if the shader actually depended on seeing its own writes
  • shader_recompiler_compute_tests all pass on host
  • bazzite 44 / rtx 3080 ti / nvidia 615.71.09

ai

used claude to add the diagnostics, work out what was overlapping and write the fix. i ran all the testing myself

**@⁠ReverendOzmund** on GitHub · 2026-10-11 07:02 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1403) `ReverendOzmund:fix/compute-self-overlap` → `main` · +13 −2 · 1 files · 4 commits · open Halo: Campaign Evolved (PPSA28038) stops at `scalar resource reads overlap a shader buffer write` (descriptors.cpp) right when the menu narration prompt comes up. added logging to see what was overlapping and its a single compute shader overlapping itself: reader stage=Compute hash=cff4569b849942cd read=[1051830018 +4] writer stage=Compute hash=cff4569b849942cd same_stage=1 buffer=4 written=[1051830000 +100] so its one dispatch reading a dword at offset 0x18 of a 256 byte buffer it also writes (looks like a small control/counter block) this skips the check only when the writer is the same compute stage as the reader. reasoning: on hardware those scalar loads go through the scalar cache which isnt coherent with the dispatch's own vector writes, so the value at dispatch start (what the specialization captured) is a valid result, and the next dispatch re-materializes from memory anyway. cross stage overlaps, image writes and address writes all still EXIT like before i know this check is there on purpose so if youd rather handle it differently (narrower write ranges, per-dword tracking etc) happy to change it ## testing - with this + #1365 halo gets past the narration prompt, renders the title screen correctly at ~29fps (screenshot below), takes input, and reaches its online login screen which fails since theres no PSN (separate thing) - no visual corruption on the title screen, which id expect if the shader actually depended on seeing its own writes - shader_recompiler_compute_tests all pass on host - bazzite 44 / rtx 3080 ti / nvidia 615.71.09 ## ai used claude to add the diagnostics, work out what was overlapping and write the fix. i ran all the testing myself
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:55:51 +00:00
Author
Owner

@⁠ReverendOzmund on GitHub · 2026-10-11 07:03 UTC · original

same shader hits it on 3 different 256 byte buffers (1051b10000, 1050ae0000, 1024220000), always reading offset 0x18, so it looks like a per-instance control block not a one off

**@⁠ReverendOzmund** on GitHub · 2026-10-11 07:03 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1403#issuecomment-6106494190) same shader hits it on 3 different 256 byte buffers (1051b10000, 1050ae0000, 1024220000), always reading offset 0x18, so it looks like a per-instance control block not a one off
Author
Owner

@⁠ReverendOzmund on GitHub · 2026-10-11 07:04 UTC · original

Screenshot_20261011_145706
**@⁠ReverendOzmund** on GitHub · 2026-10-11 07:04 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1403#issuecomment-6106502041) <img width="1284" height="747" alt="Screenshot_20261011_145706" src="https://github.com/user-attachments/assets/daafec5d-fc79-4f19-8e10-c74b4c28a029" />
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-11 07:05 UTC · original · edited 2026-10-11 09:53 UTC

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f0acc520-9d9e-4fe8-bfc4-1eeb3b3d8c4e


📥 Commits

Reviewing files that changed from the base of the PR and between 7ee598b4c7 and f26b1d7e62.



📒 Files selected for processing (1)
  • src/graphics/host_gpu/renderer/pipeline/descriptors.cpp


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




📝 Walkthrough
📝 Walkthrough

Walkthrough

FindBuffers permits sentinel-sized buffer writes to overlap scalar reads from the same compute stage. CommitBindings skips scalar-read overlap checks against buffer writes from the same compute dispatch. Both functions retain checks for other stages; CommitBindings also retains checks for image and attachment writes.

Suggested reviewers: nmzik



Priority: ➖ Normal

Change: Bug fix

Merge Risk: ⚪ Minimal · up to a9e73

The targeted same-dispatch reads can proceed when their descriptors fit the device limits, while the other overlap checks remain. No material new user-facing risk is established.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: allowing compute dispatches to read buffers that they also write through scalar loads.
Description check Passed The description directly explains the overlap failure, the proposed same-stage compute exception, preserved validation behavior, and test results.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.



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

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-11 07:05 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1403#issuecomment-6106510079) · edited 2026-10-11 09:53 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/1403?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=3"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3" alt="Review in Change Stack →" height="32"></picture></a> <!-- review_stack_entry_end --> <!-- recent_review_start --> No actionable comments were generated in the recent review. 🎉 <details> <summary><strong>ℹ️ Recent review info</strong></summary> <dl> <dd> <dl> <dd> <details> <summary><strong>⚙️ Run configuration</strong></summary> <dl> <dd> <dl> <dd> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `f0acc520-9d9e-4fe8-bfc4-1eeb3b3d8c4e` <hr> </dd> </dl> <hr> </dd> </dl> </details> <details> <summary><strong>📥 Commits</strong></summary> <dl> <dd> <dl> <dd> Reviewing files that changed from the base of the PR and between 7ee598b4c74ca5b0a1e7c1a3250d9a9dee5afec1 and f26b1d7e62e3db0e06f0acb8c0cab21fb707d89c. <hr> </dd> </dl> <hr> </dd> </dl> </details> <details> <summary><strong>📒 Files selected for processing (1)</strong></summary> <dl> <dd> <dl> <dd> * `src/graphics/host_gpu/renderer/pipeline/descriptors.cpp` <hr> </dd> </dl> <hr> </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review. <hr> </dd> </dl> <hr> </dd> </dl> </details> --- <!-- recent_review_end --> <!-- walkthrough_start --> <details> <summary><strong>📝 Walkthrough</strong></summary> <dl> <dd> <details> <summary><strong>📝 Walkthrough</strong></summary> <dl> <dd> ## Walkthrough `FindBuffers` permits sentinel-sized buffer writes to overlap scalar reads from the same compute stage. `CommitBindings` skips scalar-read overlap checks against buffer writes from the same compute dispatch. Both functions retain checks for other stages; `CommitBindings` also retains checks for image and attachment writes. **Suggested reviewers:** `nmzik` <hr> </dd> </dl> </details> <hr> </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ➖ Normal <!-- change_assessment_commit:"f26b1d7e62e3db0e06f0acb8c0cab21fb707d89c" --> **Change:** Bug fix <!-- change_assessment_end --> <!-- final_review_risk_start --> **Merge Risk:** **⚪ Minimal** · up to `a9e73` <!-- final_review_risk_coverage:{"sourceCommitId":"f26b1d7e62e3db0e06f0acb8c0cab21fb707d89c","coveredCommitId":"a9e73f4ef29829e4f8cf063e22254d805d9293ba","kind":"no_op_rewrite_carry_forward"} --> The targeted same-dispatch reads can proceed when their descriptors fit the device limits, while the other overlap checks remain. No material new user-facing risk is established. <!-- final_review_risk_end --> <!-- pre_merge_checks_walkthrough_start --> <details> <summary><strong>Pre-merge checks | <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v1.svg" width="14" height="17" align="middle" alt="Passed" title="Passed"></picture></sup> 4 | <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v1.svg" width="14" height="17" align="middle" alt="Failed" title="Failed"></picture></sup> 1</strong></summary> <dl> <dd> <dl> <dd> ### ❌ Failed checks (1 warning) | Check name | Status | Explanation | Resolution | | :---------------- | :----------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ![Warning](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-warning.svg) | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 1 files. | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary><strong>✅ Passed checks (4 passed)</strong></summary> <dl> <dd> <dl> <dd> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------- | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title clearly and concisely describes the main change: allowing compute dispatches to read buffers that they also write through scalar loads. | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description directly explains the overlap failure, the proposed same-stage compute exception, preserved validation behavior, and test results. | | Linked Issues check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | </dd> </dl> <hr> </dd> </dl> </details> <hr> </dd> </dl> <hr> </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">Autofix</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts <!-- autopilot:end --> <!-- tips_start --> --- Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=1403)! 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) <hr> </dd> </dl> </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
@ -973,0 +980,4 @@
// writes, so the value captured at dispatch start is a valid result. The next
// dispatch re-materializes its specialization from memory, so the writes are still
// observed from then on.
if (writer == reader && program.stage == ShaderType::Compute) continue;
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-11 07:05 UTC · original · edited 2026-10-11 07:19 UTC

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Apply the compute exception before FindBuffers handles sentinel writes.

If a writable buffer has NumRecords()==UINT32_MAX and overlaps a specialization read, FindBuffers runs first. It can exit on the overlap or truncate the write range at the read address, so this exception cannot preserve the full same-dispatch write range. Update that earlier check to allow same-stage compute overlaps while retaining cross-stage checks. The compute path in src/graphics/host_gpu/renderer/renderCompute.cpp, Lines 337–356, calls FindBuffers before CommitBindings.

✅ Addressed in commit 7ee598b

**@⁠coderabbitai[bot]** on GitHub · 2026-10-11 07:05 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1403#discussion_r4240620632) · edited 2026-10-11 07:19 UTC **🎯 Functional Correctness** | **🟡 Minor** | **⚡ Quick win** **Apply the compute exception before `FindBuffers` handles sentinel writes.** If a writable buffer has `NumRecords()==UINT32_MAX` and overlaps a specialization read, `FindBuffers` runs first. It can exit on the overlap or truncate the write range at the read address, so this exception cannot preserve the full same-dispatch write range. Update that earlier check to allow same-stage compute overlaps while retaining cross-stage checks. The compute path in `src/graphics/host_gpu/renderer/renderCompute.cpp`, Lines 337–356, calls `FindBuffers` before `CommitBindings`. <!-- fingerprinting:phantom:triton:serval --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:a56baef9b88f6c8565fc9f16 --> <!-- This is an auto-generated reply by CodeRabbit --> ✅ Addressed in commit 7ee598b
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-11 07:05 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: 0bad9939-d60d-49d6-a45e-d5b6940013f9
📥 Commits

Reviewing files that changed from the base of the PR and between 730e1a3cf3 and a9d34f7074.

📒 Files selected for processing (1)
  • src/graphics/host_gpu/renderer/pipeline/descriptors.cpp

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

**@⁠coderabbitai[bot]** on GitHub · 2026-10-11 07:05 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1403#pullrequestreview-5482274944) · **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**: `0bad9939-d60d-49d6-a45e-d5b6940013f9` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 730e1a3cf39d50c787d477e813e0bef92006a063 and a9d34f7074389ad539a74ed9ace1360c5750ac90. </details> <details> <summary>📒 Files selected for processing (1)</summary> * `src/graphics/host_gpu/renderer/pipeline/descriptors.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=d59907cd-6117-4ec2-a71a-ccbd1a781405 attempt=83995579-57b8-4ccd-9959-9ef39c1c64b8 batch=1/1 -->
@ -973,0 +980,4 @@
// writes, so the value captured at dispatch start is a valid result. The next
// dispatch re-materializes its specialization from memory, so the writes are still
// observed from then on.
if (writer == reader && program.stage == ShaderType::Compute) continue;
Author
Owner

@⁠ReverendOzmund on GitHub · 2026-10-11 07:10 UTC · original

good catch, the sentinel range path in FindBuffers had the same check. applied the same same-stage compute exception there so both places agree. halo didnt hit that path so its just for consistency, retested halo + shader_recompiler_compute_tests still pass

**@⁠ReverendOzmund** on GitHub · 2026-10-11 07:10 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1403#discussion_r4240631110) good catch, the sentinel range path in FindBuffers had the same check. applied the same same-stage compute exception there so both places agree. halo didnt hit that path so its just for consistency, retested halo + shader_recompiler_compute_tests still pass
Author
Owner

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

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

🟠 Major · Preserve the full sentinel range when removing the size limit. · descriptors.cpp:779-780

src/graphics/host_gpu/renderer/pipeline/descriptors.cpp:779-780
🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift

Preserve the full sentinel range when removing the size limit.

When a compute stage skips its own scalar reads, ClampRangeSize can merge adjacent committed ranges beyond maxStorageBufferRange. NativeStorageBuffer then exits because it passes size + adjustment as the Vulkan descriptor range. Capping only size to maxStorageBufferRange still fails when adjustment is non-zero.

A cap that accounts for alignment would bind the descriptor, but it would reduce OpArrayLength. The generated shader skips loads and stores whose indices exceed that length, so writes beyond the cap would be lost. Use a range-preserving binding strategy, such as splitting the resource and updating the generated access mapping, instead of a simple clamp.


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0f2eda76-44a4-472f-b0fc-889023d638f8
📥 Commits

Reviewing files that changed from the base of the PR and between a9d34f7074 and 7ee598b4c7.

📒 Files selected for processing (1)
  • src/graphics/host_gpu/renderer/pipeline/descriptors.cpp
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/graphics/host_gpu/renderer/pipeline/descriptors.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-11 07:14 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1403#pullrequestreview-5482298395) · **reviewed** > [!CAUTION] > Some comments are outside the diff and can’t be posted inline due to GitHub limitations. > > **⚠️ Outside diff range comments (1)** > > <details> > <summary><strong>🟠 Major</strong> · Preserve the full sentinel range when removing the size limit. · <code>descriptors.cpp:779-780</code></summary><blockquote> > > `src/graphics/host_gpu/renderer/pipeline/descriptors.cpp:779-780` > **🩺 Stability & Availability** | **🟠 Major** | **🏗️ Heavy lift** > > **Preserve the full sentinel range when removing the size limit.** > > When a compute stage skips its own scalar reads, `ClampRangeSize` can merge adjacent committed ranges beyond `maxStorageBufferRange`. `NativeStorageBuffer` then exits because it passes `size + adjustment` as the Vulkan descriptor range. Capping only `size` to `maxStorageBufferRange` still fails when `adjustment` is non-zero. > > A cap that accounts for alignment would bind the descriptor, but it would reduce `OpArrayLength`. The generated shader skips loads and stores whose indices exceed that length, so writes beyond the cap would be lost. Use a range-preserving binding strategy, such as splitting the resource and updating the generated access mapping, instead of a simple clamp. > > <!-- cr-comment:v1:59a2cde59b19e7cefe2a8f1c --> > > </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**: `0f2eda76-44a4-472f-b0fc-889023d638f8` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between a9d34f7074389ad539a74ed9ace1360c5750ac90 and 7ee598b4c74ca5b0a1e7c1a3250d9a9dee5afec1. </details> <details> <summary>📒 Files selected for processing (1)</summary> * `src/graphics/host_gpu/renderer/pipeline/descriptors.cpp` </details> <details> <summary>🚧 Files skipped from review as they are similar to previous changes (1)</summary> * src/graphics/host_gpu/renderer/pipeline/descriptors.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=2b3a8fd8-cbb8-4dd6-a01a-2f8d72dfd5cd attempt=484ce474-fd18-4815-a0fa-6bbcfef407e9 batch=1/1 -->
@ -973,0 +980,4 @@
// writes, so the value captured at dispatch start is a valid result. The next
// dispatch re-materializes its specialization from memory, so the writes are still
// observed from then on.
if (writer == reader && program.stage == ShaderType::Compute) continue;
Author
Owner

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

@ReverendOzmund Thanks for the fix and retesting. FindBuffers now applies the same-stage compute exception before it bounds sentinel write ranges. Cross-stage checks remain intact, so this addresses the finding.


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-11 07:20 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1403#discussion_r4240671241) `@ReverendOzmund` Thanks for the fix and retesting. `FindBuffers` now applies the same-stage compute exception before it bounds sentinel write ranges. Cross-stage checks remain intact, so this addresses the finding. --- <!-- 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=Great%20catch%20from%20%40coderabbitai%3A%20allow%20same-stage%20compute%20overlaps%20in%20FindBuffers%20to%20preserve%20full%20sentinel%20write%20ranges%2C%20while%20keeping%20cross-stage%20checks.%20Try%20CodeRabbit%20on%20your%20PRs!%20%F0%9F%90%87&url=https%3A%2F%2Fgithub.com%2FKytyPS5%2FKytyPS5%2Fpull%2F1403%23discussion_r4240620632)? 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

@⁠ReverendOzmund on GitHub · 2026-10-11 07:26 UTC · original

fyi the windows failure here is from main not this PR, small is a windows sdk macro (b7b335a). fix is up in #1404

**@⁠ReverendOzmund** on GitHub · 2026-10-11 07:26 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1403#issuecomment-6106663467) fyi the windows failure here is from main not this PR, `small` is a windows sdk macro (b7b335a). fix is up in #1404
Author
Owner

@⁠ReverendOzmund on GitHub · 2026-10-11 07:38 UTC · original

fair point on the sentinel range, skipping own reads entirely let the range grow past what it was before. changed it so own compute reads after the buffer start still end the range like before (so it can never get bigger than it used to), and only the overlap-at-start case that used to EXIT is allowed. range splitting would be a bigger change so leaving that for the maintainers if they want it. retested halo + shader_recompiler_compute_tests, both fine

**@⁠ReverendOzmund** on GitHub · 2026-10-11 07:38 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1403#issuecomment-6106755927) fair point on the sentinel range, skipping own reads entirely let the range grow past what it was before. changed it so own compute reads after the buffer start still end the range like before (so it can never get bigger than it used to), and only the overlap-at-start case that used to EXIT is allowed. range splitting would be a bigger change so leaving that for the maintainers if they want it. retested halo + shader_recompiler_compute_tests, both fine
Author
Owner

@⁠theantipopau on GitHub · 2026-10-11 07:40 UTC · original

Cross-checked this against the recompiler side (58b2295c local checkout) — thanks for the quick Halo repro, this unblocks scalar resource reads overlap a shader buffer write for self-reads that are architecturally valid on GCN.

A few code-level notes from reading the diff against the current head of main:

1. The gpu_scalar_reads BDA path is unaffected (good). FindBdaBuffers(snapshot.gpu_scalar_reads) in FindBuffers runs before the sentinel loop and doesn't consult specialization_reads, so GPU-side scalar loads (the LoadAddressU32 plan from commit 58b2295cb8) still get made resident unconditionally per stage. Only the host-side scalar-read plan (specialization_reads) sees the skip.

2. writer == reader && Compute skip is keyed on pointer identity of PreparedBindings. That's fine for a single dispatch, but note in the staggered case where the same compute program is bound twice in one command sequence (e.g. prepared_bindings containing two entries of the same runtime), the skip only fires when they alias. Worth a brief comment in the PR that aliasing two different dispatches of the same shader still enforces the overlap check — that's the semantics you want.

3. Coderabbit's ClampRangeSize note looks real but is unrelated to the skip condition. ClampRangeSize(address, size) at descriptors.cpp:842 already clamps down to host-mapped size before NativeStorageBuffer runs the size > maxStorageBufferRange / adjustment checks. If a sentinel write range (that reaches the else branch instead of the sentinel path) is what the note is about, that's outside this diff — worth filing separately.

4. On the "skip only when writer == reader and stage == Compute" rationale — matches the SAROS pattern in ResourceTracking.cpp (line ~811): shader-side atomics through GPU scalar loads deliberately keep their payload off the host recall plan for exactly this reason; the value at dispatch start is well-defined. Same reasoning applies here for scalar reads that overlap self-writes when the shader is re-specialized per dispatch anyway.

If CI turns green (the current Windows failure is a pre-existing const auto small RPC macro collision introduced by b7b335a on main — see #1404 for the unrelated fix), this is good to merge from my side. Nice find on always reading offset 0x18 across three different buffer addresses; that matches a per-instance control-counter pattern (a workgroup index table, likely).

**@⁠theantipopau** on GitHub · 2026-10-11 07:40 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1403#issuecomment-6106765935) Cross-checked this against the recompiler side (`58b2295c` local checkout) — thanks for the quick Halo repro, this unblocks `scalar resource reads overlap a shader buffer write` for self-reads that are architecturally valid on GCN. A few code-level notes from reading the diff against the current head of `main`: **1. The `gpu_scalar_reads` BDA path is unaffected (good).** `FindBdaBuffers(snapshot.gpu_scalar_reads)` in `FindBuffers` runs before the sentinel loop and doesn't consult `specialization_reads`, so GPU-side scalar loads (the `LoadAddressU32` plan from commit 58b2295cb8) still get made resident unconditionally per stage. Only the host-side scalar-read plan (`specialization_reads`) sees the skip. **2. `writer == reader && Compute` skip is keyed on pointer identity of `PreparedBindings`.** That's fine for a single dispatch, but note in the staggered case where the same compute program is bound twice in one command sequence (e.g. `prepared_bindings` containing two entries of the same runtime), the skip only fires when they alias. Worth a brief comment in the PR that aliasing two *different* dispatches of the same shader still enforces the overlap check — that's the semantics you want. **3. Coderabbit's ClampRangeSize note looks real but is unrelated to the skip condition.** `ClampRangeSize(address, size)` at descriptors.cpp:842 already clamps down to host-mapped size before `NativeStorageBuffer` runs the `size > maxStorageBufferRange` / `adjustment` checks. If a sentinel write range (that reaches the `else` branch instead of the sentinel path) is what the note is about, that's outside this diff — worth filing separately. **4. On the "skip only when `writer == reader` and `stage == Compute`" rationale** — matches the SAROS pattern in `ResourceTracking.cpp` (line ~811): shader-side atomics through GPU scalar loads deliberately keep their payload off the host recall plan for exactly this reason; the value at dispatch start is well-defined. Same reasoning applies here for scalar reads that overlap self-writes when the shader is re-specialized per dispatch anyway. If CI turns green (the current Windows failure is a pre-existing `const auto small` RPC macro collision introduced by b7b335a on main — see #1404 for the unrelated fix), this is good to merge from my side. Nice find on always reading offset 0x18 across three different buffer addresses; that matches a per-instance control-counter pattern (a workgroup index table, likely).
Author
Owner

@⁠ReverendOzmund on GitHub · 2026-10-11 07:43 UTC · original

thanks for the thorough look

on 2, yeah thats intended. the skip only fires when writer and reader are literally the same PreparedBindings, so two different dispatches of the same shader (or the same program bound twice in one sequence) still go through the overlap check like before. only a dispatch reading its own writes gets the pass

on 3, agreed its separate. the latest commit keeps own reads after the buffer start ending the sentinel range like before so this PR cant make that range any bigger than it already was

windows should go green once #1404 is in

**@⁠ReverendOzmund** on GitHub · 2026-10-11 07:43 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1403#issuecomment-6106791279) thanks for the thorough look on 2, yeah thats intended. the skip only fires when writer and reader are literally the same PreparedBindings, so two different dispatches of the same shader (or the same program bound twice in one sequence) still go through the overlap check like before. only a dispatch reading its own writes gets the pass on 3, agreed its separate. the latest commit keeps own reads after the buffer start ending the sentinel range like before so this PR cant make that range any bigger than it already was windows should go green once #1404 is in
Author
Owner

@⁠theantipopau on GitHub · 2026-10-12 10:18 UTC · original · approved these changes

Re-checked against main (merge-base f3836bb8) after the sentinel-range revision:

  • CommitBindings: the has_address_writes EXIT and the image/attachment overlap EXIT still run unconditionally ahead of the new skip, so the only loosened case is the exact self-pair (writer == reader, pointer identity on PreparedBindings), and two different stages binding the same compute program still enforce the check.
  • FindBuffers: own_compute_reads only suppresses the EXIT below the range start; the read_address > address branch still shrinks the sentinel range at the first own read above the buffer base, so a shifted table keeps bounding it and the range can't grow past what it was before. Own reads below the start no longer abort — which is the Halo control/counter case.
  • Scalar-load coherence reasoning holds: the dispatch's specialization was materialized from memory at dispatch time, so Seeing the start-of-dispatch value is valid, and the next dispatch re-materializes after the writes.

Windows CI was pre-existing small macro fallout (fixed by #1404) and is now green on all three platforms with this head (run 38129958667). LGTM.

**@⁠theantipopau** on GitHub · 2026-10-12 10:18 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1403#pullrequestreview-5489364030) · **approved these changes** Re-checked against main (merge-base f3836bb8) after the sentinel-range revision: - CommitBindings: the `has_address_writes` EXIT and the image/attachment overlap EXIT still run unconditionally ahead of the new skip, so the only loosened case is the exact self-pair (`writer == reader`, pointer identity on PreparedBindings), and two different stages binding the same compute program still enforce the check. - FindBuffers: `own_compute_reads` only suppresses the EXIT below the range start; the `read_address > address` branch still shrinks the sentinel range at the first own read above the buffer base, so a shifted table keeps bounding it and the range can't grow past what it was before. Own reads *below* the start no longer abort — which is the Halo control/counter case. - Scalar-load coherence reasoning holds: the dispatch's specialization was materialized from memory at dispatch time, so Seeing the start-of-dispatch value is valid, and the next dispatch re-materializes after the writes. Windows CI was pre-existing `small` macro fallout (fixed by #1404) and is now green on all three platforms with this head (run 38129958667). LGTM.
Author
Owner

@⁠ReverendOzmund on GitHub · 2026-10-12 12:05 UTC · original

thanks for the thorough re-check! appreciate you going through the sentinel range bit too

**@⁠ReverendOzmund** on GitHub · 2026-10-12 12:05 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1403#issuecomment-6123922793) thanks for the thorough re-check! appreciate you going through the sentinel range bit too
Author
Owner

@⁠ReverendOzmund on GitHub · 2026-10-18 07:43 UTC · original

re-tested on latest main (37df7f3) + #1365, still needed for halo to get to the title screen on linux. merges clean, no conflicts

(used claude to help with this, tested it myself)

**@⁠ReverendOzmund** on GitHub · 2026-10-18 07:43 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1403#issuecomment-6247258655) re-tested on latest main (37df7f3) + #1365, still needed for halo to get to the title screen on linux. merges clean, no conflicts (used claude to help with this, tested it myself)
This pull request has changes conflicting with the target branch.
  • src/graphics/host_gpu/renderer/pipeline/descriptors.cpp
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/1403/head:github-bot/gh-1403'
git switch 'github-bot/gh-1403'

Merge

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