renderer: check scalar reads against the bytes a shader buffer write can reach #1738

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

@⁠0xcrstn on GitHub · 2026-10-19 23:46 UTC · original
0xcrstn:fix/ufc6-scalar-read-write-range → main · +315 −9 · 6 files · 2 commits · closed without merging

Game and problem

EA SPORTS UFC 6 (PPSA23566, 01.004.000), Windows 11, RTX 5090 (driver 617.42), with a save that boots straight to the main menu. About 40-70 s after start the emulator exits with:

scalar resource reads overlap a shader buffer write
 in src/graphics/host_gpu/renderer/pipeline/descriptors.cpp:961

On main the game hits the GPU fault that #1737 fixes before it gets this far. The exit is still on main: with that fault avoided by skipping the one shader that triggers it (a diagnostic build, no #1737), main stops here too, 2 of 2 runs at the same point.

Cause

I logged every stage, read and written buffer at the exit:

  • It is one compute dispatch, CS 0x940345cace0f5304, reading and writing.
  • Its only specialization read is the dword at offset 0x34 of a 56-byte struct: s_load_dword s18, s[4:5], 0x34 (pc 0x000c). The value becomes the record count of four other buffers.
  • The same struct is bound as a written buffer: V# s[4:7], stride 56, 1 record, so the bound range is 56 bytes.
  • The only writes to s[4:7] in the shader binary are buffer_atomic_add at offset 0x24 (pc 0x0334), buffer_store_dword at 0x28 (pc 0x0368) and buffer_atomic_add at 0x2c (pc 0x03cc), all with offen=0, idxen=0 and soffset 0. They cover bytes 0x24-0x2f.

No write can reach the dword at 0x34. CommitBindings exits because it treats the descriptor's whole bound range as written.

Change

  • ResourceTracking records, per buffer, the bytes its writes can reach relative to the descriptor base (written_begin/written_end), when every write has index 0 and constant VGPR and SGPR offsets. That is the address CalculateBufferAddress computes. Any other write, and any formatted store, marks the range dynamic.
  • The backend accesses whole 4-byte words (8-byte words for 64-bit atomics) at the address rounded down, so the range is widened by one element minus one byte on each side (written_slack).
  • CommitBindings gathers each written buffer's range once per draw or dispatch (AppendShaderBufferWrites) and compares specialization reads with it. It falls back to the whole bound range when the V# has ADD_TID or swizzle, the range is dynamic, or the range does not fit the bound range. The check is therefore unchanged for every write it cannot bound. The image/attachment and address-write checks are untouched.

For UFC 6 the gathered write range is 0x21-0x33 and the read is 0x34-0x37.

This is narrower than #1403, which skips the check for any compute dispatch reading its own writes; its author offered "narrower write ranges, per-dword tracking" as an alternative. The two don't conflict. #1285 changes the same loop for performance; the gathered ranges are what a merged-range list would consume. The FindBuffers sentinel path (NumRecords == UINT32_MAX) keeps its own check unchanged; UFC 6 does not reach it.

Testing

  • New CheckBufferWrittenRanges in ShaderRecompilerComputeTests.cpp:
    • compiles the UFC 6 write pattern (atomic/store/atomic at 0x24/0x28/0x2c) and checks the range 0x24-0x30 with 3 bytes of slack;
    • a 64-bit atomic at offset 4: range 4-12 with 7 bytes of slack, and it still overlaps a read at offset 0;
    • a store with a thread-ID VGPR offset stays dynamic;
    • ADD_TID, swizzle, dynamic and past-the-end ranges keep the whole bound range;
    • the gathering uses each buffer's own descriptor when its resource index and descriptor slot differ.
      It fails without the tracking, without the slack, and with the descriptor looked up by slot.
  • shader_recompiler_compute_tests: all cases pass (Windows, clang-cl, RTX 5090).
  • UFC 6 with this and #1737, from the main-menu save, no input, cleared pipeline cache: 4 runs (two of 8 minutes on an earlier revision, two of 3 minutes on this one) with no exit and no GPU fault, past the point where the exit happened before.

AI use

Claude Code did the investigation (diagnostic logging, shader binary decoding, IR reading), wrote the change and the test, ran the tests and the scripted game runs, and ran the CodeRabbit, Codex and Claude reviews (the Codex review found the 64-bit atomic alignment case, now fixed). I reviewed the evidence and the change and played the game on the integration build.

