graphics: bind stencil-only depth targets with HTile #2387

Closed
github-bot wants to merge 8 commits from github-bot/gh-2387 into main AGit
Owner

@⁠Nawid3333 on GitHub · 2026-11-18 13:49 UTC · original
Nawid3333:fix/stencil-only-depth-target → main · +426 −89 · 10 files · 8 commits · closed without merging

Problem

Baldur's Gate 3 (PPSA18463, #2334) stops before its main menu. @⁠Crispy81's log on official 1e87171 ends with unsupported render state at depthRenderTarget.cpp:39; a diagnostic fork build printed the register values:

Depth target fatal: unsupported depth register state [site 160] max_mip=0 shading_rate=0 htile=1 address=0x0 write_buffer=0 | z_format=0 stencil_format=1 samples=0 z_read=0x0 z_write=0x0 s_read=0x2db440000 s_write=0x2db440000 htile_addr=0x2dbe08000 size_valid=1 size=2560x1440 slices=0..0 mip=0 expclear=0/0 | z_enable=1 z_write=0 stencil_enable=1 bounds=0 zfunc=7 | depth_clear=0 stencil_clear=1 ...

The Z format is invalid (z_format=0): the target has no Z surface, only an 8-bit stencil buffer with HTile. The game still enables the depth test (zfunc=7, always) and clears the stencil. MakeDepthTargetDesc required a Z address, so the target was rejected.

Change

  • A target with an invalid Z format and an S8 stencil format is bound as a native S8_UINT attachment over the stencil range (desc.info.data = the stencil range, one byte per element, guest format k8UInt). Its HTile metadata and compressed-stencil clears are kept.
  • TileGetDepthSize accepts such a surface: it sizes the stencil and HTile planes and returns an empty depth size.
  • Without a Z surface, the depth test, depth bounds and depth clear are off (depth_active, depth_test_enable, depth_bounds_test_enable and depth_clear_enable need a Z format), and the load clear is masked to the attachment's aspects.
  • ResolveHostDepthAttachmentFormat picks S8_UINT for such a target when the host supports it as a depth/stencil attachment; otherwise it stops with the existing "no host depth/stencil format" fatal.
  • S8_UINT images get depth/stencil attachment usage when the format supports it, copies of them use the stencil aspect (PrimaryAspect), and their sampled layout is DepthStencilReadOnlyOptimal.
  • The unbound-attachment special case is gone: with no Z and no stencil format, neither depth nor stencil is active, so the target stays unbound as before.

#1879 binds an S8 target without HTile and only with the depth test off (TopSpin 2K25). This target has HTile and an enabled depth test, so it does not cover it.

Tests

shader_recompiler_compute_tests:

  • --image-rebind-only, check "stencil-only HTile target": a stencil-only target with HTile, an enabled depth test and a stencil clear binds as an S8_UINT attachment.
  • --depth-readback-only, check "2560x1440 S8 with HTile and no Z surface": the stencil and HTile footprint of the game's surface.

RX 9070 XT (Windows 11, clang-cl, with the harness change of #2038): both checks pass. Four other --image-rebind-only checks (depth feedback loops) fail on this GPU, as they do on main with main's own tests. With main's sources and these tests, the footprint check fails and --image-rebind-only stops at the game's Depth target fatal: unsupported depth register state.

Fork build of this commit (run 44198591074): Windows, Linux and macOS build.

In a game

  • @⁠Crispy81 ran Baldur's Gate 3 with a fork build of this commit on 2638b1b (191a9a7): the game reaches its main menu and character creation, then stops at a compute shader with more than 64 images (#2292).
  • With #2292 on top (fork build daad66f, run 44248636917), the game goes in game.

Written with Claude Code (AI): Claude Code found the cause in the reporter's logs and wrote the change, the tests and the tester builds; Claude Opus reviewed the change; GLM fact-checked this text.

**@⁠Nawid3333** on GitHub · 2026-11-18 13:49 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2387) `Nawid3333:fix/stencil-only-depth-target` → `main` · +426 −89 · 10 files · 8 commits · closed without merging ## Problem Baldur's Gate 3 (PPSA18463, #2334) stops before its main menu. @⁠Crispy81's log on official 1e87171 ends with `unsupported render state` at `depthRenderTarget.cpp:39`; a diagnostic fork build printed the register values: ``` Depth target fatal: unsupported depth register state [site 160] max_mip=0 shading_rate=0 htile=1 address=0x0 write_buffer=0 | z_format=0 stencil_format=1 samples=0 z_read=0x0 z_write=0x0 s_read=0x2db440000 s_write=0x2db440000 htile_addr=0x2dbe08000 size_valid=1 size=2560x1440 slices=0..0 mip=0 expclear=0/0 | z_enable=1 z_write=0 stencil_enable=1 bounds=0 zfunc=7 | depth_clear=0 stencil_clear=1 ... ``` The Z format is invalid (`z_format=0`): the target has no Z surface, only an 8-bit stencil buffer with HTile. The game still enables the depth test (`zfunc=7`, always) and clears the stencil. `MakeDepthTargetDesc` required a Z address, so the target was rejected. ## Change - A target with an invalid Z format and an S8 stencil format is bound as a native `S8_UINT` attachment over the stencil range (`desc.info.data` = the stencil range, one byte per element, guest format `k8UInt`). Its HTile metadata and compressed-stencil clears are kept. - `TileGetDepthSize` accepts such a surface: it sizes the stencil and HTile planes and returns an empty depth size. - Without a Z surface, the depth test, depth bounds and depth clear are off (`depth_active`, `depth_test_enable`, `depth_bounds_test_enable` and `depth_clear_enable` need a Z format), and the load clear is masked to the attachment's aspects. - `ResolveHostDepthAttachmentFormat` picks `S8_UINT` for such a target when the host supports it as a depth/stencil attachment; otherwise it stops with the existing "no host depth/stencil format" fatal. - `S8_UINT` images get depth/stencil attachment usage when the format supports it, copies of them use the stencil aspect (`PrimaryAspect`), and their sampled layout is `DepthStencilReadOnlyOptimal`. - The unbound-attachment special case is gone: with no Z and no stencil format, neither depth nor stencil is active, so the target stays unbound as before. #1879 binds an S8 target without HTile and only with the depth test off (TopSpin 2K25). This target has HTile and an enabled depth test, so it does not cover it. ## Tests `shader_recompiler_compute_tests`: - `--image-rebind-only`, check "stencil-only HTile target": a stencil-only target with HTile, an enabled depth test and a stencil clear binds as an `S8_UINT` attachment. - `--depth-readback-only`, check "2560x1440 S8 with HTile and no Z surface": the stencil and HTile footprint of the game's surface. RX 9070 XT (Windows 11, clang-cl, with the harness change of #2038): both checks pass. Four other `--image-rebind-only` checks (depth feedback loops) fail on this GPU, as they do on main with main's own tests. With main's sources and these tests, the footprint check fails and `--image-rebind-only` stops at the game's `Depth target fatal: unsupported depth register state`. Fork build of this commit ([run 44198591074](https://github.com/Nawid3333/KytyPS5/actions/runs/44198591074)): Windows, Linux and macOS build. ## In a game - @⁠Crispy81 ran Baldur's Gate 3 with a fork build of this commit on 2638b1b (191a9a7): the game reaches its main menu and character creation, then stops at a compute shader with more than 64 images (#2292). - With #2292 on top (fork build daad66f, [run 44248636917](https://github.com/Nawid3333/KytyPS5/actions/runs/44248636917)), the game [goes in game](https://git.gtahub.st/github/KytyPS5--KytyPS5/issues/2334). Written with Claude Code (AI): Claude Code found the cause in the reporter's logs and wrote the change, the tests and the tester builds; Claude Opus reviewed the change; GLM fact-checked this text.
A depth target whose Z format is invalid has no Z surface: depth tests, depth
writes, depth bounds and depth clears cannot act on it, and its stencil plane is
the target's only memory. Bind such a target as a native S8 attachment over the
stencil range, keep its HTile metadata and compressed-stencil clears, and size it
with TileGetDepthSize, which now accepts a stencil-only surface.

