graphics: recreate cached depth targets narrower than the requested target #2417

Open
github-bot wants to merge 2 commits from github-bot/gh-2417 into main AGit
Owner

@⁠user9517 on GitHub · 2026-11-19 19:06 UTC · original
user9517:fix/ppsa24156-narrow-depth-target → main · +21 −0 · 1 files · 2 commits · open

Fixes a GPU fault in My First Gran Turismo (PPSA24156) on NVIDIA GPUs: a few minutes into driving, the GPU reports a depth width violation and the device is lost.

Problem: a few minutes into driving, NVIDIA logs Xid 13 "3D WIDTH ZT Violation" and the device is lost (masterSemaphore.cpp:54). The game renders narrow depth targets of several widths (for example 4, 13 and 26 pixels, x512) at one address. Their tiled pitch and footprint match, so ResolveDepthOverlap returned the cached narrow image for the wider targets, while the render area used the requested width.

Change: for BindingType::DepthTarget, recreate the image when the request is wider or taller than the cached one. The existing replacement path copies the old contents.

Testing

  • Windows 11, RTX 5090 (driver 621.24), Ryzen 9 9950X3D (--amd-cpu).
  • Before: Xid 13 "3D WIDTH ZT Violation", then device loss and a stop at masterSemaphore.cpp:54, within a few minutes of driving. After: no GPU fault in a 15-minute session at 1080p.
  • On NVIDIA this point is only reachable once the other two fixes (separate PRs) are in.
  • Rebased on current main and smoke-tested with all three fixes together: a 5-minute unattended run reached in-race rendering with no crash or GPU fault.
  • The CI build targets compile, and the regression tests pass (ctest --preset win-release).
  • Not tested: AMD or Intel GPUs, and Linux.

AI use

I made this change with Claude Code (Claude Opus 5.5). It wrote the investigation tooling (pipeline capture and replay, a crash-dump handler, per-second counters) and drafted the code change and this description.

What I did: I reviewed the diff, and I ran the game sessions listed under Testing.

🤖 Generated with Claude Code

**@⁠user9517** on GitHub · 2026-11-19 19:06 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2417) `user9517:fix/ppsa24156-narrow-depth-target` → `main` · +21 −0 · 1 files · 2 commits · open Fixes a GPU fault in **My First Gran Turismo (PPSA24156)** on NVIDIA GPUs: a few minutes into driving, the GPU reports a depth width violation and the device is lost. **Problem:** a few minutes into driving, NVIDIA logs Xid 13 "3D WIDTH ZT Violation" and the device is lost (`masterSemaphore.cpp:54`). The game renders narrow depth targets of several widths (for example 4, 13 and 26 pixels, x512) at one address. Their tiled pitch and footprint match, so `ResolveDepthOverlap` returned the cached narrow image for the wider targets, while the render area used the requested width. **Change:** for `BindingType::DepthTarget`, recreate the image when the request is wider or taller than the cached one. The existing replacement path copies the old contents. ## Testing - Windows 11, RTX 5090 (driver 621.24), Ryzen 9 9950X3D (`--amd-cpu`). - Before: Xid 13 "3D WIDTH ZT Violation", then device loss and a stop at `masterSemaphore.cpp:54`, within a few minutes of driving. After: no GPU fault in a 15-minute session at 1080p. - On NVIDIA this point is only reachable once the other two fixes (separate PRs) are in. - Rebased on current `main` and smoke-tested with all three fixes together: a 5-minute unattended run reached in-race rendering with no crash or GPU fault. - The CI build targets compile, and the regression tests pass (`ctest --preset win-release`). - Not tested: AMD or Intel GPUs, and Linux. ## AI use I made this change with Claude Code (Claude Opus 5.5). It wrote the investigation tooling (pipeline capture and replay, a crash-dump handler, per-second counters) and drafted the code change and this description. What I did: I reviewed the diff, and I ran the game sessions listed under Testing. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
My First Gran Turismo (PPSA24156) renders 4-, 13- and 26-wide (x512)
depth targets at one address. Their tiled pitch and footprint match, so
ResolveDepthOverlap returned the cached 4-wide image for the wider
targets while the render area used the requested width. NVIDIA reports
"3D WIDTH ZT Violation", resets the GPU, and the emulator stops on
device loss (masterSemaphore.cpp:54).

