Fix the Marvel-logo hang in Spider-Man: Miles Morales (PPSA01411) #2012

Open
github-bot wants to merge 5 commits from github-bot/gh-2012 into main AGit
Owner

@⁠Xx-LiDAF-xX on GitHub · 2026-10-31 10:34 UTC · original
Xx-LiDAF-xX:codex/ppsa01411-linear-storage-readback → main · +177 −40 · 8 files · 5 commits · open

Problem

Spider-Man: Miles Morales (PPSA01411) stalls at the Marvel logo while polling the last float in a 384×216 reprojection image written by a compute shader. On upstream 02618916, that value remained -1.0 in guest memory. Full linear readback alone also stalled because frame-boundary processing depended on the guest submitting another frame.

Fix

Track writes to linear storage images with at most 512 KiB of backing. At the end of each draw or dispatch, RenderExecutor::ResetBindings copies pending image results into the buffer cache at the same guest address, before a subsequent ReleaseMem packet or completion interrupt.

The buffer cache marks the copied range GPU-written and protects its guest pages. Guest read faults retrieve the current bytes; write faults resolve pending GPU data before the CPU store proceeds. A write fault before publication waits for the GPU command thread to publish the image and resolve ownership for the faulting page. This preserves untouched GPU-written texels while allowing a later CPU store to change one texel.

Publication replaces older overlapping buffer contents and avoids deferred callbacks that could overwrite newer CPU stores. With full linear readback enabled, eager readback uses the same buffer-cache path. Before publication, neighboring writes that removed a page watch are checked and unchanged images are tracked again. Partial writes into a published buffer invalidate the overlapping native image before reuse.

Integration

Rebased onto main at 9a29dc62; the current head is cd839081. Conflict resolutions retain upstream's texture-cache simplifications and adapt pending-storage detection to the current overlap API while preserving coverage of the full faulting page. The Windows test compilation fix from #2010 is already upstream and is no longer a separate commit in this PR.

Verification

For the rebased head cd839081:

  • Windows Release build passed.
  • All five selected local CTest entries passed: shader_recompiler_compute (the full GPU suite), texture_cache_layered_image, image_page_table, memory_tracker, and page_manager.
  • Regression coverage includes replacing older GPU buffer contents, guest writes before publication and before GPU completion, publication at the draw boundary, partial alias writes, and padding preservation.
  • image_page_table and memory_tracker passed with AddressSanitizer and UndefinedBehaviorSanitizer enabled. The instrumented page_manager test could not complete because its fixed-address VirtualAlloc failed; its normal Release test passed.
  • The upstream workflow for cd839081 passed its Windows, Linux, and macOS build and test jobs.

Earlier Windows gameplay validation established the original fix's effect: the game passed the PlayStation and Marvel logos, reached the menu, and entered gameplay at approximately 1–2 FPS. In a controlled RTX 4060 Ti run, upstream remained at the Marvel logo for 85 seconds, while 6f3ef314 reached the interactive “Before You Start” menu at 90 seconds and continued presenting frames through three minutes. Gameplay was not rerun for the rebased head.

Codex assisted with diagnosis, implementation, rebase conflict resolution, and automated testing.

**@⁠Xx-LiDAF-xX** on GitHub · 2026-10-31 10:34 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2012) `Xx-LiDAF-xX:codex/ppsa01411-linear-storage-readback` → `main` · +177 −40 · 8 files · 5 commits · open ## Problem Spider-Man: Miles Morales (PPSA01411) stalls at the Marvel logo while polling the last float in a 384×216 reprojection image written by a compute shader. On upstream `02618916`, that value remained `-1.0` in guest memory. Full linear readback alone also stalled because frame-boundary processing depended on the guest submitting another frame. ## Fix Track writes to linear storage images with at most 512 KiB of backing. At the end of each draw or dispatch, `RenderExecutor::ResetBindings` copies pending image results into the buffer cache at the same guest address, before a subsequent `ReleaseMem` packet or completion interrupt. The buffer cache marks the copied range GPU-written and protects its guest pages. Guest read faults retrieve the current bytes; write faults resolve pending GPU data before the CPU store proceeds. A write fault before publication waits for the GPU command thread to publish the image and resolve ownership for the faulting page. This preserves untouched GPU-written texels while allowing a later CPU store to change one texel. Publication replaces older overlapping buffer contents and avoids deferred callbacks that could overwrite newer CPU stores. With full linear readback enabled, eager readback uses the same buffer-cache path. Before publication, neighboring writes that removed a page watch are checked and unchanged images are tracked again. Partial writes into a published buffer invalidate the overlapping native image before reuse. ## Integration Rebased onto `main` at `9a29dc62`; the current head is `cd839081`. Conflict resolutions retain upstream's texture-cache simplifications and adapt pending-storage detection to the current overlap API while preserving coverage of the full faulting page. The Windows test compilation fix from #2010 is already upstream and is no longer a separate commit in this PR. ## Verification For the rebased head `cd839081`: - Windows Release build passed. - All five selected local CTest entries passed: `shader_recompiler_compute` (the full GPU suite), `texture_cache_layered_image`, `image_page_table`, `memory_tracker`, and `page_manager`. - Regression coverage includes replacing older GPU buffer contents, guest writes before publication and before GPU completion, publication at the draw boundary, partial alias writes, and padding preservation. - `image_page_table` and `memory_tracker` passed with AddressSanitizer and UndefinedBehaviorSanitizer enabled. The instrumented `page_manager` test could not complete because its fixed-address `VirtualAlloc` failed; its normal Release test passed. - The [upstream workflow for `cd839081`](https://github.com/KytyPS5/KytyPS5/actions/runs/42164559626) passed its Windows, Linux, and macOS build and test jobs. Earlier Windows gameplay validation established the original fix's effect: the game passed the PlayStation and Marvel logos, reached the menu, and entered gameplay at approximately 1–2 FPS. In a controlled RTX 4060 Ti run, upstream remained at the Marvel logo for 85 seconds, while `6f3ef314` reached the interactive “Before You Start” menu at 90 seconds and continued presenting frames through three minutes. Gameplay was not rerun for the rebased head. Codex assisted with diagnosis, implementation, rebase conflict resolution, and automated testing.
PPSA01411 polls the last float of a 384x216 reprojection image before it issues the next suspend point. Queue the image copy in the producing submission so its completion publishes the result to guest memory. Limit automatic readback to writable linear storage images with at most 512 KiB of backing.
Record the copy at the end of the producing draw or dispatch. This establishes buffer ownership before a following release signal and lets a faulting guest access synchronize with the GPU result. A later CPU store no longer races a deferred image writeback.
Reinstall the write watch and compare guest edges before discarding a maybe-dirty storage result. Record when a complete buffer copy exists so an interior buffer write invalidates the native image without losing neighboring texels that only exist in an unmirrored image.
Check for pending storage under the same lock as texture invalidation. If the fault touches a pending image page, finish publication on the GPU command lane and resolve the resulting buffer ownership before allowing the guest store. Cover a one-texel write made before the draw result has been published.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:11:34 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-31 10:41 UTC · original · edited 2026-11-06 05:11 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: 6f3ef31408ecd097349bd1c213fe611ec38358c0
  • Latest commit, not reviewed: cd8390814d

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.

Walkthrough

TextureCache queues eligible non-tiled storage images separately from ordinary downloads and publishes safe images to buffer-cache ranges. Binding resets and download processing invoke publication. Image state and GPU invalidation handling now track buffer mirrors. RenderContext handles write faults that overlap pending storage images. Tests cover publication, guest memory faults, and preservation of guest writes. RenderContext adds synchronous GPU-command dispatch, which UnmapMemory and BufferCache use.

Suggested reviewers: nmzik

Change: Bug fix

Merge Risk: Moderate · up to 6f3ef

Some overlapping GPU and guest-memory writes can lose data. These cases should be addressed before merging.

Pre-merge checks: Passed 4 · Inconclusive 1

Failed Failed checks: 1 inconclusive

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

Check name Status Explanation
Title check Passed The title clearly identifies the primary fix: resolving the Marvel-logo hang in Spider-Man: Miles Morales (PPSA01411).
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.
Description check Passed The description matches the changes to storage-image publication, buffer-cache handling, and regression tests.
Full details: Docstring Coverage

Explanation

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

Resolution

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

Tip

🎯 Customize your risk assessments

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

✅ Automatic approvals, with your rules

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

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

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 3ab75f2188248045171e98bfcd48fd323720da2c and 6f3ef31408ecd097349bd1c213fe611ec38358c0.

