texture cache: convert D16<->D24/D32 depth copies instead of crashing #1873

Manually merged
github merged 1 commit from gh-pr/1873/head into gh-pr/1873/base 2026-11-26 10:07:41 +00:00
Owner

@⁠bigjjmoneyman on GitHub · 2026-10-24 03:02 UTC · original
bigjjmoneyman:fix-mlb26-depth-crash → main · +97 −56 · 2 files · 1 commits · merged 2026-10-27 09:41 UTC

Problem

MLB The Show 26 (PPSA30630) crashed in Image::CopyImageWithBuffer during
the pitcher intro cutscene, with:

condition (levels == 0 || source_bytes == 0 || source_bytes != destination_bytes
|| source_block != destination_block) is true in image.cpp:491

The game's shadow map (a 1024x1024 depth target) switches between
D16Unorm and D24UnormS8Uint at the same address during the cutscene.
TextureCache::CopyD16 already converts a D16 depth plane to/from a
16-bit color view via the GPU tiler, but explicitly declines when both
images are depth (source_depth == destination_depth), so this case
fell through to CopyImageWithBuffer's plain buffer copy, which
requires equal bytes-per-texel between source and destination and hit
the assertion above.

Changes

  • TextureCache::CopyDepthPrecision: a new fallback for two real depth
    images at different precisions (D16Unorm <-> D24UnormS8Uint or
    D32Sfloat), reusing the existing TileManager::ConvertD16 GPU
    conversion pipeline (the same one CopyD16 already uses) instead of
    the byte-copy path.
  • Wired in between CopyD16 and the CopyImageWithBuffer fallback in
    TextureCache::CopyImage, so anything still genuinely unsupported
    keeps hitting the original assertion rather than being silently
    skipped.

Testing

  • Reproduced the crash on an unmodified build against PPSA30630, build
    KytyPS5-2026-10-23-9dcff95, Windows 11, RTX 5070 Ti.
  • Confirmed CopyD16 does not apply to this case by inspection
    (source_depth == destination_depth for both images here).
  • Built and tested locally with the fix applied: the cutscene no
    longer crashes, the shadow map renders normally, and no new errors
    or warnings appear in the log where the crash previously occurred.
  • No automated test coverage added; I don't have a reference capture
    of the correct depth output to compare against, only that the
    rendered scene looks correct and matches the non-crashing frames
    around it.

Notes

Investigated and drafted with AI assistance; I reviewed, built, and
tested the change myself before submitting.

**@⁠bigjjmoneyman** on GitHub · 2026-10-24 03:02 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1873) `bigjjmoneyman:fix-mlb26-depth-crash` → `main` · +97 −56 · 2 files · 1 commits · merged 2026-10-27 09:41 UTC ### Problem MLB The Show 26 (PPSA30630) crashed in Image::CopyImageWithBuffer during the pitcher intro cutscene, with: condition (levels == 0 || source_bytes == 0 || source_bytes != destination_bytes || source_block != destination_block) is true in image.cpp:491 The game's shadow map (a 1024x1024 depth target) switches between D16Unorm and D24UnormS8Uint at the same address during the cutscene. TextureCache::CopyD16 already converts a D16 depth plane to/from a 16-bit color view via the GPU tiler, but explicitly declines when both images are depth (source_depth == destination_depth), so this case fell through to CopyImageWithBuffer's plain buffer copy, which requires equal bytes-per-texel between source and destination and hit the assertion above. ### Changes * TextureCache::CopyDepthPrecision: a new fallback for two real depth images at different precisions (D16Unorm <-> D24UnormS8Uint or D32Sfloat), reusing the existing TileManager::ConvertD16 GPU conversion pipeline (the same one CopyD16 already uses) instead of the byte-copy path. * Wired in between CopyD16 and the CopyImageWithBuffer fallback in TextureCache::CopyImage, so anything still genuinely unsupported keeps hitting the original assertion rather than being silently skipped. ### Testing * Reproduced the crash on an unmodified build against PPSA30630, build KytyPS5-2026-10-23-9dcff95, Windows 11, RTX 5070 Ti. * Confirmed CopyD16 does not apply to this case by inspection (source_depth == destination_depth for both images here). * Built and tested locally with the fix applied: the cutscene no longer crashes, the shadow map renders normally, and no new errors or warnings appear in the log where the crash previously occurred. * No automated test coverage added; I don't have a reference capture of the correct depth output to compare against, only that the rendered scene looks correct and matches the non-crashing frames around it. ### Notes Investigated and drafted with AI assistance; I reviewed, built, and tested the change myself before submitting.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:07:39 +00:00
github manually merged commit efa6b0e610 into gh-pr/1873/base 2026-11-26 10:07:41 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-24 03:11 UTC · original · edited 2026-10-27 09:06 UTC

