HFW: fix indirect texture tracking and loading-time Vulkan errors #1980

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

@⁠tototomate123 on GitHub · 2026-10-29 18:06 UTC · original
tototomate123:fix/hfw-loading-consolidated → main · +4128 −2379 · 23 files · 5 commits · open

Horizon Forbidden West (PPSA01521) hits resource-tracking failures and invalid Vulkan image operations while loading. This consolidates the remaining shader and renderer fixes on current main.

  • Track bounded indirect texture keys, including packed selectors and padded descriptor records, while preserving runtime refresh and overlap checks.
  • Support compute stencil writes through R8 storage images with depth-preserving copyback, and map clamped float depth descriptors consistently.
  • Lower integer 3D level-zero gathers to valid SPIR-V sampling.
  • Separate cache allocation accounting from driver usage and scan past protected eviction candidates.

Earlier testing of the full local HFW branch reached the loading screen; gameplay remains blocked by compute shader a8857e9a25dfc8d8 at pc=0x41c. This consolidated branch has not yet had a fresh game run.

Validation: Linux build, resource tracking/materialization, CFG, and the full GPU regression suite pass. Windows has not been tested locally.

Supersedes #852, #976, and #977.

Related work: #1118 (indirect texture-table proofs), #373 (protected-image eviction scans), #1879 (standalone stencil targets), and #1961 (Vanguard memory pressure). These have partial or complementary scope; this PR does not supersede them. The shared shader/renderer fixes may benefit other games, which have not been tested on this branch.

AI-assisted implementation and testing.

**@⁠tototomate123** on GitHub · 2026-10-29 18:06 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1980) `tototomate123:fix/hfw-loading-consolidated` → `main` · +4128 −2379 · 23 files · 5 commits · open Horizon Forbidden West (PPSA01521) hits resource-tracking failures and invalid Vulkan image operations while loading. This consolidates the remaining shader and renderer fixes on current main. - Track bounded indirect texture keys, including packed selectors and padded descriptor records, while preserving runtime refresh and overlap checks. - Support compute stencil writes through R8 storage images with depth-preserving copyback, and map clamped float depth descriptors consistently. - Lower integer 3D level-zero gathers to valid SPIR-V sampling. - Separate cache allocation accounting from driver usage and scan past protected eviction candidates. Earlier testing of the full local HFW branch reached the loading screen; gameplay remains blocked by compute shader `a8857e9a25dfc8d8` at `pc=0x41c`. This consolidated branch has not yet had a fresh game run. Validation: Linux build, resource tracking/materialization, CFG, and the full GPU regression suite pass. Windows has not been tested locally. Supersedes #852, #976, and #977. Related work: #1118 (indirect texture-table proofs), #373 (protected-image eviction scans), #1879 (standalone stencil targets), and #1961 (Vanguard memory pressure). These have partial or complementary scope; this PR does not supersede them. The shared shader/renderer fixes may benefit other games, which have not been tested on this branch. AI-assisted implementation and testing.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:10:41 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-29 18:21 UTC · original · edited 2026-10-29 19:19 UTC

Review in Change Stack →

Walkthrough

The change adds GPU format metadata and mappings, including k32FloatClamp and k16UScaled. It adds standalone stencil-storage materialization and publication, device-memory-aware cache collection, and storage-view validation. Shader IR serialization now tracks selector metadata and inactive descriptors. SPIR-V emission supports integer level-zero 3D gathers. New tests cover these paths and update 3D image fixtures.

Suggested reviewers: nmzik, thecruz

Priority: Normal

Change: Bug fix

Merge Risk: High · up to 97e50

Fix the selector materialization failure and refresh device usage after texture eviction before merging; otherwise affected shaders may fail to load and image allocation can still abort under memory pressure.