Files selected for processing: 4

  • src/graphics/host_gpu/renderer/cache/textureCache.cpp
  • src/graphics/host_gpu/renderer/cache/textureCache.h
  • src/graphics/host_gpu/renderer/renderContext.cpp
  • tests/ShaderRecompilerComputeTests.cpp

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

**@⁠coderabbitai[bot]** on GitHub · 2026-10-31 10:41 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2012#issuecomment-6542353438) · edited 2026-11-06 05:11 UTC <!-- coderabbit-ai-generated:v1 --> <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/2012?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 --> <!-- 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: 6f3ef31408ecd097349bd1c213fe611ec38358c0 > - Latest commit, not reviewed: cd8390814dff74c95e29b9e30ba6463b4645c752 > > 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_status_start --> No actionable comments were generated in the recent review. <!-- recent_review_status_end --> <!-- walkthrough_start --> <details> <summary><strong>Walkthrough</strong></summary> <dl> <dd> <br> TextureCache queues eligible non-tiled storage images separately from ordinary downloads and publishes safe images to buffer-cache ranges. Binding resets and download processing invoke publication. Image state and GPU invalidation handling now track buffer mirrors. RenderContext handles write faults that overlap pending storage images. Tests cover publication, guest memory faults, and preservation of guest writes. RenderContext adds synchronous GPU-command dispatch, which UnmapMemory and BufferCache use. **Suggested reviewers:** `nmzik` </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> <!-- change_assessment_commit:"6f3ef31408ecd097349bd1c213fe611ec38358c0" --> <!-- change_assessment_priority:{"version":1,"urgency":"p2","manual":false} --> **Change:** Bug fix <!-- change_assessment_end --> <details> <summary><strong>Merge Risk:</strong> <strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/risk-normal-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Moderate</strong> · up to <code>6f3ef</code></summary> <dl> <dd> <br> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **🟡 Moderate** · up to `6f3ef` --> <!-- final_review_risk_coverage:{"sourceCommitId":"6f3ef31408ecd097349bd1c213fe611ec38358c0","coveredCommitId":"6f3ef31408ecd097349bd1c213fe611ec38358c0","kind":"reviewed"} --> Some overlapping GPU and guest-memory writes can lose data. These cases should be addressed before merging. <!-- final_review_risk_end --> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_start --> <details> <summary><strong>Pre-merge checks: <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> 4 · <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-inconclusive-14-v2.svg" width="14" height="14" align="middle" alt="Inconclusive" title="Inconclusive"></picture></sup> 1</strong></summary> <dl> <dd> <br> <strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> Failed checks: 1 inconclusive</strong> | Check name | Status | Explanation | Resolution | | :---------------- | :--------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ![Inconclusive](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-inconclusive.svg) | Docstring coverage is 4.35% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary><strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> Passed checks: 4 passed</strong></summary> <dl> <dd> <br> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------- | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title clearly identifies the primary fix: resolving the Marvel-logo hang in Spider-Man: Miles Morales (PPSA01411). | | 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. | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description matches the changes to storage-image publication, buffer-cache handling, and regression tests. | </dd> </dl> </details> <details> <summary><strong>Full details: Docstring Coverage</strong></summary> <dl> <dd> <br> **Explanation** Docstring coverage is 4.35% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 23 functions across 7 files. (1 skipped: 1 too large.) **Resolution** Write docstrings for the functions missing them to satisfy the coverage threshold. </dd> </dl> </details> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- announcements_start --> > [!TIP] > <details> > <summary><strong>🎯 Customize your risk assessments</strong></summary> > <dl> > <dd> > <br> > > Guide how CodeRabbit assesses merge risk and security architecture risk. Highlight sensitive changes and explain your security boundaries using **Merge Risk Instructions** and **Security Risk Instructions** in your review settings. Security architecture risk assessments require the **Advanced plan or above**. > > </dd> > </dl> > </details> > > <details> > <summary><strong>✅ Automatic approvals, with your rules</strong></summary> > <dl> > <dd> > <br> > > Let CodeRabbit approve pull requests once required threads are resolved, pre-merge checks pass, and your risk limits are met. Enable **Automatic approvals** in review settings, with overrides for teams or file paths. > > </dd> > </dl> > </details> <!-- announcements_end --> <!-- tips_start --> Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=2012)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary><strong>Share</strong></summary> <dl> <dd> <br> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </dd> </dl> </details> <!-- tips_end --> <!-- recent_review_start --> <h6> <details> <summary><strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/info.svg" width="12" height="12" align="absmiddle" alt=""></picture> Recent review info</strong></summary> <dl> <dd> <br> <!-- review_info_content --> <details> <summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog.svg" width="16" height="16" align="absmiddle" alt=""></picture> Run configuration</strong></summary> <dl> <dd> <br> - **Source mode**: Auto - **Repository**: [KytyPS5/KytyPS5](<https://github.com/KytyPS5/KytyPS5>) - **Branch**: [main](<https://github.com/KytyPS5/KytyPS5/tree/main>) - **File**: [.coderabbit.yaml](<https://github.com/KytyPS5/KytyPS5/blob/bbf96a5e9f69cad84b99791d6418c81d01913e75/.coderabbit.yaml>) - **Commit**: [bbf96a5](<https://github.com/KytyPS5/KytyPS5/commit/bbf96a5e9f69cad84b99791d6418c81d01913e75>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `3c609533-c2fb-46e1-8598-fe8044c37915` </dd> </dl> </details> <details> <summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal.svg" width="16" height="16" align="absmiddle" alt=""></picture> Commits</strong></summary> <dl> <dd> <br> Reviewing files that changed from the base of the PR and between 3ab75f2188248045171e98bfcd48fd323720da2c and 6f3ef31408ecd097349bd1c213fe611ec38358c0. </dd> </dl> </details> <details> <summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner.svg" width="16" height="16" align="absmiddle" alt=""></picture> Files selected for processing: 4</strong></summary> <dl> <dd> <br> * `src/graphics/host_gpu/renderer/cache/textureCache.cpp` * `src/graphics/host_gpu/renderer/cache/textureCache.h` * `src/graphics/host_gpu/renderer/renderContext.cpp` * `tests/ShaderRecompilerComputeTests.cpp` </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review. </dd> </dl> </details> </h6> <!-- recent_review_end -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-31 10:41 UTC · original · edited 2026-10-31 16:57 UTC
On src/graphics/guest_gpu/graphicsRun.cpp line 227 (outdated):

@@ -224,6 +224,7 @@ void CommandProcessor::BufferInit() {
 }
 
 void CommandProcessor::BufferFlush() {
+	m_renderer.GetTextureCache().ProcessStorageDownloads();

Major · Data Integrity & Integration · Heavy lift

Publish storage results before signaling completion.

If a submission writes a storage image and then issues ReleaseMem with an interrupt, ReleaseMem queues the interrupt before this call queues the image publication. The priority queue runs the interrupt first, so the guest can wake and read stale image data. Queue the readback before the completion signal. (raw.githubusercontent.com)

✅ Addressed in commits 0964efc to d98028b

**@⁠coderabbitai[bot]** on GitHub · 2026-10-31 10:41 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2012#discussion_r4431433201) · edited 2026-10-31 16:57 UTC On `src/graphics/guest_gpu/graphicsRun.cpp` line 227 (outdated): ```diff @@ -224,6 +224,7 @@ void CommandProcessor::BufferInit() { } void CommandProcessor::BufferFlush() { + m_renderer.GetTextureCache().ProcessStorageDownloads(); ``` <!-- coderabbit-ai-generated:v1 --> **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/major-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Major** · **Data Integrity & Integration** · **Heavy lift** **Publish storage results before signaling completion.** If a submission writes a storage image and then issues `ReleaseMem` with an interrupt, `ReleaseMem` queues the interrupt before this call queues the image publication. The priority queue runs the interrupt first, so the guest can wake and read stale image data. Queue the readback before the completion signal. ([raw.githubusercontent.com](https://raw.githubusercontent.com/KytyPS5/KytyPS5/120e9717628f5700e53fc2cc1bcf23c4ed5b7474/src/graphics/host_gpu/renderer/commandScheduler.cpp)) <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:8a41c7942a65de0e4419c999 --> <!-- This is an auto-generated comment by CodeRabbit --> ✅ Addressed in commits 0964efc to d98028b
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-31 10:41 UTC · original · edited 2026-10-31 16:59 UTC
On src/graphics/host_gpu/renderer/cache/textureCache.cpp line 2085 (outdated):

@@ -2071,17 +2080,24 @@ void TextureCache::RunGarbageCollector() {
 	}
 }
 
