graphics: recreate a depth target image that only grew wider (Gran Tu… #2082
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!2082
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2082/head"
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?
@newblord on GitHub · 2026-11-03 00:43 UTC · original
newblord:gt7_license_center_crash→main· +103 −77 · 2 files · 1 commits · closed without merging…rismo 7 License Center GPU hang)
Gran Turismo 7 (PPSA01317) lost the GPU (VK_ERROR_DEVICE_LOST) every time the License Center opened. The NVIDIA driver logged "3D WIDTH ZT Violation" on every GPC, a depth target narrower than the render area.
The game draws a dynamic-resolution depth target at one address with a fixed pitch (256) and allocation size (0x40000) and only the extent changing: 143x204, then 173x220, then 189x220. ImageInfo::BlockExtent() is {pitch, height}, so the 173x220 and 189x220 targets compare as the same layout. In TextureCache::ResolveDepthOverlap the DepthTarget case recreated the image for a missing depth plane, a stencil or bytes-per-block mismatch, or more resources, but never for a wider extent. The 189x220 draw was handed the cached 173x220 image while its render area stayed 189x220, so it rendered 16 pixels beyond the depth attachment. Color targets already take the ExpandImage path for this case, but depth returned before reaching it.
Recreate the depth image when the requested extent is larger than the cached one in either dimension.
The pre-commit clang-format hook rewrites all of textureCache.cpp, whose committed version was not clang-format clean, so this commit also carries formatting-only changes to the rest of the file. The only functional change is the 5 lines in ResolveDepthOverlap.
Add a regression test to UnifiedTextureCacheFlow: two linear depth targets at one address with equal pitch and height and widths 8 and 12. The wider request must get a native image at least 12 wide. It fails without the fix and passes with it.
Verified with an automated run of the game to the License Center: 4 of 4 runs hung before the change, and none did after it.
Gran Turismo 7 (PPSA01317) lost the GPU (VK_ERROR_DEVICE_LOST) every time the License Center opened. The NVIDIA driver logged "3D WIDTH ZT Violation" on every GPC, a depth target narrower than the render area. The game draws a dynamic-resolution depth target at one address with a fixed pitch (256) and allocation size (0x40000) and only the extent changing: 143x204, then 173x220, then 189x220. ImageInfo::BlockExtent() is {pitch, height}, so the 173x220 and 189x220 targets compare as the same layout. In TextureCache::ResolveDepthOverlap the DepthTarget case recreated the image for a missing depth plane, a stencil or bytes-per-block mismatch, or more resources, but never for a wider extent. The 189x220 draw was handed the cached 173x220 image while its render area stayed 189x220, so it rendered 16 pixels beyond the depth attachment. Color targets already take the ExpandImage path for this case, but depth returned before reaching it. Recreate the depth image when the requested extent is larger than the cached one in either dimension. The pre-commit clang-format hook rewrites all of textureCache.cpp, whose committed version was not clang-format clean, so this commit also carries formatting-only changes to the rest of the file. The only functional change is the 5 lines in ResolveDepthOverlap. Add a regression test to UnifiedTextureCacheFlow: two linear depth targets at one address with equal pitch and height and widths 8 and 12. The wider request must get a native image at least 12 wide. It fails without the fix and passes with it. Verified with an automated run of the game to the License Center: 4 of 4 runs hung before the change, and none did after it. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>@coderabbitai[bot] on GitHub · 2026-11-03 00:52 UTC · original
Findings
Walkthrough
ResolveDepthOverlapnow recreates a cached depth target when the requested width or height exceeds the cached extent. A compute test resolves targets with widths 8 and 12 at the same address and checks that the wider target’s backing image is at least 12 pixels wide. Other edits reformat existing declarations, expressions, and call sites.Suggested reviewers:
nmzik,claxten10,defektuChange: Bug fix
Merge Risk:
Moderate · up to
9885dThis change fixes the cached depth image being reused when a wider render area is requested, which was the cause of the reported License Center hang. The replacement image's new region may contain undefined depth data, GPU-written stencil can be lost, and the added height check never runs. Resolve these before merge, or explicitly accept them as a first step.
Pre-merge checks:
4 ·
1
Full details: Docstring Coverage
Explanation
Docstring coverage is 11.11% 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 18 functions across 1 files. (1 skipped: 1 too large.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
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
CodeRabbit Verify
fd997bb9-242b-43ca-8fe4-5aecbfbc7465Reviewing files that changed from the base of the PR and between
dfec14aa8cand9885dee827.src/graphics/host_gpu/renderer/cache/textureCache.cpptests/ShaderRecompilerComputeTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
@ -675,0 +672,4 @@// only grows wider would otherwise render beyond its native image.recreate |=cached.info.IsDepth() && (requested.extent.width > cached.info.extent.width ||requested.extent.height > cached.info.extent.height);@coderabbitai[bot] on GitHub · 2026-11-03 00:52 UTC · original
Initialize the newly exposed depth pixels.
When a target grows from 8 to 12 pixels wide,
CopyImagecopies only the first 8 pixels.PrepareImageCopyclears the replacement’s CPU-dirty state without uploading the remaining pixels, so a later depth load reads undefined values instead of guest memory. Initialize the new region before overlaying the cached image. (raw.githubusercontent.com)Preserve GPU-written stencil during replacement.
When a depth/stencil target grows,
Image::CopyImageexcludes the stencil aspect, andFreeImagedeletes the old stencil association. A subsequent association can reload stale guest stencil bytes, losing GPU-written stencil values. Transfer the stencil aspect and its ownership to the replacement. (raw.githubusercontent.com)@ -675,0 +672,4 @@// only grows wider would otherwise render beyond its native image.recreate |=cached.info.IsDepth() && (requested.extent.width > cached.info.extent.width ||requested.extent.height > cached.info.extent.height);@coderabbitai[bot] on GitHub · 2026-11-03 00:52 UTC · original
Handle height growth before the block-extent guard.
ResolveOverlapcallsResolveDepthOverlaponly whenBlockExtent()matches. For depth images,BlockExtent()includes the height, so this condition cannot handle height growth. For single-level targets, the mip fallback also rejects different heights; a new image can then load stale guest bytes instead of the GPU-written depth contents. Route height growth through an ownership-preserving replacement path. (github.com)@coderabbitai[bot] on GitHub · 2026-11-03 00:52 UTC · original · reviewed
@Nmzik on GitHub · 2026-11-04 08:05 UTC · original
Duplicate: #1748
Pull request closed