Pre-merge checks: Passed 4 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Docstring Coverage Inconclusive Docstring coverage is 11.68% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly identifies the main goals: fixing indirect texture tracking and Vulkan errors during Horizon Forbidden West loading.
Description check Passed The description directly explains the resource-tracking, stencil, depth-format, gather, and cache changes. It also states validation results and known testing limits.
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 11.68% 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 137 functions across 19 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-29 18:21 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1980#issuecomment-6504895797) · edited 2026-10-29 19:19 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/1980?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 --> <!-- walkthrough_start --> <details> <summary><strong>Walkthrough</strong></summary> <dl> <dd> The change adds GPU format metadata and mappings, including `k32FloatClamp` and `k16UScaled`. It adds standalone stencil-storage materialization and publication, device-memory-aware cache collection, and storage-view validation. Shader IR serialization now tracks selector metadata and inactive descriptors. SPIR-V emission supports integer level-zero 3D gathers. New tests cover these paths and update 3D image fixtures. **Suggested reviewers:** `nmzik`, `thecruz` </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> <strong>Priority: <picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/priority-normal-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Normal</strong> <!-- change_assessment_commit:"97e504bc056778b8995796d0bf1576e3be2a80ed" --> **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-high-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> High</strong> · up to <code>97e50</code></summary> <dl> <dd> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **🟠 High** · up to `97e50` --> <!-- final_review_risk_coverage:{"sourceCommitId":"97e504bc056778b8995796d0bf1576e3be2a80ed","coveredCommitId":"97e504bc056778b8995796d0bf1576e3be2a80ed","kind":"reviewed"} --> Fix the selector materialization failure and refresh device usage after texture eviction before merging; otherwise affected shaders may fail to load and image allocation can still abort under memory pressure. <!-- 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 11.68% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary><strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> Passed checks: 4 passed</strong></summary> <dl> <dd> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title clearly identifies the main goals: fixing indirect texture tracking and Vulkan errors during Horizon Forbidden West loading. | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description directly explains the resource-tracking, stencil, depth-format, gather, and cache changes. It also states validation results and known testing limits. | | 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 11.68% 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 137 functions across 19 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=1980)! 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 -->
@ -1208,0 +1253,4 @@
desc.info.data != association.info.data);
const auto depth_id = association.depth_id;
const auto range = association.stencil_subresources;
RefreshImage(depth_id);
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-29 18:21 UTC · original · edited 2026-10-29 18:59 UTC

Major · Data Integrity & Integration · Quick win

Refresh the stencil association before copying its contents.

If guest memory changes after a stencil association is created, the association can be CPU-dirty while its depth owner remains clean. RefreshImage(depth_id) does not upload that association. CopyStencilStorage then copies stale native stencil bytes into the storage image, so a partial compute write preserves incorrect values. Refresh id before copying, while it still refers to the association. (raw.githubusercontent.com)

✅ Addressed in commit 97e504b

**@⁠coderabbitai[bot]** on GitHub · 2026-10-29 18:21 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1980#discussion_r4416265029) · edited 2026-10-29 18:59 UTC <!-- coderabbit-ai-generated:v1 --> **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/major-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Major** · **Data Integrity & Integration** · **Quick win** **Refresh the stencil association before copying its contents.** If guest memory changes after a stencil association is created, the association can be CPU-dirty while its depth owner remains clean. `RefreshImage(depth_id)` does not upload that association. `CopyStencilStorage` then copies stale native stencil bytes into the storage image, so a partial compute write preserves incorrect values. Refresh `id` before copying, while it still refers to the association. ([raw.githubusercontent.com](https://raw.githubusercontent.com/KytyPS5/KytyPS5/f40f5e6672f607dc490db1be564a12d35b94f758/src/graphics/host_gpu/renderer/image/image.cpp)) <!-- fingerprinting:phantom:poseidon:wombat --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:51fa72d3adae44c487a1eca5 --> <!-- This is an auto-generated comment by CodeRabbit --> ✅ Addressed in commit 97e504b
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-29 18:21 UTC · original · reviewed

Actionable comments posted: 1

Nitpick comments: 1
tests/ResourceMaterializationTests.cpp: 1

1497-1497: Trivial · Maintainability & Code Quality · Quick win

Route the format-140 depth test through Extract.

The file comment at line 21 states that every extracted plan below is the plan a restarted game loads from the shader cache. TestFloatClampDepthDescriptor calls ExtractResourcePlan directly, so its format-140 plans skip the save and load path. If SaveResourcePlan or LoadResourcePlan changes depth_compare or the format state, this test can still pass while a restarted game materializes a different specialization.

Extract saves the plan, loads it back, checks that the loaded plan saves to the same bytes, and rejects truncated and padded input. Its return value is the deserialized plan, so the materialization assertions in this test run against the path a restarted game uses.

♻️ Proposed fix
-    auto plan = ExtractResourcePlan(program);
+    auto plan = Extract(program);

Review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 5eab0ec738 and f40f5e6672.