+void TextureCache::ProcessStorageDownloads() {
+	std::scoped_lock lock {m_lock};
+	DownloadImages(m_storage_downloads);

Major · Data Integrity & Integration · Heavy lift

Supported by static analysis

Script executed:

rg -n 'DownloadImages|ProcessStorageDownloads|DownloadImageMemory|m_storage_downloads|TrackImageDownload' src/graphics
sed -n '2060,2130p' src/graphics/host_gpu/renderer/cache/textureCache.cpp

Repository: KytyPS5/KytyPS5

Length of output: 3579


Script executed:

set -o pipefail
printf '%s\n' '--- relevant definitions and callers ---'
rg -n -F --glob '*.{cpp,h}' -e 'FindTexture' -e 'DownloadImageMemory' -e 'TrackImageDownload' -e 'CreateImage' -e 'Invalidate' -e 'GPU.*Dirty' -e 'IsGpuModified' -e 'SubmitReadback' -e 'StorageDownloads' src tests || true
printf '%s\n' '--- texture cache declarations and core definitions ---'
sed -n '220,455p' src/graphics/host_gpu/renderer/cache/textureCache.cpp
sed -n '1400,1520p' src/graphics/host_gpu/renderer/cache/textureCache.cpp
sed -n '1820,1915p' src/graphics/host_gpu/renderer/cache/textureCache.cpp
sed -n '2000,2110p' src/graphics/host_gpu/renderer/cache/textureCache.cpp
printf '%s\n' '--- tests mentioning image readback or submit ---'
rg -n -i -F --glob '*.{cpp,h}' -e 'readback' -e 'storage' -e 'submit' tests/ShaderRecompilerComputeTests.cpp || true
printf '%s\n' '--- relevant base/head diff ---'
git diff --unified=35 026189166f71cc1995f5851dee1ddad7d5826e99 120e9717628f5700e53fc2cc1bcf23c4ed5b7474 -- src/graphics/host_gpu/renderer/cache/textureCache.cpp tests/ShaderRecompilerComputeTests.cpp

Repository: KytyPS5/KytyPS5

Length of output: 42469


Script executed:

set -o pipefail
rg -n -F --glob '*.cpp' --glob '*.h' -e 'FindTexture' -e 'DownloadImageMemory' -e 'TrackImageDownload' -e 'CreateImage' -e 'Invalidate' -e 'IsGpuModified' -e 'SubmitReadback' -e 'ProcessStorageDownloads' src tests || true
sed -n '220,455p' src/graphics/host_gpu/renderer/cache/textureCache.cpp
sed -n '1400,1520p' src/graphics/host_gpu/renderer/cache/textureCache.cpp
sed -n '1820,1915p' src/graphics/host_gpu/renderer/cache/textureCache.cpp
sed -n '2000,2110p' src/graphics/host_gpu/renderer/cache/textureCache.cpp
rg -n -i -F --glob '*.cpp' --glob '*.h' -e 'readback' -e 'storage' -e 'submit' tests/ShaderRecompilerComputeTests.cpp || true
git diff --unified=35 026189166f71cc1995f5851dee1ddad7d5826e99 120e9717628f5700e53fc2cc1bcf23c4ed5b7474 -- src/graphics/host_gpu/renderer/cache/textureCache.cpp tests/ShaderRecompilerComputeTests.cpp

Repository: KytyPS5/KytyPS5

Length of output: 42365


Script executed:

set -o pipefail
printf '%s\n' '--- exact texture-cache ownership and publication paths ---'
nl -ba src/graphics/host_gpu/renderer/cache/textureCache.cpp | sed -n '1080,1220p'
nl -ba src/graphics/host_gpu/renderer/cache/textureCache.cpp | sed -n '1415,1510p'
nl -ba src/graphics/host_gpu/renderer/cache/textureCache.cpp | sed -n '1715,1945p'
printf '%s\n' '--- exact buffer-cache invalidation and dirty tracking ---'
nl -ba src/graphics/host_gpu/renderer/cache/bufferCache.cpp | sed -n '180,325p'
nl -ba src/graphics/host_gpu/renderer/cache/bufferCache.cpp | sed -n '540,625p'
printf '%s\n' '--- image insertion/refresh definitions ---'
rg -n -F -- 'InsertImage(' 'RefreshImage(' 'ObtainBuffer(' src/graphics/host_gpu/renderer/cache src/graphics/host_gpu/renderer
nl -ba src/graphics/host_gpu/renderer/cache/textureCache.cpp | sed -n '1240,1420p'
printf '%s\n' '--- complete submit-readback test block ---'
nl -ba tests/ShaderRecompilerComputeTests.cpp | sed -n '9630,9805p'
printf '%s\n' '--- base versions of changed functions ---'
git show 026189166f71cc1995f5851dee1ddad7d5826e99:src/graphics/host_gpu/renderer/cache/textureCache.cpp | nl -ba | sed -n '1850,1935p'
git show 026189166f71cc1995f5851dee1ddad7d5826e99:src/graphics/host_gpu/renderer/cache/textureCache.cpp | nl -ba | sed -n '1425,1505p'

Repository: KytyPS5/KytyPS5

Length of output: 42740


Script executed:

set -o pipefail
nl -ba src/graphics/host_gpu/renderer/cache/textureCache.cpp | sed -n '1080,1220p'
nl -ba src/graphics/host_gpu/renderer/cache/textureCache.cpp | sed -n '1415,1510p'
nl -ba src/graphics/host_gpu/renderer/cache/textureCache.cpp | sed -n '1715,1945p'
nl -ba src/graphics/host_gpu/renderer/cache/bufferCache.cpp | sed -n '180,325p'
nl -ba src/graphics/host_gpu/renderer/cache/bufferCache.cpp | sed -n '540,625p'
rg -n -F -- 'InsertImage(' 'RefreshImage(' 'ObtainBuffer(' src/graphics/host_gpu/renderer/cache src/graphics/host_gpu/renderer
nl -ba src/graphics/host_gpu/renderer/cache/textureCache.cpp | sed -n '1240,1420p'
nl -ba tests/ShaderRecompilerComputeTests.cpp | sed -n '9630,9805p'
git show 026189166f71cc1995f5851dee1ddad7d5826e99:src/graphics/host_gpu/renderer/cache/textureCache.cpp | nl -ba | sed -n '1850,1935p'
git show 026189166f71cc1995f5851dee1ddad7d5826e99:src/graphics/host_gpu/renderer/cache/textureCache.cpp | nl -ba | sed -n '1425,1505p'

Repository: KytyPS5/KytyPS5

Length of output: 43315


Script executed:

set -o pipefail
printf '%s\n' '--- buffer read and fault paths ---'
rg -n -F --glob '*.cpp' --glob '*.h' -e 'SynchronizeBufferFromImage' -e 'ReadMemory(' -e 'HasGpuDirtyBytes' -e 'DownloadBuffer' -e 'GPU dirty' src/graphics/host_gpu/renderer/cache src/graphics/host_gpu/renderer
nl -ba src/graphics/host_gpu/renderer/cache/bufferCache.cpp | sed -n '1,340p'
nl -ba src/graphics/host_gpu/renderer/cache/bufferCache.cpp | sed -n '340,640p'
printf '%s\n' '--- remainder of submit-readback test ---'
nl -ba tests/ShaderRecompilerComputeTests.cpp | sed -n '9790,9845p'
printf '%s\n' '--- exact image invalidation remainder ---'
nl -ba src/graphics/host_gpu/renderer/cache/textureCache.cpp | sed -n '1900,1985p'

Repository: KytyPS5/KytyPS5

Length of output: 42838


Script executed:

set -o pipefail
rg -n -F --glob '*.cpp' --glob '*.h' -e 'SynchronizeBufferFromImage' -e 'ReadMemory(' -e 'HasGpuDirtyBytes' -e 'DownloadBuffer' -e 'GPU dirty' src/graphics/host_gpu/renderer/cache src/graphics/host_gpu/renderer
nl -ba src/graphics/host_gpu/renderer/cache/bufferCache.cpp | sed -n '1,340p'
nl -ba src/graphics/host_gpu/renderer/cache/bufferCache.cpp | sed -n '340,640p'
nl -ba tests/ShaderRecompilerComputeTests.cpp | sed -n '9790,9845p'
nl -ba src/graphics/host_gpu/renderer/cache/textureCache.cpp | sed -n '1900,1985p'

Repository: KytyPS5/KytyPS5

Length of output: 42717


Reconcile older buffer ownership before publishing the image.

DownloadImageMemory publishes the image to guest backing but does not clear or update overlapping BufferCache GPU-dirty ranges. A later guest fault can therefore download the stale buffer and overwrite the image result. SynchronizeBufferFromImage does not protect this path because the fault calls ReadMemory with is_write=true.

The same ownership gap existed through the previous TrackImageDownload path, but this change makes it reachable for small storage images even when linear readback is disabled. Reconcile the overlapping buffer’s dirty ranges and contents when the image becomes authoritative.


Major · Data Integrity & Integration · Heavy lift

Supported by static analysis

Script executed:

rg -n 'DownloadImageMemory|DownloadImages|PriorityCallback|AddPriority|QueueCallback' src/graphics
sed -n '2060,2130p' src/graphics/host_gpu/renderer/cache/textureCache.cpp

Repository: KytyPS5/KytyPS5

Length of output: 2433


Script executed:

# Read DownloadImageMemory and its callback scheduling.
ast-grep outline src/graphics/host_gpu/renderer/cache/textureCache.cpp --view expanded | head -n 200
sed -n '1860,1990p' src/graphics/host_gpu/renderer/cache/textureCache.cpp

# Locate CPU write invalidation, pending callback handling, and storage-download queue users.
rg -n -F -e 'm_storage_downloads' -e 'm_download_images' -e 'IsGpuModified' -e 'AddPriority' -e 'QueueCallback' -e 'PriorityCallback' -e 'WriteMemory' -e 'UnmapMemory' -e 'InvalidateMemory' -- src/graphics || test "$?" -eq 1

# Compare the pre-PR merge-base version of the download path, if the commit is present.
git show 026189166f71cc1995f5851dee1ddad7d5826e99:src/graphics/host_gpu/renderer/cache/textureCache.cpp 2>&1 | rg -n -F -e 'DownloadImageMemory' -e 'ProcessDownloadImages' -e 'TrackImageDownload' -e 'm_download_images' || test "$?" -eq 1

Repository: KytyPS5/KytyPS5

Length of output: 15695


Script executed:

# Read the CPU-write invalidation entry point used by the tracker.
sed -n '1734,1741p' src/graphics/host_gpu/renderer/cache/textureCache.cpp

# Confirm when deferred priority operations execute relative to submission completion.
rg -n -F -e 'DeferPriorityOperation' -e 'priority_operations' -e 'PriorityOperation' -- src/graphics || test "$?" -eq 1

Repository: KytyPS5/KytyPS5

Length of output: 4276


Script executed:

sed -n '35,120p' src/graphics/host_gpu/renderer/renderContext.cpp

Repository: KytyPS5/KytyPS5

Length of output: 3032


Protect queued storage readbacks from later CPU writes.

DownloadImageMemory queues a deferred callback that writes the full image range back to guest memory. A CPU write to that range after the readback is queued, and before the callback runs, is overwritten by the callback's snapshot. CPU write invalidation does not wait for or cancel the pending callback. The write path marks the image CPU-dirty and untracks it, but it does not serialize with the priority queue.

The general download path (m_download_images) already has this window before this change. This change extends it to the storage queue.

Serialize CPU writes with pending readbacks that overlap the written range, or merge the CPU write into the readback before publication. The inspected code does not establish a safe localized edit, so this comment does not include a patch.

✅ Addressed in commits 0964efc to d98028b

**@⁠coderabbitai[bot]** on GitHub · 2026-10-31 10:41 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2012#discussion_r4431433203) · edited 2026-10-31 16:59 UTC On `src/graphics/host_gpu/renderer/cache/textureCache.cpp` line 2085 (outdated): ```diff @@ -2071,17 +2080,24 @@ void TextureCache::RunGarbageCollector() { } } +void TextureCache::ProcessStorageDownloads() { + std::scoped_lock lock {m_lock}; + DownloadImages(m_storage_downloads); ``` <!-- coderabbit-ai-generated:v1 --> **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/major-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Major** · **Data Integrity & Integration** · **Heavy lift** <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/review-details-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/review-details.svg" width="16" height="16" align="absmiddle" alt=""></picture> Supported by static analysis</summary> <dl> <dd> Script executed: ```bash rg -n 'DownloadImages|ProcessStorageDownloads|DownloadImageMemory|m_storage_downloads|TrackImageDownload' src/graphics sed -n '2060,2130p' src/graphics/host_gpu/renderer/cache/textureCache.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 3579 --- Script executed: ```bash set -o pipefail printf '%s\n' '--- relevant definitions and callers ---' rg -n -F --glob '*.{cpp,h}' -e 'FindTexture' -e 'DownloadImageMemory' -e 'TrackImageDownload' -e 'CreateImage' -e 'Invalidate' -e 'GPU.*Dirty' -e 'IsGpuModified' -e 'SubmitReadback' -e 'StorageDownloads' src tests || true printf '%s\n' '--- texture cache declarations and core definitions ---' sed -n '220,455p' src/graphics/host_gpu/renderer/cache/textureCache.cpp sed -n '1400,1520p' src/graphics/host_gpu/renderer/cache/textureCache.cpp sed -n '1820,1915p' src/graphics/host_gpu/renderer/cache/textureCache.cpp sed -n '2000,2110p' src/graphics/host_gpu/renderer/cache/textureCache.cpp printf '%s\n' '--- tests mentioning image readback or submit ---' rg -n -i -F --glob '*.{cpp,h}' -e 'readback' -e 'storage' -e 'submit' tests/ShaderRecompilerComputeTests.cpp || true printf '%s\n' '--- relevant base/head diff ---' git diff --unified=35 026189166f71cc1995f5851dee1ddad7d5826e99 120e9717628f5700e53fc2cc1bcf23c4ed5b7474 -- src/graphics/host_gpu/renderer/cache/textureCache.cpp tests/ShaderRecompilerComputeTests.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 42469 --- Script executed: ```bash set -o pipefail rg -n -F --glob '*.cpp' --glob '*.h' -e 'FindTexture' -e 'DownloadImageMemory' -e 'TrackImageDownload' -e 'CreateImage' -e 'Invalidate' -e 'IsGpuModified' -e 'SubmitReadback' -e 'ProcessStorageDownloads' src tests || true sed -n '220,455p' src/graphics/host_gpu/renderer/cache/textureCache.cpp sed -n '1400,1520p' src/graphics/host_gpu/renderer/cache/textureCache.cpp sed -n '1820,1915p' src/graphics/host_gpu/renderer/cache/textureCache.cpp sed -n '2000,2110p' src/graphics/host_gpu/renderer/cache/textureCache.cpp rg -n -i -F --glob '*.cpp' --glob '*.h' -e 'readback' -e 'storage' -e 'submit' tests/ShaderRecompilerComputeTests.cpp || true git diff --unified=35 026189166f71cc1995f5851dee1ddad7d5826e99 120e9717628f5700e53fc2cc1bcf23c4ed5b7474 -- src/graphics/host_gpu/renderer/cache/textureCache.cpp tests/ShaderRecompilerComputeTests.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 42365 --- Script executed: ```bash set -o pipefail printf '%s\n' '--- exact texture-cache ownership and publication paths ---' nl -ba src/graphics/host_gpu/renderer/cache/textureCache.cpp | sed -n '1080,1220p' nl -ba src/graphics/host_gpu/renderer/cache/textureCache.cpp | sed -n '1415,1510p' nl -ba src/graphics/host_gpu/renderer/cache/textureCache.cpp | sed -n '1715,1945p' printf '%s\n' '--- exact buffer-cache invalidation and dirty tracking ---' nl -ba src/graphics/host_gpu/renderer/cache/bufferCache.cpp | sed -n '180,325p' nl -ba src/graphics/host_gpu/renderer/cache/bufferCache.cpp | sed -n '540,625p' printf '%s\n' '--- image insertion/refresh definitions ---' rg -n -F -- 'InsertImage(' 'RefreshImage(' 'ObtainBuffer(' src/graphics/host_gpu/renderer/cache src/graphics/host_gpu/renderer nl -ba src/graphics/host_gpu/renderer/cache/textureCache.cpp | sed -n '1240,1420p' printf '%s\n' '--- complete submit-readback test block ---' nl -ba tests/ShaderRecompilerComputeTests.cpp | sed -n '9630,9805p' printf '%s\n' '--- base versions of changed functions ---' git show 026189166f71cc1995f5851dee1ddad7d5826e99:src/graphics/host_gpu/renderer/cache/textureCache.cpp | nl -ba | sed -n '1850,1935p' git show 026189166f71cc1995f5851dee1ddad7d5826e99:src/graphics/host_gpu/renderer/cache/textureCache.cpp | nl -ba | sed -n '1425,1505p' ``` Repository: KytyPS5/KytyPS5 Length of output: 42740 --- Script executed: ```bash set -o pipefail nl -ba src/graphics/host_gpu/renderer/cache/textureCache.cpp | sed -n '1080,1220p' nl -ba src/graphics/host_gpu/renderer/cache/textureCache.cpp | sed -n '1415,1510p' nl -ba src/graphics/host_gpu/renderer/cache/textureCache.cpp | sed -n '1715,1945p' nl -ba src/graphics/host_gpu/renderer/cache/bufferCache.cpp | sed -n '180,325p' nl -ba src/graphics/host_gpu/renderer/cache/bufferCache.cpp | sed -n '540,625p' rg -n -F -- 'InsertImage(' 'RefreshImage(' 'ObtainBuffer(' src/graphics/host_gpu/renderer/cache src/graphics/host_gpu/renderer nl -ba src/graphics/host_gpu/renderer/cache/textureCache.cpp | sed -n '1240,1420p' nl -ba tests/ShaderRecompilerComputeTests.cpp | sed -n '9630,9805p' git show 026189166f71cc1995f5851dee1ddad7d5826e99:src/graphics/host_gpu/renderer/cache/textureCache.cpp | nl -ba | sed -n '1850,1935p' git show 026189166f71cc1995f5851dee1ddad7d5826e99:src/graphics/host_gpu/renderer/cache/textureCache.cpp | nl -ba | sed -n '1425,1505p' ``` Repository: KytyPS5/KytyPS5 Length of output: 43315 --- Script executed: ```bash set -o pipefail printf '%s\n' '--- buffer read and fault paths ---' rg -n -F --glob '*.cpp' --glob '*.h' -e 'SynchronizeBufferFromImage' -e 'ReadMemory(' -e 'HasGpuDirtyBytes' -e 'DownloadBuffer' -e 'GPU dirty' src/graphics/host_gpu/renderer/cache src/graphics/host_gpu/renderer nl -ba src/graphics/host_gpu/renderer/cache/bufferCache.cpp | sed -n '1,340p' nl -ba src/graphics/host_gpu/renderer/cache/bufferCache.cpp | sed -n '340,640p' printf '%s\n' '--- remainder of submit-readback test ---' nl -ba tests/ShaderRecompilerComputeTests.cpp | sed -n '9790,9845p' printf '%s\n' '--- exact image invalidation remainder ---' nl -ba src/graphics/host_gpu/renderer/cache/textureCache.cpp | sed -n '1900,1985p' ``` Repository: KytyPS5/KytyPS5 Length of output: 42838 --- Script executed: ```bash set -o pipefail rg -n -F --glob '*.cpp' --glob '*.h' -e 'SynchronizeBufferFromImage' -e 'ReadMemory(' -e 'HasGpuDirtyBytes' -e 'DownloadBuffer' -e 'GPU dirty' src/graphics/host_gpu/renderer/cache src/graphics/host_gpu/renderer nl -ba src/graphics/host_gpu/renderer/cache/bufferCache.cpp | sed -n '1,340p' nl -ba src/graphics/host_gpu/renderer/cache/bufferCache.cpp | sed -n '340,640p' nl -ba tests/ShaderRecompilerComputeTests.cpp | sed -n '9790,9845p' nl -ba src/graphics/host_gpu/renderer/cache/textureCache.cpp | sed -n '1900,1985p' ``` Repository: KytyPS5/KytyPS5 Length of output: 42717 --- </dd> </dl> </details> **Reconcile older buffer ownership before publishing the image.** `DownloadImageMemory` publishes the image to guest backing but does not clear or update overlapping `BufferCache` GPU-dirty ranges. A later guest fault can therefore download the stale buffer and overwrite the image result. `SynchronizeBufferFromImage` does not protect this path because the fault calls `ReadMemory` with `is_write=true`. The same ownership gap existed through the previous `TrackImageDownload` path, but this change makes it reachable for small storage images even when linear readback is disabled. Reconcile the overlapping buffer’s dirty ranges and contents when the image becomes authoritative. <!-- fingerprinting:phantom:medusa:beignet55 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:91fb0a9d833951da41a1b743 --> --- **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/major-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Major** · **Data Integrity & Integration** · **Heavy lift** <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/review-details-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/review-details.svg" width="16" height="16" align="absmiddle" alt=""></picture> Supported by static analysis</summary> <dl> <dd> Script executed: ```bash rg -n 'DownloadImageMemory|DownloadImages|PriorityCallback|AddPriority|QueueCallback' src/graphics sed -n '2060,2130p' src/graphics/host_gpu/renderer/cache/textureCache.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 2433 --- Script executed: ```bash # Read DownloadImageMemory and its callback scheduling. ast-grep outline src/graphics/host_gpu/renderer/cache/textureCache.cpp --view expanded | head -n 200 sed -n '1860,1990p' src/graphics/host_gpu/renderer/cache/textureCache.cpp # Locate CPU write invalidation, pending callback handling, and storage-download queue users. rg -n -F -e 'm_storage_downloads' -e 'm_download_images' -e 'IsGpuModified' -e 'AddPriority' -e 'QueueCallback' -e 'PriorityCallback' -e 'WriteMemory' -e 'UnmapMemory' -e 'InvalidateMemory' -- src/graphics || test "$?" -eq 1 # Compare the pre-PR merge-base version of the download path, if the commit is present. git show 026189166f71cc1995f5851dee1ddad7d5826e99:src/graphics/host_gpu/renderer/cache/textureCache.cpp 2>&1 | rg -n -F -e 'DownloadImageMemory' -e 'ProcessDownloadImages' -e 'TrackImageDownload' -e 'm_download_images' || test "$?" -eq 1 ``` Repository: KytyPS5/KytyPS5 Length of output: 15695 --- Script executed: ```bash # Read the CPU-write invalidation entry point used by the tracker. sed -n '1734,1741p' src/graphics/host_gpu/renderer/cache/textureCache.cpp # Confirm when deferred priority operations execute relative to submission completion. rg -n -F -e 'DeferPriorityOperation' -e 'priority_operations' -e 'PriorityOperation' -- src/graphics || test "$?" -eq 1 ``` Repository: KytyPS5/KytyPS5 Length of output: 4276 --- Script executed: ```bash sed -n '35,120p' src/graphics/host_gpu/renderer/renderContext.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 3032 --- </dd> </dl> </details> **Protect queued storage readbacks from later CPU writes.** `DownloadImageMemory` queues a deferred callback that writes the full image range back to guest memory. A CPU write to that range after the readback is queued, and before the callback runs, is overwritten by the callback's snapshot. CPU write invalidation does not wait for or cancel the pending callback. The write path marks the image CPU-dirty and untracks it, but it does not serialize with the priority queue. The general download path (`m_download_images`) already has this window before this change. This change extends it to the storage queue. Serialize CPU writes with pending readbacks that overlap the written range, or merge the CPU write into the readback before publication. The inspected code does not establish a safe localized edit, so this comment does not include a patch. <!-- fingerprinting:phantom:medusa:beignet55 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:a3a96f78557c2a7fcf5ab6a8 --> <!-- This is an auto-generated comment by CodeRabbit --> ✅ Addressed in commits 0964efc to d98028b
Author
Owner

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

Actionable comments posted: 3


Review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 026189166f and 120e9717628f5700e53fc2cc1bcf23c4ed5b7474.

Files selected for processing: 4
  • src/graphics/guest_gpu/graphicsRun.cpp
  • src/graphics/host_gpu/renderer/cache/textureCache.cpp
  • src/graphics/host_gpu/renderer/cache/textureCache.h
  • tests/ShaderRecompilerComputeTests.cpp

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

**@⁠coderabbitai[bot]** on GitHub · 2026-10-31 10:41 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2012#pullrequestreview-5722392732) · **reviewed** <!-- coderabbit-ai-generated:v1 --> **Actionable comments posted: 3** --- <details> <summary><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/info.svg" width="16" height="16" align="absmiddle" alt=""></picture> Review info</summary> <dl> <dd> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog.svg" width="16" height="16" align="absmiddle" alt=""></picture> Run configuration</summary> <dl> <dd> - **Source mode**: Auto - **Repository**: [KytyPS5/KytyPS5](<https://github.com/KytyPS5/KytyPS5>) - **Branch**: [main](<https://github.com/KytyPS5/KytyPS5/tree/main>) - **File**: [.coderabbit.yaml](<https://github.com/KytyPS5/KytyPS5/blob/026189166f71cc1995f5851dee1ddad7d5826e99/.coderabbit.yaml>) - **Commit**: [0261891](<https://github.com/KytyPS5/KytyPS5/commit/026189166f71cc1995f5851dee1ddad7d5826e99>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `5f673feb-e398-4826-9185-1cbfd725ce0e` </dd> </dl> </details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal.svg" width="16" height="16" align="absmiddle" alt=""></picture> Commits</summary> <dl> <dd> Reviewing files that changed from the base of the PR and between 026189166f71cc1995f5851dee1ddad7d5826e99 and 120e9717628f5700e53fc2cc1bcf23c4ed5b7474. </dd> </dl> </details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner.svg" width="16" height="16" align="absmiddle" alt=""></picture> Files selected for processing: 4</summary> <dl> <dd> * `src/graphics/guest_gpu/graphicsRun.cpp` * `src/graphics/host_gpu/renderer/cache/textureCache.cpp` * `src/graphics/host_gpu/renderer/cache/textureCache.h` * `tests/ShaderRecompilerComputeTests.cpp` </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. </dd> </dl> </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=d69a1e8d-4bbd-4313-af98-2637d2331db6 attempt=db1a1b09-123c-4fa0-8e46-5c4557a441a4 batch=1/1 -->
@ -1996,0 +2018,4 @@
eager_readbacks.push_back(image.info.data);
}
}
m_storage_downloads.clear();
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-31 17:05 UTC · original · edited 2026-10-31 22:24 UTC