For depth targets, recreate the image when the request is wider or
taller than the cached one; the existing path copies the old contents.

Tested: no render area exceeds an attachment and no GPU fault in a
15-minute session through the tutorial; 32 CI regression tests pass.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Two gaps in the ResolveDepthOverlap replacement path, raised in review:

- CopyImage copies only the overlap with the cached extent and marks the
  replacement refreshed, so a wider or taller replacement exposed
  undefined texels. A larger replacement now loads the guest bytes first;
  the copy then fills the overlap.
- Freeing the cached image erased the HTile clear state it owned, so a
  pending fast clear never reached the next pass. When the replacement
  uses the same HTile range, it now takes ownership before the cached
  image is freed.

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

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

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

ResolveDepthOverlap now recreates a cached depth target when the requested width or height exceeds its extent. If the replacement is larger in either dimension, the function initializes it before copying the cached image. When both images use HTile metadata at the same address, ownership transfers to the replacement if the cached image owns it.

Suggested reviewers: nmzik, thecruz

Change: Bug fix

Merge Risk: Minimal · up to 5daf0

Depth targets that grow in width or height are now recreated with their guest contents loaded before the old contents are copied over. The HTile clear state also moves to the replacement. No concrete merge-blocking risk remains, though testing covered only NVIDIA on Windows.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: cached depth targets narrower than the requested target are recreated. The raw summary and objectives confirm that ResolveDepthOverlap now recreates the DepthTarget im…
Description check Passed The description states the GPU fault being fixed (Xid 13 in My First Gran Turismo on NVIDIA), the root cause in ResolveDepthOverlap, the change itself (recreating the depth image when the request is w…
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: Title check

Explanation

The title names the main change: cached depth targets narrower than the requested target are recreated. The raw summary and objectives confirm that ResolveDepthOverlap now recreates the DepthTarget image when the request is wider or taller. The title is specific and concise, and it does not describe anything absent from the changeset.

Full details: Description check

Explanation

The description states the GPU fault being fixed (Xid 13 in My First Gran Turismo on NVIDIA), the root cause in ResolveDepthOverlap, the change itself (recreating the depth image when the request is wider or taller), and the testing performed. It is directly related to the changeset.

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 6381644241 and 5daf007b4f.

Files selected for processing: 1

  • src/graphics/host_gpu/renderer/cache/textureCache.cpp

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

**@⁠coderabbitai[bot]** on GitHub · 2026-11-19 19:10 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2417#issuecomment-7019383759) · edited 2026-11-19 19:36 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/2417?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-buttons-v1/explain-change-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change.svg" alt="Explain Change →" height="32"></picture></a> <!-- review_stack_entry_end --> <!-- 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> ResolveDepthOverlap now recreates a cached depth target when the requested width or height exceeds its extent. If the replacement is larger in either dimension, the function initializes it before copying the cached image. When both images use HTile metadata at the same address, ownership transfers to the replacement if the cached image owns it. **Suggested reviewers:** `nmzik`, `thecruz` </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> <!-- change_assessment_commit:"5daf007b4f416ee3cb5d45b8be9b39f5626da678" --> <!-- 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-unassessed-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minimal</strong> · up to <code>5daf0</code></summary> <dl> <dd> <br> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **⚪ Minimal** · up to `5daf0` --> <!-- final_review_risk_coverage:{"sourceCommitId":"5daf007b4f416ee3cb5d45b8be9b39f5626da678","coveredCommitId":"5daf007b4f416ee3cb5d45b8be9b39f5626da678","kind":"reviewed"} --> Depth targets that grow in width or height are now recreated with their guest contents loaded before the old contents are copied over. The HTile clear state also moves to the replacement. No concrete merge-blocking risk remains, though testing covered only NVIDIA on Windows. <!-- 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</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 names the main change: cached depth targets narrower than the requested target are recreated. The raw summary and objectives confirm that ResolveDepthOverlap now recreates the DepthTarget im… | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description states the GPU fault being fixed (Xid 13 in My First Gran Turismo on NVIDIA), the root cause in ResolveDepthOverlap, the change itself (recreating the depth image when the request is w… | | 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. | <details> <summary><strong>Full details: Title check</strong></summary> <dl> <dd> <br> **Explanation** The title names the main change: cached depth targets narrower than the requested target are recreated. The raw summary and objectives confirm that ResolveDepthOverlap now recreates the DepthTarget image when the request is wider or taller. The title is specific and concise, and it does not describe anything absent from the changeset. </dd> </dl> </details> <details> <summary><strong>Full details: Description check</strong></summary> <dl> <dd> <br> **Explanation** The description states the GPU fault being fixed (Xid 13 in My First Gran Turismo on NVIDIA), the root cause in ResolveDepthOverlap, the change itself (recreating the depth image when the request is wider or taller), and the testing performed. It is directly related to the changeset. </dd> </dl> </details> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- tips_start --> Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=2417)! 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/5ad27cdd1aeb48a7885b1a71d5a8321590b31ecd/.coderabbit.yaml>) - **Commit**: [5ad27cd](<https://github.com/KytyPS5/KytyPS5/commit/5ad27cdd1aeb48a7885b1a71d5a8321590b31ecd>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `aa28a41f-fad6-499d-bf9f-cfe2b28d72b2` </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 6381644241f79dd89a6bdc33fba43d9b9ecec69b and 5daf007b4f416ee3cb5d45b8be9b39f5626da678. </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: 1</strong></summary> <dl> <dd> <br> * `src/graphics/host_gpu/renderer/cache/textureCache.cpp` </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review. </dd> </dl> </details> </h6> <!-- recent_review_end -->
Author
Owner

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

Actionable comments posted: 2

Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 5ad27cdd1a and 6381644241.

Files selected for processing: 1

  • src/graphics/host_gpu/renderer/cache/textureCache.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-11-19 19:10 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2417#pullrequestreview-5981557306) · **reviewed** <!-- coderabbit-ai-generated:v1 --> **Actionable comments posted: 2** <h6> <details> <summary><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/info.svg" width="12" height="12" align="absmiddle" alt=""></picture> Review info</summary> <dl> <dd> <br> <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> <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/5ad27cdd1aeb48a7885b1a71d5a8321590b31ecd/.coderabbit.yaml>) - **Commit**: [5ad27cd](<https://github.com/KytyPS5/KytyPS5/commit/5ad27cdd1aeb48a7885b1a71d5a8321590b31ecd>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `49b1be8d-ab86-4fd3-85ba-68abdc7009e8` </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> <br> Reviewing files that changed from the base of the PR and between 5ad27cdd1aeb48a7885b1a71d5a8321590b31ecd and 6381644241f79dd89a6bdc33fba43d9b9ecec69b. </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: 1</summary> <dl> <dd> <br> * `src/graphics/host_gpu/renderer/cache/textureCache.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> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=f8ed6b33-a930-4d23-8d2e-845640046f71 attempt=10df06e0-1641-4405-a93a-8d9b52078188 batch=1/1 -->
@ -630,0 +631,4 @@
// the cached image can be narrower than the render area; drawing past it faults on the
// host GPU (NVIDIA: "3D WIDTH ZT Violation"). A target view cannot grow its image.
recreate |= requested.extent.width > cached.info.extent.width ||
requested.extent.height > cached.info.extent.height;
Author
Owner

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

Major · Data Integrity & Integration · Heavy lift

Initialize the columns that a grown depth replacement exposes.

When a cached depth target grows, CopyImage copies only the overlap with the old extent, and Image::CopyImage clamps each copy to the smaller of the two extents. The replacement is then marked refreshed before this copy, so this path does not load guest memory into it. Columns beyond the old width can therefore contain undefined GPU data. Depth tests in those columns can read those values, which can corrupt occlusion in the frame that first renders the wider area.

The replacement must hold the guest depth contents in every column it exposes, not only the copied overlap. Choose the initialization mechanism that gives the replacement the guest contents for the non-overlap region, and confirm that it does so before the first draw.


Major · Data Integrity & Integration · Heavy lift

Keep the HTile clear state when a depth target grows.

On growth, ResolveDepthOverlap frees the cached image at line 682. If that image owns the HTile entry, DeleteImage erases the entry. The replacement is not made owner before this point, and it starts with htile_initial_clear = false. Its new entry therefore has no clear mask. A pending fast clear on the old target is discarded instead of carried to the replacement.

Before the cached image is freed, the HTile clear state must move to the replacement, or the record must otherwise survive growth. Choose the mechanism that keeps the clear state tied to the HTile range.

**@⁠coderabbitai[bot]** on GitHub · 2026-11-19 19:10 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2417#discussion_r4633730429) · edited 2026-11-19 20:17 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** **Initialize the columns that a grown depth replacement exposes.** When a cached depth target grows, `CopyImage` copies only the overlap with the old extent, and `Image::CopyImage` clamps each copy to the smaller of the two extents. The replacement is then marked refreshed before this copy, so this path does not load guest memory into it. Columns beyond the old width can therefore contain undefined GPU data. Depth tests in those columns can read those values, which can corrupt occlusion in the frame that first renders the wider area. The replacement must hold the guest depth contents in every column it exposes, not only the copied overlap. Choose the initialization mechanism that gives the replacement the guest contents for the non-overlap region, and confirm that it does so before the first draw. <!-- fingerprinting:phantom:triton:okapi --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:18b021ba67277d1cb23d937d --> --- **<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** **Keep the HTile clear state when a depth target grows.** On growth, `ResolveDepthOverlap` frees the cached image at line 682. If that image owns the HTile entry, `DeleteImage` erases the entry. The replacement is not made owner before this point, and it starts with `htile_initial_clear = false`. Its new entry therefore has no clear mask. A pending fast clear on the old target is discarded instead of carried to the replacement. Before the cached image is freed, the HTile clear state must move to the replacement, or the record must otherwise survive growth. Choose the mechanism that keeps the clear state tied to the HTile range. <!-- fingerprinting:phantom:triton:okapi --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:b49b1970194b41cdafd63034 --> <!-- This is an auto-generated reply by CodeRabbit -->
@ -630,0 +631,4 @@
// the cached image can be narrower than the render area; drawing past it faults on the
// host GPU (NVIDIA: "3D WIDTH ZT Violation"). A target view cannot grow its image.
recreate |= requested.extent.width > cached.info.extent.width ||
requested.extent.height > cached.info.extent.height;
Author
Owner

@⁠user9517 on GitHub · 2026-11-19 20:17 UTC · original

Fixed in 5daf007b. When the replacement is wider or taller than the cached image, it now loads the guest bytes (InitializeImage) before CopyImage fills the overlap. Multisampled replacements have no guest upload path, so their extra texels are still not loaded; that case is unchanged.

**@⁠user9517** on GitHub · 2026-11-19 20:17 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2417#discussion_r4634532236) Fixed in 5daf007b. When the replacement is wider or taller than the cached image, it now loads the guest bytes (`InitializeImage`) before `CopyImage` fills the overlap. Multisampled replacements have no guest upload path, so their extra texels are still not loaded; that case is unchanged.
@ -630,0 +631,4 @@
// the cached image can be narrower than the render area; drawing past it faults on the
// host GPU (NVIDIA: "3D WIDTH ZT Violation"). A target view cannot grow its image.
recreate |= requested.extent.width > cached.info.extent.width ||
requested.extent.height > cached.info.extent.height;
Author
Owner

@⁠user9517 on GitHub · 2026-11-19 20:17 UTC · original

Fixed in 5daf007b. When the replacement uses the same HTile range, it takes ownership of the clear state before the cached image is freed, so DeleteImage no longer erases a pending fast clear. If the replacement has a different HTile range or none, the entry is released as before.

**@⁠user9517** on GitHub · 2026-11-19 20:17 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2417#discussion_r4634532807) Fixed in 5daf007b. When the replacement uses the same HTile range, it takes ownership of the clear state before the cached image is freed, so `DeleteImage` no longer erases a pending fast clear. If the replacement has a different HTile range or none, the entry is released as before.
@ -630,0 +631,4 @@
// the cached image can be narrower than the render area; drawing past it faults on the
// host GPU (NVIDIA: "3D WIDTH ZT Violation"). A target view cannot grow its image.
recreate |= requested.extent.width > cached.info.extent.width ||
requested.extent.height > cached.info.extent.height;
Author
Owner

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

Analysis chain

Script executed:

#!/bin/bash
set -u
printf '%s\n' '=== Repository revision ==='
git rev-parse HEAD
printf '%s\n' '=== Candidate image files ==='
fd -i '^(image|texturecache)\.(cpp|h)$' src
printf '%s\n' '=== Image copy, construction and flags ==='
rg -n -C 4 'Image::Image\s*\(|Image::CopyImage\s*\(|IsCpuDirty\s*\(|IsBufferModified\s*\(|cpu_dirty|MarkCpuDirty|RefreshComplete\s*\(' src/graphics/host_gpu/renderer/image src/graphics/host_gpu/renderer/cache/textureCache.cpp
printf '%s\n' '=== Relevant samples and render loads ==='
rg -n -C 3 'ResolveDepthOverlap\s*\(|AttachmentLoadOp::eLoad|ReinterpretColorAsMsDepth\s*\(' src/graphics/host_gpu/renderer

Length of output: 29200


Script executed:

#!/bin/bash
set -u
ast-grep outline src/graphics/host_gpu/renderer/image/image.cpp --match 'Image|CopyImage' --view expanded
printf '%s\n' '=== Copy implementation ==='
cat -n src/graphics/host_gpu/renderer/image/image.cpp | sed -n '340,420p'
printf '%s\n' '=== Construction ==='
cat -n src/graphics/host_gpu/renderer/image/image.cpp | sed -n '681,750p'
printf '%s\n' '=== Attachment load ==='
cat -n src/graphics/host_gpu/renderer/context.cpp | sed -n '40,80p'

Length of output: 13097


@user9517 The single-sample replacement now initializes before the overlap copy.

The multisampled case still has the original risk. InitializeImage skips the upload, and Image::CopyImage copies only the overlap. If the next depth pass loads the attachment instead of clearing it, newly exposed texels can contain undefined depth values.

Please initialize those texels or establish that they are cleared before use. I’m not marking the finding as addressed while that case remains.


📝 Learnings were not changed: only organization members or users with write access to this repository can add or remove learnings.


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

Thank you for using CodeRabbit!

You are interacting with an AI system.

**@⁠coderabbitai[bot]** on GitHub · 2026-11-19 20:18 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2417#discussion_r4634552243) <!-- coderabbit-ai-generated:v1 --> <details> <summary>Analysis chain</summary> <dl> <dd> <br> Script executed: ```shell #!/bin/bash set -u printf '%s\n' '=== Repository revision ===' git rev-parse HEAD printf '%s\n' '=== Candidate image files ===' fd -i '^(image|texturecache)\.(cpp|h)$' src printf '%s\n' '=== Image copy, construction and flags ===' rg -n -C 4 'Image::Image\s*\(|Image::CopyImage\s*\(|IsCpuDirty\s*\(|IsBufferModified\s*\(|cpu_dirty|MarkCpuDirty|RefreshComplete\s*\(' src/graphics/host_gpu/renderer/image src/graphics/host_gpu/renderer/cache/textureCache.cpp printf '%s\n' '=== Relevant samples and render loads ===' rg -n -C 3 'ResolveDepthOverlap\s*\(|AttachmentLoadOp::eLoad|ReinterpretColorAsMsDepth\s*\(' src/graphics/host_gpu/renderer ``` Length of output: 29200 --- Script executed: ```shell #!/bin/bash set -u ast-grep outline src/graphics/host_gpu/renderer/image/image.cpp --match 'Image|CopyImage' --view expanded printf '%s\n' '=== Copy implementation ===' cat -n src/graphics/host_gpu/renderer/image/image.cpp | sed -n '340,420p' printf '%s\n' '=== Construction ===' cat -n src/graphics/host_gpu/renderer/image/image.cpp | sed -n '681,750p' printf '%s\n' '=== Attachment load ===' cat -n src/graphics/host_gpu/renderer/context.cpp | sed -n '40,80p' ``` Length of output: 13097 --- </dd> </dl> </details> `@user9517` The single-sample replacement now initializes before the overlap copy. The multisampled case still has the original risk. `InitializeImage` skips the upload, and `Image::CopyImage` copies only the overlap. If the next depth pass loads the attachment instead of clearing it, newly exposed texels can contain undefined depth values. Please initialize those texels or establish that they are cleared before use. I’m not marking the finding as addressed while that case remains. --- > 📝 Learnings were not changed: only organization members or users with write access to this repository can add or remove learnings. --- <!-- This is an auto-generated comment: tweet message by coderabbit.ai --> If you found this review helpful, would you consider giving us a shout-out on [X](https://twitter.com/intent/tweet?related=CodeRabbitAI&text=Depth-target%20growth%20now%20loads%20newly%20exposed%20guest%20data%2C%20and%20preserves%20pending%20HTile%20fast%20clears%20when%20reusing%20the%20same%20range%E2%80%94helping%20prevent%20corrupted%20occlusion.%20Try%20%40coderabbitai%20for%20actionable%20code%20reviews.%20%F0%9F%90%87%E2%9C%85&url=https%3A%2F%2Fgithub.com%2FKytyPS5%2FKytyPS5%2Fpull%2F2417%23discussion_r4633730429)? Thank you for using CodeRabbit! <!-- end of auto-generated comment: tweet message by coderabbit.ai --> <sub><i>You are interacting with an AI system.</i></sub> <!-- This is an auto-generated reply by CodeRabbit -->
@ -630,0 +631,4 @@
// the cached image can be narrower than the render area; drawing past it faults on the
// host GPU (NVIDIA: "3D WIDTH ZT Violation"). A target view cannot grow its image.
recreate |= requested.extent.width > cached.info.extent.width ||
requested.extent.height > cached.info.extent.height;
Author
Owner

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

Analysis chain

Script executed:

#!/bin/bash
set -u
printf '%s\n' '--- Revision ---'
git rev-parse HEAD
printf '%s\n' '--- Repository instructions ---'
fd -H -t f -g 'AGENTS.md' -g '.coderabbit.yaml' -g '.coderabbit.yml' . | while IFS= read -r file; do
  printf '\n--- %s ---\n' "$file"
  cat "$file"
done
printf '%s\n' '--- Texture cache outline ---'
ast-grep outline src/graphics/host_gpu/renderer/cache/textureCache.cpp --match 'ResolveDepthOverlap|DeleteImage|InitializeImage|CopyImage'
printf '%s\n' '--- Relevant texture cache source ---'
cat -n src/graphics/host_gpu/renderer/cache/textureCache.cpp | sed -n '240,280p;510,705p;995,1025p'
printf '%s\n' '--- Image source candidates ---'
fd -t f -i '^image\.(cpp|h)$' . | while IFS= read -r file; do
  printf '\n--- %s ---\n' "$file"
  ast-grep outline "$file" --match 'CopyImage|Image|RefreshComplete' 2>/dev/null || true
  rg -n -C 5 'Image::CopyImage\(|Image::Image\(|RefreshComplete\(|IsCpuDirty\(' "$file" || true
done

Length of output: 19946


Script executed:

#!/bin/bash
set -u
printf '%s\n' '--- Applicable repository instructions ---'
fd -H -t f -g 'AGENTS.md' . | while IFS= read -r file; do
  case "$file" in
    ./AGENTS.md|./src/AGENTS.md|./src/graphics/AGENTS.md|./src/graphics/host_gpu/AGENTS.md|./src/graphics/host_gpu/renderer/AGENTS.md|./src/graphics/host_gpu/renderer/cache/AGENTS.md|./src/graphics/host_gpu/renderer/image/AGENTS.md)
      printf '\n--- %s ---\n' "$file"
      cat "$file"
      ;;
  esac