Files selected for processing: 22
  • CMakeLists.txt
  • src/graphics/guest_gpu/gpu_defs.h
  • src/graphics/guest_gpu/gpu_format.cpp
  • src/graphics/host_gpu/renderer/cache/bufferCache.cpp
  • src/graphics/host_gpu/renderer/cache/textureCache.cpp
  • src/graphics/host_gpu/renderer/cache/textureCache.h
  • src/graphics/host_gpu/renderer/image/image.h
  • src/graphics/host_gpu/renderer/image/imageInfo.h
  • src/graphics/host_gpu/renderer/image/imageView.cpp
  • src/graphics/host_gpu/renderer/pipeline/descriptors.cpp
  • src/graphics/host_gpu/renderer/render.h
  • src/graphics/host_gpu/renderer/renderCompute.cpp
  • src/graphics/host_gpu/vulkanCommon.cpp
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterImage.cpp
  • src/graphics/shader/recompiler/ir/Serialize.h
  • src/graphics/shader/recompiler/ir/ShaderIR.h
  • src/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cpp
  • src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp
  • src/graphics/shader/recompiler/ir/passes/SrtWalker.cpp
  • tests/ResourceMaterializationTests.cpp
  • tests/ResourceTrackingTests.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-29 18:21 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1980#pullrequestreview-5702869767) · **reviewed** <!-- coderabbit-ai-generated:v1 --> **Actionable comments posted: 1** <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/ResourceMaterializationTests.cpp: 1</summary><blockquote> <dl> <dd> `1497-1497`: **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/neutral-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Trivial** · **Maintainability & Code Quality** · **Quick win** **Route the format-140 depth test through `Extract`.** The file comment at line 21 states that every extracted plan below is the plan a restarted game loads from the shader cache. `TestFloatClampDepthDescriptor` calls `ExtractResourcePlan` directly, so its format-140 plans skip the save and load path. If `SaveResourcePlan` or `LoadResourcePlan` changes `depth_compare` or the format state, this test can still pass while a restarted game materializes a different specialization. `Extract` saves the plan, loads it back, checks that the loaded plan saves to the same bytes, and rejects truncated and padded input. Its return value is the deserialized plan, so the materialization assertions in this test run against the path a restarted game uses. <details> <summary>♻️ Proposed fix</summary> <dl> <dd> ```diff - auto plan = ExtractResourcePlan(program); + auto plan = Extract(program); ``` </dd> </dl> </details> <!-- cr-comment:v1:ad6d369f971c93b60710a079 --> </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/5eab0ec73855acdf776f5c0669911e2f5ddfb743/.coderabbit.yaml>) - **Commit**: [5eab0ec](<https://github.com/KytyPS5/KytyPS5/commit/5eab0ec73855acdf776f5c0669911e2f5ddfb743>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `c6b07ba8-f57e-4dc5-8320-e206d798d286` </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 5eab0ec73855acdf776f5c0669911e2f5ddfb743 and f40f5e6672f607dc490db1be564a12d35b94f758. </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: 22</summary> <dl> <dd> * `CMakeLists.txt` * `src/graphics/guest_gpu/gpu_defs.h` * `src/graphics/guest_gpu/gpu_format.cpp` * `src/graphics/host_gpu/renderer/cache/bufferCache.cpp` * `src/graphics/host_gpu/renderer/cache/textureCache.cpp` * `src/graphics/host_gpu/renderer/cache/textureCache.h` * `src/graphics/host_gpu/renderer/image/image.h` * `src/graphics/host_gpu/renderer/image/imageInfo.h` * `src/graphics/host_gpu/renderer/image/imageView.cpp` * `src/graphics/host_gpu/renderer/pipeline/descriptors.cpp` * `src/graphics/host_gpu/renderer/render.h` * `src/graphics/host_gpu/renderer/renderCompute.cpp` * `src/graphics/host_gpu/vulkanCommon.cpp` * `src/graphics/shader/recompiler/backend/spirv/spirvEmitterImage.cpp` * `src/graphics/shader/recompiler/ir/Serialize.h` * `src/graphics/shader/recompiler/ir/ShaderIR.h` * `src/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cpp` * `src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp` * `src/graphics/shader/recompiler/ir/passes/SrtWalker.cpp` * `tests/ResourceMaterializationTests.cpp` * `tests/ResourceTrackingTests.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=ad268997-163a-4043-a864-aef2b9ef0192 attempt=8bc4a3bb-affc-49f0-96bf-c893fa1fbb53 batch=1/1 -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-29 18:49 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 · Use the standalone image range for stencil copyback. · textureCache.cpp:1295

src/graphics/host_gpu/renderer/cache/textureCache.cpp:1295
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Use the standalone image range for stencil copyback.

When record.stencil_storage is true and the stencil association changes, depth.stencil_subresources can differ from the range used to create the standalone image. The mismatch reaches CopyStencilStorage, whose EXIT_NOT_IMPLEMENTED path logs a fatal error and terminates the emulator with _Exit(321). Use record.stencil_subresources for the copyback.