Review in Change Stack →

Walkthrough

CopyD16 now selects promotion or demotion based on the depth-aspect transfer widths and uses the narrow image’s type to select its copy aspect. The test reads image aspects into four 32-bit words and checks fallback depth values when stencil is removed and restored.

Suggested reviewers: nmzik

Priority: Normal

Change: Bug fix

Merge Risk: Low · up to efa6b

Depth conversion may leave stale stencil values in the replacement image. Preserve the stencil plane before merging, or explicitly accept this bounded risk.

Pre-merge checks: Passed 4 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Docstring Coverage Inconclusive Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within survi… 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 names the main change: converting D16 to and from D24/D32 depth copies in the texture cache, as an alternative to crashing. It matches the PR objectives and the description of the new CopyDe…
Description check Passed The description states the problem, the code changes, the testing done, and the limits of that testing. It relates directly to the texture cache change. It explains the CopyD16 and CopyImageWithBuffer…
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: converting D16 to and from D24/D32 depth copies in the texture cache, as an alternative to crashing. It matches the PR objectives and the description of the new CopyDepthPrecision fallback. The title is 69 characters, which is within a reasonable length for a commit title.

Full details: Description check

Explanation

The description states the problem, the code changes, the testing done, and the limits of that testing. It relates directly to the texture cache change. It explains the CopyD16 and CopyImageWithBuffer fallback path and the new CopyDepthPrecision function. It also notes that the author added no automated test coverage.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 1 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-24 03:11 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1873#issuecomment-6379149957) · edited 2026-10-27 09:06 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/1873?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> `CopyD16` now selects promotion or demotion based on the depth-aspect transfer widths and uses the narrow image’s type to select its copy aspect. The test reads image aspects into four 32-bit words and checks fallback depth values when stencil is removed and restored. **Suggested reviewers:** `nmzik` </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:"efa6b0e610e94b0502280a65255f826a6408226a" --> **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-low-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Low</strong> · up to <code>efa6b</code></summary> <dl> <dd> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **🔵 Low** · up to `efa6b` --> <!-- final_review_risk_coverage:{"sourceCommitId":"efa6b0e610e94b0502280a65255f826a6408226a","coveredCommitId":"efa6b0e610e94b0502280a65255f826a6408226a","kind":"reviewed"} --> Depth conversion may leave stale stencil values in the replacement image. Preserve the stencil plane before merging, or explicitly accept this bounded risk. <!-- 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 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within survi… | 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 names the main change: converting D16 to and from D24/D32 depth copies in the texture cache, as an alternative to crashing. It matches the PR objectives and the description of the new CopyDe… | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description states the problem, the code changes, the testing done, and the limits of that testing. It relates directly to the texture cache change. It explains the CopyD16 and CopyImageWithBuffer… | | 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> **Explanation** The title names the main change: converting D16 to and from D24/D32 depth copies in the texture cache, as an alternative to crashing. It matches the PR objectives and the description of the new CopyDepthPrecision fallback. The title is 69 characters, which is within a reasonable length for a commit title. </dd> </dl> </details> <details> <summary><strong>Full details: Description check</strong></summary> <dl> <dd> **Explanation** The description states the problem, the code changes, the testing done, and the limits of that testing. It relates directly to the texture cache change. It explains the CopyD16 and CopyImageWithBuffer fallback path and the new CopyDepthPrecision function. It also notes that the author added no automated test coverage. </dd> </dl> </details> </dd> </dl> </details> <details> <summary><strong>Full details: Docstring Coverage</strong></summary> <dl> <dd> **Explanation** Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 1 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=1873)! 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 -->
@ -528,2 +526,3 @@
0, 0, layers},
{},
color.info.extent}};
narrow.info.extent}};
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-27 09:06 UTC · original

