gpu: fix vanishing models when freed depth-buffer metadata memory is reused (PPSA09809) #1803

Open
github-bot wants to merge 14 commits from github-bot/gh-1803 into main AGit
Owner

@⁠MrBigBritches on GitHub · 2026-10-21 22:32 UTC · original
MrBigBritches:htile-reuse-dispatch-fix → main · +524 −24 · 4 files · 14 commits · open

Depth buffers on the PS5 come with HTILE, a compact metadata block that records per-tile depth information so the GPU can skip work and compress depth. Games often reset HTILE with a small compute shader. Kyty doesn't emulate the HTILE bytes themselves. It recognizes these clear dispatches and replaces them with a logical "clear this depth surface's metadata" operation.

Kyty remembered which memory held HTILE until the memory was unmapped or the depth image was freed. Games free depth targets and reuse that memory for other things. In Octopath Traveler II, battle depth targets are freed and their HTILE memory becomes Unreal Engine's GPUScene buffer, which holds per-object data for every model in the scene. The GPUScene resize and upload shaders wrote to a "known HTILE" address, so Kyty swallowed them as metadata clears. GPUScene then kept stale memory, and after battles and scene changes characters and objects vanished. Sometimes a giant plane cut through the scene instead.

Example
boat-scene-1

Changes

Recognise only real metadata clears

A compute dispatch is now consumed as a metadata clear only if all of these hold:

  • It writes only registered metadata. Any other buffer write means the shader is doing real work.
  • Each write stays within the surface's metadata size. That size is recorded when the depth target is registered, and a clear is never consumed while the size is unknown. An unbounded descriptor is still accepted, since a clear shader can address the whole surface that way.
  • It reads no buffer larger than 4 KiB. Real clears read at most a small constant buffer. A data copy reads a large source.
  • It writes no storage image.
  • It reaches no memory outside its bound buffers. Shaders that read or write through raw addresses, access buffers through descriptors the GPU picks at run time, or use GDS run normally, because a clear would drop those accesses.

Anything else runs as a normal dispatch.

Check and clear in one step

TextureCache::ClearMetaSurfaces checks every buffer the dispatch binds and marks the written surfaces cleared only if all of them pass, under one lock. A dispatch rejected partway through never leaves some surfaces cleared, and an unmap on another thread can't remove a surface between the check and the clear.

Keep the per-dispatch cost low

  • The check is split into IsMetaClearShaderCandidate and AddMetaClearTarget, each under 50 lines.
  • A shader that writes no buffer, and so can't be a clear, is turned away before any descriptor is decoded or lock taken.
  • Targets are collected in a fixed array sized for every buffer a shader can bind, so there is no allocation per dispatch.

Metadata size with shared HTILE

Two live depth images can share an HTILE base. The recorded size stays the larger one, so binding the smaller image doesn't turn away clears of the larger one. A code comment explains why, and a test pins it.

Testing

New tests in ShaderRecompilerComputeTests, each checked against a deliberately broken classifier:

  • ComputeMetaClearClassification gains reused-HTILE cases:
    • a data copy into reused HTILE memory is kept
    • a write past the surface is kept
    • a dispatch writing metadata and other memory is kept
    • a dispatch that also writes a storage image is kept
    • a constant-driven clear is consumed
  • ComputeMetaClearInputs:
    • an unbounded clear is consumed
    • an unbounded read is kept
    • a read of exactly 4 KiB is consumed and one element more is kept
    • a null descriptor slot doesn't block a clear
    • a dispatch writing only null slots is kept
  • MetaClearSurfacesAllOrNothing: a later failing target leaves earlier ones uncleared, for unregistered, oversized and read-as-input targets, and for dispatches writing no surface.
  • ComputeMetaClearShaderGuards: a clear-shaped dispatch is consumed, and the same dispatch with raw-address writes, run-time descriptors or GDS is kept.
  • Shared HTILE size: two depth targets sharing an HTILE base keep the larger size, and freeing one lets the next binding record its own.

The full suite passes except kernel_file_system, which fails the same way on main.

In-game, with a temporary diagnostic (not committed) on the overlay and in the log:

Octopath Traveler II (with a battle) Astro Bot
Clears consumed 1.0/frame 3.0/frame
Dispatches rejected that touched metadata 0 0
Depth loads after a rejected clear 0 0
Cost of the check 5 µs/frame 11 µs/frame

Real clears in both games bind a bounded descriptor exactly the size of the HTILE surface, plus at most one 16-byte constant, and use none of the raw-address, run-time descriptor or GDS features. An earlier 26-minute Octopath Traveler II session ran 95 GPUScene resizes with no dropped dispatches and no missing models.

Known limitations

These predate this PR and are left for follow-ups:

  • Reused HTILE memory is still recognised as metadata. A metadata entry survives while its memory stays mapped, even after a game reuses it. A constant fill of that memory that fits the surface is still consumed as a clear. Dropping entries on reuse needs care. Colour images legitimately share memory with HTILE, and a game can update HTILE in place between frames. If such a write counted as reuse, the next real clear would be rejected.
  • Freeing one of two depth images that share an HTILE base drops the entry. Binding the other one again recreates it as cleared, which can clear depth it still needs.
  • An HTILE base that moves leaves the old entry behind.
  • A DMA fill at an HTILE address counts as a clear whatever its size.
**@⁠MrBigBritches** on GitHub · 2026-10-21 22:32 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1803) `MrBigBritches:htile-reuse-dispatch-fix` → `main` · +524 −24 · 4 files · 14 commits · open Depth buffers on the PS5 come with **HTILE**, a compact metadata block that records per-tile depth information so the GPU can skip work and compress depth. Games often reset HTILE with a small compute shader. Kyty doesn't emulate the HTILE bytes themselves. It recognizes these clear dispatches and replaces them with a logical "clear this depth surface's metadata" operation. Kyty remembered which memory held HTILE until the memory was unmapped or the depth image was freed. Games free depth targets and reuse that memory for other things. In Octopath Traveler II, battle depth targets are freed and their HTILE memory becomes Unreal Engine's GPUScene buffer, which holds per-object data for every model in the scene. The GPUScene resize and upload shaders wrote to a "known HTILE" address, so Kyty swallowed them as metadata clears. GPUScene then kept stale memory, and after battles and scene changes characters and objects vanished. Sometimes a giant plane cut through the scene instead. **Example** <img width="3842" height="2160" alt="boat-scene-1" src="https://github.com/user-attachments/assets/dc7f9711-505a-414c-856c-be59379c36e7" /> ## Changes ### Recognise only real metadata clears A compute dispatch is now consumed as a metadata clear only if all of these hold: - **It writes only registered metadata.** Any other buffer write means the shader is doing real work. - **Each write stays within the surface's metadata size.** That size is recorded when the depth target is registered, and a clear is never consumed while the size is unknown. An unbounded descriptor is still accepted, since a clear shader can address the whole surface that way. - **It reads no buffer larger than 4 KiB.** Real clears read at most a small constant buffer. A data copy reads a large source. - **It writes no storage image.** - **It reaches no memory outside its bound buffers.** Shaders that read or write through raw addresses, access buffers through descriptors the GPU picks at run time, or use GDS run normally, because a clear would drop those accesses. Anything else runs as a normal dispatch. ### Check and clear in one step `TextureCache::ClearMetaSurfaces` checks every buffer the dispatch binds and marks the written surfaces cleared only if all of them pass, under one lock. A dispatch rejected partway through never leaves some surfaces cleared, and an unmap on another thread can't remove a surface between the check and the clear. ### Keep the per-dispatch cost low - The check is split into `IsMetaClearShaderCandidate` and `AddMetaClearTarget`, each under 50 lines. - A shader that writes no buffer, and so can't be a clear, is turned away before any descriptor is decoded or lock taken. - Targets are collected in a fixed array sized for every buffer a shader can bind, so there is no allocation per dispatch. ### Metadata size with shared HTILE Two live depth images can share an HTILE base. The recorded size stays the larger one, so binding the smaller image doesn't turn away clears of the larger one. A code comment explains why, and a test pins it. ## Testing New tests in `ShaderRecompilerComputeTests`, each checked against a deliberately broken classifier: - **`ComputeMetaClearClassification`** gains reused-HTILE cases: - a data copy into reused HTILE memory is kept - a write past the surface is kept - a dispatch writing metadata and other memory is kept - a dispatch that also writes a storage image is kept - a constant-driven clear is consumed - **`ComputeMetaClearInputs`:** - an unbounded clear is consumed - an unbounded read is kept - a read of exactly 4 KiB is consumed and one element more is kept - a null descriptor slot doesn't block a clear - a dispatch writing only null slots is kept - **`MetaClearSurfacesAllOrNothing`:** a later failing target leaves earlier ones uncleared, for unregistered, oversized and read-as-input targets, and for dispatches writing no surface. - **`ComputeMetaClearShaderGuards`:** a clear-shaped dispatch is consumed, and the same dispatch with raw-address writes, run-time descriptors or GDS is kept. - **Shared HTILE size:** two depth targets sharing an HTILE base keep the larger size, and freeing one lets the next binding record its own. The full suite passes except `kernel_file_system`, which fails the same way on `main`. In-game, with a temporary diagnostic (not committed) on the overlay and in the log: | | Octopath Traveler II (with a battle) | Astro Bot | |---|---|---| | Clears consumed | 1.0/frame | 3.0/frame | | Dispatches rejected that touched metadata | 0 | 0 | | Depth loads after a rejected clear | 0 | 0 | | Cost of the check | 5 µs/frame | 11 µs/frame | Real clears in both games bind a bounded descriptor exactly the size of the HTILE surface, plus at most one 16-byte constant, and use none of the raw-address, run-time descriptor or GDS features. An earlier 26-minute Octopath Traveler II session ran 95 GPUScene resizes with no dropped dispatches and no missing models. ## Known limitations These predate this PR and are left for follow-ups: - **Reused HTILE memory is still recognised as metadata.** A metadata entry survives while its memory stays mapped, even after a game reuses it. A constant fill of that memory that fits the surface is still consumed as a clear. Dropping entries on reuse needs care. Colour images legitimately share memory with HTILE, and a game can update HTILE in place between frames. If such a write counted as reuse, the next real clear would be rejected. - **Freeing one of two depth images that share an HTILE base** drops the entry. Binding the other one again recreates it as cleared, which can clear depth it still needs. - **An HTILE base that moves** leaves the old entry behind. - **A DMA fill at an HTILE address** counts as a clear whatever its size.
TryConsumeComputeMetaClear replaced any compute dispatch that wrote a
registered HTILE address with a logical metadata clear. Metadata
entries outlive the memory they describe: a game can free a depth
target and reuse its HTILE memory for other data while the entry stays.
Octopath Traveler II (PPSA09809) does this after battles and scene
changes; its GPUScene resize and upload dispatches then landed on a
stale HTILE address and were dropped, so the new scene buffer kept
whatever the memory held before and models disappeared.