Suggested fix
-				CopyStencilStorage(depth, record, depth.stencil_subresources, true);
+				CopyStencilStorage(depth, record, record.stencil_subresources, true);

This prevents the fatal validation path and preserves the standalone image's range before the record is updated. The guard runs before either transfer, so the inspected code establishes a terminated workflow rather than partial stencil copyback or data corruption.


Review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between f40f5e6672 and b703fde38b.

Files selected for processing: 4
  • src/graphics/host_gpu/renderer/cache/textureCache.cpp
  • tests/ResourceMaterializationTests.cpp
  • tests/ShaderRayTracingGpuTests.inc
  • 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-29 18:49 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1980#pullrequestreview-5703246516) · **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> · Use the standalone image range for stencil copyback. · <code>textureCache.cpp:1295</code></summary><blockquote> > <dl> > <dd> > > `src/graphics/host_gpu/renderer/cache/textureCache.cpp:1295` > **🩺 Stability & Availability** | **🟠 Major** | **⚡ Quick win** > > **Use the standalone image range for stencil copyback.** > > When `record.stencil_storage` is true and the stencil association changes, `depth.stencil_subresources` can differ from the range used to create the standalone image. The mismatch reaches `CopyStencilStorage`, whose `EXIT_NOT_IMPLEMENTED` path logs a fatal error and terminates the emulator with `_Exit(321)`. Use `record.stencil_subresources` for the copyback. > > <details> > <summary>Suggested fix</summary> > <dl> > <dd> > > ```diff > - CopyStencilStorage(depth, record, depth.stencil_subresources, true); > + CopyStencilStorage(depth, record, record.stencil_subresources, true); > ``` > > </dd> > </dl> > </details> > > This prevents the fatal validation path and preserves the standalone image's range before the record is updated. The guard runs before either transfer, so the inspected code establishes a terminated workflow rather than partial stencil copyback or data corruption. > > <!-- cr-comment:v1:8903d538d36be558a9c8623f --> > > </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/5eab0ec73855acdf776f5c0669911e2f5ddfb743/.coderabbit.yaml>) - **Commit**: [5eab0ec](<https://github.com/KytyPS5/KytyPS5/commit/5eab0ec73855acdf776f5c0669911e2f5ddfb743>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `55de5c69-fd2a-4344-84e4-03e4bd00188a` </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 f40f5e6672f607dc490db1be564a12d35b94f758 and b703fde38b5de4eaae5379ec1aa5679916c02d75. </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` * `tests/ResourceMaterializationTests.cpp` * `tests/ShaderRayTracingGpuTests.inc` * `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=635a072b-bcc1-469f-969f-237b5db5e836 attempt=f810dc08-5f57-484a-b4f6-d73a4ac978c2 batch=1/1 -->
Author
Owner

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

Caution

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

⚠️ Outside diff range comments (2)

Major · Refresh device usage after freeing a reported image. · textureCache.cpp:2116-2131

src/graphics/host_gpu/renderer/cache/textureCache.cpp:2116-2131
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Refresh device usage after freeing a reported image.

When memory reporting is enabled, used_memory is device-wide VMA usage, but line 2116 subtracts the image's cache-local AccountedSize(). These values can differ. The estimate can fall below m_critical_gc_memory while actual device usage remains above it, which disables the aggressive pass and can leave later vmaCreateImage calls failing under pressure.

Suggested fix
+			const auto accounted = owner->AccountedSize();
-			used_memory -= std::min(used_memory, owner->AccountedSize());
 			FreeImage(id);
+			if (m_graphics.CanReportMemoryUsage()) {
+				used_memory = m_graphics.GetDeviceMemoryUsage();
+			} else {
+				used_memory -= std::min(used_memory, accounted);
+			}
Major · Gate the MaskRanks source. · ResourceTracking.cpp:3230-3234

src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp:3230-3234
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Gate the MaskRanks source.

When maximum == 31u, ResourceTracking.cpp creates a MaskRanks selector. WalkerCompiler::Consume gates the table, selector, and row sources, but not selector->ranks->source. ResourceMaterialization then calls WalkedDescriptor for the rank source, which can remain unknown and cause materialization to return false.

Suggested fix
 			if (indirect->selector) {
 				add(indirect->selector->source);
 				if (indirect->selector->rows) add(indirect->selector->rows->source);
+				if (indirect->selector->ranks) add(indirect->selector->ranks->source);
 			}

Review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between b703fde38b and 97e504bc05.