Major · Data Integrity & Integration · Heavy lift

Supported by static analysis

Script executed:

rg -n 'maybe_dirty|MaybeDirty|SafeToDownload|CanDownload|InvalidateCpuAliases' src/graphics/host_gpu/renderer
sed -n '2070,2125p' src/graphics/host_gpu/renderer/cache/textureCache.cpp

Repository: KytyPS5/KytyPS5

Length of output: 3762


Script executed:

rg -n -i -e 'maybe.dirty' -e 'SafeToDownload' -e 'm_storage_downloads' -e 'IsGpuModified' -e 'ResolveMaybe' -- src/graphics/host_gpu/renderer || test "$?" -eq 1
echo '--- image.h 60-140'
sed -n '60,140p' src/graphics/host_gpu/renderer/image/image.h
echo '--- textureCache.cpp 290-310'
sed -n '290,310p' src/graphics/host_gpu/renderer/cache/textureCache.cpp
echo '--- textureCache.cpp 370-415'
sed -n '370,415p' src/graphics/host_gpu/renderer/cache/textureCache.cpp
echo '--- textureCache.cpp 1925-1960'
sed -n '1925,1960p' src/graphics/host_gpu/renderer/cache/textureCache.cpp

Repository: KytyPS5/KytyPS5

Length of output: 10007