Minor · Data Integrity & Integration · Quick win

Supported by static analysis

Script executed:

sed -n '480,605p' src/graphics/host_gpu/renderer/cache/textureCache.cpp
rg -n 'bytes_per_block|D16UnormS8Uint|D24UnormS8Uint|CopyImage\(' src/graphics/host_gpu/renderer/cache/textureCache.cpp src/graphics/host_gpu/renderer/image/imageInfo.h src/graphics/host_gpu/renderer/cache | head -115

Repository: KytyPS5/KytyPS5

Length of output: 12890


Script executed:

set -o pipefail
printf '%s\n' '--- PR diff ---'
git diff --unified=35 fd6b28c4b261a59b35f8f6a225a8fbe87b41f993 efa6b0e610e94b0502280a65255f826a6408226a -- src/graphics/host_gpu/renderer/cache/textureCache.cpp

printf '%s\n' '--- Image copy declarations and definitions ---'
rg -n -F --glob '*.{h,cpp}' -e 'CopyImageWithBuffer' -e 'void Image::CopyImage' -e 'CopyImage(const Image' -e 'CopyImage\(' src/graphics/host_gpu/renderer/image src/graphics/host_gpu/renderer/cache || test "$?" -eq 1
sed -n '430,515p' src/graphics/host_gpu/renderer/image/image.cpp
rg -n -F --glob '*.{h,cpp}' -e 'CopyImageMip(' -e 'CopyImage\(' src/graphics/host_gpu/renderer/cache src/graphics/host_gpu/renderer | head -180

printf '%s\n' '--- Image aspect and format contracts ---'
sed -n '150,305p' src/graphics/host_gpu/renderer/image/imageInfo.h
sed -n '1,180p' src/graphics/host_gpu/renderer/image/image.h

Repository: KytyPS5/KytyPS5

Length of output: 28941


Script executed:

set -o pipefail
printf '%s\n' '--- Image::CopyImage complete definition ---'
sed -n '320,430p' src/graphics/host_gpu/renderer/image/image.cpp

printf '%s\n' '--- Image::CopyImageWithBuffer complete definition ---'
sed -n '474,590p' src/graphics/host_gpu/renderer/image/image.cpp

printf '%s\n' '--- TextureCache copy callers and enclosing flows ---'
sed -n '600,680p' src/graphics/host_gpu/renderer/cache/textureCache.cpp
sed -n '860,950p' src/graphics/host_gpu/renderer/cache/textureCache.cpp
rg -n -F --glob '*.{cpp,h}' -e 'stencil_ids' -e 'stencil_subresources' -e 'depth_id' src/graphics/host_gpu/renderer | head -160

printf '%s\n' '--- Full aspect helper and copy-related tests ---'
rg -n -F --glob '*.{cpp,h}' -e 'FullAspectMask' -e 'CopyD16' -e 'CopyImageWithBuffer' -e 'CopyImage(' tests src/graphics/host_gpu/renderer | head -220

Repository: KytyPS5/KytyPS5

Length of output: 30221


Script executed:

set -o pipefail
printf '%s\n' '--- FullAspectMask and stencil transfer helpers ---'
sed -n '95,125p' src/graphics/host_gpu/renderer/image/image.cpp
sed -n '940,1010p' src/graphics/host_gpu/renderer/cache/textureCache.cpp
sed -n '1825,1875p' src/graphics/host_gpu/renderer/cache/textureCache.cpp