Baldur's Gate 3 (#2334) binds a stencil-only target with HTile, an enabled depth
test with ZFUNC ALWAYS and a stencil clear; it stopped with
'Depth target fatal: unsupported depth register state'.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A stencil-only target consumed the whole HTile clear state of its
slice, so a later depth target over the same HTile lost its pending
depth clear. The clear state is now kept per aspect: a stencil-only
bind takes only the stencil clear, every other bind takes both as
before.

A stencil-only draw also stopped on distinct Z read and write
addresses that it does not use; that check now needs a Z surface. A
multisampled stencil-only target passed format selection but failed
cache validation; it now stops with its own message. The stencil-only
test cases run only where the host has an S8 depth/stencil attachment.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A depth attachment takes the pending HTile clear aspects of the planes
it has: a depth-only bind leaves a pending stencil clear for a later
stencil bind over the same HTile, as a stencil-only bind leaves the
depth clear. A stencil plane without HTile stencil compression still
drops the stencil clear without applying it. IsMetaCleared keeps
main's meaning (pending depth clear).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Deleting the last image to bind an HTile range erased the range's clear
state while another image over the same HTile (a stencil-only image and
the depth image beside it) still used it: a pending depth clear was
lost, and the survivor's next bind re-created the state with both
clears set. An image that moved to another HTile, or a stencil-only
image adopted as a depth target's stencil plane, kept owning the old
range, so a new image over it skipped its initial clear. All three
paths now release the range through ReleaseHtileOwner, which passes it
to a live image with the same HTile range and erases it only when none
is left.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Deleting the image that last bound an HTile range while another image
over the same HTile lives keeps the pending clear and makes the
survivor the owner: deleting the survivor then releases the range, so a
new image over it gets its initial clear.

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

@⁠coderabbitai[bot] on GitHub · 2026-11-18 14:00 UTC · original · edited 2026-11-23 23:44 UTC

Explain Change →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • Resume reviews
  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The changes add support for stencil-only S8 surfaces across image format checks, image aspects and operations, depth-target setup, and guest footprint calculation. Render-target acquisition consumes pending HTile clear aspects according to the attachment format. Image refresh skips S8 images with compressed stencil metadata. Tests cover stencil-only HTile targets and depth, stencil, and HTile footprints.

Suggested reviewers: nmzik

Change: Bug fix

Merge Risk: Moderate · previous review 2f964