A dispatch is now consumed as a metadata clear only when it writes
nothing but registered metadata surfaces, each within the surface
size (now recorded when the depth target registers it), and reads no
buffer larger than a small constant block. Everything else runs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A write to a metadata entry whose surface size is unknown is no longer
consumed as a clear. Unbounded descriptors (NumRecords = 0xffffffff)
stay allowed: clear shaders commonly address a whole surface that way,
and such a dispatch must still write only metadata from constants.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
TryConsumeComputeMetaClear walked the dispatch's buffers three times before
deciding: once for metadata that is read, once for the size of read constants
and once for the written metadata surfaces. Check all three per buffer in a
single pass, decoding each descriptor once. The result is unchanged; every
check only rejects, and the metadata is still cleared only after all buffers
pass.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Comment why each check in TryConsumeComputeMetaClear is needed, and
restructure the loop so a buffer goes through at most four tests:

- skip unbound slots before any cache lookup;
- look the address up once with FindMeta, instead of IsMeta for some
  buffers and FindMeta for others;
- split read-only bindings from written ones, so each kind is tested only
  for what applies to it;
- reject a buffer that is both read and written directly. Such a buffer
  could never pass before either: being read ruled out metadata, and being
  written required it.

The decision is the same for every dispatch, since no metadata surface is
registered at address 0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A shader that writes a registered metadata buffer and a storage image could
pass the buffer checks and be taken for a metadata clear. DispatchDirect
then returned without running the dispatch, so the image write was lost.
Reject the clear when any image in the shader is written (image atomics
count as writes), and let the dispatch run normally.

The new case in the HTILE reuse test binds the same buffers as the consumed
clear, plus a written storage image. It fails without the fix.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Main now passes compute shaders to the render executor as a ShaderModule
(ShaderStageRuntime::module), so the HTILE reuse cases build their
dispatch input the same way as the other metadata-clear cases.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Add ComputeMetaClearInputs, which gives each case its own HTILE entry:
- an unbounded write descriptor reading only constants is still a clear,
  as full-surface clear shaders address HTILE that way
- an unbounded read is real data, so the dispatch runs
- constants up to the 4 KiB read limit keep a clear eligible, and one
  element more does not
- a null descriptor slot doesn't block a clear, and a dispatch writing
  only null slots is not one

Point the existing constant-driven clear case at HTILE that was never
reused. A fill of reused HTILE memory is still consumed while the memory
stays mapped, which is left to a follow-up.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
TryConsumeComputeMetaClear took the texture cache lock once per bound
buffer to look up its metadata, then again per written buffer to clear
it, and ignored whether the clear succeeded. An unmap on a guest thread
could drop a surface in between, so a dispatch could be skipped with
nothing cleared.

Replace FindMeta, which this branch added, with ClearMetaSurfaces. It
checks every target and marks the written surfaces cleared only if all
of them pass, under one lock. The classifier keeps its descriptor-only
checks, collects the targets into a fixed array sized for every buffer a
shader can bind, and makes one call. Decisions are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
TryConsumeComputeMetaClear had grown past the 50-line limit. Move the
shader-level checks into IsMetaClearShaderCandidate and the per-buffer
descriptor checks into AddMetaClearTarget.

The shader-level check also turns away shaders that write no buffer.
Such a dispatch can never be a metadata clear, so the result is the
same, but it now returns before decoding descriptors or taking the
texture cache lock.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A shader that reads or writes through raw addresses, accesses buffers
through descriptors the GPU picks at run time, or uses GDS touches memory
the bound-buffer checks never see. Consuming such a dispatch as a
metadata clear would drop those accesses, so it now runs normally.

The real HTILE clears seen in Octopath Traveler II and Astro Bot use none
of these, so they are still consumed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Two live depth images can share an HTILE base. FindDepthTarget keeps the
larger registered size so binding the smaller image doesn't turn away
clears of the larger one. Say so where the size is stored and updated.

Test that a smaller image at a shared base keeps the larger size, and
that once an image is freed the next binding records its own size.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
CheckComputeMetaClearClassification built its buffer bindings with a
local lambda that repeated the shared AddMetaClearBuffer helper. Use the
helper instead. The only difference was write_extent, which the
classifier never reads, so no case changes behaviour.

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

@⁠coderabbitai[bot] on GitHub · 2026-10-21 22:39 UTC · original · edited 2026-10-27 23:56 UTC

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 4eae95dd14 and 6d3ad8f97a.

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; 8 remain after this review.

Walkthrough

Texture metadata records now retain the largest registered range size for each address. TextureCache::ClearMetaSurfaces validates all targets under one lock and marks written targets cleared only if validation succeeds. Compute metadata-clear classification screens shader operations and buffer descriptors before submitting targets to the cache. Tests cover metadata range tracking, accepted and rejected dispatches, and all-or-nothing validation.

Suggested reviewers: claxten10

Priority: Normal

Change: Bug fix

Merge Risk: Moderate · up to 6d3ad

Some compute dispatches can still be mistaken for metadata clears and skipped, potentially causing missing rendered content. Resolve the outstanding range and overlap checks before merging.

Pre-merge checks: Passed 4 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Docstring Coverage Inconclusive Docstring coverage is 57.14% 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 surv… 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 clearly identifies the GPU metadata-reuse bug and the resulting vanishing models. It accurately summarizes the main change.
Description check Passed The description directly explains the HTILE metadata-clear bug, the classifier changes, locking behavior, tests, performance results, and known limitations.
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: Docstring Coverage

Explanation

Docstring coverage is 57.14% 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 7 functions across 3 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-21 22:39 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1803#issuecomment-6328132954) · edited 2026-10-27 23:56 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/1803?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 --> <!-- recent_review_start --> No actionable comments were generated in the recent review. <details> <summary><strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/info.svg" width="16" height="16" align="absmiddle" alt=""></picture> Recent review info</strong></summary> <dl> <dd> <!-- 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> - **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/1be1c6c4f928e52f740ae7f76841c1da74220e54/.coderabbit.yaml>) - **Commit**: [1be1c6c](<https://github.com/KytyPS5/KytyPS5/commit/1be1c6c4f928e52f740ae7f76841c1da74220e54>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `8be49e6b-2fc9-4f56-a93e-7d1a55a26f1e` </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> Reviewing files that changed from the base of the PR and between 4eae95dd142525e11147397d43a12e0b2914034f and 6d3ad8f97aa0580e95b62fcfd202cc3d8bd8ef10. </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> * `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> <!-- recent_review_end --> <!-- walkthrough_start --> <details> <summary><strong>Walkthrough</strong></summary> <dl> <dd> Texture metadata records now retain the largest registered range size for each address. `TextureCache::ClearMetaSurfaces` validates all targets under one lock and marks written targets cleared only if validation succeeds. Compute metadata-clear classification screens shader operations and buffer descriptors before submitting targets to the cache. Tests cover metadata range tracking, accepted and rejected dispatches, and all-or-nothing validation. **Suggested reviewers:** `claxten10` </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:"6d3ad8f97aa0580e95b62fcfd202cc3d8bd8ef10" --> **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> · up to <code>6d3ad</code></summary> <dl> <dd> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **🟡 Moderate** · up to `6d3ad` --> <!-- final_review_risk_coverage:{"sourceCommitId":"6d3ad8f97aa0580e95b62fcfd202cc3d8bd8ef10","coveredCommitId":"6d3ad8f97aa0580e95b62fcfd202cc3d8bd8ef10","kind":"reviewed"} --> Some compute dispatches can still be mistaken for metadata clears and skipped, potentially causing missing rendered content. Resolve the outstanding range and overlap checks before merging. <!-- 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 57.14% 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 surv… | 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 clearly identifies the GPU metadata-reuse bug and the resulting vanishing models. It accurately summarizes the main change. | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description directly explains the HTILE metadata-clear bug, the classifier changes, locking behavior, tests, performance results, and known limitations. | | 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. | </dd> </dl> </details> <details> <summary><strong>Full details: Docstring Coverage</strong></summary> <dl> <dd> **Explanation** Docstring coverage is 57.14% 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 7 functions across 3 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=1803)! 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 -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-21 22:39 UTC · original · edited 2026-10-21 23:08 UTC
On src/graphics/host_gpu/renderer/renderCompute.cpp line 106 (outdated):

@@ -69,19 +69,55 @@ bool RenderExecutor::TryConsumeComputeMetaClear(const ShaderComputeInputInfo& in
 		}
 	}
 