printf '%s\n' '--- ExpandImage and replacement callers ---'
sed -n '680,725p' src/graphics/host_gpu/renderer/cache/textureCache.cpp
sed -n '885,935p' src/graphics/host_gpu/renderer/cache/textureCache.cpp
rg -n -F --glob '*.{cpp,h}' -e 'ExpandImage(' -e 'AssociateStencil(' src/graphics/host_gpu/renderer/cache src/graphics/host_gpu/renderer | head -120

printf '%s\n' '--- Stencil association implementation and registration flow ---'
sed -n '1195,1270p' src/graphics/host_gpu/renderer/cache/textureCache.cpp
sed -n '1265,1310p' src/graphics/host_gpu/renderer/cache/textureCache.cpp
sed -n '1420,1510p' src/graphics/host_gpu/renderer/cache/textureCache.cpp

Repository: KytyPS5/KytyPS5

Length of output: 21603


Script executed:

set -o pipefail
printf '%s\n' '--- Image insertion, initialization, refresh, and download ---'
rg -n -F --glob 'textureCache.cpp' -e 'ImageId TextureCache::InsertImage' -e 'void TextureCache::InitializeImage' -e 'void TextureCache::RefreshImage' -e 'void TextureCache::DownloadImage' -e 'void TextureCache::FreeImage' src/graphics/host_gpu/renderer/cache
sed -n '210,330p' src/graphics/host_gpu/renderer/cache/textureCache.cpp
sed -n '1780,1865p' src/graphics/host_gpu/renderer/cache/textureCache.cpp
sed -n '1865,1945p' src/graphics/host_gpu/renderer/cache/textureCache.cpp

printf '%s\n' '--- FindImage post-overlap handling ---'
sed -n '1310,1425p' src/graphics/host_gpu/renderer/cache/textureCache.cpp

Repository: KytyPS5/KytyPS5

Length of output: 14425


Script executed:

set -o pipefail
sed -n '190,230p' src/graphics/host_gpu/renderer/cache/textureCache.cpp
sed -n '1000,1065p' src/graphics/host_gpu/renderer/cache/textureCache.cpp
sed -n '1168,1210p' src/graphics/host_gpu/renderer/cache/textureCache.cpp
sed -n '1745,1818p' src/graphics/host_gpu/renderer/cache/textureCache.cpp

Repository: KytyPS5/KytyPS5

Length of output: 9073


Script executed:

set -o pipefail
rg -n -F --glob 'image.cpp' -e 'Image::Image' -e 'm_buffer_modified' -e 'm_cpu_dirty' src/graphics/host_gpu/renderer/image
sed -n '215,285p' src/graphics/host_gpu/renderer/image/image.cpp

Repository: KytyPS5/KytyPS5

Length of output: 3978


Copy the stencil aspect during D16 conversion.

ExpandImage initializes the replacement, copies the source, and then frees the source. For stenciled D16-to-D24/D32 images with both guest bytes_per_block values equal to two, CopyImage reaches CopyD16, which transfers only eDepth. It does not transfer eStencil.