done
for file in .coderabbit.yaml .coderabbit.yml; do
  if [ -f "$file" ]; then printf '\n--- %s ---\n' "$file"; cat "$file"; fi
done
printf '%s\n' '--- Copy extent and image creation ---'
ast-grep outline src/graphics/host_gpu/renderer/image/image.cpp --match 'CopyImage|Image'
cat -n src/graphics/host_gpu/renderer/image/image.cpp | sed -n '325,398p;681,730p'
printf '%s\n' '--- Multisample initialization ---'
ast-grep outline src/graphics/host_gpu/renderer/cache/textureCache.cpp --match 'InitializeImage'
cat -n src/graphics/host_gpu/renderer/cache/textureCache.cpp | sed -n '973,995p'
printf '%s\n' '--- Image dirty state defaults ---'
ast-grep outline src/graphics/host_gpu/renderer/image/image.h --items all --match 'Image|RefreshComplete|dirty'
rg -n -C 3 'm_cpu_dirty|m_maybe_cpu_dirty|m_buffer_modified|RefreshComplete' src/graphics/host_gpu/renderer/image/image.h

Length of output: 14274


@user9517 The HTile ownership transfer is in place before FreeImage. The code compares HTile addresses, not range sizes.

The initialization finding still applies to multisampled growth. InitializeImage returns without uploading, and Image::CopyImage copies only the overlap. Unless a full clear occurs before the first read, the new texels can remain undefined. Please initialize them or establish that clear as an invariant.