Script executed:

echo '--- textureCache.cpp 1190-1230'
sed -n '1190,1230p' src/graphics/host_gpu/renderer/cache/textureCache.cpp
echo '--- textureCache.cpp 1450-1480'
sed -n '1450,1480p' src/graphics/host_gpu/renderer/cache/textureCache.cpp
echo '--- textureCache.cpp 410-430'
sed -n '410,430p' src/graphics/host_gpu/renderer/cache/textureCache.cpp

Repository: KytyPS5/KytyPS5

Length of output: 3608


Keep a maybe-dirty storage image on the publish path.

A CPU write to the same page, but outside the image range, marks a queued storage image maybe-dirty. SafeToDownload() then returns false for that image. PublishStorageImages skips it and clears m_storage_downloads, so the GPU result is not copied to the buffer cache at that boundary. The state is resolved only when a later binding of the image runs RefreshImage. Until that happens, a guest read of the storage memory can return stale data.

The write does not need to change any bytes to cause this. The maybe-dirty mark is set first. The byte comparison happens only when ResolveMaybeCpuHash runs. Earlier wording about the state lasting indefinitely is too broad. It persists until the next binding of that image.

The correction should resolve the maybe-dirty state before the SafeToDownload() check, using the same hash comparison as RefreshImage. An unchanged image should then publish at the draw boundary. The image must also be re-tracked after resolution, because MarkAsMaybeDirty untracks it.