-	if (!program.info.has_bitwise_xor) {
-		for (uint32_t i = 0; i < program.info.buffers.size(); i++) {
-			const auto& resource = program.info.buffers[i];
-			if (resource.written) {
-				const auto descriptor =
-				    DecodeNativeDescriptor<ShaderBufferResource>(resources.buffers[i]);
-				if (cache.ClearMeta(descriptor.Base48())) {
-					return true;
-				}
-			}
+	if (program.info.has_bitwise_xor) {
+		return false;
+	}
+	// A metadata clear writes constant values into metadata surfaces and nothing else. Metadata
+	// entries outlive the memory they describe when a game frees a depth target and reuses its
+	// HTILE for something else, so the target address alone does not identify a clear. A dispatch
+	// that reads real data, writes other memory, or writes past the surface must run.
+	// PPSA09809: the scene-buffer resize and upload landed on a stale HTILE address after battles
+	// and were dropped, so models vanished.
+	constexpr uint64_t MaxClearConstantsBytes = 4096;
+	for (uint32_t i = 0; i < program.info.buffers.size(); i++) {
+		const auto& resource   = program.info.buffers[i];
+		const auto  descriptor = DecodeNativeDescriptor<ShaderBufferResource>(resources.buffers[i]);
+		if (!resource.read || descriptor.Base48() == 0) {
+			continue;
+		}
+		if (descriptor.NumRecords() == UINT32_MAX ||
+		    descriptor.GetSize() > MaxClearConstantsBytes) {
+			return false;
 		}
 	}
-	return false;
+	bool any_meta = false;
+	for (uint32_t i = 0; i < program.info.buffers.size(); i++) {
+		const auto& resource   = program.info.buffers[i];
+		const auto  descriptor = DecodeNativeDescriptor<ShaderBufferResource>(resources.buffers[i]);
+		if (!resource.written || descriptor.Base48() == 0) {
+			continue;
+		}
+		uint64_t meta_size = 0;
+		if (!cache.FindMeta(descriptor.Base48(), meta_size)) {
+			return false;
+		}
+		if (descriptor.NumRecords() != UINT32_MAX && meta_size != 0 &&
+		    descriptor.GetSize() > meta_size) {
+			return false;

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '60,130p' src/graphics/host_gpu/renderer/renderCompute.cpp
rg -n 'GetSize|NumRecords' src/graphics/shader/shaderBindings.h
rg -n 'metadata\.range|meta_data\[|MetaDataInfo' src/graphics --glob '*.cpp' --glob '*.h' | head -40

Repository: KytyPS5/KytyPS5

Length of output: 5508


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- TryConsumeComputeMetaClear declarations/callers ---'
rg -n -F -- 'TryConsumeComputeMetaClear' src
printf '%s\n' '--- FindMeta and metadata registration definitions/usages ---'
rg -n -F -e 'FindMeta' -e 'FindDepthTarget' -e 'm_surface_metas' -e 'MetaDataInfo' src/graphics/host_gpu/renderer
printf '%s\n' '--- TextureCache metadata implementation ---'
sed -n '60,105p' src/graphics/host_gpu/renderer/cache/textureCache.h
sed -n '1010,1060p' src/graphics/host_gpu/renderer/cache/textureCache.cpp
sed -n '1390,1445p' src/graphics/host_gpu/renderer/cache/textureCache.cpp
printf '%s\n' '--- ShaderBufferResource complete definition ---'
sed -n '1,65p' src/graphics/shader/shaderBindings.h
printf '%s\n' '--- base and head implementations ---'
git show 7b7f9a70c652afd6ec8ea8599884d9b4b3abc9f3:src/graphics/host_gpu/renderer/renderCompute.cpp | sed -n '55,125p'
sed -n '55,125p' src/graphics/host_gpu/renderer/renderCompute.cpp

Repository: KytyPS5/KytyPS5

Length of output: 18942


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- FindMeta and related metadata state ---'
sed -n '1825,1875p' src/graphics/host_gpu/renderer/cache/textureCache.cpp
printf '%s\n' '--- HasMetadata and metadata range declarations ---'
rg -n -F -e 'HasMetadata' -e 'metadata.range' -e 'ImageMetadata' src/graphics/host_gpu/renderer src/graphics/guest_gpu
printf '%s\n' '--- relevant metadata descriptor construction ---'
sed -n '210,255p' src/graphics/host_gpu/renderer/depthRenderTarget.cpp
sed -n '560,610p' src/graphics/host_gpu/renderer/pipeline/descriptors.cpp
sed -n '570,620p' src/graphics/presentation/videoOut.cpp
printf '%s\n' '--- exact function diff ---'
git diff 7b7f9a70c652afd6ec8ea8599884d9b4b3abc9f3 -- src/graphics/host_gpu/renderer/renderCompute.cpp

Repository: KytyPS5/KytyPS5

Length of output: 16160


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- FindDepthTarget callers and depth-target construction ---'
rg -n -F -e 'FindDepthTarget(' -e 'GetHtileSize' -e 'has_htile' src/graphics/host_gpu/renderer
sed -n '180,250p' src/graphics/host_gpu/renderer/depthRenderTarget.cpp
printf '%s\n' '--- GuestRange validity and ImageInfo validation ---'
rg -n -F -e 'struct GuestRange' -e 'class GuestRange' -e 'bool Valid' -e 'Valid() const' src
sed -n '90,125p' src/graphics/host_gpu/renderer/image/imageInfo.h
sed -n '645,680p' src/graphics/host_gpu/renderer/image/image.cpp
printf '%s\n' '--- all m_surface_metas writes/registration ---'
rg -n -F -e 'm_surface_metas.try_emplace' -e 'm_surface_metas[' -e 'm_surface_metas.insert' src/graphics/host_gpu/renderer

Repository: KytyPS5/KytyPS5

Length of output: 11942


Reject unbounded write descriptors before consuming the dispatch.

NumRecords() == UINT32_MAX bypasses the write-size check. If the descriptor targets registered metadata, the dispatch can be consumed without proving that its write range fits the metadata surface. Treat meta_size == 0 as unknown and reject it as well.

🐛 Suggested fix
-		if (descriptor.NumRecords() != UINT32_MAX && meta_size != 0 &&
-		    descriptor.GetSize() > meta_size) {
+		if (descriptor.NumRecords() == UINT32_MAX || meta_size == 0 ||
+		    descriptor.GetSize() > meta_size) {
			return false;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

		if (descriptor.NumRecords() == UINT32_MAX || meta_size == 0 ||
		    descriptor.GetSize() > meta_size) {
			return false;

✅ Confirmed as addressed by @⁠MrBigBritches

**@⁠coderabbitai[bot]** on GitHub · 2026-10-21 22:39 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1803#discussion_r4342700236) · edited 2026-10-21 23:08 UTC On `src/graphics/host_gpu/renderer/renderCompute.cpp` line 106 (outdated): ```diff @@ -69,19 +69,55 @@ bool RenderExecutor::TryConsumeComputeMetaClear(const ShaderComputeInputInfo& in } } - if (!program.info.has_bitwise_xor) { - for (uint32_t i = 0; i < program.info.buffers.size(); i++) { - const auto& resource = program.info.buffers[i]; - if (resource.written) { - const auto descriptor = - DecodeNativeDescriptor<ShaderBufferResource>(resources.buffers[i]); - if (cache.ClearMeta(descriptor.Base48())) { - return true; - } - } + if (program.info.has_bitwise_xor) { + return false; + } + // A metadata clear writes constant values into metadata surfaces and nothing else. Metadata + // entries outlive the memory they describe when a game frees a depth target and reuses its + // HTILE for something else, so the target address alone does not identify a clear. A dispatch + // that reads real data, writes other memory, or writes past the surface must run. + // PPSA09809: the scene-buffer resize and upload landed on a stale HTILE address after battles + // and were dropped, so models vanished. + constexpr uint64_t MaxClearConstantsBytes = 4096; + for (uint32_t i = 0; i < program.info.buffers.size(); i++) { + const auto& resource = program.info.buffers[i]; + const auto descriptor = DecodeNativeDescriptor<ShaderBufferResource>(resources.buffers[i]); + if (!resource.read || descriptor.Base48() == 0) { + continue; + } + if (descriptor.NumRecords() == UINT32_MAX || + descriptor.GetSize() > MaxClearConstantsBytes) { + return false; } } - return false; + bool any_meta = false; + for (uint32_t i = 0; i < program.info.buffers.size(); i++) { + const auto& resource = program.info.buffers[i]; + const auto descriptor = DecodeNativeDescriptor<ShaderBufferResource>(resources.buffers[i]); + if (!resource.written || descriptor.Base48() == 0) { + continue; + } + uint64_t meta_size = 0; + if (!cache.FindMeta(descriptor.Base48(), meta_size)) { + return false; + } + if (descriptor.NumRecords() != UINT32_MAX && meta_size != 0 && + descriptor.GetSize() > meta_size) { + return false; ``` <!-- coderabbit-ai-generated:v1 --> **🗄️ Data Integrity & Integration** | **🟠 Major** | **⚡ Quick win** <details> <summary>🔎 Supported by static analysis</summary> 🏁 Script executed: ```bash sed -n '60,130p' src/graphics/host_gpu/renderer/renderCompute.cpp rg -n 'GetSize|NumRecords' src/graphics/shader/shaderBindings.h rg -n 'metadata\.range|meta_data\[|MetaDataInfo' src/graphics --glob '*.cpp' --glob '*.h' | head -40 ``` Repository: KytyPS5/KytyPS5 Length of output: 5508 --- 🏁 Script executed: ```bash set -o pipefail printf '%s\n' '--- TryConsumeComputeMetaClear declarations/callers ---' rg -n -F -- 'TryConsumeComputeMetaClear' src printf '%s\n' '--- FindMeta and metadata registration definitions/usages ---' rg -n -F -e 'FindMeta' -e 'FindDepthTarget' -e 'm_surface_metas' -e 'MetaDataInfo' src/graphics/host_gpu/renderer printf '%s\n' '--- TextureCache metadata implementation ---' sed -n '60,105p' src/graphics/host_gpu/renderer/cache/textureCache.h sed -n '1010,1060p' src/graphics/host_gpu/renderer/cache/textureCache.cpp sed -n '1390,1445p' src/graphics/host_gpu/renderer/cache/textureCache.cpp printf '%s\n' '--- ShaderBufferResource complete definition ---' sed -n '1,65p' src/graphics/shader/shaderBindings.h printf '%s\n' '--- base and head implementations ---' git show 7b7f9a70c652afd6ec8ea8599884d9b4b3abc9f3:src/graphics/host_gpu/renderer/renderCompute.cpp | sed -n '55,125p' sed -n '55,125p' src/graphics/host_gpu/renderer/renderCompute.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 18942 --- 🏁 Script executed: ```bash set -o pipefail printf '%s\n' '--- FindMeta and related metadata state ---' sed -n '1825,1875p' src/graphics/host_gpu/renderer/cache/textureCache.cpp printf '%s\n' '--- HasMetadata and metadata range declarations ---' rg -n -F -e 'HasMetadata' -e 'metadata.range' -e 'ImageMetadata' src/graphics/host_gpu/renderer src/graphics/guest_gpu printf '%s\n' '--- relevant metadata descriptor construction ---' sed -n '210,255p' src/graphics/host_gpu/renderer/depthRenderTarget.cpp sed -n '560,610p' src/graphics/host_gpu/renderer/pipeline/descriptors.cpp sed -n '570,620p' src/graphics/presentation/videoOut.cpp printf '%s\n' '--- exact function diff ---' git diff 7b7f9a70c652afd6ec8ea8599884d9b4b3abc9f3 -- src/graphics/host_gpu/renderer/renderCompute.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 16160 --- 🏁 Script executed: ```bash set -o pipefail printf '%s\n' '--- FindDepthTarget callers and depth-target construction ---' rg -n -F -e 'FindDepthTarget(' -e 'GetHtileSize' -e 'has_htile' src/graphics/host_gpu/renderer sed -n '180,250p' src/graphics/host_gpu/renderer/depthRenderTarget.cpp printf '%s\n' '--- GuestRange validity and ImageInfo validation ---' rg -n -F -e 'struct GuestRange' -e 'class GuestRange' -e 'bool Valid' -e 'Valid() const' src sed -n '90,125p' src/graphics/host_gpu/renderer/image/imageInfo.h sed -n '645,680p' src/graphics/host_gpu/renderer/image/image.cpp printf '%s\n' '--- all m_surface_metas writes/registration ---' rg -n -F -e 'm_surface_metas.try_emplace' -e 'm_surface_metas[' -e 'm_surface_metas.insert' src/graphics/host_gpu/renderer ``` Repository: KytyPS5/KytyPS5 Length of output: 11942 --- </details> **Reject unbounded write descriptors before consuming the dispatch.** `NumRecords() == UINT32_MAX` bypasses the write-size check. If the descriptor targets registered metadata, the dispatch can be consumed without proving that its write range fits the metadata surface. Treat `meta_size == 0` as unknown and reject it as well. <details> <summary>🐛 Suggested fix</summary> ```diff - if (descriptor.NumRecords() != UINT32_MAX && meta_size != 0 && - descriptor.GetSize() > meta_size) { + if (descriptor.NumRecords() == UINT32_MAX || meta_size == 0 || + descriptor.GetSize() > meta_size) { return false; ``` </details> <!-- suggestion_start --> <details> <summary>📝 Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. ```suggestion if (descriptor.NumRecords() == UINT32_MAX || meta_size == 0 || descriptor.GetSize() > meta_size) { return false; ``` </details> <!-- suggestion_end --> <!-- fingerprinting:phantom:medusa:beignet55 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:d1e8a666f5939b12515ef61f --> <!-- This is an auto-generated reply by CodeRabbit --> ✅ Confirmed as addressed by @⁠MrBigBritches <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-21 22:39 UTC · original · reviewed

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e9f6beaf-1f17-4a9e-803a-a489cffe6afa
📥 Commits

Reviewing files that changed from the base of the PR and between 286481889f and cce6676855f69cfa0125eab206d4f411eaf24e16.

📒 Files selected for processing: 4
  • src/graphics/host_gpu/renderer/cache/textureCache.cpp
  • src/graphics/host_gpu/renderer/cache/textureCache.h
  • src/graphics/host_gpu/renderer/renderCompute.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-21 22:39 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1803#pullrequestreview-5607097590) · **reviewed** <!-- coderabbit-ai-generated:v1 --> **Actionable comments posted: 1** --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `e9f6beaf-1f17-4a9e-803a-a489cffe6afa` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 286481889fcdda9390c6ef2bf7e66c84aff978ba and cce6676855f69cfa0125eab206d4f411eaf24e16. </details> <details> <summary>📒 Files selected for processing: 4</summary> * `src/graphics/host_gpu/renderer/cache/textureCache.cpp` * `src/graphics/host_gpu/renderer/cache/textureCache.h` * `src/graphics/host_gpu/renderer/renderCompute.cpp` * `tests/ShaderRecompilerComputeTests.cpp` </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. </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=96822eca-f9a7-4b2f-a354-256ebd403b35 attempt=2e036c46-346a-4023-bad5-bb8aad63b707 batch=1/1 -->
Author
Owner

@⁠MrBigBritches on GitHub · 2026-10-21 22:57 UTC · original
On src/graphics/host_gpu/renderer/renderCompute.cpp line 106 (outdated):

@@ -69,19 +69,55 @@ bool RenderExecutor::TryConsumeComputeMetaClear(const ShaderComputeInputInfo& in
 		}
 	}
 
-	if (!program.info.has_bitwise_xor) {
-		for (uint32_t i = 0; i < program.info.buffers.size(); i++) {
-			const auto& resource = program.info.buffers[i];
-			if (resource.written) {
-				const auto descriptor =
-				    DecodeNativeDescriptor<ShaderBufferResource>(resources.buffers[i]);
-				if (cache.ClearMeta(descriptor.Base48())) {
-					return true;
-				}
-			}
+	if (program.info.has_bitwise_xor) {
+		return false;
+	}
+	// A metadata clear writes constant values into metadata surfaces and nothing else. Metadata
+	// entries outlive the memory they describe when a game frees a depth target and reuses its
+	// HTILE for something else, so the target address alone does not identify a clear. A dispatch
+	// that reads real data, writes other memory, or writes past the surface must run.
+	// PPSA09809: the scene-buffer resize and upload landed on a stale HTILE address after battles
+	// and were dropped, so models vanished.
+	constexpr uint64_t MaxClearConstantsBytes = 4096;
+	for (uint32_t i = 0; i < program.info.buffers.size(); i++) {
+		const auto& resource   = program.info.buffers[i];
+		const auto  descriptor = DecodeNativeDescriptor<ShaderBufferResource>(resources.buffers[i]);
+		if (!resource.read || descriptor.Base48() == 0) {
+			continue;
+		}
+		if (descriptor.NumRecords() == UINT32_MAX ||
+		    descriptor.GetSize() > MaxClearConstantsBytes) {
+			return false;
 		}
 	}
-	return false;
+	bool any_meta = false;
+	for (uint32_t i = 0; i < program.info.buffers.size(); i++) {
+		const auto& resource   = program.info.buffers[i];
+		const auto  descriptor = DecodeNativeDescriptor<ShaderBufferResource>(resources.buffers[i]);
+		if (!resource.written || descriptor.Base48() == 0) {
+			continue;
+		}
+		uint64_t meta_size = 0;
+		if (!cache.FindMeta(descriptor.Base48(), meta_size)) {
+			return false;
+		}
+		if (descriptor.NumRecords() != UINT32_MAX && meta_size != 0 &&
+		    descriptor.GetSize() > meta_size) {
+			return false;

Applied the meta_size == 0 half in 4ca3a181: a write to metadata of unknown size is no longer consumed (registration always records a size in practice; the test fixture now does too, and there’s a new case for it). I kept unbounded descriptors (NumRecords == 0xffffffff) eligible: clear shaders commonly address the whole surface that way, so rejecting them would turn real HTILE clears into native writes the depth path never sees. Such a dispatch is still required to write only metadata and read at most 4 KiB of constants.

**@⁠MrBigBritches** on GitHub · 2026-10-21 22:57 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1803#discussion_r4342817251) On `src/graphics/host_gpu/renderer/renderCompute.cpp` line 106 (outdated): ```diff @@ -69,19 +69,55 @@ bool RenderExecutor::TryConsumeComputeMetaClear(const ShaderComputeInputInfo& in } } - if (!program.info.has_bitwise_xor) { - for (uint32_t i = 0; i < program.info.buffers.size(); i++) { - const auto& resource = program.info.buffers[i]; - if (resource.written) { - const auto descriptor = - DecodeNativeDescriptor<ShaderBufferResource>(resources.buffers[i]); - if (cache.ClearMeta(descriptor.Base48())) { - return true; - } - } + if (program.info.has_bitwise_xor) { + return false; + } + // A metadata clear writes constant values into metadata surfaces and nothing else. Metadata + // entries outlive the memory they describe when a game frees a depth target and reuses its + // HTILE for something else, so the target address alone does not identify a clear. A dispatch + // that reads real data, writes other memory, or writes past the surface must run. + // PPSA09809: the scene-buffer resize and upload landed on a stale HTILE address after battles + // and were dropped, so models vanished. + constexpr uint64_t MaxClearConstantsBytes = 4096; + for (uint32_t i = 0; i < program.info.buffers.size(); i++) { + const auto& resource = program.info.buffers[i]; + const auto descriptor = DecodeNativeDescriptor<ShaderBufferResource>(resources.buffers[i]); + if (!resource.read || descriptor.Base48() == 0) { + continue; + } + if (descriptor.NumRecords() == UINT32_MAX || + descriptor.GetSize() > MaxClearConstantsBytes) { + return false; } } - return false; + bool any_meta = false; + for (uint32_t i = 0; i < program.info.buffers.size(); i++) { + const auto& resource = program.info.buffers[i]; + const auto descriptor = DecodeNativeDescriptor<ShaderBufferResource>(resources.buffers[i]); + if (!resource.written || descriptor.Base48() == 0) { + continue; + } + uint64_t meta_size = 0; + if (!cache.FindMeta(descriptor.Base48(), meta_size)) { + return false; + } + if (descriptor.NumRecords() != UINT32_MAX && meta_size != 0 && + descriptor.GetSize() > meta_size) { + return false; ``` Applied the meta_size == 0 half in 4ca3a181: a write to metadata of unknown size is no longer consumed (registration always records a size in practice; the test fixture now does too, and there’s a new case for it). I kept unbounded descriptors (NumRecords == 0xffffffff) eligible: clear shaders commonly address the whole surface that way, so rejecting them would turn real HTILE clears into native writes the depth path never sees. Such a dispatch is still required to write only metadata and read at most 4 KiB of constants.
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-21 23:08 UTC · original
On src/graphics/host_gpu/renderer/renderCompute.cpp line 106 (outdated):

@@ -69,19 +69,55 @@ bool RenderExecutor::TryConsumeComputeMetaClear(const ShaderComputeInputInfo& in
 		}
 	}
 
-	if (!program.info.has_bitwise_xor) {
-		for (uint32_t i = 0; i < program.info.buffers.size(); i++) {
-			const auto& resource = program.info.buffers[i];
-			if (resource.written) {
-				const auto descriptor =
-				    DecodeNativeDescriptor<ShaderBufferResource>(resources.buffers[i]);
-				if (cache.ClearMeta(descriptor.Base48())) {
-					return true;
-				}
-			}
+	if (program.info.has_bitwise_xor) {
+		return false;
+	}
+	// A metadata clear writes constant values into metadata surfaces and nothing else. Metadata
+	// entries outlive the memory they describe when a game frees a depth target and reuses its
+	// HTILE for something else, so the target address alone does not identify a clear. A dispatch
+	// that reads real data, writes other memory, or writes past the surface must run.
+	// PPSA09809: the scene-buffer resize and upload landed on a stale HTILE address after battles
+	// and were dropped, so models vanished.
+	constexpr uint64_t MaxClearConstantsBytes = 4096;
+	for (uint32_t i = 0; i < program.info.buffers.size(); i++) {
+		const auto& resource   = program.info.buffers[i];
+		const auto  descriptor = DecodeNativeDescriptor<ShaderBufferResource>(resources.buffers[i]);
+		if (!resource.read || descriptor.Base48() == 0) {
+			continue;
+		}
+		if (descriptor.NumRecords() == UINT32_MAX ||
+		    descriptor.GetSize() > MaxClearConstantsBytes) {
+			return false;
 		}
 	}
-	return false;
+	bool any_meta = false;
+	for (uint32_t i = 0; i < program.info.buffers.size(); i++) {
+		const auto& resource   = program.info.buffers[i];
+		const auto  descriptor = DecodeNativeDescriptor<ShaderBufferResource>(resources.buffers[i]);
+		if (!resource.written || descriptor.Base48() == 0) {
+			continue;
+		}
+		uint64_t meta_size = 0;
+		if (!cache.FindMeta(descriptor.Base48(), meta_size)) {
+			return false;
+		}
+		if (descriptor.NumRecords() != UINT32_MAX && meta_size != 0 &&
+		    descriptor.GetSize() > meta_size) {
+			return false;

@⁠MrBigBritches Thanks for the fix and clarification. The supplied code rejects meta_size == 0 before consuming the dispatch.

I retract the recommendation to reject every unbounded descriptor. That would exclude the full-surface HTILE clears you described. Keeping those descriptors eligible is consistent with this classifier, although the remaining checks are a heuristic rather than proof of the shader’s write extent.


✏️ Learnings added
Learnt from: MrBigBritches
Repo: KytyPS5/KytyPS5 PR: 1803
File: src/graphics/host_gpu/renderer/renderCompute.cpp:0-0
Timestamp: 2026-10-21T23:08:33.584Z
Learning: In KytyPS5/KytyPS5, HTILE clear shaders commonly use buffer descriptors with NumRecords() == UINT32_MAX to address a whole metadata surface. Do not recommend blanket rejection of these descriptors in src/graphics/host_gpu/renderer/renderCompute.cpp::RenderExecutor::TryConsumeComputeMetaClear: native writes do not provide the metadata-clear notification that the depth path requires. Evaluate the metadata-target and constant-read checks separately from proof of the shader's write extent.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.


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

Thank you for using CodeRabbit!

✅ Review thread resolved.

You are interacting with an AI system.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-21 23:08 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1803#discussion_r4342906431) On `src/graphics/host_gpu/renderer/renderCompute.cpp` line 106 (outdated): ```diff @@ -69,19 +69,55 @@ bool RenderExecutor::TryConsumeComputeMetaClear(const ShaderComputeInputInfo& in } } - if (!program.info.has_bitwise_xor) { - for (uint32_t i = 0; i < program.info.buffers.size(); i++) { - const auto& resource = program.info.buffers[i]; - if (resource.written) { - const auto descriptor = - DecodeNativeDescriptor<ShaderBufferResource>(resources.buffers[i]); - if (cache.ClearMeta(descriptor.Base48())) { - return true; - } - } + if (program.info.has_bitwise_xor) { + return false; + } + // A metadata clear writes constant values into metadata surfaces and nothing else. Metadata + // entries outlive the memory they describe when a game frees a depth target and reuses its + // HTILE for something else, so the target address alone does not identify a clear. A dispatch + // that reads real data, writes other memory, or writes past the surface must run. + // PPSA09809: the scene-buffer resize and upload landed on a stale HTILE address after battles + // and were dropped, so models vanished. + constexpr uint64_t MaxClearConstantsBytes = 4096; + for (uint32_t i = 0; i < program.info.buffers.size(); i++) { + const auto& resource = program.info.buffers[i]; + const auto descriptor = DecodeNativeDescriptor<ShaderBufferResource>(resources.buffers[i]); + if (!resource.read || descriptor.Base48() == 0) { + continue; + } + if (descriptor.NumRecords() == UINT32_MAX || + descriptor.GetSize() > MaxClearConstantsBytes) { + return false; } } - return false; + bool any_meta = false; + for (uint32_t i = 0; i < program.info.buffers.size(); i++) { + const auto& resource = program.info.buffers[i]; + const auto descriptor = DecodeNativeDescriptor<ShaderBufferResource>(resources.buffers[i]); + if (!resource.written || descriptor.Base48() == 0) { + continue; + } + uint64_t meta_size = 0; + if (!cache.FindMeta(descriptor.Base48(), meta_size)) { + return false; + } + if (descriptor.NumRecords() != UINT32_MAX && meta_size != 0 && + descriptor.GetSize() > meta_size) { + return false; ``` <!-- coderabbit-ai-generated:v1 --> @⁠MrBigBritches Thanks for the fix and clarification. The supplied code rejects `meta_size == 0` before consuming the dispatch. I retract the recommendation to reject every unbounded descriptor. That would exclude the full-surface HTILE clears you described. Keeping those descriptors eligible is consistent with this classifier, although the remaining checks are a heuristic rather than proof of the shader’s write extent. --- <details> <summary>✏️ Learnings added</summary> ``` Learnt from: MrBigBritches Repo: KytyPS5/KytyPS5 PR: 1803 File: src/graphics/host_gpu/renderer/renderCompute.cpp:0-0 Timestamp: 2026-10-21T23:08:33.584Z Learning: In KytyPS5/KytyPS5, HTILE clear shaders commonly use buffer descriptors with NumRecords() == UINT32_MAX to address a whole metadata surface. Do not recommend blanket rejection of these descriptors in src/graphics/host_gpu/renderer/renderCompute.cpp::RenderExecutor::TryConsumeComputeMetaClear: native writes do not provide the metadata-clear notification that the depth path requires. Evaluate the metadata-target and constant-read checks separately from proof of the shader's write extent. ``` > Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure [review instructions](https://docs.coderabbit.ai/guides/review-instructions). You can manage existing learnings in the [app](https://app.coderabbit.ai/learnings). </details> --- <!-- This is an auto-generated comment: tweet message by coderabbit.ai --> If you found this review helpful, would you consider giving us a shout-out on [X](https://twitter.com/intent/tweet?related=CodeRabbitAI&text=%40coderabbitai%20caught%20a%20GPU%20data-integrity%20risk%3A%20reject%20unknown-size%20metadata%20writes%20while%20preserving%20valid%20whole-surface%20HTILE%20clears.%20Safer%20dispatches%2C%20smarter%20reviews%E2%80%94try%20it!%20%F0%9F%9B%A1%EF%B8%8F&url=https%3A%2F%2Fgithub.com%2FKytyPS5%2FKytyPS5%2Fpull%2F1803%23discussion_r4342700236)? Thank you for using CodeRabbit! <!-- end of auto-generated comment: tweet message by coderabbit.ai --> ✅ Review thread resolved. _You are interacting with an AI system._ <!-- This is an auto-generated reply by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-25 16:50 UTC · original · reviewed

Actionable comments posted: 1


Review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 4ca3a181de180613f78c43304fc61ac63caa4a01 and fb2dada18e5dd32fe3f76c0915c69b6d27c84e7b.

Files selected for processing: 1
  • src/graphics/host_gpu/renderer/renderCompute.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-25 16:50 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1803#pullrequestreview-5644203211) · **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/286481889fcdda9390c6ef2bf7e66c84aff978ba/.coderabbit.yaml>) - **Commit**: [2864818](<https://github.com/KytyPS5/KytyPS5/commit/286481889fcdda9390c6ef2bf7e66c84aff978ba>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `d27c2402-24a1-4176-a153-c1a3575ad772` </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 4ca3a181de180613f78c43304fc61ac63caa4a01 and fb2dada18e5dd32fe3f76c0915c69b6d27c84e7b. </dd> </dl> </details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner.svg" width="16" height="16" align="absmiddle" alt=""></picture> Files selected for processing: 1</summary> <dl> <dd> * `src/graphics/host_gpu/renderer/renderCompute.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=fd18072e-499f-4b70-88ce-b1aa046e926a attempt=93647786-f2d6-49f0-81ec-14f5c8f33eed batch=1/1 -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-25 16:50 UTC · original · edited 2026-10-25 17:06 UTC
On src/graphics/host_gpu/renderer/renderCompute.cpp line 72 (outdated):

@@ -58,30 +58,60 @@ bool RenderExecutor::TryConsumeComputeMetaClear(const ShaderComputeInputInfo& in
 	if (resources.buffers.size() != program.info.buffers.size()) {
 		EXIT("compute runtime buffer count does not match shader metadata\n");
 	}
-	auto& cache = buffer.GetContext().GetTextureCache();
+	if (program.info.has_bitwise_xor) {
+		return false;
+	}
+	// A metadata clear writes constant values into metadata surfaces and nothing else. Metadata
+	// entries outlive the memory they describe when a game frees a depth target and reuses its
+	// HTILE for something else, so the target address alone does not identify a clear. A dispatch
+	// that reads real data, writes other memory, or writes past the surface must run.
+	// PPSA09809: the scene-buffer resize and upload landed on a stale HTILE address after battles
+	// and were dropped, so models vanished.
+	constexpr uint64_t MaxClearConstantsBytes = 4096;
+	auto&              cache                  = buffer.GetContext().GetTextureCache();
+	bool               any_meta               = false;

Major · Functional Correctness · Quick win

Reject dispatches that also write storage images.

If a shader writes a registered metadata buffer and a storage image, the buffer checks can classify the dispatch as a metadata clear. DispatchDirect then returns without executing the storage-image write. Check program.info.images for writes before consuming the dispatch; otherwise, let the dispatch run normally.

✅ Addressed in commit d576736

**@⁠coderabbitai[bot]** on GitHub · 2026-10-25 16:50 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1803#discussion_r4371583178) · edited 2026-10-25 17:06 UTC On `src/graphics/host_gpu/renderer/renderCompute.cpp` line 72 (outdated): ```diff @@ -58,30 +58,60 @@ bool RenderExecutor::TryConsumeComputeMetaClear(const ShaderComputeInputInfo& in if (resources.buffers.size() != program.info.buffers.size()) { EXIT("compute runtime buffer count does not match shader metadata\n"); } - auto& cache = buffer.GetContext().GetTextureCache(); + if (program.info.has_bitwise_xor) { + return false; + } + // A metadata clear writes constant values into metadata surfaces and nothing else. Metadata + // entries outlive the memory they describe when a game frees a depth target and reuses its + // HTILE for something else, so the target address alone does not identify a clear. A dispatch + // that reads real data, writes other memory, or writes past the surface must run. + // PPSA09809: the scene-buffer resize and upload landed on a stale HTILE address after battles + // and were dropped, so models vanished. + constexpr uint64_t MaxClearConstantsBytes = 4096; + auto& cache = buffer.GetContext().GetTextureCache(); + bool any_meta = false; ``` <!-- 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** **Reject dispatches that also write storage images.** If a shader writes a registered metadata buffer and a storage image, the buffer checks can classify the dispatch as a metadata clear. `DispatchDirect` then returns without executing the storage-image write. Check `program.info.images` for writes before consuming the dispatch; otherwise, let the dispatch run normally. <!-- fingerprinting:phantom:poseidon:wombat --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:01072080a470dd89b10a6ab3 --> <!-- This is an auto-generated comment by CodeRabbit --> ✅ Addressed in commit d576736
Author
Owner

@⁠MrBigBritches on GitHub · 2026-10-26 01:38 UTC · original

@⁠coderabbitai resume

**@⁠MrBigBritches** on GitHub · 2026-10-26 01:38 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1803#issuecomment-6406313568) @⁠coderabbitai resume
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-26 01:38 UTC · original · edited 2026-10-26 01:45 UTC

✅ Action performed

Reviews resumed and review finished.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-26 01:38 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1803#issuecomment-6406315116) · edited 2026-10-26 01:45 UTC <!-- coderabbit-ai-generated:v1 --> <!-- This is an auto-generated reply by CodeRabbit --> <!-- CodeRabbit review command invocation: 71244c22-9bcd-4945-bfa7-179753d9d073 --> <details> <summary>✅ Action performed</summary> <dl> <dd> Reviews resumed and review finished. </dd> </dl> </details>
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-26 01:45 UTC · original · reviewed

🧹 Nitpick comments: 1
tests/ShaderRecompilerComputeTests.cpp: 1

5742-5742: Trivial · Functional Correctness · Quick win

Add an accepted unbounded HTILE-clear case.

The accepted-clear case passes records = 0xa000, so it does not exercise the NumRecords() == UINT32_MAX acceptance path. Add a separate accepted-clear case with an unbounded write descriptor and a small constant-read descriptor.


Review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 56005d2743db0957751801fb07ec925a8a031e25 and fa6905215296d727f0389acfc24abc1f60a37335.

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

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

**@⁠coderabbitai[bot]** on GitHub · 2026-10-26 01:45 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1803#pullrequestreview-5646535050) · **reviewed** <!-- coderabbit-ai-generated:v1 --> <details> <summary>🧹 Nitpick comments: 1</summary><blockquote> <dl> <dd> <details> <summary>tests/ShaderRecompilerComputeTests.cpp: 1</summary><blockquote> <dl> <dd> `5742-5742`: **<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** · **Functional Correctness** · **Quick win** **Add an accepted unbounded HTILE-clear case.** The accepted-clear case passes `records = 0xa000`, so it does not exercise the `NumRecords() == UINT32_MAX` acceptance path. Add a separate accepted-clear case with an unbounded write descriptor and a small constant-read descriptor. <!-- cr-comment:v1:5e6b096e4b0bee093efb1c13 --> </dd> </dl> </blockquote></details> </dd> </dl> </blockquote></details> --- <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/b2c9ec76094460ed26a993ff8f483779ee4556bf/.coderabbit.yaml>) - **Commit**: [b2c9ec7](<https://github.com/KytyPS5/KytyPS5/commit/b2c9ec76094460ed26a993ff8f483779ee4556bf>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `f44b9f13-0d34-42e6-8bac-0b41a7d6e8de` </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 56005d2743db0957751801fb07ec925a8a031e25 and fa6905215296d727f0389acfc24abc1f60a37335. </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: 3</summary> <dl> <dd> * `src/graphics/host_gpu/renderer/cache/textureCache.cpp` * `src/graphics/host_gpu/renderer/renderCompute.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; 6 remain after this review. </dd> </dl> </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=2755e2ff-831b-4535-9931-a528d13cd6c7 attempt=c9bb9100-a37f-4ae2-aa13-d0fbce8fa083 batch=1/1 -->
@ -1504,1 +1504,4 @@
}
// Keep the larger size, so binding a smaller image at the same base doesn't turn away
// clears of a larger one that is still alive.
metadata->second.size = std::max(metadata->second.size, desc.info.metadata.range.size);
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-27 23:33 UTC · original · edited 2026-10-27 23:42 UTC

Major · Data Integrity & Integration · Heavy lift

Supported by static analysis

Script executed:

sed -n '1480,1520p' src/graphics/host_gpu/renderer/cache/textureCache.cpp
rg -n 'm_surface_metas' src/graphics/host_gpu/renderer/cache/textureCache.cpp

Repository: KytyPS5/KytyPS5

Length of output: 3059


Script executed:

set -eu
printf '%s\n' '--- owning declarations and callers ---'
rg -n -F --glob '*.cpp' --glob '*.h' \
  -e 'FindDepthTarget' \
  -e 'ClearMetaSurfaces' \
  -e 'm_surface_metas.erase' \
  -e 'smaller image' \
  -e 'larger image remains' \
  -e 'ComputeMetaClearClassification' \
  src tests || true

printf '%s\n' '--- metadata registration and nearby function ---'
sed -n '1435,1520p' src/graphics/host_gpu/renderer/cache/textureCache.cpp

printf '%s\n' '--- erasure at image cleanup ---'
sed -n '220,290p' src/graphics/host_gpu/renderer/cache/textureCache.cpp
printf '%s\n' '--- erasure at range cleanup ---'
sed -n '1015,1070p' src/graphics/host_gpu/renderer/cache/textureCache.cpp

printf '%s\n' '--- metadata queries and ClearMetaSurfaces ---'
sed -n '1900,2030p' src/graphics/host_gpu/renderer/cache/textureCache.cpp

printf '%s\n' '--- matching test source ---'
rg -n -F --glob '*Test*' --glob '*.cpp' --glob '*.h' \
  -e 'ComputeMetaClearClassification' \
  -e 'smaller' \
  -e 'larger' \
  . || true

Repository: KytyPS5/KytyPS5

Length of output: 41511


Script executed:

set -eu
sed -n '8770,8970p' tests/ShaderRecompilerComputeTests.cpp

Repository: KytyPS5/KytyPS5

Length of output: 12375


Script executed:

set -eu
rg -n -F --glob 'textureCache.cpp' --glob 'textureCache.h' \
  -e 'ImageId TextureCache::FindImage' \
  -e 'TextureCache::FindImage' \
  -e 'needs_rebind' \
  -e 'FindImagesInRegion' \
  src/graphics/host_gpu/renderer/cache/textureCache.cpp \
  src/graphics/host_gpu/renderer/cache/textureCache.h
sed -n '300,620p' src/graphics/host_gpu/renderer/cache/textureCache.cpp
sed -n '620,900p' src/graphics/host_gpu/renderer/cache/textureCache.cpp

Repository: KytyPS5/KytyPS5

Length of output: 28803


Script executed:

set -eu
sed -n '1235,1390p' src/graphics/host_gpu/renderer/cache/textureCache.cpp

Repository: KytyPS5/KytyPS5

Length of output: 5865


Script executed:

set -eu
rg -n -F --glob '*.cpp' --glob '*.h' \
  -e 'struct MetaClearTarget' \
  -e 'class MetaClearTarget' \
  -e 'MetaClearTarget' \
  -e 'SameBacking' \
  -e 'ClearMetaSurfaces' \
  src/graphics/host_gpu/renderer/cache/textureCache.cpp \
  src/graphics/host_gpu/renderer/cache/textureCache.h \
  src/graphics/host_gpu/renderer/renderCompute.cpp \
  src/graphics/host_gpu/renderer || true
sed -n '110,165p' src/graphics/host_gpu/renderer/renderCompute.cpp
sed -n '520,610p' src/graphics/host_gpu/renderer/cache/textureCache.cpp

Repository: KytyPS5/KytyPS5

Length of output: 11251


Script executed:

set -eu
sed -n '140,180p' src/graphics/host_gpu/renderer/cache/textureCache.cpp
sed -n '70,112p' src/graphics/host_gpu/renderer/renderCompute.cpp
sed -n '70,92p' src/graphics/host_gpu/renderer/cache/textureCache.h

Repository: KytyPS5/KytyPS5

Length of output: 4456


Track metadata sizes for each live depth binding.

When FindImage reuses one cached image for a smaller compatible depth binding, FindDepthTarget replaces image.info.metadata but retains the old maximum in m_surface_metas. A bounded write larger than the new range but no larger than the retained size can pass ClearMetaSurfaces, so TryConsumeComputeMetaClear may consume the dispatch and discard that write.

Retain the maximum while separate image IDs remain live, but recompute it when a cached image changes its metadata binding or is freed.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-27 23:33 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1803#discussion_r4395366766) · edited 2026-10-27 23:42 UTC <!-- coderabbit-ai-generated:v1 --> **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/major-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Major** · **Data Integrity & Integration** · **Heavy lift** <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 '1480,1520p' src/graphics/host_gpu/renderer/cache/textureCache.cpp rg -n 'm_surface_metas' src/graphics/host_gpu/renderer/cache/textureCache.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 3059 --- Script executed: ```bash set -eu printf '%s\n' '--- owning declarations and callers ---' rg -n -F --glob '*.cpp' --glob '*.h' \ -e 'FindDepthTarget' \ -e 'ClearMetaSurfaces' \ -e 'm_surface_metas.erase' \ -e 'smaller image' \ -e 'larger image remains' \ -e 'ComputeMetaClearClassification' \ src tests || true printf '%s\n' '--- metadata registration and nearby function ---' sed -n '1435,1520p' src/graphics/host_gpu/renderer/cache/textureCache.cpp printf '%s\n' '--- erasure at image cleanup ---' sed -n '220,290p' src/graphics/host_gpu/renderer/cache/textureCache.cpp printf '%s\n' '--- erasure at range cleanup ---' sed -n '1015,1070p' src/graphics/host_gpu/renderer/cache/textureCache.cpp printf '%s\n' '--- metadata queries and ClearMetaSurfaces ---' sed -n '1900,2030p' src/graphics/host_gpu/renderer/cache/textureCache.cpp printf '%s\n' '--- matching test source ---' rg -n -F --glob '*Test*' --glob '*.cpp' --glob '*.h' \ -e 'ComputeMetaClearClassification' \ -e 'smaller' \ -e 'larger' \ . || true ``` Repository: KytyPS5/KytyPS5 Length of output: 41511 --- Script executed: ```bash set -eu sed -n '8770,8970p' tests/ShaderRecompilerComputeTests.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 12375 --- Script executed: ```bash set -eu rg -n -F --glob 'textureCache.cpp' --glob 'textureCache.h' \ -e 'ImageId TextureCache::FindImage' \ -e 'TextureCache::FindImage' \ -e 'needs_rebind' \ -e 'FindImagesInRegion' \ src/graphics/host_gpu/renderer/cache/textureCache.cpp \ src/graphics/host_gpu/renderer/cache/textureCache.h sed -n '300,620p' src/graphics/host_gpu/renderer/cache/textureCache.cpp sed -n '620,900p' src/graphics/host_gpu/renderer/cache/textureCache.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 28803 --- Script executed: ```bash set -eu sed -n '1235,1390p' src/graphics/host_gpu/renderer/cache/textureCache.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 5865 --- Script executed: ```bash set -eu rg -n -F --glob '*.cpp' --glob '*.h' \ -e 'struct MetaClearTarget' \ -e 'class MetaClearTarget' \ -e 'MetaClearTarget' \ -e 'SameBacking' \ -e 'ClearMetaSurfaces' \ src/graphics/host_gpu/renderer/cache/textureCache.cpp \ src/graphics/host_gpu/renderer/cache/textureCache.h \ src/graphics/host_gpu/renderer/renderCompute.cpp \ src/graphics/host_gpu/renderer || true sed -n '110,165p' src/graphics/host_gpu/renderer/renderCompute.cpp sed -n '520,610p' src/graphics/host_gpu/renderer/cache/textureCache.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 11251 --- Script executed: ```bash set -eu sed -n '140,180p' src/graphics/host_gpu/renderer/cache/textureCache.cpp sed -n '70,112p' src/graphics/host_gpu/renderer/renderCompute.cpp sed -n '70,92p' src/graphics/host_gpu/renderer/cache/textureCache.h ``` Repository: KytyPS5/KytyPS5 Length of output: 4456 --- </dd> </dl> </details> **Track metadata sizes for each live depth binding.** When `FindImage` reuses one cached image for a smaller compatible depth binding, `FindDepthTarget` replaces `image.info.metadata` but retains the old maximum in `m_surface_metas`. A bounded write larger than the new range but no larger than the retained size can pass `ClearMetaSurfaces`, so `TryConsumeComputeMetaClear` may consume the dispatch and discard that write. Retain the maximum while separate image IDs remain live, but recompute it when a cached image changes its metadata binding or is freed. <!-- fingerprinting:phantom:medusa:beignet55 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:4b6571c04f172929652f1e09 --> <!-- This is an auto-generated reply by CodeRabbit -->
@ -1952,0 +1961,4 @@
for (const auto& target: targets) {
const auto found = m_surface_metas.find(target.address);
const bool is_meta = found != m_surface_metas.end();
if (!target.written) {
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-27 23:33 UTC · original · edited 2026-10-27 23:43 UTC

Minor · Data Integrity & Integration · Quick win

Supported by static analysis

Script executed:

sed -n '50,150p' src/graphics/host_gpu/renderer/renderCompute.cpp
sed -n '1950,2000p' src/graphics/host_gpu/renderer/cache/textureCache.cpp

Repository: KytyPS5/KytyPS5

Length of output: 7263


Reject read-only bindings that overlap a metadata range, not only ones at its base.

ClearMetaSurfaces checks read-only targets only with find(target.address). A read-only binding that starts inside a registered metadata range, but not at its base, is not rejected. If a dispatch reads that data and writes another registered surface, it can be consumed as a clear, and its data-dependent writes are dropped. The exact-base check is correct for written targets, which must be registered surfaces. Read-only targets need an overlap test against the full range they cover.

🐛 Suggested fix
 		if (!target.written) {
-			// A metadata surface bound without being written is input to the dispatch, so the
-			// dispatch is not a full overwrite.
+			// A metadata surface, or any part of one, bound without being written is input to the
+			// dispatch, so the dispatch is not a full overwrite.
 			if (is_meta) {
 				return false;
 			}
+			for (const auto& [base, meta]: m_surface_metas) {
+				if (target.address < base + meta.size && base < target.address + target.size) {
+					return false;
+				}
+			}
 			continue;
 		}
**@⁠coderabbitai[bot]** on GitHub · 2026-10-27 23:33 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1803#discussion_r4395366770) · edited 2026-10-27 23:43 UTC <!-- 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 '50,150p' src/graphics/host_gpu/renderer/renderCompute.cpp sed -n '1950,2000p' src/graphics/host_gpu/renderer/cache/textureCache.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 7263 --- </dd> </dl> </details> **Reject read-only bindings that overlap a metadata range, not only ones at its base.** `ClearMetaSurfaces` checks read-only targets only with `find(target.address)`. A read-only binding that starts inside a registered metadata range, but not at its base, is not rejected. If a dispatch reads that data and writes another registered surface, it can be consumed as a clear, and its data-dependent writes are dropped. The exact-base check is correct for written targets, which must be registered surfaces. Read-only targets need an overlap test against the full range they cover. <details> <summary>🐛 Suggested fix</summary> <dl> <dd> ```diff if (!target.written) { - // A metadata surface bound without being written is input to the dispatch, so the - // dispatch is not a full overwrite. + // A metadata surface, or any part of one, bound without being written is input to the + // dispatch, so the dispatch is not a full overwrite. if (is_meta) { return false; } + for (const auto& [base, meta]: m_surface_metas) { + if (target.address < base + meta.size && base < target.address + target.size) { + return false; + } + } continue; } ``` </dd> </dl> </details> <!-- fingerprinting:phantom:medusa:beignet55 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:2861e9fde25eb496304976af --> <!-- This is an auto-generated reply by CodeRabbit -->
Author
Owner

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

Actionable comments posted: 2

🔇 Additional comments: 1
tests/ShaderRecompilerComputeTests.cpp: 1

5859-5883: Trivial · Maintainability & Code Quality · Quick win

⚠️ Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.

Reuse AddMetaClearBuffer instead of the local AddBuffer lambda.

The AddBuffer lambda builds the same buffer resource and descriptor as AddMetaClearBuffer at Lines 5975-5999. The only difference is that AddBuffer does not set write_extent. The new comment at Lines 5984-5985 says the classifier does not read write_extent. Two copies of this descriptor layout can drift apart, for example if the classifier later reads write_extent or the descriptor encoding changes. In that case the tests in this function would exercise different inputs than the later tests.

Delete the lambda and call the static helper. It is a class member, so its later declaration is visible inside this member function body.

♻️ Proposed refactor
-    const auto AddBuffer = [](uint64_t address, bool read, bool written, uint32_t records,
-                              ShaderModule &module,
-                              ShaderRecompiler::IR::ResourceSnapshot &snapshot) {
-      ...
-    };
+    const auto AddBuffer = AddMetaClearBuffer;

You could also rename the call sites to AddMetaClearBuffer. MakeDispatch at Lines 5885-5891 duplicates the three-line input setup that the Consume lambdas repeat. You can move it into a shared static helper at the same time.


Review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between fa6905215296d727f0389acfc24abc1f60a37335 and 4eae95dd14.

Files selected for processing: 4
  • src/graphics/host_gpu/renderer/cache/textureCache.cpp
  • src/graphics/host_gpu/renderer/cache/textureCache.h
  • src/graphics/host_gpu/renderer/renderCompute.cpp
  • 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-10-27 23:33 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1803#pullrequestreview-5675855740) · **reviewed** <!-- coderabbit-ai-generated:v1 --> **Actionable comments posted: 2** <details> <summary>🔇 Additional comments: 1</summary><blockquote> <dl> <dd> <details> <summary>tests/ShaderRecompilerComputeTests.cpp: 1</summary><blockquote> <dl> <dd> `5859-5883`: **<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** ⚠️ **Unverified finding** Verification ran but could not confirm this finding. It is shown for review, not as a verified issue. **Reuse `AddMetaClearBuffer` instead of the local `AddBuffer` lambda.** The `AddBuffer` lambda builds the same buffer resource and descriptor as `AddMetaClearBuffer` at Lines 5975-5999. The only difference is that `AddBuffer` does not set `write_extent`. The new comment at Lines 5984-5985 says the classifier does not read `write_extent`. Two copies of this descriptor layout can drift apart, for example if the classifier later reads `write_extent` or the descriptor encoding changes. In that case the tests in this function would exercise different inputs than the later tests. Delete the lambda and call the static helper. It is a class member, so its later declaration is visible inside this member function body. <details> <summary>♻️ Proposed refactor</summary> <dl> <dd> ```diff - const auto AddBuffer = [](uint64_t address, bool read, bool written, uint32_t records, - ShaderModule &module, - ShaderRecompiler::IR::ResourceSnapshot &snapshot) { - ... - }; + const auto AddBuffer = AddMetaClearBuffer; ``` </dd> </dl> </details> You could also rename the call sites to `AddMetaClearBuffer`. `MakeDispatch` at Lines 5885-5891 duplicates the three-line input setup that the `Consume` lambdas repeat. You can move it into a shared static helper at the same time. </dd> </dl> </blockquote></details> </dd> </dl> </blockquote></details> --- <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/1be1c6c4f928e52f740ae7f76841c1da74220e54/.coderabbit.yaml>) - **Commit**: [1be1c6c](<https://github.com/KytyPS5/KytyPS5/commit/1be1c6c4f928e52f740ae7f76841c1da74220e54>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `e022ea55-ebb3-4e66-bbc4-61f63e7ca2a5` </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 fa6905215296d727f0389acfc24abc1f60a37335 and 4eae95dd142525e11147397d43a12e0b2914034f. </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: 4</summary> <dl> <dd> * `src/graphics/host_gpu/renderer/cache/textureCache.cpp` * `src/graphics/host_gpu/renderer/cache/textureCache.h` * `src/graphics/host_gpu/renderer/renderCompute.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; 9 remain after this review. </dd> </dl> </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=9cffe1c7-3bd6-496c-a9e8-4ebefa3463b3 attempt=9a051e16-066b-4977-a82f-937279b67ee6 batch=1/1 -->
@ -1504,1 +1504,4 @@
}
// Keep the larger size, so binding a smaller image at the same base doesn't turn away
// clears of a larger one that is still alive.
metadata->second.size = std::max(metadata->second.size, desc.info.metadata.range.size);
Author
Owner

@⁠MrBigBritches on GitHub · 2026-10-27 23:42 UTC · original

Intentional. 4eae95dd keeps the largest registered size so a smaller binding at the same base can't turn away clears of a larger surface. Shrinking the entry when one cached image is rebound smaller needs size tracking for each live image, which is the same ownership rework as the "two depth images share an HTILE base" item in Known limitations. Octopath and Astro Bot showed no real clears relying on the slack, so I'm leaving it as a follow-up.

**@⁠MrBigBritches** on GitHub · 2026-10-27 23:42 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1803#discussion_r4395418122) Intentional. 4eae95dd keeps the largest registered size so a smaller binding at the same base can't turn away clears of a larger surface. Shrinking the entry when one cached image is rebound smaller needs size tracking for each live image, which is the same ownership rework as the "two depth images share an HTILE base" item in Known limitations. Octopath and Astro Bot showed no real clears relying on the slack, so I'm leaving it as a follow-up.
@ -1504,1 +1504,4 @@
}
// Keep the larger size, so binding a smaller image at the same base doesn't turn away
// clears of a larger one that is still alive.
metadata->second.size = std::max(metadata->second.size, desc.info.metadata.range.size);
Author
Owner

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

@⁠MrBigBritches Understood. Retaining the maximum preserves clears for larger surfaces at the same HTILE base. Correct shrinking needs per-image ownership tracking, not a smaller-binding assignment.

I accept deferring that rework. The retained-size risk remains a known limitation, so this finding is deferred rather than fixed.

Would you like me to open a follow-up GitHub issue for the ownership tracking and rebind/free regression cases?


🧠 Learnings used
Learnt from: MrBigBritches
Repo: KytyPS5/KytyPS5

Timestamp: 2026-10-21T23:08:38.353Z
Learning: In KytyPS5/KytyPS5, HTILE clear shaders commonly use buffer descriptors with NumRecords() == UINT32_MAX to address a whole metadata surface. Do not recommend blanket rejection of these descriptors in src/graphics/host_gpu/renderer/renderCompute.cpp::RenderExecutor::TryConsumeComputeMetaClear: native writes do not provide the metadata-clear notification that the depth path requires. Evaluate the metadata-target and constant-read checks separately from proof of the shader's write extent.

You are interacting with an AI system.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-27 23:43 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1803#discussion_r4395420510) <!-- coderabbit-ai-generated:v1 --> @⁠MrBigBritches Understood. Retaining the maximum preserves clears for larger surfaces at the same HTILE base. Correct shrinking needs per-image ownership tracking, not a smaller-binding assignment. I accept deferring that rework. The retained-size risk remains a known limitation, so this finding is deferred rather than fixed. Would you like me to open a follow-up GitHub issue for the ownership tracking and rebind/free regression cases? --- <details> <summary>🧠 Learnings used</summary> <dl> <dd> ``` Learnt from: MrBigBritches Repo: KytyPS5/KytyPS5 Timestamp: 2026-10-21T23:08:38.353Z Learning: In KytyPS5/KytyPS5, HTILE clear shaders commonly use buffer descriptors with NumRecords() == UINT32_MAX to address a whole metadata surface. Do not recommend blanket rejection of these descriptors in src/graphics/host_gpu/renderer/renderCompute.cpp::RenderExecutor::TryConsumeComputeMetaClear: native writes do not provide the metadata-clear notification that the depth path requires. Evaluate the metadata-target and constant-read checks separately from proof of the shader's write extent. ``` </dd> </dl> </details> <sub><i>You are interacting with an AI system.</i></sub> <!-- This is an auto-generated reply by CodeRabbit -->
@ -1952,0 +1961,4 @@
for (const auto& target: targets) {
const auto found = m_surface_metas.find(target.address);
const bool is_meta = found != m_surface_metas.end();
if (!target.written) {
Author
Owner

@⁠MrBigBritches on GitHub · 2026-10-27 23:43 UTC · original

Fair gap, but reads are already capped at 4 KiB of bounded constants. With stale entries surviving while their memory stays mapped (Known limitations), an overlap test would also reject real clears whose constants land in reused HTILE memory. I'll measure that before tightening it, and if I do, I'll use an ordered upper_bound lookup rather than a full scan under the lock.

**@⁠MrBigBritches** on GitHub · 2026-10-27 23:43 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1803#discussion_r4395421047) Fair gap, but reads are already capped at 4 KiB of bounded constants. With stale entries surviving while their memory stays mapped (Known limitations), an overlap test would also reject real clears whose constants land in reused HTILE memory. I'll measure that before tightening it, and if I do, I'll use an ordered upper_bound lookup rather than a full scan under the lock.
@ -1952,0 +1961,4 @@
for (const auto& target: targets) {
const auto found = m_surface_metas.find(target.address);
const bool is_meta = found != m_surface_metas.end();
if (!target.written) {
Author
Owner

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

@⁠MrBigBritches Agreed. Measure the false-rejection risk before tightening this check. My suggested full scan did not account for stale HTILE entries rejecting valid constant-driven clears.

The 4 KiB bound limits reads, but it does not prove that those reads are constants. The classification gap remains open; your explanation supports deferring the proposed change, not treating the gap as fixed.

For measurement, distinguish reads from live HTILE metadata from constants in reused HTILE memory. That will help determine whether an overlap check improves classification without rejecting real clears.


🧠 Learnings used
Learnt from: MrBigBritches
Repo: KytyPS5/KytyPS5

Timestamp: 2026-10-21T23:08:38.353Z
Learning: In KytyPS5/KytyPS5, HTILE clear shaders commonly use buffer descriptors with NumRecords() == UINT32_MAX to address a whole metadata surface. Do not recommend blanket rejection of these descriptors in src/graphics/host_gpu/renderer/renderCompute.cpp::RenderExecutor::TryConsumeComputeMetaClear: native writes do not provide the metadata-clear notification that the depth path requires. Evaluate the metadata-target and constant-read checks separately from proof of the shader's write extent.

You are interacting with an AI system.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-27 23:43 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1803#discussion_r4395423405) <!-- coderabbit-ai-generated:v1 --> @⁠MrBigBritches Agreed. Measure the false-rejection risk before tightening this check. My suggested full scan did not account for stale HTILE entries rejecting valid constant-driven clears. The 4 KiB bound limits reads, but it does not prove that those reads are constants. The classification gap remains open; your explanation supports deferring the proposed change, not treating the gap as fixed. For measurement, distinguish reads from live HTILE metadata from constants in reused HTILE memory. That will help determine whether an overlap check improves classification without rejecting real clears. --- <details> <summary>🧠 Learnings used</summary> <dl> <dd> ``` Learnt from: MrBigBritches Repo: KytyPS5/KytyPS5 Timestamp: 2026-10-21T23:08:38.353Z Learning: In KytyPS5/KytyPS5, HTILE clear shaders commonly use buffer descriptors with NumRecords() == UINT32_MAX to address a whole metadata surface. Do not recommend blanket rejection of these descriptors in src/graphics/host_gpu/renderer/renderCompute.cpp::RenderExecutor::TryConsumeComputeMetaClear: native writes do not provide the metadata-clear notification that the depth path requires. Evaluate the metadata-target and constant-read checks separately from proof of the shader's write extent. ``` </dd> </dl> </details> <sub><i>You are interacting with an AI system.</i></sub> <!-- This is an auto-generated reply by CodeRabbit -->
Author
Owner

@⁠MrBigBritches on GitHub · 2026-10-28 00:09 UTC · original

Done in 6d3ad8f9: the classification test now uses AddMetaClearBuffer. The accepted unbounded-clear case was added in 58f03f35 (unbounded HTile clear consumed in ComputeMetaClearInputs)

**@⁠MrBigBritches** on GitHub · 2026-10-28 00:09 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1803#issuecomment-6456942425) Done in 6d3ad8f9: the classification test now uses AddMetaClearBuffer. The accepted unbounded-clear case was added in 58f03f35 (unbounded HTile clear consumed in ComputeMetaClearInputs)
This pull request has changes conflicting with the target branch.
  • src/graphics/host_gpu/renderer/cache/textureCache.cpp
  • src/graphics/host_gpu/renderer/cache/textureCache.h
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1803/head:github-bot/gh-1803'
git switch 'github-bot/gh-1803'

Merge

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