RefreshImage does not download GPU-modified contents. Therefore, a source with current GPU stencil data can leave the replacement with stale or undefined stencil values. Transfer the stencil aspect explicitly at this conversion boundary, using the stencil plane's one-byte layout and existing stencil association ranges.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-27 09:06 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1873#discussion_r4386825667) <!-- coderabbit-ai-generated:v1 --> **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/amber-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minor** · **Data Integrity & Integration** · **Quick win** <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/review-details-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/review-details.svg" width="16" height="16" align="absmiddle" alt=""></picture> Supported by static analysis</summary> <dl> <dd> Script executed: ```bash sed -n '480,605p' src/graphics/host_gpu/renderer/cache/textureCache.cpp rg -n 'bytes_per_block|D16UnormS8Uint|D24UnormS8Uint|CopyImage\(' src/graphics/host_gpu/renderer/cache/textureCache.cpp src/graphics/host_gpu/renderer/image/imageInfo.h src/graphics/host_gpu/renderer/cache | head -115 ``` Repository: KytyPS5/KytyPS5 Length of output: 12890 --- Script executed: ```bash set -o pipefail printf '%s\n' '--- PR diff ---' git diff --unified=35 fd6b28c4b261a59b35f8f6a225a8fbe87b41f993 efa6b0e610e94b0502280a65255f826a6408226a -- src/graphics/host_gpu/renderer/cache/textureCache.cpp printf '%s\n' '--- Image copy declarations and definitions ---' rg -n -F --glob '*.{h,cpp}' -e 'CopyImageWithBuffer' -e 'void Image::CopyImage' -e 'CopyImage(const Image' -e 'CopyImage\(' src/graphics/host_gpu/renderer/image src/graphics/host_gpu/renderer/cache || test "$?" -eq 1 sed -n '430,515p' src/graphics/host_gpu/renderer/image/image.cpp rg -n -F --glob '*.{h,cpp}' -e 'CopyImageMip(' -e 'CopyImage\(' src/graphics/host_gpu/renderer/cache src/graphics/host_gpu/renderer | head -180 printf '%s\n' '--- Image aspect and format contracts ---' sed -n '150,305p' src/graphics/host_gpu/renderer/image/imageInfo.h sed -n '1,180p' src/graphics/host_gpu/renderer/image/image.h ``` Repository: KytyPS5/KytyPS5 Length of output: 28941 --- Script executed: ```bash set -o pipefail printf '%s\n' '--- Image::CopyImage complete definition ---' sed -n '320,430p' src/graphics/host_gpu/renderer/image/image.cpp printf '%s\n' '--- Image::CopyImageWithBuffer complete definition ---' sed -n '474,590p' src/graphics/host_gpu/renderer/image/image.cpp printf '%s\n' '--- TextureCache copy callers and enclosing flows ---' sed -n '600,680p' src/graphics/host_gpu/renderer/cache/textureCache.cpp sed -n '860,950p' src/graphics/host_gpu/renderer/cache/textureCache.cpp rg -n -F --glob '*.{cpp,h}' -e 'stencil_ids' -e 'stencil_subresources' -e 'depth_id' src/graphics/host_gpu/renderer | head -160 printf '%s\n' '--- Full aspect helper and copy-related tests ---' rg -n -F --glob '*.{cpp,h}' -e 'FullAspectMask' -e 'CopyD16' -e 'CopyImageWithBuffer' -e 'CopyImage(' tests src/graphics/host_gpu/renderer | head -220 ``` Repository: KytyPS5/KytyPS5 Length of output: 30221 --- Script executed: ```bash set -o pipefail printf '%s\n' '--- FullAspectMask and stencil transfer helpers ---' sed -n '95,125p' src/graphics/host_gpu/renderer/image/image.cpp sed -n '940,1010p' src/graphics/host_gpu/renderer/cache/textureCache.cpp sed -n '1825,1875p' src/graphics/host_gpu/renderer/cache/textureCache.cpp printf '%s\n' '--- ExpandImage and replacement callers ---' sed -n '680,725p' src/graphics/host_gpu/renderer/cache/textureCache.cpp sed -n '885,935p' src/graphics/host_gpu/renderer/cache/textureCache.cpp rg -n -F --glob '*.{cpp,h}' -e 'ExpandImage(' -e 'AssociateStencil(' src/graphics/host_gpu/renderer/cache src/graphics/host_gpu/renderer | head -120 printf '%s\n' '--- Stencil association implementation and registration flow ---' sed -n '1195,1270p' src/graphics/host_gpu/renderer/cache/textureCache.cpp sed -n '1265,1310p' src/graphics/host_gpu/renderer/cache/textureCache.cpp sed -n '1420,1510p' src/graphics/host_gpu/renderer/cache/textureCache.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 21603 --- Script executed: ```bash set -o pipefail printf '%s\n' '--- Image insertion, initialization, refresh, and download ---' rg -n -F --glob 'textureCache.cpp' -e 'ImageId TextureCache::InsertImage' -e 'void TextureCache::InitializeImage' -e 'void TextureCache::RefreshImage' -e 'void TextureCache::DownloadImage' -e 'void TextureCache::FreeImage' src/graphics/host_gpu/renderer/cache sed -n '210,330p' src/graphics/host_gpu/renderer/cache/textureCache.cpp sed -n '1780,1865p' src/graphics/host_gpu/renderer/cache/textureCache.cpp sed -n '1865,1945p' src/graphics/host_gpu/renderer/cache/textureCache.cpp printf '%s\n' '--- FindImage post-overlap handling ---' sed -n '1310,1425p' src/graphics/host_gpu/renderer/cache/textureCache.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 14425 --- Script executed: ```bash set -o pipefail sed -n '190,230p' src/graphics/host_gpu/renderer/cache/textureCache.cpp sed -n '1000,1065p' src/graphics/host_gpu/renderer/cache/textureCache.cpp sed -n '1168,1210p' src/graphics/host_gpu/renderer/cache/textureCache.cpp sed -n '1745,1818p' src/graphics/host_gpu/renderer/cache/textureCache.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 9073 --- Script executed: ```bash set -o pipefail rg -n -F --glob 'image.cpp' -e 'Image::Image' -e 'm_buffer_modified' -e 'm_cpu_dirty' src/graphics/host_gpu/renderer/image sed -n '215,285p' src/graphics/host_gpu/renderer/image/image.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 3978 --- </dd> </dl> </details> **Copy the stencil aspect during D16 conversion.** `ExpandImage` initializes the replacement, copies the source, and then frees the source. For stenciled D16-to-D24/D32 images with both guest `bytes_per_block` values equal to two, `CopyImage` reaches `CopyD16`, which transfers only `eDepth`. It does not transfer `eStencil`. `RefreshImage` does not download GPU-modified contents. Therefore, a source with current GPU stencil data can leave the replacement with stale or undefined stencil values. Transfer the stencil aspect explicitly at this conversion boundary, using the stencil plane's one-byte layout and existing stencil association ranges. <!-- fingerprinting:phantom:medusa:wombat --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:a6ca38d3b1a7b842f9f72cb6 --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-27 09:06 UTC · original · reviewed

Actionable comments posted: 1


Review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 11491620a9a49d98af143fbccd99ac95158ab273 and efa6b0e610.

Files selected for processing: 2
  • src/graphics/host_gpu/renderer/cache/textureCache.cpp
  • tests/ShaderRecompilerComputeTests.cpp

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

**@⁠coderabbitai[bot]** on GitHub · 2026-10-27 09:06 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1873#pullrequestreview-5664579770) · **reviewed** <!-- coderabbit-ai-generated:v1 --> **Actionable comments posted: 1** --- <details> <summary><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/info.svg" width="16" height="16" align="absmiddle" alt=""></picture> Review info</summary> <dl> <dd> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog.svg" width="16" height="16" align="absmiddle" alt=""></picture> Run configuration</summary> <dl> <dd> - **Source mode**: Auto - **Repository**: [KytyPS5/KytyPS5](<https://github.com/KytyPS5/KytyPS5>) - **Branch**: [main](<https://github.com/KytyPS5/KytyPS5/tree/main>) - **File**: [.coderabbit.yaml](<https://github.com/KytyPS5/KytyPS5/blob/358333125da6548e680ca864d95254c114179226/.coderabbit.yaml>) - **Commit**: [3583331](<https://github.com/KytyPS5/KytyPS5/commit/358333125da6548e680ca864d95254c114179226>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `c2c9b98f-3a76-452e-9337-0ce20a170bde` </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 11491620a9a49d98af143fbccd99ac95158ab273 and efa6b0e610e94b0502280a65255f826a6408226a. </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: 2</summary> <dl> <dd> * `src/graphics/host_gpu/renderer/cache/textureCache.cpp` * `tests/ShaderRecompilerComputeTests.cpp` </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 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=febdcad8-ec77-4230-8530-3a829b291938 attempt=22291031-ac7f-4228-ba4e-45a1f750507a batch=1/1 -->
This discussion has been locked. Commenting is limited to contributors.
No description provided.