✅ Addressed in commit 6f3ef31

**@⁠coderabbitai[bot]** on GitHub · 2026-10-31 17:05 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2012#discussion_r4432538588) · edited 2026-10-31 22:24 UTC <!-- coderabbit-ai-generated:v1 --> **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/major-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Major** · **Data Integrity & Integration** · **Heavy lift** <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/review-details-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/review-details.svg" width="16" height="16" align="absmiddle" alt=""></picture> Supported by static analysis</summary> <dl> <dd> Script executed: ```bash rg -n 'maybe_dirty|MaybeDirty|SafeToDownload|CanDownload|InvalidateCpuAliases' src/graphics/host_gpu/renderer sed -n '2070,2125p' src/graphics/host_gpu/renderer/cache/textureCache.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 3762 --- Script executed: ```bash rg -n -i -e 'maybe.dirty' -e 'SafeToDownload' -e 'm_storage_downloads' -e 'IsGpuModified' -e 'ResolveMaybe' -- src/graphics/host_gpu/renderer || test "$?" -eq 1 echo '--- image.h 60-140' sed -n '60,140p' src/graphics/host_gpu/renderer/image/image.h echo '--- textureCache.cpp 290-310' sed -n '290,310p' src/graphics/host_gpu/renderer/cache/textureCache.cpp echo '--- textureCache.cpp 370-415' sed -n '370,415p' src/graphics/host_gpu/renderer/cache/textureCache.cpp echo '--- textureCache.cpp 1925-1960' sed -n '1925,1960p' src/graphics/host_gpu/renderer/cache/textureCache.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 10007 --- Script executed: ```bash echo '--- textureCache.cpp 1190-1230' sed -n '1190,1230p' src/graphics/host_gpu/renderer/cache/textureCache.cpp echo '--- textureCache.cpp 1450-1480' sed -n '1450,1480p' src/graphics/host_gpu/renderer/cache/textureCache.cpp echo '--- textureCache.cpp 410-430' sed -n '410,430p' src/graphics/host_gpu/renderer/cache/textureCache.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 3608 --- </dd> </dl> </details> **Keep a maybe-dirty storage image on the publish path.** A CPU write to the same page, but outside the image range, marks a queued storage image maybe-dirty. `SafeToDownload()` then returns false for that image. `PublishStorageImages` skips it and clears `m_storage_downloads`, so the GPU result is not copied to the buffer cache at that boundary. The state is resolved only when a later binding of the image runs `RefreshImage`. Until that happens, a guest read of the storage memory can return stale data. The write does not need to change any bytes to cause this. The maybe-dirty mark is set first. The byte comparison happens only when `ResolveMaybeCpuHash` runs. Earlier wording about the state lasting indefinitely is too broad. It persists until the next binding of that image. The correction should resolve the maybe-dirty state before the `SafeToDownload()` check, using the same hash comparison as `RefreshImage`. An unchanged image should then publish at the draw boundary. The image must also be re-tracked after resolution, because `MarkAsMaybeDirty` untracks it. <!-- fingerprinting:phantom:medusa:beignet55 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:071aa094255954b9f0f7756c --> <!-- This is an auto-generated comment by CodeRabbit --> ✅ Addressed in commit 6f3ef31
@ -1997,0 +2031,4 @@
}
const auto range = image.info.data;
auto [buffer, offset] = m_buffer_cache.ObtainBuffer(range.address, range.size, true);
DownloadImage(image, *buffer, offset, range.size, image.info.resources.levels);
Author
Owner

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

Major · Data Integrity & Integration · Heavy lift

Supported by static analysis

Script executed:

rg -n 'InvalidateMemoryFromGPU|FillBuffer|SynchronizeBufferFromImage|CopyImageToBufferCache' src/graphics/host_gpu/renderer
sed -n '2070,2125p' src/graphics/host_gpu/renderer/cache/textureCache.cpp

Repository: KytyPS5/KytyPS5

Length of output: 3330


Invalidate overlapping images before partial buffer writes.