I am not marking this thread as addressed while that case remains.


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

Thank you for using CodeRabbit!

You are interacting with an AI system.

**@⁠coderabbitai[bot]** on GitHub · 2026-11-19 20:18 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2417#discussion_r4634553863) <!-- coderabbit-ai-generated:v1 --> <details> <summary>Analysis chain</summary> <dl> <dd> <br> Script executed: ```shell #!/bin/bash set -u printf '%s\n' '--- Revision ---' git rev-parse HEAD printf '%s\n' '--- Repository instructions ---' fd -H -t f -g 'AGENTS.md' -g '.coderabbit.yaml' -g '.coderabbit.yml' . | while IFS= read -r file; do printf '\n--- %s ---\n' "$file" cat "$file" done printf '%s\n' '--- Texture cache outline ---' ast-grep outline src/graphics/host_gpu/renderer/cache/textureCache.cpp --match 'ResolveDepthOverlap|DeleteImage|InitializeImage|CopyImage' printf '%s\n' '--- Relevant texture cache source ---' cat -n src/graphics/host_gpu/renderer/cache/textureCache.cpp | sed -n '240,280p;510,705p;995,1025p' printf '%s\n' '--- Image source candidates ---' fd -t f -i '^image\.(cpp|h)$' . | while IFS= read -r file; do printf '\n--- %s ---\n' "$file" ast-grep outline "$file" --match 'CopyImage|Image|RefreshComplete' 2>/dev/null || true rg -n -C 5 'Image::CopyImage\(|Image::Image\(|RefreshComplete\(|IsCpuDirty\(' "$file" || true done ``` Length of output: 19946 --- Script executed: ```shell #!/bin/bash set -u printf '%s\n' '--- Applicable repository instructions ---' fd -H -t f -g 'AGENTS.md' . | while IFS= read -r file; do case "$file" in ./AGENTS.md|./src/AGENTS.md|./src/graphics/AGENTS.md|./src/graphics/host_gpu/AGENTS.md|./src/graphics/host_gpu/renderer/AGENTS.md|./src/graphics/host_gpu/renderer/cache/AGENTS.md|./src/graphics/host_gpu/renderer/image/AGENTS.md) printf '\n--- %s ---\n' "$file" cat "$file" ;; esac done for file in .coderabbit.yaml .coderabbit.yml; do if [ -f "$file" ]; then printf '\n--- %s ---\n' "$file"; cat "$file"; fi done printf '%s\n' '--- Copy extent and image creation ---' ast-grep outline src/graphics/host_gpu/renderer/image/image.cpp --match 'CopyImage|Image' cat -n src/graphics/host_gpu/renderer/image/image.cpp | sed -n '325,398p;681,730p' printf '%s\n' '--- Multisample initialization ---' ast-grep outline src/graphics/host_gpu/renderer/cache/textureCache.cpp --match 'InitializeImage' cat -n src/graphics/host_gpu/renderer/cache/textureCache.cpp | sed -n '973,995p' printf '%s\n' '--- Image dirty state defaults ---' ast-grep outline src/graphics/host_gpu/renderer/image/image.h --items all --match 'Image|RefreshComplete|dirty' rg -n -C 3 'm_cpu_dirty|m_maybe_cpu_dirty|m_buffer_modified|RefreshComplete' src/graphics/host_gpu/renderer/image/image.h ``` Length of output: 14274 --- </dd> </dl> </details> `@user9517` The HTile ownership transfer is in place before `FreeImage`. The code compares HTile addresses, not range sizes. The initialization finding still applies to multisampled growth. `InitializeImage` returns without uploading, and `Image::CopyImage` copies only the overlap. Unless a full clear occurs before the first read, the new texels can remain undefined. Please initialize them or establish that clear as an invariant. I am not marking this thread as addressed while that case remains. --- <!-- This is an auto-generated comment: tweet message by coderabbit.ai --> If you found this review helpful, would you consider giving us a shout-out on [X](https://twitter.com/intent/tweet?related=CodeRabbitAI&text=%40coderabbitai%20caught%20two%20depth-growth%20bugs%3A%20replacements%20now%20load%20guest%20bytes%20beyond%20the%20overlap%20and%20preserve%20pending%20HTile%20fast%20clears.%20Try%20CodeRabbit%20for%20reviews%20that%20protect%20data%20integrity!%20%F0%9F%9B%A1%EF%B8%8F&url=https%3A%2F%2Fgithub.com%2FKytyPS5%2FKytyPS5%2Fpull%2F2417%23discussion_r4633730429)? Thank you for using CodeRabbit! <!-- end of auto-generated comment: tweet message by coderabbit.ai --> <sub><i>You are interacting with an AI system.</i></sub> <!-- This is an auto-generated reply by CodeRabbit -->
This pull request has changes conflicting with the target branch.
  • src/graphics/host_gpu/renderer/cache/textureCache.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/2417/head:github-bot/gh-2417'
git switch 'github-bot/gh-2417'

Merge

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