Files selected for processing: 3
  • src/graphics/host_gpu/renderer/cache/textureCache.cpp
  • tests/ResourceMaterializationTests.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-29 19:19 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1980#pullrequestreview-5703660281) · **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 (2)** > > <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> · Refresh device usage after freeing a reported image. · <code>textureCache.cpp:2116-2131</code></summary><blockquote> > <dl> > <dd> > > `src/graphics/host_gpu/renderer/cache/textureCache.cpp:2116-2131` > **🩺 Stability & Availability** | **🟠 Major** | **⚡ Quick win** > > **Refresh device usage after freeing a reported image.** > > When memory reporting is enabled, `used_memory` is device-wide VMA usage, but line 2116 subtracts the image's cache-local `AccountedSize()`. These values can differ. The estimate can fall below `m_critical_gc_memory` while actual device usage remains above it, which disables the aggressive pass and can leave later `vmaCreateImage` calls failing under pressure. > > <details> > <summary>Suggested fix</summary> > <dl> > <dd> > > ```diff > + const auto accounted = owner->AccountedSize(); > - used_memory -= std::min(used_memory, owner->AccountedSize()); > FreeImage(id); > + if (m_graphics.CanReportMemoryUsage()) { > + used_memory = m_graphics.GetDeviceMemoryUsage(); > + } else { > + used_memory -= std::min(used_memory, accounted); > + } > ``` > > </dd> > </dl> > </details> > > <!-- cr-comment:v1:2a1831757257a87df625133d --> > > </dd> > </dl> > </blockquote></details> > <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> · Gate the <code>MaskRanks</code> source. · <code>ResourceTracking.cpp:3230-3234</code></summary><blockquote> > <dl> > <dd> > > `src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp:3230-3234` > **🩺 Stability & Availability** | **🟠 Major** | **⚡ Quick win** > > **Gate the `MaskRanks` source.** > > When `maximum == 31u`, `ResourceTracking.cpp` creates a `MaskRanks` selector. `WalkerCompiler::Consume` gates the table, selector, and row sources, but not `selector->ranks->source`. `ResourceMaterialization` then calls `WalkedDescriptor` for the rank source, which can remain unknown and cause materialization to return `false`. > > <details> > <summary>Suggested fix</summary> > <dl> > <dd> > > ```diff > if (indirect->selector) { > add(indirect->selector->source); > if (indirect->selector->rows) add(indirect->selector->rows->source); > + if (indirect->selector->ranks) add(indirect->selector->ranks->source); > } > ``` > > </dd> > </dl> > </details> > > <!-- cr-comment:v1:7d540eb8ef2ac1c3e9937cdb --> > > </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/5eab0ec73855acdf776f5c0669911e2f5ddfb743/.coderabbit.yaml>) - **Commit**: [5eab0ec](<https://github.com/KytyPS5/KytyPS5/commit/5eab0ec73855acdf776f5c0669911e2f5ddfb743>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `262826f7-6651-40ff-a337-fc2cbc5a8b50` </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 b703fde38b5de4eaae5379ec1aa5679916c02d75 and 97e504bc056778b8995796d0bf1576e3be2a80ed. </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: 3</summary> <dl> <dd> * `src/graphics/host_gpu/renderer/cache/textureCache.cpp` * `tests/ResourceMaterializationTests.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> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=3d0dbade-247b-4024-b302-5f340b1d24d1 attempt=bd78ee75-c7f1-47b1-8be8-c743ffde50c4 batch=1/1 -->
This pull request has changes conflicting with the target branch.
  • src/graphics/host_gpu/renderer/cache/bufferCache.cpp
  • src/graphics/host_gpu/renderer/cache/textureCache.cpp
  • src/graphics/host_gpu/renderer/cache/textureCache.h
  • src/graphics/host_gpu/renderer/image/image.h
  • src/graphics/host_gpu/renderer/image/imageInfo.h
  • src/graphics/host_gpu/renderer/image/imageView.cpp
  • src/graphics/host_gpu/renderer/pipeline/descriptors.cpp
  • src/graphics/host_gpu/renderer/render.h
  • src/graphics/host_gpu/renderer/renderCompute.cpp
  • src/graphics/shader/recompiler/backend/spirv/spirvEmitterImage.cpp
  • src/graphics/shader/recompiler/ir/Serialize.h
  • src/graphics/shader/recompiler/ir/ShaderIR.h
  • src/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cpp
  • src/graphics/shader/recompiler/ir/passes/ResourceTracking.cpp
  • src/graphics/shader/recompiler/ir/passes/SrtWalker.cpp
  • tests/ResourceMaterializationTests.cpp
  • tests/ShaderRayTracingGpuTests.inc
  • tests/ShaderRecompilerComputeTests.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/1980/head:github-bot/gh-1980'
git switch 'github-bot/gh-1980'

Merge

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