graphics: recreate cached depth targets narrower than the requested target #2417
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!2417
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2417"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@user9517 on GitHub · 2026-11-19 19:06 UTC · original
user9517:fix/ppsa24156-narrow-depth-target→main· +21 −0 · 1 files · 2 commits · openFixes 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, soResolveDepthOverlapreturned 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
--amd-cpu).masterSemaphore.cpp:54, within a few minutes of driving. After: no GPU fault in a 15-minute session at 1080p.mainand smoke-tested with all three fixes together: a 5-minute unattended run reached in-race rendering with no crash or GPU fault.ctest --preset win-release).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
@coderabbitai[bot] on GitHub · 2026-11-19 19:10 UTC · original · edited 2026-11-19 19:36 UTC
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,thecruzChange: Bug fix
Merge Risk:
Minimal · up to
5daf0Depth 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:
4
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
aa28a41f-fad6-499d-bf9f-cfe2b28d72b2Reviewing files that changed from the base of the PR and between
6381644241and5daf007b4f.src/graphics/host_gpu/renderer/cache/textureCache.cppIncluded 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 · reviewed
Actionable comments posted: 2
49b1be8d-ab86-4fd3-85ba-68abdc7009e8Reviewing files that changed from the base of the PR and between
5ad27cdd1aand6381644241.src/graphics/host_gpu/renderer/cache/textureCache.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
@ -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;@coderabbitai[bot] on GitHub · 2026-11-19 19:10 UTC · original · edited 2026-11-19 20:17 UTC
Initialize the columns that a grown depth replacement exposes.
When a cached depth target grows,
CopyImagecopies only the overlap with the old extent, andImage::CopyImageclamps 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.
Keep the HTile clear state when a depth target grows.
On growth,
ResolveDepthOverlapfrees the cached image at line 682. If that image owns the HTile entry,DeleteImageerases the entry. The replacement is not made owner before this point, and it starts withhtile_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.
@ -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;@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) beforeCopyImagefills 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;@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, soDeleteImageno 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;@coderabbitai[bot] on GitHub · 2026-11-19 20:18 UTC · original
Analysis chain
Script executed:
Length of output: 29200
Script executed:
Length of output: 13097
@user9517The single-sample replacement now initializes before the overlap copy.The multisampled case still has the original risk.
InitializeImageskips the upload, andImage::CopyImagecopies 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.
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.
@ -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;@coderabbitai[bot] on GitHub · 2026-11-19 20:18 UTC · original
Analysis chain
Script executed:
Length of output: 19946
Script executed:
Length of output: 14274
@user9517The HTile ownership transfer is in place beforeFreeImage. The code compares HTile addresses, not range sizes.The initialization finding still applies to multisampled growth.
InitializeImagereturns without uploading, andImage::CopyImagecopies 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.
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.Merge
Merge the changes and update on Forgejo.