Stencil-only depth targets are now supported with several earlier issues fixed. Switching a target between combined depth+stencil and stencil-only over the same stencil memory can still lose stencil contents or hit an unsupported lookup path. The author defers this to a follow-up, so it should be accepted explicitly before merge.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: binding stencil-only depth targets (no Z surface, S8 stencil) as S8_UINT attachments with HTile metadata. The raw summary shows changes to tile.cpp, textureCache, dept…
Description check Passed The description explains the problem (Baldur's Gate 3 stopping at an unsupported depth register state), the fix (binding S8-only depth targets as S8_UINT attachments, sizing stencil and HTile planes, …
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: binding stencil-only depth targets (no Z surface, S8 stencil) as S8_UINT attachments with HTile metadata. The raw summary shows changes to tile.cpp, textureCache, depthRenderTarget, image, imageInfo, imageView, renderDraw and tests that match this focus. The title is specific and accurate.

Full details: Description check

Explanation

The description explains the problem (Baldur's Gate 3 stopping at an unsupported depth register state), the fix (binding S8-only depth targets as S8_UINT attachments, sizing stencil and HTile planes, disabling depth test and clears without a Z format, and S8 image usage and copy aspect changes), and the tests run. It matches the changeset closely.

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 7b02cd1ac38251a2534701600375e128422ccf0d and 2f964edb09.

Files selected for processing: 1

  • tests/ShaderRecompilerComputeTests.cpp

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

**@⁠coderabbitai[bot]** on GitHub · 2026-11-18 14:00 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2387#issuecomment-6980765681) · edited 2026-11-23 23:44 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/2387?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 --> <!-- This is an auto-generated comment: review paused by coderabbit.ai --> > [!NOTE] > ## Reviews paused > > It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the `reviews.auto_review.auto_pause_after_reviewed_commits` setting. > > - Last reviewed commit: 2f964edb0904453320c2d4d12c3c2703fb91b3b4 > - Latest commit, not reviewed: 044e0eb002ae7016c98c7fd94d9b61a4be22b1f8 > > Use the following commands to manage reviews: > - `@coderabbitai resume` to resume automatic reviews. > - `@coderabbitai review` to trigger a single review. > > Use the checkboxes below for quick actions: > - [ ] <!-- {"checkboxId":"7f6cc2e2-2e4e-497a-8c31-c9e4573e93d1"} --> Resume reviews > - [ ] <!-- {"checkboxId":"e9bb8d72-00e8-4f67-9cb2-caf3b22574fe"} --> Trigger review <!-- end of auto-generated comment: review paused by coderabbit.ai --> <!-- 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> The changes add support for stencil-only S8 surfaces across image format checks, image aspects and operations, depth-target setup, and guest footprint calculation. Render-target acquisition consumes pending HTile clear aspects according to the attachment format. Image refresh skips S8 images with compressed stencil metadata. Tests cover stencil-only HTile targets and depth, stencil, and HTile footprints. **Suggested reviewers:** `nmzik` </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> <!-- change_assessment_commit:"2f964edb0904453320c2d4d12c3c2703fb91b3b4" --> <!-- 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-normal-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Moderate</strong> · previous review <code>2f964</code></summary> <dl> <dd> <br> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **🟡 Moderate** · up to `2f964` --> <!-- final_review_risk_coverage:{"sourceCommitId":"2f964edb0904453320c2d4d12c3c2703fb91b3b4","coveredCommitId":"2f964edb0904453320c2d4d12c3c2703fb91b3b4","kind":"reviewed"} --> Stencil-only depth targets are now supported with several earlier issues fixed. Switching a target between combined depth+stencil and stencil-only over the same stencil memory can still lose stencil contents or hit an unsupported lookup path. The author defers this to a follow-up, so it should be accepted explicitly before merge. <!-- 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: binding stencil-only depth targets (no Z surface, S8 stencil) as S8_UINT attachments with HTile metadata. The raw summary shows changes to tile.cpp, textureCache, dept… | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description explains the problem (Baldur's Gate 3 stopping at an unsupported depth register state), the fix (binding S8-only depth targets as S8_UINT attachments, sizing stencil and HTile planes, … | | 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: binding stencil-only depth targets (no Z surface, S8 stencil) as S8_UINT attachments with HTile metadata. The raw summary shows changes to tile.cpp, textureCache, depthRenderTarget, image, imageInfo, imageView, renderDraw and tests that match this focus. The title is specific and accurate. </dd> </dl> </details> <details> <summary><strong>Full details: Description check</strong></summary> <dl> <dd> <br> **Explanation** The description explains the problem (Baldur's Gate 3 stopping at an unsupported depth register state), the fix (binding S8-only depth targets as S8_UINT attachments, sizing stencil and HTile planes, disabling depth test and clears without a Z format, and S8 image usage and copy aspect changes), and the tests run. It matches the changeset closely. </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=2387)! 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/a90be8dd7304640cf4176a975871d51443710292/.coderabbit.yaml>) - **Commit**: [a90be8d](<https://github.com/KytyPS5/KytyPS5/commit/a90be8dd7304640cf4176a975871d51443710292>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `3f856956-e371-4b91-9848-9f964c659595` </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 7b02cd1ac38251a2534701600375e128422ccf0d and 2f964edb0904453320c2d4d12c3c2703fb91b3b4. </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> * `tests/ShaderRecompilerComputeTests.cpp` </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. </dd> </dl> </details> </h6> <!-- recent_review_end -->
@ -123,2 +121,2 @@
return supports(policy.depth_attachment_format) ? policy.depth_attachment_format
: vk::Format::eUndefined;
if (policy == nullptr) {
return supports(vk::Format::eS8Uint) ? vk::Format::eS8Uint : vk::Format::eUndefined;
Author
Owner

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

Major · Stability & Availability · Heavy lift

Stencil-only targets must not reach the fatal path on devices without a usable S8 attachment.

A stencil-only target calls ResolveHostDepthAttachmentFormat with a null policy. Line 122 queries VK_FORMAT_S8_UINT with DepthTargetImageUsage(). Vulkan does not require native S8 support for optimal-tiling depth/stencil use, so this query can fail on a supported GPU. The caller at lines 194-198 then passes eUndefined to DepthFatal. A stencil-only target on such a GPU therefore stops the depth target path.

Define the required behavior for this case. A stencil-only target must not reach the fatal path only because the S8 query fails. Choose the fallback or unbound behavior for this case explicitly, and keep the Z-plus-stencil paths unchanged.

**@⁠coderabbitai[bot]** on GitHub · 2026-11-18 14:00 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2387#discussion_r4615150623) <!-- 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** · **Stability & Availability** · **Heavy lift** **Stencil-only targets must not reach the fatal path on devices without a usable S8 attachment.** A stencil-only target calls `ResolveHostDepthAttachmentFormat` with a null policy. Line 122 queries `VK_FORMAT_S8_UINT` with `DepthTargetImageUsage()`. Vulkan does not require native S8 support for optimal-tiling depth/stencil use, so this query can fail on a supported GPU. The caller at lines 194-198 then passes `eUndefined` to `DepthFatal`. A stencil-only target on such a GPU therefore stops the depth target path. Define the required behavior for this case. A stencil-only target must not reach the fatal path only because the S8 query fails. Choose the fallback or unbound behavior for this case explicitly, and keep the Z-plus-stencil paths unchanged. <!-- fingerprinting:phantom:poseidon:wombat62 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:027bf0593334bf394bcf8a85 --> <!-- This is an auto-generated comment by CodeRabbit -->
@ -223,3 +232,1 @@
desc.info.data = {depth_address, depth_backing_size};
desc.info.stencil =
has_stencil ? GuestRange {stencil_address, stencil_backing_size} : GuestRange {};
desc.info.data = has_depth ? GuestRange {depth_address, depth_backing_size} : stencil_range;
Author
Owner

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

Major · Data Integrity & Integration · Heavy lift

Resolve stencil-only targets to native attachments, not association records.

Render to a 64×64 single-sample Z32+S8 target, then disable Z and keep the same stencil allocation. The new descriptor uses that allocation as info.data. Its backing key matches the existing eS8Uint association, so FindImage can return the association's ID. FindDepthTarget rejects that ID because depth_id is set. (raw.githubusercontent.com)

For a stencil-only target lookup, distinguish native attachments from association records. If the current contents belong to a combined attachment, transfer them to native S8 before the first load. Keep the association available for lookups that need the combined attachment's stencil plane.

**@⁠coderabbitai[bot]** on GitHub · 2026-11-18 14:00 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2387#discussion_r4615150636) <!-- 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** **Resolve stencil-only targets to native attachments, not association records.** Render to a 64×64 single-sample Z32+S8 target, then disable Z and keep the same stencil allocation. The new descriptor uses that allocation as `info.data`. Its backing key matches the existing `eS8Uint` association, so `FindImage` can return the association's ID. `FindDepthTarget` rejects that ID because `depth_id` is set. ([raw.githubusercontent.com](https://raw.githubusercontent.com/KytyPS5/KytyPS5/191a9a76a3103348f12340e6059cd829cb6180cc/src/graphics/host_gpu/renderer/cache/textureCache.cpp)) For a stencil-only target lookup, distinguish native attachments from association records. If the current contents belong to a combined attachment, transfer them to native S8 before the first load. Keep the association available for lookups that need the combined attachment's stencil plane. <!-- fingerprinting:phantom:poseidon:wombat62 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:3b73486e10c234ed0d29d7fe --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-18 14:00 UTC · original
On src/graphics/host_gpu/renderer/depthRenderTarget.cpp line 285 (outdated):

@@ -261,42 +266,20 @@ void RenderExecutor::ResolveRenderDepthTarget(CommandBuffer& buffer, RenderDepth
 	const auto& dc          = hw.GetDepthControl();
 	const auto& sc          = hw.GetStencilControl();
 	const auto& sm          = hw.GetStencilMask();
+	const bool  has_depth   = z.z_info.format != Prospero::DepthFormat::kInvalid;
 	const bool  has_stencil = z.stencil_info.format != Prospero::StencilFormat::kInvalid;
 	// With HTile, DEPTH_COMPRESS_DISABLE expands touched tiles even with depth/stencil tests off.
 	// PPSA32236 fast-clears HTile each frame, runs this pass, then samples the depth as raw memory.
 	// Unbound, the clear never lands: NaN depth makes one compute pass ~95 ms (60 -> 10 fps).
-	const bool depth_active = dc.z_enable || dc.depth_bounds_enable || rc.depth_clear_enable ||
-	                          rc.copy_depth_to_color ||
-	                          (rc.depth_compress_disable && z.z_info.htile_acceleration);
+	const bool depth_active =
+	    has_depth &&
+	    (dc.z_enable || dc.depth_bounds_enable || rc.depth_clear_enable || rc.copy_depth_to_color ||
+	     (rc.depth_compress_disable && z.z_info.htile_acceleration));
 	const bool stencil_active =
 	    has_stencil && (dc.stencil_enable || rc.stencil_clear_enable || rc.copy_stencil_to_color);
 	if (!depth_active && !stencil_active) {
 		return;
 	}
-	const bool attachment_unbound =
-	    z.z_info.format == Prospero::DepthFormat::kInvalid &&
-	    z.stencil_info.format == Prospero::StencilFormat::kInvalid && z.z_info.num_samples == 0 &&
-	    z.z_info.texture_compatibility == Prospero::TextureCompatiblePlaneCompression::kDisable &&
-	    !z.z_info.expclear_enabled && !z.z_info.partially_resident && z.z_info.max_mip_level == 0 &&
-	    z.stencil_info.texture_compatibility == Prospero::TextureCompatibleStencil::kDisable &&
-	    !z.stencil_info.expclear_enabled && !z.stencil_info.partially_resident &&
-	    z.depth_view.slice_start == 0 && z.depth_view.slice_max == 0 &&
-	    z.depth_view.current_mip_level == 0 && !z.depth_view.depth_write_disable &&
-	    !z.depth_view.stencil_write_disable && z.z_read_base_addr == 0 && z.z_write_base_addr == 0 &&
-	    z.stencil_read_base_addr == 0 && z.stencil_write_base_addr == 0 &&
-	    z.htile_data_base_addr == 0 &&
-	    // DB_DEPTH_SIZE_XY is independent state and may remain programmed after the attachment
-	    // formats and addresses are unbound. A zero encoding is the valid 1x1 value, so its
-	    // presence alone must not manufacture a depth attachment.
-	    !z.z_info.htile_acceleration && z.shading_rate_encoding == 0 && z.size.x_max == 0 &&
-	    z.size.y_max == 0;
-	if (attachment_unbound) {
-		static std::atomic_bool logged = false;
-		if (!logged.exchange(true, std::memory_order_relaxed)) {
-			LOGF("DepthTarget: ignoring enabled depth/stencil state without a bound attachment\n");
-		}
-		return;
-	}
 	if (rc.copy_stencil_to_color ||
 	    dc.zfunc > static_cast<uint8_t>(vk::CompareOp::eAlways) ||
 	    (!z.depth_view.depth_write_disable && z.z_write_base_addr != z.z_read_base_addr) ||

Major · Functional Correctness · Quick win

Ignore unused Z addresses on stencil-only draws.

If the guest leaves distinct Z read and write addresses after a depth copy, then disables Z and enables stencil testing, the draw reaches this check through stencil_active. With depth_write_disable unset, the check terminates the draw even though MakeDepthTargetDesc does not use either Z address. Gate this comparison on has_depth. Keep the existing check for draws that bind a Z plane.

**@⁠coderabbitai[bot]** on GitHub · 2026-11-18 14:00 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2387#discussion_r4615150649) On `src/graphics/host_gpu/renderer/depthRenderTarget.cpp` line 285 (outdated): ```diff @@ -261,42 +266,20 @@ void RenderExecutor::ResolveRenderDepthTarget(CommandBuffer& buffer, RenderDepth const auto& dc = hw.GetDepthControl(); const auto& sc = hw.GetStencilControl(); const auto& sm = hw.GetStencilMask(); + const bool has_depth = z.z_info.format != Prospero::DepthFormat::kInvalid; const bool has_stencil = z.stencil_info.format != Prospero::StencilFormat::kInvalid; // With HTile, DEPTH_COMPRESS_DISABLE expands touched tiles even with depth/stencil tests off. // PPSA32236 fast-clears HTile each frame, runs this pass, then samples the depth as raw memory. // Unbound, the clear never lands: NaN depth makes one compute pass ~95 ms (60 -> 10 fps). - const bool depth_active = dc.z_enable || dc.depth_bounds_enable || rc.depth_clear_enable || - rc.copy_depth_to_color || - (rc.depth_compress_disable && z.z_info.htile_acceleration); + const bool depth_active = + has_depth && + (dc.z_enable || dc.depth_bounds_enable || rc.depth_clear_enable || rc.copy_depth_to_color || + (rc.depth_compress_disable && z.z_info.htile_acceleration)); const bool stencil_active = has_stencil && (dc.stencil_enable || rc.stencil_clear_enable || rc.copy_stencil_to_color); if (!depth_active && !stencil_active) { return; } - const bool attachment_unbound = - z.z_info.format == Prospero::DepthFormat::kInvalid && - z.stencil_info.format == Prospero::StencilFormat::kInvalid && z.z_info.num_samples == 0 && - z.z_info.texture_compatibility == Prospero::TextureCompatiblePlaneCompression::kDisable && - !z.z_info.expclear_enabled && !z.z_info.partially_resident && z.z_info.max_mip_level == 0 && - z.stencil_info.texture_compatibility == Prospero::TextureCompatibleStencil::kDisable && - !z.stencil_info.expclear_enabled && !z.stencil_info.partially_resident && - z.depth_view.slice_start == 0 && z.depth_view.slice_max == 0 && - z.depth_view.current_mip_level == 0 && !z.depth_view.depth_write_disable && - !z.depth_view.stencil_write_disable && z.z_read_base_addr == 0 && z.z_write_base_addr == 0 && - z.stencil_read_base_addr == 0 && z.stencil_write_base_addr == 0 && - z.htile_data_base_addr == 0 && - // DB_DEPTH_SIZE_XY is independent state and may remain programmed after the attachment - // formats and addresses are unbound. A zero encoding is the valid 1x1 value, so its - // presence alone must not manufacture a depth attachment. - !z.z_info.htile_acceleration && z.shading_rate_encoding == 0 && z.size.x_max == 0 && - z.size.y_max == 0; - if (attachment_unbound) { - static std::atomic_bool logged = false; - if (!logged.exchange(true, std::memory_order_relaxed)) { - LOGF("DepthTarget: ignoring enabled depth/stencil state without a bound attachment\n"); - } - return; - } if (rc.copy_stencil_to_color || dc.zfunc > static_cast<uint8_t>(vk::CompareOp::eAlways) || (!z.depth_view.depth_write_disable && z.z_write_base_addr != z.z_read_base_addr) || ``` <!-- 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** · **Functional Correctness** · **Quick win** **Ignore unused Z addresses on stencil-only draws.** If the guest leaves distinct Z read and write addresses after a depth copy, then disables Z and enables stencil testing, the draw reaches this check through `stencil_active`. With `depth_write_disable` unset, the check terminates the draw even though `MakeDepthTargetDesc` does not use either Z address. Gate this comparison on `has_depth`. Keep the existing check for draws that bind a Z plane. <!-- fingerprinting:phantom:poseidon:wombat62 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:9b050700d0da7ade4f58ca46 --> <!-- This is an auto-generated comment by CodeRabbit -->
@ -241,1 +241,4 @@
const auto* policy = FindGuestDepthFormatPolicy(info.guest_format);
if (info.pixel_format == vk::Format::eS8Uint) {
return info.guest_format == Prospero::BufferFormat::k8UInt && info.bytes_per_block == 1 &&
!info.HasStencil() && info.samples == 1 && info.resources.levels == 1 &&
Author
Owner

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

Major · Stability & Availability · Heavy lift

Reconcile the stencil-only S8 sample-count policy between depth setup and cache validation.

MakeDepthTargetDesc sets desc.info.samples from z.z_info.num_samples. ResolveHostDepthAttachmentFormat selects eS8Uint for a null policy when the host supports it at that sample count. On such a host, a stencil-only target with more than one sample reaches FindImage. IsSupportedDepthTargetFormat rejects it because the S8 branch requires info.samples == 1. ValidateImageDesc, which FindImage calls, then exits the process.

Use one sample-count policy for both stages. Either limit stencil-only S8 selection to one sample before the target reaches the cache, or extend IsSupportedDepthTargetFormat to accept multisampled S8. If multisampled S8 is accepted, also handle its initialization. InitializeImage skips the guest upload for images with more than one sample, so such an image does not receive guest contents before its first use.

**@⁠coderabbitai[bot]** on GitHub · 2026-11-18 14:00 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2387#discussion_r4615150665) <!-- 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** · **Stability & Availability** · **Heavy lift** **Reconcile the stencil-only S8 sample-count policy between depth setup and cache validation.** `MakeDepthTargetDesc` sets `desc.info.samples` from `z.z_info.num_samples`. `ResolveHostDepthAttachmentFormat` selects `eS8Uint` for a null policy when the host supports it at that sample count. On such a host, a stencil-only target with more than one sample reaches `FindImage`. `IsSupportedDepthTargetFormat` rejects it because the S8 branch requires `info.samples == 1`. `ValidateImageDesc`, which `FindImage` calls, then exits the process. Use one sample-count policy for both stages. Either limit stencil-only S8 selection to one sample before the target reaches the cache, or extend `IsSupportedDepthTargetFormat` to accept multisampled S8. If multisampled S8 is accepted, also handle its initialization. `InitializeImage` skips the guest upload for images with more than one sample, so such an image does not receive guest contents before its first use. <!-- fingerprinting:phantom:medusa:beignet55 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:8fafb94a57a045dadfb33c3d --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-18 14:00 UTC · original · edited 2026-11-18 18:42 UTC
On src/graphics/host_gpu/renderer/renderDraw.cpp line 491 (outdated):

@@ -488,6 +488,7 @@ RenderState RenderExecutor::AcquireRenderTargets(CommandBuffer& buffer, RenderCo
 		// Apply pending clears to compressed stencil as well as depth.
 		if (depth.stencil_clear_enable || (meta_clear && metadata.stencil_compressed))
 			depth.load_clear_aspects |= vk::ImageAspectFlagBits::eStencil;
+		depth.load_clear_aspects &= ImageViewOps::DepthAspectMask(depth.desc.view_info.format);

Major · Data Integrity & Integration · Heavy lift

A stencil-only pass consumes a pending depth clear without applying it.

At renderDraw.cpp:491, the mask removes the depth aspect for a format without depth. The HTile clear state is still consumed at lines 492-493. TouchMeta(..., false) clears the slice bit in clear_mask. A later depth pass on the same HTile address and slice then reads that bit as false and receives no depth clear. The depth buffer keeps its prior contents, which can change depth test results. This applies when the guest rebinds the same HTile range without first re-clearing it.

The pending depth clear must survive a pass that does not apply it. Consume the HTile clear state only when the depth clear is applied, or keep the slice clear pending for a later depth pass.

✅ Addressed in commit ffd2fe4

**@⁠coderabbitai[bot]** on GitHub · 2026-11-18 14:00 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2387#discussion_r4615150676) · edited 2026-11-18 18:42 UTC On `src/graphics/host_gpu/renderer/renderDraw.cpp` line 491 (outdated): ```diff @@ -488,6 +488,7 @@ RenderState RenderExecutor::AcquireRenderTargets(CommandBuffer& buffer, RenderCo // Apply pending clears to compressed stencil as well as depth. if (depth.stencil_clear_enable || (meta_clear && metadata.stencil_compressed)) depth.load_clear_aspects |= vk::ImageAspectFlagBits::eStencil; + depth.load_clear_aspects &= ImageViewOps::DepthAspectMask(depth.desc.view_info.format); ``` <!-- 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** **A stencil-only pass consumes a pending depth clear without applying it.** At `renderDraw.cpp:491`, the mask removes the depth aspect for a format without depth. The HTile clear state is still consumed at lines 492-493. `TouchMeta(..., false)` clears the slice bit in `clear_mask`. A later depth pass on the same HTile address and slice then reads that bit as false and receives no depth clear. The depth buffer keeps its prior contents, which can change depth test results. This applies when the guest rebinds the same HTile range without first re-clearing it. The pending depth clear must survive a pass that does not apply it. Consume the HTile clear state only when the depth clear is applied, or keep the slice clear pending for a later depth pass. <!-- fingerprinting:phantom:poseidon:wombat62 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:6d55516ae1984ff56d6c8f0d --> <!-- This is an auto-generated comment by CodeRabbit --> ✅ Addressed in commit ffd2fe4
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-18 14:00 UTC · original
On tests/ShaderRecompilerComputeTests.cpp line 17995 (outdated):

@@ -17966,6 +17966,55 @@ class VulkanHarness {
           "inactive stencil state changed a depth-only HTile attachment");
       RenderExecutorTestAccess::ResetBindings(executor);
 
+      constexpr uint64_t stencil_only_address = base + 0x2c0000;
+      constexpr uint64_t stencil_only_htile_address = base + 0x2d0000;
+      HW::DepthRenderTarget stencil_only_target{};
+      stencil_only_target.z_info.htile_acceleration = true;
+      stencil_only_target.stencil_info.format = Prospero::StencilFormat::k8UInt;
+      stencil_only_target.stencil_info.texture_compatibility =
+          Prospero::TextureCompatibleStencil::kEnable;
+      stencil_only_target.stencil_info.htile_stencil_disabled = false;
+      stencil_only_target.stencil_read_base_addr = stencil_only_address;
+      stencil_only_target.stencil_write_base_addr = stencil_only_address;
+      stencil_only_target.htile_data_base_addr = stencil_only_htile_address;
+      stencil_only_target.size = {63, 63, true};
+      registers.SetDepthRenderTarget(stencil_only_target);
+      HW::DepthControl stencil_only_control{};
+      stencil_only_control.z_enable = true;
+      stencil_only_control.zfunc = static_cast<uint8_t>(vk::CompareOp::eAlways);
+      stencil_only_control.stencil_enable = true;
+      stencil_only_control.stencilfunc = static_cast<uint8_t>(vk::CompareOp::eAlways);
+      registers.SetDepthControl(stencil_only_control);
+      HW::RenderControl stencil_only_render_control{};
+      stencil_only_render_control.stencil_clear_enable = true;
+      registers.SetRenderControl(stencil_only_render_control);
+      registers.SetStencilControl({});
+      registers.SetStencilMask({});
+      RenderDepthInfo stencil_only{};
+      RenderExecutorTestAccess::ResolveRenderDepthTarget(
+          executor, scheduler.Current(), stencil_only);

Minor · Stability & Availability · Quick win

Guard the stencil-only S8 case against unsupported eS8Uint attachments.

The stencil-only path depends on ResolveHostDepthAttachmentFormat finding VK_FORMAT_S8_UINT for optimal tiling, with the depth-target usage and the target's sample count. Vulkan does not require VK_FORMAT_S8_UINT as a depth/stencil attachment. The VulkanHarness device filter does not check this format either. On a device that passes the filter but rejects the query, MakeDepthTargetDesc calls DepthFatal, and DepthFatal exits. The --image-rebind-only run then ends before the later checks.

Query the same format, usage, and sample count in the harness before running the stencil-only case. When the query fails, skip that case and report the skip. Keep the S8 case as a required check on devices that report support.

**@⁠coderabbitai[bot]** on GitHub · 2026-11-18 14:00 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2387#discussion_r4615150695) On `tests/ShaderRecompilerComputeTests.cpp` line 17995 (outdated): ```diff @@ -17966,6 +17966,55 @@ class VulkanHarness { "inactive stencil state changed a depth-only HTile attachment"); RenderExecutorTestAccess::ResetBindings(executor); + constexpr uint64_t stencil_only_address = base + 0x2c0000; + constexpr uint64_t stencil_only_htile_address = base + 0x2d0000; + HW::DepthRenderTarget stencil_only_target{}; + stencil_only_target.z_info.htile_acceleration = true; + stencil_only_target.stencil_info.format = Prospero::StencilFormat::k8UInt; + stencil_only_target.stencil_info.texture_compatibility = + Prospero::TextureCompatibleStencil::kEnable; + stencil_only_target.stencil_info.htile_stencil_disabled = false; + stencil_only_target.stencil_read_base_addr = stencil_only_address; + stencil_only_target.stencil_write_base_addr = stencil_only_address; + stencil_only_target.htile_data_base_addr = stencil_only_htile_address; + stencil_only_target.size = {63, 63, true}; + registers.SetDepthRenderTarget(stencil_only_target); + HW::DepthControl stencil_only_control{}; + stencil_only_control.z_enable = true; + stencil_only_control.zfunc = static_cast<uint8_t>(vk::CompareOp::eAlways); + stencil_only_control.stencil_enable = true; + stencil_only_control.stencilfunc = static_cast<uint8_t>(vk::CompareOp::eAlways); + registers.SetDepthControl(stencil_only_control); + HW::RenderControl stencil_only_render_control{}; + stencil_only_render_control.stencil_clear_enable = true; + registers.SetRenderControl(stencil_only_render_control); + registers.SetStencilControl({}); + registers.SetStencilMask({}); + RenderDepthInfo stencil_only{}; + RenderExecutorTestAccess::ResolveRenderDepthTarget( + executor, scheduler.Current(), stencil_only); ``` <!-- 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** · **Stability & Availability** · **Quick win** **Guard the stencil-only S8 case against unsupported `eS8Uint` attachments.** The stencil-only path depends on `ResolveHostDepthAttachmentFormat` finding `VK_FORMAT_S8_UINT` for optimal tiling, with the depth-target usage and the target's sample count. Vulkan does not require `VK_FORMAT_S8_UINT` as a depth/stencil attachment. The `VulkanHarness` device filter does not check this format either. On a device that passes the filter but rejects the query, `MakeDepthTargetDesc` calls `DepthFatal`, and `DepthFatal` exits. The `--image-rebind-only` run then ends before the later checks. Query the same format, usage, and sample count in the harness before running the stencil-only case. When the query fails, skip that case and report the skip. Keep the S8 case as a required check on devices that report support. <!-- fingerprinting:phantom:poseidon:wombat62 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:785785c134861b9c8f52a462 --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-18 14:00 UTC · original · reviewed

Actionable comments posted: 6

Caution

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

⚠️ Outside diff range comments (1)

Major · Preserve native S8 writes when the stencil range becomes part of a… · textureCache.cpp:1184-1187

src/graphics/host_gpu/renderer/cache/textureCache.cpp:1184-1187
Major · Data Integrity & Integration · Heavy lift

Preserve native S8 writes when the stencil range becomes part of a combined target.

Draw a nonzero stencil value into a native S8 target with HTile disabled. Then bind a Z32+S8 target over the same stencil range without clearing it. AssociateStencil selects the native S8 image by range and extent and sets its depth_id. It does not copy the GPU-written stencil values to the combined backing. The next stencil test reads the combined backing, not the previously written S8 image. (raw.githubusercontent.com)

Distinguish native S8 backing from an association record. Transfer the current stencil contents before switching which backing supplies the range. Keep the lightweight association path for ranges that have no native S8 backing.

Nitpick comments: 2

tests/ShaderRecompilerComputeTests.cpp: 2

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

Test a stencil clear driven only by HTile metadata.

The explicit stencil_clear_enable flag makes stencil_clear true even if acquisition ignores the pending compressed-stencil clear. Keep the explicit-clear case. Add a pass that marks the selected HTile layer clear with the explicit flag off. Verify that acquisition clears stencil only and consumes the pending clear. (raw.githubusercontent.com)


53804-53805: Trivial · Maintainability & Code Quality · Quick win

Check the footprint against fixed byte counts.

Both calls share the stencil and HTile sizing logic. If that logic returns the same wrong size for both formats, the assertion passes. For this single-sample extent, check 0x3c0000 stencil bytes and 0x48000 HTile bytes. Keep the alignment checks and the zero-depth check. (raw.githubusercontent.com)

Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between b3295bebc6 and 191a9a76a3103348f12340e6059cd829cb6180cc.

Files selected for processing: 9

  • src/graphics/guest_gpu/tile.cpp
  • src/graphics/host_gpu/renderer/cache/textureCache.cpp
  • src/graphics/host_gpu/renderer/depthRenderTarget.cpp
  • src/graphics/host_gpu/renderer/image/image.cpp
  • src/graphics/host_gpu/renderer/image/image.h
  • src/graphics/host_gpu/renderer/image/imageInfo.h
  • src/graphics/host_gpu/renderer/image/imageView.cpp
  • src/graphics/host_gpu/renderer/renderDraw.cpp
  • tests/ShaderRecompilerComputeTests.cpp

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

**@⁠coderabbitai[bot]** on GitHub · 2026-11-18 14:00 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2387#pullrequestreview-5958101566) · **reviewed** <!-- coderabbit-ai-generated:v1 --> **Actionable comments posted: 6** > [!CAUTION] > Some comments are outside the diff and can’t be posted inline due to GitHub limitations. > > **⚠️ Outside diff range comments (1)** > > <details> > <summary><strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/major-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Major</strong> · Preserve native S8 writes when the stencil range becomes part of a… · <code>textureCache.cpp:1184-1187</code></summary><blockquote> > <dl> > <dd> > <br> > > `src/graphics/host_gpu/renderer/cache/textureCache.cpp:1184-1187` > **<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** > > **Preserve native S8 writes when the stencil range becomes part of a combined target.** > > Draw a nonzero stencil value into a native S8 target with HTile disabled. Then bind a Z32+S8 target over the same stencil range without clearing it. `AssociateStencil` selects the native S8 image by range and extent and sets its `depth_id`. It does not copy the GPU-written stencil values to the combined backing. The next stencil test reads the combined backing, not the previously written S8 image. ([raw.githubusercontent.com](https://raw.githubusercontent.com/KytyPS5/KytyPS5/191a9a76a3103348f12340e6059cd829cb6180cc/src/graphics/host_gpu/renderer/cache/textureCache.cpp)) > > Distinguish native S8 backing from an association record. Transfer the current stencil contents before switching which backing supplies the range. Keep the lightweight association path for ranges that have no native S8 backing. > > <!-- cr-comment:v1:39005d8e61e35a12f778b2c6 --> > > </dd> > </dl> > </blockquote></details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/brush-cleaning-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/brush-cleaning.svg" width="16" height="16" align="absmiddle" alt=""></picture> Nitpick comments: 2</summary><blockquote> <dl> <dd> <br> <details> <summary>tests/ShaderRecompilerComputeTests.cpp: 2</summary><blockquote> <dl> <dd> <br> `17989-17989`: **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/neutral-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Trivial** · **Maintainability & Code Quality** · **Quick win** **Test a stencil clear driven only by HTile metadata.** The explicit `stencil_clear_enable` flag makes `stencil_clear` true even if acquisition ignores the pending compressed-stencil clear. Keep the explicit-clear case. Add a pass that marks the selected HTile layer clear with the explicit flag off. Verify that acquisition clears stencil only and consumes the pending clear. ([raw.githubusercontent.com](https://raw.githubusercontent.com/KytyPS5/KytyPS5/191a9a76a3103348f12340e6059cd829cb6180cc/tests/ShaderRecompilerComputeTests.cpp)) <!-- cr-comment:v1:298ba76f109eeca480abf7ca --> --- `53804-53805`: **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/neutral-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Trivial** · **Maintainability & Code Quality** · **Quick win** **Check the footprint against fixed byte counts.** Both calls share the stencil and HTile sizing logic. If that logic returns the same wrong size for both formats, the assertion passes. For this single-sample extent, check `0x3c0000` stencil bytes and `0x48000` HTile bytes. Keep the alignment checks and the zero-depth check. ([raw.githubusercontent.com](https://raw.githubusercontent.com/KytyPS5/KytyPS5/191a9a76a3103348f12340e6059cd829cb6180cc/src/graphics/guest_gpu/tile.cpp)) <!-- cr-comment:v1:cc7437be0b418951cfefd9ea --> </dd> </dl> </blockquote></details> </dd> </dl> </blockquote></details> <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/b3295bebc698a776e3b40283fdfbc70e732e79b4/.coderabbit.yaml>) - **Commit**: [b3295be](<https://github.com/KytyPS5/KytyPS5/commit/b3295bebc698a776e3b40283fdfbc70e732e79b4>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `d54d556d-efe9-42fa-bd98-924a5456778f` </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 b3295bebc698a776e3b40283fdfbc70e732e79b4 and 191a9a76a3103348f12340e6059cd829cb6180cc. </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: 9</summary> <dl> <dd> <br> * `src/graphics/guest_gpu/tile.cpp` * `src/graphics/host_gpu/renderer/cache/textureCache.cpp` * `src/graphics/host_gpu/renderer/depthRenderTarget.cpp` * `src/graphics/host_gpu/renderer/image/image.cpp` * `src/graphics/host_gpu/renderer/image/image.h` * `src/graphics/host_gpu/renderer/image/imageInfo.h` * `src/graphics/host_gpu/renderer/image/imageView.cpp` * `src/graphics/host_gpu/renderer/renderDraw.cpp` * `tests/ShaderRecompilerComputeTests.cpp` </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review. </dd> </dl> </details> </h6> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=4422133f-e6c2-4982-9bb9-9c206729f050 attempt=fd35b1c8-db0a-4409-80cf-a4c2693b975e batch=1/1 -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-18 18:11 UTC · original
On src/graphics/host_gpu/renderer/renderDraw.cpp line 486 (outdated):

@@ -479,19 +479,24 @@ RenderState RenderExecutor::AcquireRenderTargets(CommandBuffer& buffer, RenderCo
 	if (depth.image_id) {
 		const auto  image_view = cache.FindDepthTarget(depth.image_id, depth.desc);
 		const auto& metadata   = depth.desc.info.metadata;
-		const bool meta_clear =
-		    metadata.kind == ImageMetadataKind::Htile &&
-		    cache.IsMetaCleared(metadata.range.address, depth.desc.view_info.base_layer);
+		const auto  attachment_aspects = ImageViewOps::DepthAspectMask(depth.desc.view_info.format);
+		const auto  stencil_only       = attachment_aspects == vk::ImageAspectFlagBits::eStencil;
+		const auto  all_aspects =
+		    vk::ImageAspectFlagBits::eDepth | vk::ImageAspectFlagBits::eStencil;
+		const auto meta_aspects = stencil_only ? attachment_aspects : all_aspects;

Major · Data Integrity & Integration · Quick win

Do not consume pending stencil clears for depth-only attachments.

After ClearMeta sets both bits, a depth-only acquisition requests both aspects here. TakeMetaClear resets both bits, but Line 499 discards the stencil result. A later compressed S8 attachment on the same HTile address and slice receives no stencil clear.

Request only the aspects that this acquisition will materialize. Exclude stencil when the attachment has no stencil aspect or metadata.stencil_compressed is false. Keep both aspects for compressed combined attachments and stencil alone for compressed S8 attachments.

**@⁠coderabbitai[bot]** on GitHub · 2026-11-18 18:11 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2387#discussion_r4618683387) On `src/graphics/host_gpu/renderer/renderDraw.cpp` line 486 (outdated): ```diff @@ -479,19 +479,24 @@ RenderState RenderExecutor::AcquireRenderTargets(CommandBuffer& buffer, RenderCo if (depth.image_id) { const auto image_view = cache.FindDepthTarget(depth.image_id, depth.desc); const auto& metadata = depth.desc.info.metadata; - const bool meta_clear = - metadata.kind == ImageMetadataKind::Htile && - cache.IsMetaCleared(metadata.range.address, depth.desc.view_info.base_layer); + const auto attachment_aspects = ImageViewOps::DepthAspectMask(depth.desc.view_info.format); + const auto stencil_only = attachment_aspects == vk::ImageAspectFlagBits::eStencil; + const auto all_aspects = + vk::ImageAspectFlagBits::eDepth | vk::ImageAspectFlagBits::eStencil; + const auto meta_aspects = stencil_only ? attachment_aspects : all_aspects; ``` <!-- coderabbit-ai-generated:v1 --> **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/major-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Major** · **Data Integrity & Integration** · **Quick win** **Do not consume pending stencil clears for depth-only attachments.** After `ClearMeta` sets both bits, a depth-only acquisition requests both aspects here. `TakeMetaClear` resets both bits, but Line 499 discards the stencil result. A later compressed S8 attachment on the same HTile address and slice receives no stencil clear. Request only the aspects that this acquisition will materialize. Exclude stencil when the attachment has no stencil aspect or `metadata.stencil_compressed` is false. Keep both aspects for compressed combined attachments and stencil alone for compressed S8 attachments. <!-- fingerprinting:phantom:medusa:wombat61 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:0007cdfa61ef82ddd097eb01 --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

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

Actionable comments posted: 1

Caution

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

⚠️ Outside diff range comments (1)

Major · Retiring an HTile owner erases a pending depth clear that another… · textureCache.cpp:267-268

src/graphics/host_gpu/renderer/cache/textureCache.cpp:267-268
Major · Data Integrity & Integration · Heavy lift

Retiring an HTile owner erases a pending depth clear that another live image can still need.

DeleteImage removes the whole m_surface_metas entry when the owner image is deleted. The pending depth bit is stored in that entry, so it is removed for every image that shares the HTile range. ResolveOverlap and RunGarbageCollector can both free a standalone S8 owner before its pending depth clear is consumed. Neither path checks pending clear aspects.

Keep the metadata entry while any aspect remains pending for a live image. Alternatively, transfer ownership to a surviving image before the erase. The choice between these options is open. The required behavior is that retirement must not discard a pending depth clear that a live image still needs.

Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 191a9a76a3103348f12340e6059cd829cb6180cc and 56c1102e5c8bf2d4ca8a4c85c2a47791f801a33a.

Files selected for processing: 5

  • src/graphics/host_gpu/renderer/cache/textureCache.cpp
  • src/graphics/host_gpu/renderer/cache/textureCache.h
  • src/graphics/host_gpu/renderer/depthRenderTarget.cpp
  • src/graphics/host_gpu/renderer/renderDraw.cpp
  • tests/ShaderRecompilerComputeTests.cpp

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

**@⁠coderabbitai[bot]** on GitHub · 2026-11-18 18:11 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2387#pullrequestreview-5962423761) · **reviewed** <!-- coderabbit-ai-generated:v1 --> **Actionable comments posted: 1** > [!CAUTION] > Some comments are outside the diff and can’t be posted inline due to GitHub limitations. > > **⚠️ Outside diff range comments (1)** > > <details> > <summary><strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/major-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Major</strong> · Retiring an HTile owner erases a pending depth clear that another… · <code>textureCache.cpp:267-268</code></summary><blockquote> > <dl> > <dd> > <br> > > `src/graphics/host_gpu/renderer/cache/textureCache.cpp:267-268` > **<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** > > **Retiring an HTile owner erases a pending depth clear that another live image can still need.** > > `DeleteImage` removes the whole `m_surface_metas` entry when the owner image is deleted. The pending depth bit is stored in that entry, so it is removed for every image that shares the HTile range. `ResolveOverlap` and `RunGarbageCollector` can both free a standalone S8 owner before its pending depth clear is consumed. Neither path checks pending clear aspects. > > Keep the metadata entry while any aspect remains pending for a live image. Alternatively, transfer ownership to a surviving image before the erase. The choice between these options is open. The required behavior is that retirement must not discard a pending depth clear that a live image still needs. > > <!-- cr-comment:v1:28f782c229d668bc205ea028 --> > > </dd> > </dl> > </blockquote></details> <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/6c618255ee2593edbf6a79eaf488f4795a550039/.coderabbit.yaml>) - **Commit**: [6c61825](<https://github.com/KytyPS5/KytyPS5/commit/6c618255ee2593edbf6a79eaf488f4795a550039>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `441fcca9-6779-42bf-84f0-8b9c306c98a5` </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 191a9a76a3103348f12340e6059cd829cb6180cc and 56c1102e5c8bf2d4ca8a4c85c2a47791f801a33a. </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: 5</summary> <dl> <dd> <br> * `src/graphics/host_gpu/renderer/cache/textureCache.cpp` * `src/graphics/host_gpu/renderer/cache/textureCache.h` * `src/graphics/host_gpu/renderer/depthRenderTarget.cpp` * `src/graphics/host_gpu/renderer/renderDraw.cpp` * `tests/ShaderRecompilerComputeTests.cpp` </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review. </dd> </dl> </details> </h6> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=37ad1827-b7e6-428d-9c82-06ed22ac4e73 attempt=91d28807-e4f7-4981-ae22-8e5e333a84cf batch=1/1 -->
Author
Owner

@⁠Nawid3333 on GitHub · 2026-11-18 19:44 UTC · original

Rebased onto main (6c618255e) and pushed 56c1102e5, ffd2fe490 and 7b02cd1ac for the CodeRabbit reviews:

  • renderDraw.cpp:491 (pending depth clear) and renderDraw.cpp:486 (pending stencil clear): fixed. The HTile clear state is now kept per aspect, and a bind takes only the aspects it has planes for, so a stencil-only bind leaves a pending depth clear and a depth-only bind leaves a pending stencil clear. A stencil plane without HTile stencil compression takes the stencil clear without applying it, as on main. Three new checks clear the HTile with the explicit clear flags off and then bind over the same HTile: stencil-only then depth-only Z32, Z32 then stencil-only, and Z32+S8 with uncompressed stencil then with compressed stencil. "stencil-only bind keeps a pending HTile depth clear" fails with the first commit's sources, "depth-only bind keeps a pending HTile stencil clear" fails with 56c1102e5, "uncompressed stencil bind drops the pending HTile stencil clear" fails with an intermediate version that left that bit pending; all three pass with ffd2fe490. IsMetaCleared keeps main's meaning (a pending depth clear), which the existing depth-only checks rely on. This also covers the nitpick on a stencil clear that comes only from HTile metadata.
  • Outside-diff textureCache.cpp:267-268 (retiring the HTile owner): fixed in 7b02cd1ac. ReleaseHtileOwner passes the HTile clear state to a live image with the same HTile range and erases it only when none is left. It runs when the owner is deleted, when an image moves to another HTile, and when AssociateStencil adopts a stencil-only image as a depth target's stencil plane; before, the last two kept the old range owned, and a deletion also made the survivor's next bind re-create the state with both clears set. Checks "retiring the HTile owner keeps the shared clear state", "a depth image moved to another HTile releases the old one" and "an adopted stencil image releases its HTile" fail with the sources before each fix and pass with 7b02cd1ac.
  • depthRenderTarget.cpp:285: fixed, the Z read/write address check now needs a Z surface. The stencil-only test target now keeps a stale Z read address; with the first commit's sources the test stops at Depth target fatal: unsupported depth register state.
  • imageInfo.h:248: a multisampled stencil-only target now stops in MakeDepthTargetDesc with its own message. Multisampled stencil-only targets stay unsupported in this PR.
  • ShaderRecompilerComputeTests.cpp:17995: the stencil-only cases run only when the host reports S8_UINT with the depth-target usage at one sample; otherwise the test prints that they were skipped.
  • Footprint nitpick: the check now also requires 0x3c0000 stencil bytes and 0x48000 HTile bytes.
  • depthRenderTarget.cpp:122 (no S8_UINT attachment on the host), depthRenderTarget.cpp:229 and textureCache.cpp:1184 (a stencil-only target over a Z+S8 target's stencil plane, and back): main stops at every stencil-only target, so these cases stop on main too. Baldur's Gate 3 reached the game with the first commit and #2292 (#2334) without hitting them. They need a fallback format and a stencil copy between native S8 and combined images, which I would rather do in a follow-up PR with its own tests.

RX 9070 XT (Windows 11, clang-cl, with the harness change of #2038), 7b02cd1ac: --image-rebind-only fails only the four depth feedback-loop checks that also fail on main; --depth-readback-only passes; the full compute suite passes 192 cases and fails only the two checks that also fail with main's sources on this GPU. The macOS job fails on main's own VirtualMemoryAllocationTests.cpp Xbyak error, not on this PR.

**@⁠Nawid3333** on GitHub · 2026-11-18 19:44 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2387#issuecomment-6989603593) Rebased onto main (6c618255e) and pushed 56c1102e5, ffd2fe490 and 7b02cd1ac for the CodeRabbit reviews: - [`renderDraw.cpp:491`](https://git.gtahub.st/github/KytyPS5--KytyPS5/pulls/2387) (pending depth clear) and [`renderDraw.cpp:486`](https://git.gtahub.st/github/KytyPS5--KytyPS5/pulls/2387) (pending stencil clear): fixed. The HTile clear state is now kept per aspect, and a bind takes only the aspects it has planes for, so a stencil-only bind leaves a pending depth clear and a depth-only bind leaves a pending stencil clear. A stencil plane without HTile stencil compression takes the stencil clear without applying it, as on main. Three new checks clear the HTile with the explicit clear flags off and then bind over the same HTile: stencil-only then depth-only Z32, Z32 then stencil-only, and Z32+S8 with uncompressed stencil then with compressed stencil. "stencil-only bind keeps a pending HTile depth clear" fails with the first commit's sources, "depth-only bind keeps a pending HTile stencil clear" fails with 56c1102e5, "uncompressed stencil bind drops the pending HTile stencil clear" fails with an intermediate version that left that bit pending; all three pass with ffd2fe490. `IsMetaCleared` keeps main's meaning (a pending depth clear), which the existing depth-only checks rely on. This also covers the nitpick on a stencil clear that comes only from HTile metadata. - [Outside-diff `textureCache.cpp:267-268`](https://git.gtahub.st/github/KytyPS5--KytyPS5/pulls/2387) (retiring the HTile owner): fixed in 7b02cd1ac. `ReleaseHtileOwner` passes the HTile clear state to a live image with the same HTile range and erases it only when none is left. It runs when the owner is deleted, when an image moves to another HTile, and when `AssociateStencil` adopts a stencil-only image as a depth target's stencil plane; before, the last two kept the old range owned, and a deletion also made the survivor's next bind re-create the state with both clears set. Checks "retiring the HTile owner keeps the shared clear state", "a depth image moved to another HTile releases the old one" and "an adopted stencil image releases its HTile" fail with the sources before each fix and pass with 7b02cd1ac. - [`depthRenderTarget.cpp:285`](https://git.gtahub.st/github/KytyPS5--KytyPS5/pulls/2387): fixed, the Z read/write address check now needs a Z surface. The stencil-only test target now keeps a stale Z read address; with the first commit's sources the test stops at `Depth target fatal: unsupported depth register state`. - [`imageInfo.h:248`](https://git.gtahub.st/github/KytyPS5--KytyPS5/pulls/2387): a multisampled stencil-only target now stops in `MakeDepthTargetDesc` with its own message. Multisampled stencil-only targets stay unsupported in this PR. - [`ShaderRecompilerComputeTests.cpp:17995`](https://git.gtahub.st/github/KytyPS5--KytyPS5/pulls/2387): the stencil-only cases run only when the host reports `S8_UINT` with the depth-target usage at one sample; otherwise the test prints that they were skipped. - Footprint nitpick: the check now also requires 0x3c0000 stencil bytes and 0x48000 HTile bytes. - [`depthRenderTarget.cpp:122`](https://git.gtahub.st/github/KytyPS5--KytyPS5/pulls/2387) (no `S8_UINT` attachment on the host), [`depthRenderTarget.cpp:229`](https://git.gtahub.st/github/KytyPS5--KytyPS5/pulls/2387) and `textureCache.cpp:1184` (a stencil-only target over a Z+S8 target's stencil plane, and back): main stops at every stencil-only target, so these cases stop on main too. Baldur's Gate 3 reached the game with the first commit and #2292 (#2334) without hitting them. They need a fallback format and a stencil copy between native S8 and combined images, which I would rather do in a follow-up PR with its own tests. RX 9070 XT (Windows 11, clang-cl, with the harness change of #2038), 7b02cd1ac: `--image-rebind-only` fails only the four depth feedback-loop checks that also fail on main; `--depth-readback-only` passes; the full compute suite passes 192 cases and fails only the two checks that also fail with main's sources on this GPU. The macOS job fails on main's own `VirtualMemoryAllocationTests.cpp` Xbyak error, not on this PR.
github-bot closed this pull request 2026-11-27 00:43:21 +00:00
Author
Owner

@⁠Nawid3333 on GitHub · 2026-11-26 21:31 UTC · original

Main has this since b446af9d2 (graphics: render stencil-only targets and preserve shared stencil contents), which renders the stencil-only targets of #2334 as well, so I'm closing this one.

**@⁠Nawid3333** on GitHub · 2026-11-26 21:31 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2387#issuecomment-7203802116) Main has this since b446af9d2 (graphics: render stencil-only targets and preserve shared stencil contents), which renders the stencil-only targets of #2334 as well, so I'm closing this one.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.