When CopyImageToBufferCache publishes an image, the buffer cache marks the image range as GPU-dirty, but the image remains GPU-current. A later partial FillBuffer or buffer write can update an address inside that range. InvalidateMemoryFromGPU must invalidate every overlapping image, not only an image whose base address equals the write address. Otherwise, a later PublishStorageImages call can copy the stale image over the newer buffer bytes.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-31 17:05 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2012#discussion_r4432538594) <!-- coderabbit-ai-generated:v1 --> **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/major-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Major** · **Data Integrity & Integration** · **Heavy lift** <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/review-details-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/review-details.svg" width="16" height="16" align="absmiddle" alt=""></picture> Supported by static analysis</summary> <dl> <dd> Script executed: ```bash rg -n 'InvalidateMemoryFromGPU|FillBuffer|SynchronizeBufferFromImage|CopyImageToBufferCache' src/graphics/host_gpu/renderer sed -n '2070,2125p' src/graphics/host_gpu/renderer/cache/textureCache.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 3330 --- </dd> </dl> </details> **Invalidate overlapping images before partial buffer writes.** When `CopyImageToBufferCache` publishes an image, the buffer cache marks the image range as GPU-dirty, but the image remains GPU-current. A later partial `FillBuffer` or buffer write can update an address inside that range. `InvalidateMemoryFromGPU` must invalidate every overlapping image, not only an image whose base address equals the write address. Otherwise, a later `PublishStorageImages` call can copy the stale image over the newer buffer bytes. <!-- fingerprinting:phantom:medusa:beignet55 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:87c23606acfda41ab3c0f255 --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-31 17:05 UTC · original · reviewed

Follow-up Comments

Nitpick Test publication through an actual draw.

16220-16220: Trivial · Functional Correctness · Heavy lift

Test publication through an actual draw.

This check calls ResetBindings directly, without executing a draw. It also checks only that the queue is empty; PublishStorageImages clears the queue even when it skips a copy. (raw.githubusercontent.com)

Exercise a draw that writes a storage image, then verify the guest-visible value through a read fault before an explicit scheduler.Finish(). This would detect a missing or prematurely placed publication at the draw boundary.

Open the source location


Review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 120e9717628f5700e53fc2cc1bcf23c4ed5b7474 and d98028bbb0a1bbafe4efd32e9d7e04ca6b85e0cc.

Files selected for processing: 4
  • src/graphics/host_gpu/renderer/cache/textureCache.cpp
  • src/graphics/host_gpu/renderer/cache/textureCache.h
  • src/graphics/host_gpu/renderer/pipeline/descriptors.cpp
  • tests/ShaderRecompilerComputeTests.cpp

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