**@⁠0xcrstn** on GitHub · 2026-10-19 23:46 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1738) `0xcrstn:fix/ufc6-scalar-read-write-range` → `main` · +315 −9 · 6 files · 2 commits · closed without merging ## Game and problem EA SPORTS UFC 6 (PPSA23566, 01.004.000), Windows 11, RTX 5090 (driver 617.42), with a save that boots straight to the main menu. About 40-70 s after start the emulator exits with: ``` scalar resource reads overlap a shader buffer write in src/graphics/host_gpu/renderer/pipeline/descriptors.cpp:961 ``` On `main` the game hits the GPU fault that #1737 fixes before it gets this far. The exit is still on `main`: with that fault avoided by skipping the one shader that triggers it (a diagnostic build, no #1737), `main` stops here too, 2 of 2 runs at the same point. ## Cause I logged every stage, read and written buffer at the exit: - It is one compute dispatch, CS `0x940345cace0f5304`, reading and writing. - Its only specialization read is the dword at offset `0x34` of a 56-byte struct: `s_load_dword s18, s[4:5], 0x34` (pc 0x000c). The value becomes the record count of four other buffers. - The same struct is bound as a written buffer: V# `s[4:7]`, stride 56, 1 record, so the bound range is 56 bytes. - The only writes to `s[4:7]` in the shader binary are `buffer_atomic_add` at offset 0x24 (pc 0x0334), `buffer_store_dword` at 0x28 (pc 0x0368) and `buffer_atomic_add` at 0x2c (pc 0x03cc), all with offen=0, idxen=0 and soffset 0. They cover bytes 0x24-0x2f. No write can reach the dword at 0x34. `CommitBindings` exits because it treats the descriptor's whole bound range as written. ## Change - `ResourceTracking` records, per buffer, the bytes its writes can reach relative to the descriptor base (`written_begin`/`written_end`), when every write has index 0 and constant VGPR and SGPR offsets. That is the address `CalculateBufferAddress` computes. Any other write, and any formatted store, marks the range dynamic. - The backend accesses whole 4-byte words (8-byte words for 64-bit atomics) at the address rounded down, so the range is widened by one element minus one byte on each side (`written_slack`). - `CommitBindings` gathers each written buffer's range once per draw or dispatch (`AppendShaderBufferWrites`) and compares specialization reads with it. It falls back to the whole bound range when the V# has ADD_TID or swizzle, the range is dynamic, or the range does not fit the bound range. The check is therefore unchanged for every write it cannot bound. The image/attachment and address-write checks are untouched. For UFC 6 the gathered write range is 0x21-0x33 and the read is 0x34-0x37. This is narrower than #1403, which skips the check for any compute dispatch reading its own writes; its author offered "narrower write ranges, per-dword tracking" as an alternative. The two don't conflict. #1285 changes the same loop for performance; the gathered ranges are what a merged-range list would consume. The `FindBuffers` sentinel path (`NumRecords == UINT32_MAX`) keeps its own check unchanged; UFC 6 does not reach it. ## Testing - New `CheckBufferWrittenRanges` in `ShaderRecompilerComputeTests.cpp`: - compiles the UFC 6 write pattern (atomic/store/atomic at 0x24/0x28/0x2c) and checks the range 0x24-0x30 with 3 bytes of slack; - a 64-bit atomic at offset 4: range 4-12 with 7 bytes of slack, and it still overlaps a read at offset 0; - a store with a thread-ID VGPR offset stays dynamic; - ADD_TID, swizzle, dynamic and past-the-end ranges keep the whole bound range; - the gathering uses each buffer's own descriptor when its resource index and descriptor slot differ. It fails without the tracking, without the slack, and with the descriptor looked up by slot. - `shader_recompiler_compute_tests`: all cases pass (Windows, clang-cl, RTX 5090). - UFC 6 with this and #1737, from the main-menu save, no input, cleared pipeline cache: 4 runs (two of 8 minutes on an earlier revision, two of 3 minutes on this one) with no exit and no GPU fault, past the point where the exit happened before. ## AI use Claude Code did the investigation (diagnostic logging, shader binary decoding, IR reading), wrote the change and the test, ran the tests and the scripted game runs, and ran the CodeRabbit, Codex and Claude reviews (the Codex review found the 64-bit atomic alignment case, now fixed). I reviewed the evidence and the change and played the game on the integration build.
CommitBindings exits with "scalar resource reads overlap a shader buffer
write" when a specialization read overlaps the whole bound range of any
buffer the draw or dispatch writes. In EA SPORTS UFC 6 (PPSA23566) this
stops the game at the main menu: compute shader 0x940345cace0f5304
specializes on `s_load_dword s18, s[4:5], 0x34` and binds the same
56-byte struct as a written buffer (V# s[4:7], stride 56, 1 record). Its
only writes to that buffer are buffer_atomic_add at offset 0x24,
buffer_store_dword at 0x28 and buffer_atomic_add at 0x2c (offen=0,
idxen=0, soffset 0), bytes 0x24-0x2f, so no write can reach the dword
read at 0x34.

Resource tracking now records, per buffer, the byte range its writes can
reach when every write has index 0 and constant VGPR and SGPR offsets
(the address CalculateBufferAddress computes); any other write, and any
formatted store, marks the range dynamic. The backend accesses whole
4-byte words (8-byte words for 64-bit atomics) at the address rounded
down, so the range is widened by one element minus one byte on each
side. CommitBindings gathers each written buffer's range once per draw
or dispatch (AppendShaderBufferWrites) and compares specialization reads
with it when the bound descriptor has neither ADD_TID nor swizzle and the
range fits the bound range; otherwise it keeps the whole bound range, so
the check is unchanged for every write it cannot bound.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
BufferWrittenRanges checked the narrowed write range on its own, so it would
still pass if CommitBindings ignored or misused the gathered writes. Commit a
compute stage shaped like UFC 6 (PPSA23566) shader 0x940345cace0f5304:
constant-offset writes at +0x24..+0x30 and a scalar read at +0x34 must
commit, and a read at +0x28 must exit with the overlap error (child process
on Windows, ExpectFatal elsewhere).

Without the write-range narrowing the +0x34 read exits with "scalar resource
reads overlap a shader buffer write"; with CommitBindings skipping the
gathered writes the +0x28 read no longer exits.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:04:04 +00:00
github-bot closed this pull request 2026-11-26 10:04:04 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-19 23:53 UTC · original · edited 2026-10-20 00:16 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: a380fb40-0d97-4761-b598-925bc7b83b6d
📥 Commits

Reviewing files that changed from the base of the PR and between 0fbf0d2827 and 598f6b01d5.

📒 Files selected for processing: 1
  • 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.

📝 Walkthrough

The change records shader buffer write bounds, slack, and dynamic status during resource tracking. Prepared bindings derive valid shader buffer write ranges and use them to check scalar specialization reads for overlap. Tests cover constant and dynamic writes, range narrowing, fallback cases, buffer gathering, and scalar-read overlap handling.

Suggested reviewers: nmzik

Priority: ➖ Normal

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 598f6

The new checks cover the intended overlap behavior, and no merge-blocking issue is identified.

Pre-merge checks: Passed 4 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Docstring Coverage Inconclusive Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 5 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description check Passed The description clearly explains the shader buffer write-range tracking change, fallback behavior, affected UFC 6 issue, and test coverage.
Title check Passed The title concisely and accurately identifies the main change: checking scalar reads against the bytes reachable by shader buffer writes.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

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

Resolution

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

  • 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-19 23:53 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1738#issuecomment-6279944518) · edited 2026-10-20 00:16 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/1738?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> <details> <summary><strong>⚙️ Run configuration</strong></summary> <dl> <dd> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `a380fb40-0d97-4761-b598-925bc7b83b6d` </dd> </dl> </details> <details> <summary><strong>📥 Commits</strong></summary> <dl> <dd> Reviewing files that changed from the base of the PR and between 0fbf0d2827b48bb87bf594262af2923bdb323cb6 and 598f6b01d5a99aa123648a34bc1cee96849c3566. </dd> </dl> </details> <details> <summary><strong>📒 Files selected for processing: 1</strong></summary> <dl> <dd> * `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; 6 remain after this review. </dd> </dl> </details> <!-- recent_review_end --> <!-- walkthrough_start --> <details> <summary><strong>📝 Walkthrough</strong></summary> <dl> <dd> The change records shader buffer write bounds, slack, and dynamic status during resource tracking. Prepared bindings derive valid shader buffer write ranges and use them to check scalar specialization reads for overlap. Tests cover constant and dynamic writes, range narrowing, fallback cases, buffer gathering, and scalar-read overlap handling. **Suggested reviewers:** `nmzik` </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ➖ Normal <!-- change_assessment_commit:"598f6b01d5a99aa123648a34bc1cee96849c3566" --> **Change:** Bug fix <!-- change_assessment_end --> <details> <summary><strong>Merge Risk:</strong> <strong>⚪ Minimal</strong> · up to <code>598f6</code></summary> <dl> <dd> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **⚪ Minimal** · up to `598f6` --> <!-- final_review_risk_coverage:{"sourceCommitId":"598f6b01d5a99aa123648a34bc1cee96849c3566","coveredCommitId":"598f6b01d5a99aa123648a34bc1cee96849c3566","kind":"reviewed"} --> The new checks cover the intended overlap behavior, and no merge-blocking issue is identified. <!-- 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 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 5 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 | | :------------------------ | :--------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------ | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description clearly explains the shader buffer write-range tracking change, fallback behavior, affected UFC 6 issue, and test coverage. | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title concisely and accurately identifies the main change: checking scalar reads against the bytes reachable by shader buffer writes. | | Linked Issues check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | </dd> </dl> </details> <details> <summary><strong>Full details: Docstring Coverage</strong></summary> <dl> <dd> **Explanation** Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 5 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">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=1738)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary><strong>❤️ Share</strong></summary> <dl> <dd> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </dd> </dl> </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-19 23:53 UTC · original · reviewed

🧹 Nitpick comments: 1
tests/ShaderRecompilerComputeTests.cpp: 1

1899-2032: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Exercise CommitBindings for both overlap outcomes.

CheckBufferWrittenRanges validates ShaderBufferWrittenRange and AppendShaderBufferWrites, but it never calls CommitBindings. Its disjoint check evaluates overlap locally. A regression in the consumer logic could therefore pass while CommitBindings ignores or misuses m_buffer_writes.

Add an integration case with a specialization_reads entry. Assert that a read at +0x34 commits for the narrowed write range, and that a read inside the narrowed range is rejected. This is a coverage gap, not evidence of a current production failure.


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a9d03ed4-f386-4d38-85a7-ef72af74819b
📥 Commits

Reviewing files that changed from the base of the PR and between 0cad4672e9 and 0fbf0d2827.

📒 Files selected for processing: 6
  • src/graphics/host_gpu/renderer/pipeline/descriptors.cpp
  • src/graphics/host_gpu/renderer/pipeline/descriptors.h
  • src/graphics/host_gpu/renderer/render.h
  • src/graphics/shader/recompiler/ir/ShaderIR.h
  • src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp
  • tests/ShaderRecompilerComputeTests.cpp

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

**@⁠coderabbitai[bot]** on GitHub · 2026-10-19 23:53 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1738#pullrequestreview-5579141114) · **reviewed** <details> <summary>🧹 Nitpick comments: 1</summary><blockquote> <details> <summary>tests/ShaderRecompilerComputeTests.cpp: 1</summary><blockquote> `1899-2032`: **🎯 Functional Correctness** | **🔵 Trivial** | **⚡ Quick win** **Exercise `CommitBindings` for both overlap outcomes.** `CheckBufferWrittenRanges` validates `ShaderBufferWrittenRange` and `AppendShaderBufferWrites`, but it never calls `CommitBindings`. Its disjoint check evaluates overlap locally. A regression in the consumer logic could therefore pass while `CommitBindings` ignores or misuses `m_buffer_writes`. Add an integration case with a `specialization_reads` entry. Assert that a read at `+0x34` commits for the narrowed write range, and that a read inside the narrowed range is rejected. This is a coverage gap, not evidence of a current production failure. <!-- cr-comment:v1:827b0b4a902966710ba5f0db --> </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**: `a9d03ed4-f386-4d38-85a7-ef72af74819b` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 0cad4672e948b92b92e1aaf6e9bb5b144d8075ac and 0fbf0d2827b48bb87bf594262af2923bdb323cb6. </details> <details> <summary>📒 Files selected for processing: 6</summary> * `src/graphics/host_gpu/renderer/pipeline/descriptors.cpp` * `src/graphics/host_gpu/renderer/pipeline/descriptors.h` * `src/graphics/host_gpu/renderer/render.h` * `src/graphics/shader/recompiler/ir/ShaderIR.h` * `src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp` * `tests/ShaderRecompilerComputeTests.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=64969beb-3484-4229-b114-34ae4f0e8dca attempt=daebe172-a680-4d14-8be0-61e652854cfd batch=1/1 -->
Author
Owner

@⁠0xcrstn on GitHub · 2026-10-20 00:16 UTC · original

@⁠coderabbitai Thanks, agreed that CheckBufferWrittenRanges only checked the narrowed range directly and would not catch CommitBindings misusing the gathered writes. Addressed in 598f6b01:

  • ScalarReadBufferWriteRange commits a compute stage through CommitBindings with the shape of UFC 6 shader 0x940345cace0f5304: constant-offset writes at +0x24..+0x30, and a scalar read at +0x34 that must commit.
  • A read at +0x28 must exit with the overlap error. This runs in a child process on Windows (--scalar-read-overlap-death, exit code 321) and through ExpectFatal elsewhere.

Checked on Windows (RTX 5090), on this branch:

  • With the narrowing in ShaderBufferWrittenRange disabled, the +0x34 read exits with scalar resource reads overlap a shader buffer write.
  • With CommitBindings ignoring the gathered writes, the +0x28 read no longer exits and the test fails.
  • The full shader_recompiler_compute_tests suite passes.

The Linux ExpectFatal path is not compiled or run yet.

The test and these checks were written and run by Claude Code (an AI agent) at my direction; I reviewed the results.

**@⁠0xcrstn** on GitHub · 2026-10-20 00:16 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1738#issuecomment-6280254285) @⁠coderabbitai Thanks, agreed that `CheckBufferWrittenRanges` only checked the narrowed range directly and would not catch `CommitBindings` misusing the gathered writes. Addressed in 598f6b01: - `ScalarReadBufferWriteRange` commits a compute stage through `CommitBindings` with the shape of UFC 6 shader `0x940345cace0f5304`: constant-offset writes at `+0x24..+0x30`, and a scalar read at `+0x34` that must commit. - A read at `+0x28` must exit with the overlap error. This runs in a child process on Windows (`--scalar-read-overlap-death`, exit code 321) and through `ExpectFatal` elsewhere. Checked on Windows (RTX 5090), on this branch: - With the narrowing in `ShaderBufferWrittenRange` disabled, the `+0x34` read exits with `scalar resource reads overlap a shader buffer write`. - With `CommitBindings` ignoring the gathered writes, the `+0x28` read no longer exits and the test fails. - The full `shader_recompiler_compute_tests` suite passes. The Linux `ExpectFatal` path is not compiled or run yet. The test and these checks were written and run by Claude Code (an AI agent) at my direction; I reviewed the results.
Author
Owner

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

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
ast-grep outline tests/ShaderRecompilerComputeTests.cpp --match 'CommitScalarReadAfterBufferWrite|CheckScalarReadBufferWriteRange|ExpectFatal|main' --view expanded
rg -n -C 28 'void CommitScalarReadAfterBufferWrite|void CheckScalarReadBufferWriteRange|scalar-read-overlap-death|ScalarReadBufferWriteRange|scalar_read_buffer_write_range' tests/ShaderRecompilerComputeTests.cpp

Length of output: 11211


@0xcrstn Thanks for the fix and the detailed validation. I checked the test code. It calls CommitBindings for both the non-overlapping read at +0x34 and the overlapping read at +0x28. It also runs in the default suite.

Your reported Windows mutation checks cover both failure modes from the original concern. This addresses the integration-coverage gap. The Linux ExpectFatal path remains unverified; I did not build or run the tests.


If you found this review helpful, would you consider giving us a shout-out on X?

Thank you for using CodeRabbit!

You are interacting with an AI system.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-20 00:17 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1738#issuecomment-6280263540) <!-- This is an auto-generated reply by CodeRabbit --> > [!TIP] > For best results, initiate chat on the files or code changes. <details> <summary>🧩 Analysis chain</summary> 🏁 Script executed: ```shell #!/bin/bash ast-grep outline tests/ShaderRecompilerComputeTests.cpp --match 'CommitScalarReadAfterBufferWrite|CheckScalarReadBufferWriteRange|ExpectFatal|main' --view expanded rg -n -C 28 'void CommitScalarReadAfterBufferWrite|void CheckScalarReadBufferWriteRange|scalar-read-overlap-death|ScalarReadBufferWriteRange|scalar_read_buffer_write_range' tests/ShaderRecompilerComputeTests.cpp ``` Length of output: 11211 --- </details> `@0xcrstn` Thanks for the fix and the detailed validation. I checked the test code. It calls `CommitBindings` for both the non-overlapping read at `+0x34` and the overlapping read at `+0x28`. It also runs in the default suite. Your reported Windows mutation checks cover both failure modes from the original concern. This addresses the integration-coverage gap. The Linux `ExpectFatal` path remains unverified; I did not build or run the tests. --- <!-- This is an auto-generated comment: tweet message by coderabbit.ai --> If you found this review helpful, would you consider giving us a shout-out on [X](https://twitter.com/intent/tweet?related=CodeRabbitAI&text=%40coderabbitai%20caught%20a%20subtle%20%60CommitBindings%60%20bug%20where%20narrowed%20buffer%20ranges%20missed%20scalar-read%20overlaps.%20Cross-platform%20regression%20tests%20now%20pass%20the%20full%20compute%20suite.%20Try%20it%20for%20sharper%20reviews!%20%F0%9F%94%8D%E2%9C%85&url=https%3A%2F%2Fgithub.com%2FKytyPS5%2FKytyPS5%2Fpull%2F1738)? Thank you for using CodeRabbit! <!-- end of auto-generated comment: tweet message by coderabbit.ai --> _You are interacting with an AI system._
Author
Owner

@⁠theantipopau on GitHub · 2026-10-20 00:49 UTC · original · approved these changes

Checked the soundness-critical parts: defaults (begin=MAX, end=0) force the whole-range fallback for untracked buffers; the gather guards dynamic ranges, empty ranges, past-the-end ranges (end+slack > size) and address underflow (address < slack); widening by slack is conservative (can only preserve exits, never skip a real overlap); narrowing applies only to fully-bounded writes with constant index-0 offsets, and ADD_TID/swizzle/formatted stores stay dynamic. The UFC 6 numbers check out (writes 0x24-0x30 + slack 3 = 0x21-0x33 vs read at 0x34). Test covers 32-bit, 64-bit, dynamic, ADD_TID, swizzle, past-the-end, and descriptor-slot aliasing.

**@⁠theantipopau** on GitHub · 2026-10-20 00:49 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1738#pullrequestreview-5579503666) · **approved these changes** Checked the soundness-critical parts: defaults (begin=MAX, end=0) force the whole-range fallback for untracked buffers; the gather guards dynamic ranges, empty ranges, past-the-end ranges (end+slack > size) and address underflow (address < slack); widening by slack is conservative (can only preserve exits, never skip a real overlap); narrowing applies only to fully-bounded writes with constant index-0 offsets, and ADD_TID/swizzle/formatted stores stay dynamic. The UFC 6 numbers check out (writes 0x24-0x30 + slack 3 = 0x21-0x33 vs read at 0x34). Test covers 32-bit, 64-bit, dynamic, ADD_TID, swizzle, past-the-end, and descriptor-slot aliasing.
Author
Owner

@⁠Crispy81 on GitHub · 2026-10-20 10:10 UTC · original

"scalar resource reads overlap a shader buffer write in src/graphics/host_gpu/renderer/pipeline/descriptors.cpp:961"

I've seen a stack of games, including RE Engine games and Little Nightmares games with this exact error, so am keen to see this merged.

**@⁠Crispy81** on GitHub · 2026-10-20 10:10 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1738#issuecomment-6288561725) "scalar resource reads overlap a shader buffer write in src/graphics/host_gpu/renderer/pipeline/descriptors.cpp:961" I've seen a stack of games, including RE Engine games and Little Nightmares games with this exact error, so am keen to see this merged.
Author
Owner

@⁠Nmzik on GitHub · 2026-10-21 19:41 UTC · original

Superseded by 68d0ba5a8.

**@⁠Nmzik** on GitHub · 2026-10-21 19:41 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1738#issuecomment-6324929266) Superseded by 68d0ba5a8.

Pull request closed

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