**@⁠coderabbitai[bot]** on GitHub · 2026-10-31 17:05 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2012#pullrequestreview-5723958259) · **reviewed** <!-- coderabbit-ai-generated:v1 --> ## Follow-up Comments <details> <summary><sub><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-finding-badges-v1/contrast-v2/nitpick-dark.svg" /><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-finding-badges-v1/nitpick.svg" /><img width="85" height="16" alt="Nitpick" src="https://storage.googleapis.com/coderabbit_public_assets/review-finding-badges-v1/nitpick.svg" /></picture></sub> Test publication through an actual draw.</summary><blockquote> <dl> <dd> `16220-16220`: **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/neutral-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Trivial** · **Functional Correctness** · **Heavy lift** **Test publication through an actual draw.** This check calls `ResetBindings` directly, without executing a draw. It also checks only that the queue is empty; `PublishStorageImages` clears the queue even when it skips a copy. ([raw.githubusercontent.com](https://raw.githubusercontent.com/KytyPS5/KytyPS5/d98028bbb0a1bbafe4efd32e9d7e04ca6b85e0cc/src/graphics/host_gpu/renderer/cache/textureCache.cpp)) Exercise a draw that writes a storage image, then verify the guest-visible value through a read fault before an explicit `scheduler.Finish()`. This would detect a missing or prematurely placed publication at the draw boundary. <!-- cr-comment:v1:6a35e007ea949cc76db9340c --> [Open the source location](https://github.com/KytyPS5/KytyPS5/blob/d98028bbb0a1bbafe4efd32e9d7e04ca6b85e0cc/tests/ShaderRecompilerComputeTests.cpp#L16220) </dd> </dl> </blockquote></details> --- <details> <summary><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/info.svg" width="16" height="16" align="absmiddle" alt=""></picture> Review info</summary> <dl> <dd> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog.svg" width="16" height="16" align="absmiddle" alt=""></picture> Run configuration</summary> <dl> <dd> - **Source mode**: Auto - **Repository**: [KytyPS5/KytyPS5](<https://github.com/KytyPS5/KytyPS5>) - **Branch**: [main](<https://github.com/KytyPS5/KytyPS5/tree/main>) - **File**: [.coderabbit.yaml](<https://github.com/KytyPS5/KytyPS5/blob/026189166f71cc1995f5851dee1ddad7d5826e99/.coderabbit.yaml>) - **Commit**: [0261891](<https://github.com/KytyPS5/KytyPS5/commit/026189166f71cc1995f5851dee1ddad7d5826e99>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `466c8b12-a2d1-491c-b500-f2b90c04d7ac` </dd> </dl> </details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal.svg" width="16" height="16" align="absmiddle" alt=""></picture> Commits</summary> <dl> <dd> Reviewing files that changed from the base of the PR and between 120e9717628f5700e53fc2cc1bcf23c4ed5b7474 and d98028bbb0a1bbafe4efd32e9d7e04ca6b85e0cc. </dd> </dl> </details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner.svg" width="16" height="16" align="absmiddle" alt=""></picture> Files selected for processing: 4</summary> <dl> <dd> * `src/graphics/host_gpu/renderer/cache/textureCache.cpp` * `src/graphics/host_gpu/renderer/cache/textureCache.h` * `src/graphics/host_gpu/renderer/pipeline/descriptors.cpp` * `tests/ShaderRecompilerComputeTests.cpp` </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. </dd> </dl> </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=78329e9a-013e-4ce1-bf34-d79cfdf67366 attempt=1f5080c1-a495-4266-8985-e891115c6712 batch=1/1 -->
@ -1996,0 +2011,4 @@
TrackImage(id);
(void)image.ResolveMaybeCpuHash(image.HashGuestEdges());
}
if (!image.SafeToDownload() || !CopyImageToBufferCache(image)) {
Author
Owner

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

Major · Data Integrity & Integration · Heavy lift

Preserve GPU results when a guest write precedes publication.

If a guest write faults after a storage draw is recorded but before ResetBindings() publishes it, the buffer cache may not yet have GPU ownership. The fault then marks the image CPU-dirty without resolving its GPU contents. This check skips the image and the queue is cleared, so untouched GPU-written texels can be lost. The existing pending-write test faults only after publication. (raw.githubusercontent.com)

Establish GPU ownership before guest writes can proceed, or merge the pending image result with the guest write.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-31 22:00 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2012#discussion_r4433452808) <!-- coderabbit-ai-generated:v1 --> **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/major-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Major** · **Data Integrity & Integration** · **Heavy lift** **Preserve GPU results when a guest write precedes publication.** If a guest write faults after a storage draw is recorded but before `ResetBindings()` publishes it, the buffer cache may not yet have GPU ownership. The fault then marks the image CPU-dirty without resolving its GPU contents. This check skips the image and the queue is cleared, so untouched GPU-written texels can be lost. The existing pending-write test faults only after publication. ([raw.githubusercontent.com](https://raw.githubusercontent.com/KytyPS5/KytyPS5/47723af7e63122e6117cb01403a96a7927639db1/src/graphics/host_gpu/renderer/renderContext.cpp)) Establish GPU ownership before guest writes can proceed, or merge the pending image result with the guest write. <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:4d4bd7ba4440f966f3c3489e --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-31 22:00 UTC · original · reviewed

Actionable comments posted: 1


Review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between d98028bbb0a1bbafe4efd32e9d7e04ca6b85e0cc and 47723af7e63122e6117cb01403a96a7927639db1.

Files selected for processing: 6
  • src/graphics/host_gpu/renderer/cache/bufferCache.cpp
  • src/graphics/host_gpu/renderer/cache/textureCache.cpp
  • src/graphics/host_gpu/renderer/image/image.h
  • src/graphics/host_gpu/renderer/renderContext.cpp
  • src/graphics/host_gpu/renderer/renderContext.h
  • tests/ShaderRecompilerComputeTests.cpp

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

**@⁠coderabbitai[bot]** on GitHub · 2026-10-31 22:00 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2012#pullrequestreview-5725133915) · **reviewed** <!-- coderabbit-ai-generated:v1 --> **Actionable comments posted: 1** --- <details> <summary><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/info.svg" width="16" height="16" align="absmiddle" alt=""></picture> Review info</summary> <dl> <dd> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog.svg" width="16" height="16" align="absmiddle" alt=""></picture> Run configuration</summary> <dl> <dd> - **Source mode**: Auto - **Repository**: [KytyPS5/KytyPS5](<https://github.com/KytyPS5/KytyPS5>) - **Branch**: [main](<https://github.com/KytyPS5/KytyPS5/tree/main>) - **File**: [.coderabbit.yaml](<https://github.com/KytyPS5/KytyPS5/blob/026189166f71cc1995f5851dee1ddad7d5826e99/.coderabbit.yaml>) - **Commit**: [0261891](<https://github.com/KytyPS5/KytyPS5/commit/026189166f71cc1995f5851dee1ddad7d5826e99>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `5e23539b-c921-4629-ae19-3b6c2cbc5db6` </dd> </dl> </details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal.svg" width="16" height="16" align="absmiddle" alt=""></picture> Commits</summary> <dl> <dd> Reviewing files that changed from the base of the PR and between d98028bbb0a1bbafe4efd32e9d7e04ca6b85e0cc and 47723af7e63122e6117cb01403a96a7927639db1. </dd> </dl> </details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner.svg" width="16" height="16" align="absmiddle" alt=""></picture> Files selected for processing: 6</summary> <dl> <dd> * `src/graphics/host_gpu/renderer/cache/bufferCache.cpp` * `src/graphics/host_gpu/renderer/cache/textureCache.cpp` * `src/graphics/host_gpu/renderer/image/image.h` * `src/graphics/host_gpu/renderer/renderContext.cpp` * `src/graphics/host_gpu/renderer/renderContext.h` * `tests/ShaderRecompilerComputeTests.cpp` </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. </dd> </dl> </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=2d3a10f6-be4d-427b-9a4d-722e89f66d60 attempt=0774c9e0-26a6-4c01-bcea-82d1b0c86f1b batch=1/1 -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-31 22:21 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 maybe-dirty tracking after trimming a partial-page watch. · textureCache.cpp:2082-2085

src/graphics/host_gpu/renderer/cache/textureCache.cpp:2082-2085
Major · Data Integrity & Integration · Quick win

Preserve maybe-dirty tracking after trimming a partial-page watch.

When a neighboring CPU store removes only the head or tail watch, InvalidateCpuAliases() leaves the image clean. A later in-image store can then occur before PublishStorageImages(). The reviewed head can publish stale native bytes as a GPU-owned full-image buffer, and eager readback or a later CPU invalidation can flush those bytes over the newer guest data.

Mark the image maybe-dirty after either partial-watch removal. A changed hash then makes SafeToDownload() fail before publication. Keep the existing !IsCpuDirty() guard so repeated invalidations preserve the original hash.

Suggested fix
 		if (page_end < image_end) {
 			UntrackImageHead(id);
+			owner.MarkMaybeCpuDirty();
 		} else if (image_begin < page_begin) {
 			UntrackImageTail(id);
+			owner.MarkMaybeCpuDirty();
 		} else {
 			MarkAsMaybeDirty(id, owner);
Nitpick comments: 1
tests/ShaderRecompilerComputeTests.cpp: 1

16252-16254: Trivial · Functional Correctness · Quick win

Check the published bytes at this boundary.

PendingDownload only checks queue membership. TextureCache::PublishStorageImages clears the queue even when it skips the copy, so this assertion can pass while guest memory remains stale. The stale value is written before an earlier ResetBindings, which also publishes storage images. Set a distinct stale value before this reset, then check the resulting bytes before the next binding. (raw.githubusercontent.com)


Review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 47723af7e63122e6117cb01403a96a7927639db1 and 3ab75f2188248045171e98bfcd48fd323720da2c.

Files selected for processing: 4
  • src/graphics/host_gpu/renderer/cache/textureCache.h
  • src/graphics/host_gpu/renderer/image/image.h
  • src/graphics/host_gpu/renderer/renderContext.h
  • tests/ShaderRecompilerComputeTests.cpp

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

**@⁠coderabbitai[bot]** on GitHub · 2026-10-31 22:21 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2012#pullrequestreview-5725237064) · **reviewed** <!-- coderabbit-ai-generated:v1 --> > [!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><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/major-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Major</strong> · Preserve maybe-dirty tracking after trimming a partial-page watch. · <code>textureCache.cpp:2082-2085</code></summary><blockquote> > <dl> > <dd> > > `src/graphics/host_gpu/renderer/cache/textureCache.cpp:2082-2085` > **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/major-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Major** · **Data Integrity & Integration** · **Quick win** > > **Preserve maybe-dirty tracking after trimming a partial-page watch.** > > When a neighboring CPU store removes only the head or tail watch, `InvalidateCpuAliases()` leaves the image clean. A later in-image store can then occur before `PublishStorageImages()`. The reviewed head can publish stale native bytes as a GPU-owned full-image buffer, and eager readback or a later CPU invalidation can flush those bytes over the newer guest data. > > Mark the image maybe-dirty after either partial-watch removal. A changed hash then makes `SafeToDownload()` fail before publication. Keep the existing `!IsCpuDirty()` guard so repeated invalidations preserve the original hash. > > <details> > <summary>Suggested fix</summary> > <dl> > <dd> > > ```diff > if (page_end < image_end) { > UntrackImageHead(id); > + owner.MarkMaybeCpuDirty(); > } else if (image_begin < page_begin) { > UntrackImageTail(id); > + owner.MarkMaybeCpuDirty(); > } else { > MarkAsMaybeDirty(id, owner); > ``` > > </dd> > </dl> > </details> > > <!-- cr-comment:v1:d2af49aac240ff9d724d6977 --> > > </dd> > </dl> > </blockquote></details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/brush-cleaning-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/brush-cleaning.svg" width="16" height="16" align="absmiddle" alt=""></picture> Nitpick comments: 1</summary><blockquote> <dl> <dd> <details> <summary>tests/ShaderRecompilerComputeTests.cpp: 1</summary><blockquote> <dl> <dd> `16252-16254`: **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/neutral-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Trivial** · **Functional Correctness** · **Quick win** **Check the published bytes at this boundary.** `PendingDownload` only checks queue membership. `TextureCache::PublishStorageImages` clears the queue even when it skips the copy, so this assertion can pass while guest memory remains stale. The stale value is written before an earlier `ResetBindings`, which also publishes storage images. Set a distinct stale value before this reset, then check the resulting bytes before the next binding. ([raw.githubusercontent.com](https://raw.githubusercontent.com/KytyPS5/KytyPS5/3ab75f2188248045171e98bfcd48fd323720da2c/src/graphics/host_gpu/renderer/cache/textureCache.cpp)) <!-- cr-comment:v1:802e60f8b443b31b2d0cd86a --> </dd> </dl> </blockquote></details> </dd> </dl> </blockquote></details> --- <details> <summary><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/info.svg" width="16" height="16" align="absmiddle" alt=""></picture> Review info</summary> <dl> <dd> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog.svg" width="16" height="16" align="absmiddle" alt=""></picture> Run configuration</summary> <dl> <dd> - **Source mode**: Auto - **Repository**: [KytyPS5/KytyPS5](<https://github.com/KytyPS5/KytyPS5>) - **Branch**: [main](<https://github.com/KytyPS5/KytyPS5/tree/main>) - **File**: [.coderabbit.yaml](<https://github.com/KytyPS5/KytyPS5/blob/bbf96a5e9f69cad84b99791d6418c81d01913e75/.coderabbit.yaml>) - **Commit**: [bbf96a5](<https://github.com/KytyPS5/KytyPS5/commit/bbf96a5e9f69cad84b99791d6418c81d01913e75>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `2d43175c-7c7b-4774-bebd-74811577f65e` </dd> </dl> </details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal.svg" width="16" height="16" align="absmiddle" alt=""></picture> Commits</summary> <dl> <dd> Reviewing files that changed from the base of the PR and between 47723af7e63122e6117cb01403a96a7927639db1 and 3ab75f2188248045171e98bfcd48fd323720da2c. </dd> </dl> </details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner.svg" width="16" height="16" align="absmiddle" alt=""></picture> Files selected for processing: 4</summary> <dl> <dd> * `src/graphics/host_gpu/renderer/cache/textureCache.h` * `src/graphics/host_gpu/renderer/image/image.h` * `src/graphics/host_gpu/renderer/renderContext.h` * `tests/ShaderRecompilerComputeTests.cpp` </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review. </dd> </dl> </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=faed369b-ac3b-4bfb-8187-2fb8d84b80e1 attempt=d4c4696f-1a51-4eac-9c10-eec6a63f699c batch=1/1 -->
This pull request has changes conflicting with the target branch.
  • src/graphics/host_gpu/renderer/cache/textureCache.cpp
  • src/graphics/host_gpu/renderer/cache/textureCache.h
  • src/graphics/host_gpu/renderer/renderContext.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/2012/head:github-bot/gh-2012'
git switch 'github-bot/gh-2012'

Merge

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