gpu: check DCC fast clears on the GPU instead of reading metadata back (PPSA32309) #1819

Closed
github-bot wants to merge 1 commit from gh-pr/1819/head into gh-pr/1819/base
Owner

@⁠MrBigBritches on GitHub · 2026-10-22 05:38 UTC · original
MrBigBritches:dcc-gpu-clear-check → main · +659 −5 · 10 files · 1 commits · closed without merging

When a surface with DCC metadata is looked up, MaterializeColorClear reads its metadata to find slices fast-cleared to a single code, and clears them. If the GPU had written that metadata, this was a synchronous download that drained the GPU.

The Adventures of Elliot (PPSA32309) fast-clears several surfaces, including 3D volumes, with a compute shader every frame, and binds them throughout the frame. That added up to about 1,000 downloads and 330 ms of GPU waits per second, holding even a black-screen cutscene at ~45 fps (1% low ~30 fps).

#1124

Changes

  • GPU check: with VK_EXT_conditional_rendering, a small compute shader (color_clear_check.comp) replaces the readback.
    • One workgroup per slice checks whether every byte holds the same code.
    • It sets a predicate for that code, if the surface can decode it.
    • It resets a matched slice to 0xff, as the CPU path does after materializing.
  • Conditional clears: the surface gets one vkCmdClearAttachments per slice and candidate code under conditional rendering, using the clear values the CPU path would use.
  • Skipping repeat checks: the texture cache remembers which slices it has checked, and for which codes, until a GPU write through the buffer cache overlaps them. Later binds skip the check.
  • Fallback: depth, multisampled and non-renderable surfaces, CMASK metadata, and devices without conditional rendering keep the readback path.

Results (RTX 5090, Ryzen 7 7800X3D)

  • The PPSA32309 cutscene goes from ~45 to ~60 fps.
  • No metadata readbacks remain: about 2,000 surface checks a second run on the GPU instead, and about 4,900 binds a second skip the check.
  • The scene renders correctly.

Tests

New CheckColorClearCheck (skipped without conditional rendering):

  • A uniform slice sets exactly its code's predicate; mixed and 0xff slices set none.
  • Matched slices are reset to 0xff; others are untouched.
  • A GPU write forgets exactly the checked slices it overlaps.

The test harness enables conditional rendering when the GPU supports it.

**@⁠MrBigBritches** on GitHub · 2026-10-22 05:38 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1819) `MrBigBritches:dcc-gpu-clear-check` → `main` · +659 −5 · 10 files · 1 commits · closed without merging When a surface with DCC metadata is looked up, `MaterializeColorClear` reads its metadata to find slices fast-cleared to a single code, and clears them. If the GPU had written that metadata, this was a synchronous download that drained the GPU. The Adventures of Elliot (PPSA32309) fast-clears several surfaces, including 3D volumes, with a compute shader every frame, and binds them throughout the frame. That added up to about 1,000 downloads and 330 ms of GPU waits per second, holding even a black-screen cutscene at ~45 fps (1% low ~30 fps). https://git.gtahub.st/github/KytyPS5--KytyPS5/issues/1124 ### Changes - **GPU check:** with `VK_EXT_conditional_rendering`, a small compute shader (`color_clear_check.comp`) replaces the readback. - One workgroup per slice checks whether every byte holds the same code. - It sets a predicate for that code, if the surface can decode it. - It resets a matched slice to 0xff, as the CPU path does after materializing. - **Conditional clears:** the surface gets one `vkCmdClearAttachments` per slice and candidate code under conditional rendering, using the clear values the CPU path would use. - **Skipping repeat checks:** the texture cache remembers which slices it has checked, and for which codes, until a GPU write through the buffer cache overlaps them. Later binds skip the check. - **Fallback:** depth, multisampled and non-renderable surfaces, CMASK metadata, and devices without conditional rendering keep the readback path. ### Results (RTX 5090, Ryzen 7 7800X3D) - The PPSA32309 cutscene goes from ~45 to ~60 fps. - No metadata readbacks remain: about 2,000 surface checks a second run on the GPU instead, and about 4,900 binds a second skip the check. - The scene renders correctly. ### Tests New `CheckColorClearCheck` (skipped without conditional rendering): - A uniform slice sets exactly its code's predicate; mixed and 0xff slices set none. - Matched slices are reset to 0xff; others are untouched. - A GPU write forgets exactly the checked slices it overlaps. The test harness enables conditional rendering when the GPU supports it.
When a surface with DCC metadata is looked up, MaterializeColorClear
reads the metadata to find slices fast-cleared to a single code and
clears them. If the GPU had written that metadata, this was a
synchronous download that drained the GPU. The Adventures of Elliot
(PPSA32309) fast-clears several surfaces, including 3D volumes, with
compute every frame and binds them throughout the frame: ~1,000
downloads and ~330 ms of GPU waits per second, holding a black-screen
cutscene at ~45 fps.

With VK_EXT_conditional_rendering, record a small compute check
instead. One workgroup per slice tests whether every byte holds the
same code, sets a predicate for that code if the surface can decode it,
and resets a matched slice to 0xff as the CPU path does. The surface is
then cleared with one conditional clear per slice and candidate code,
using the clear values the CPU path would use.

The texture cache remembers which slices it has checked, and for which
codes, until a GPU write through the buffer cache overlaps them, so
later binds skip the check. Depth, multisampled and non-renderable
surfaces, CMASK metadata, and devices without conditional rendering
keep the readback path.

The scene now runs at ~60 fps with no metadata readbacks.

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:34 +00:00
github-bot closed this pull request 2026-11-26 10:06:34 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-22 05:47 UTC · original

Review in Change Stack →

📝 Walkthrough

The change adds conditional-rendering capability detection and a compute shader that checks color-metadata slices against candidate clear codes. The texture cache uses the resulting predicates to conditionally materialize supported color clears and tracks checked metadata codes. GPU writes invalidate overlapping cached checks. Compute tests cover predicate results, reset behavior, and range invalidation.

Suggested reviewers: nmzik

Priority: ⬆️ High

Change: Bug fix

Merge Risk: 🔵 Low · up to c6f26

A recreated VideoOut image may miss a color clear. Restricting the cache entries and testing invalidation through a GPU write would address the remaining bounded risk before merge.

Pre-merge checks: Passed 4 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Docstring Coverage Inconclusive Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 7 files. (3 skipped: … 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 and concisely describes the main change: moving DCC fast-clear checks from metadata readbacks to GPU execution.
Description check Passed The description directly explains the GPU-based DCC fast-clear checks, conditional rendering, caching, fallback behavior, performance results, and tests.
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 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 7 files. (3 skipped: 2 unsupported, 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-22 05:47 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1819#issuecomment-6333743960) <!-- 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/1819?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=3"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3" alt="Review in Change Stack →" height="32"></picture></a> <!-- review_stack_entry_end --> <!-- walkthrough_start --> <details> <summary><strong>📝 Walkthrough</strong></summary> <dl> <dd> The change adds conditional-rendering capability detection and a compute shader that checks color-metadata slices against candidate clear codes. The texture cache uses the resulting predicates to conditionally materialize supported color clears and tracks checked metadata codes. GPU writes invalidate overlapping cached checks. Compute tests cover predicate results, reset behavior, and range invalidation. **Suggested reviewers:** `nmzik` </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ⬆️ High <!-- change_assessment_commit:"c6f26c12013b4d5c42c654981943ac7615837938" --> **Change:** Bug fix <!-- change_assessment_end --> <details> <summary><strong>Merge Risk:</strong> <strong>🔵 Low</strong> · up to <code>c6f26</code></summary> <dl> <dd> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **🔵 Low** · up to `c6f26` --> <!-- final_review_risk_coverage:{"sourceCommitId":"c6f26c12013b4d5c42c654981943ac7615837938","coveredCommitId":"c6f26c12013b4d5c42c654981943ac7615837938","kind":"reviewed"} --> A recreated VideoOut image may miss a color clear. Restricting the cache entries and testing invalidation through a GPU write would address the remaining bounded risk before merge. <!-- final_review_risk_end --> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_start --> <details> <summary><strong>Pre-merge checks: <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> 4 · <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 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 7 files. (3 skipped: … | 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 and concisely describes the main change: moving DCC fast-clear checks from metadata readbacks to GPU execution. | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description directly explains the GPU-based DCC fast-clear checks, conditional rendering, caching, fallback behavior, performance results, and tests. | | 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 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 7 files. (3 skipped: 2 unsupported, 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=1819)! 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 -->
@ -1038,0 +1125,4 @@
checked = {slice_size, 0};
}
checked.codes |= code_mask;
}
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-22 05:47 UTC · original

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
rg -nP -C4 'MaterializeColorClear\(|m_checked_color_meta|BindingType::VideoOut' src/graphics/host_gpu/renderer/cache/textureCache.cpp

Repository: KytyPS5/KytyPS5

Length of output: 6028


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- checked-cache declarations and callers ---'
rg -n -F --glob '*.{cpp,h,hpp}' -e 'ForgetColorMetaChecks' -e 'm_checked_color_meta' -e 'MaterializeColorClearOnGpu' src/graphics/host_gpu/renderer/cache src/graphics/host_gpu/renderer
printf '%s\n' '--- image lookup/recreation and binding paths ---'
sed -n '560,730p' src/graphics/host_gpu/renderer/cache/textureCache.cpp
sed -n '1000,1165p' src/graphics/host_gpu/renderer/cache/textureCache.cpp
sed -n '1165,1300p' src/graphics/host_gpu/renderer/cache/textureCache.cpp
printf '%s\n' '--- relevant declarations ---'
rg -n -C4 -F --glob '*.{h,hpp}' -e 'GetImage' -e 'FindImage' -e 'CreateImage' -e 'MaterializeColorClear' src/graphics/host_gpu/renderer/cache

Repository: KytyPS5/KytyPS5

Length of output: 29875


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- buffer invalidation ---'
sed -n '470,545p' src/graphics/host_gpu/renderer/cache/bufferCache.cpp
printf '%s\n' '--- image lookup/update/bind flow ---'
rg -n -F -- 'ImageId TextureCache::FindImage' 'ImageId TextureCache::UpdateImage' 'MaterializeColorClear(result' src/graphics/host_gpu/renderer/cache/textureCache.cpp
sed -n '320,560p' src/graphics/host_gpu/renderer/cache/textureCache.cpp
sed -n '1360,1485p' src/graphics/host_gpu/renderer/cache/textureCache.cpp
printf '%s\n' '--- all metadata invalidation callers in buffer cache ---'
rg -n -C8 -F -- 'InvalidateMemory(' src/graphics/host_gpu/renderer/cache/bufferCache.cpp

Repository: KytyPS5/KytyPS5

Length of output: 3678


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- FindImage and range lookup ---'
sed -n '1335,1515p' src/graphics/host_gpu/renderer/cache/textureCache.cpp
printf '%s\n' '--- InvalidateMemory definition and callers ---'
rg -n -F -- 'void BufferCache::InvalidateMemory' src/graphics/host_gpu/renderer/cache/bufferCache.cpp
rg -n -F -- 'InvalidateMemory(' src/graphics/host_gpu/renderer/cache/bufferCache.cpp
printf '%s\n' '--- surrounding invalidation implementation ---'
line=$(rg -n -F -- 'void BufferCache::InvalidateMemory' src/graphics/host_gpu/renderer/cache/bufferCache.cpp | cut -d: -f1)
if [ -n "$line" ]; then
  start=$((line-8)); end=$((line+55))
  sed -n "${start},${end}p" src/graphics/host_gpu/renderer/cache/bufferCache.cpp
fi

Repository: KytyPS5/KytyPS5

Length of output: 8653


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- overlap resolution and image lifetime ---'
rg -n -F -- 'TextureCache::ResolveOverlap' src/graphics/host_gpu/renderer/cache/textureCache.cpp
rg -n -F -- 'TextureCache::InsertImage' src/graphics/host_gpu/renderer/cache/textureCache.cpp
rg -n -F -- 'TextureCache::FreeImage' src/graphics/host_gpu/renderer/cache/textureCache.cpp
line=$(rg -n -F -- 'TextureCache::ResolveOverlap' src/graphics/host_gpu/renderer/cache/textureCache.cpp | cut -d: -f1)
if [ -n "$line" ]; then sed -n "$((line-15)),$((line+180))p" src/graphics/host_gpu/renderer/cache/textureCache.cpp; fi
printf '%s\n' '--- VideoOut and metadata write paths ---'
rg -n -P -C5 'BindingType::VideoOut|VideoOutCompression|ObtainBuffer\\([^\\n]*true|MarkGpuModified|CommitGpuWrite' src/graphics/host_gpu/renderer/cache src/graphics/host_gpu/renderer | head -n 320
printf '%s\n' '--- conditional-clear test references ---'
rg -n -P -C5 'CheckColorClearCheck|VideoOut' tests src | head -n 240

Repository: KytyPS5/KytyPS5

Length of output: 28303


Do not cache checked metadata for VideoOut.

VideoOut keeps its metadata code, but the current cache records it as checked. If FindImage creates a replacement image with the same metadata range, all_checked can return before the replacement receives the clear. Cache entries only when the check resets the metadata.

🐛 Suggested fix
-	// After the check (whose own metadata write forgets older entries), remember these slices.
-	{
+	// Only reset metadata can safely prove that these slices have no pending clear.
+	if (reset) {
 		std::scoped_lock lock {m_checked_color_meta_lock};
 		if (m_checked_color_meta.size() > 65536) {
 			m_checked_color_meta.clear();
@@
 			checked.codes |= code_mask;
 		}
 	}
**@⁠coderabbitai[bot]** on GitHub · 2026-10-22 05:47 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1819#discussion_r4344963379) <!-- coderabbit-ai-generated:v1 --> **🎯 Functional Correctness** | **🟡 Minor** | **⚡ Quick win** <details> <summary>🔎 Supported by static analysis</summary> 🏁 Script executed: ```bash #!/bin/bash rg -nP -C4 'MaterializeColorClear\(|m_checked_color_meta|BindingType::VideoOut' src/graphics/host_gpu/renderer/cache/textureCache.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 6028 --- 🏁 Script executed: ```bash #!/bin/bash set -e printf '%s\n' '--- checked-cache declarations and callers ---' rg -n -F --glob '*.{cpp,h,hpp}' -e 'ForgetColorMetaChecks' -e 'm_checked_color_meta' -e 'MaterializeColorClearOnGpu' src/graphics/host_gpu/renderer/cache src/graphics/host_gpu/renderer printf '%s\n' '--- image lookup/recreation and binding paths ---' sed -n '560,730p' src/graphics/host_gpu/renderer/cache/textureCache.cpp sed -n '1000,1165p' src/graphics/host_gpu/renderer/cache/textureCache.cpp sed -n '1165,1300p' src/graphics/host_gpu/renderer/cache/textureCache.cpp printf '%s\n' '--- relevant declarations ---' rg -n -C4 -F --glob '*.{h,hpp}' -e 'GetImage' -e 'FindImage' -e 'CreateImage' -e 'MaterializeColorClear' src/graphics/host_gpu/renderer/cache ``` Repository: KytyPS5/KytyPS5 Length of output: 29875 --- 🏁 Script executed: ```bash #!/bin/bash set -e printf '%s\n' '--- buffer invalidation ---' sed -n '470,545p' src/graphics/host_gpu/renderer/cache/bufferCache.cpp printf '%s\n' '--- image lookup/update/bind flow ---' rg -n -F -- 'ImageId TextureCache::FindImage' 'ImageId TextureCache::UpdateImage' 'MaterializeColorClear(result' src/graphics/host_gpu/renderer/cache/textureCache.cpp sed -n '320,560p' src/graphics/host_gpu/renderer/cache/textureCache.cpp sed -n '1360,1485p' src/graphics/host_gpu/renderer/cache/textureCache.cpp printf '%s\n' '--- all metadata invalidation callers in buffer cache ---' rg -n -C8 -F -- 'InvalidateMemory(' src/graphics/host_gpu/renderer/cache/bufferCache.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 3678 --- 🏁 Script executed: ```bash #!/bin/bash set -e printf '%s\n' '--- FindImage and range lookup ---' sed -n '1335,1515p' src/graphics/host_gpu/renderer/cache/textureCache.cpp printf '%s\n' '--- InvalidateMemory definition and callers ---' rg -n -F -- 'void BufferCache::InvalidateMemory' src/graphics/host_gpu/renderer/cache/bufferCache.cpp rg -n -F -- 'InvalidateMemory(' src/graphics/host_gpu/renderer/cache/bufferCache.cpp printf '%s\n' '--- surrounding invalidation implementation ---' line=$(rg -n -F -- 'void BufferCache::InvalidateMemory' src/graphics/host_gpu/renderer/cache/bufferCache.cpp | cut -d: -f1) if [ -n "$line" ]; then start=$((line-8)); end=$((line+55)) sed -n "${start},${end}p" src/graphics/host_gpu/renderer/cache/bufferCache.cpp fi ``` Repository: KytyPS5/KytyPS5 Length of output: 8653 --- 🏁 Script executed: ```bash #!/bin/bash set -e printf '%s\n' '--- overlap resolution and image lifetime ---' rg -n -F -- 'TextureCache::ResolveOverlap' src/graphics/host_gpu/renderer/cache/textureCache.cpp rg -n -F -- 'TextureCache::InsertImage' src/graphics/host_gpu/renderer/cache/textureCache.cpp rg -n -F -- 'TextureCache::FreeImage' src/graphics/host_gpu/renderer/cache/textureCache.cpp line=$(rg -n -F -- 'TextureCache::ResolveOverlap' src/graphics/host_gpu/renderer/cache/textureCache.cpp | cut -d: -f1) if [ -n "$line" ]; then sed -n "$((line-15)),$((line+180))p" src/graphics/host_gpu/renderer/cache/textureCache.cpp; fi printf '%s\n' '--- VideoOut and metadata write paths ---' rg -n -P -C5 'BindingType::VideoOut|VideoOutCompression|ObtainBuffer\\([^\\n]*true|MarkGpuModified|CommitGpuWrite' src/graphics/host_gpu/renderer/cache src/graphics/host_gpu/renderer | head -n 320 printf '%s\n' '--- conditional-clear test references ---' rg -n -P -C5 'CheckColorClearCheck|VideoOut' tests src | head -n 240 ``` Repository: KytyPS5/KytyPS5 Length of output: 28303 --- </details> **Do not cache checked metadata for `VideoOut`.** `VideoOut` keeps its metadata code, but the current cache records it as checked. If `FindImage` creates a replacement image with the same metadata range, `all_checked` can return before the replacement receives the clear. Cache entries only when the check resets the metadata. <details> <summary>🐛 Suggested fix</summary> ```diff - // After the check (whose own metadata write forgets older entries), remember these slices. - { + // Only reset metadata can safely prove that these slices have no pending clear. + if (reset) { std::scoped_lock lock {m_checked_color_meta_lock}; if (m_checked_color_meta.size() > 65536) { m_checked_color_meta.clear(); @@ checked.codes |= code_mask; } } ``` </details> <!-- fingerprinting:phantom:medusa:beignet55 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:4b17a394177d6b98cc02c9f0 --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

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

Actionable comments posted: 1

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

5406-5406: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy lift

Exercise invalidation through BufferCache::ObtainBuffer.

CheckColorClearCheck calls TextureCache::ForgetColorMetaChecks directly. Its overlap assertion can pass even if BufferCache::ObtainBuffer stops invalidating checked metadata for is_written requests. Use a mapped buffer fixture and issue an overlapping write through context.GetBufferCache().ObtainBuffer(..., true, ...), then keep the assertion that only the overlapping entry was removed.


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f3c6ca8e-8e78-48d2-ae37-6858b2043ff1
📥 Commits

Reviewing files that changed from the base of the PR and between c5016d9455 and c6f26c1201.

📒 Files selected for processing: 10
  • CMakeLists.txt
  • src/graphics/host_gpu/graphicContext.h
  • src/graphics/host_gpu/renderer/cache/bufferCache.cpp
  • src/graphics/host_gpu/renderer/cache/colorClearCheck.cpp
  • src/graphics/host_gpu/renderer/cache/colorClearCheck.h
  • src/graphics/host_gpu/renderer/cache/textureCache.cpp
  • src/graphics/host_gpu/renderer/cache/textureCache.h
  • src/graphics/host_gpu/shaders/color_clear_check.comp
  • src/graphics/presentation/window/vulkanWindow.cpp
  • tests/ShaderRecompilerComputeTests.cpp

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

**@⁠coderabbitai[bot]** on GitHub · 2026-10-22 05:47 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1819#pullrequestreview-5609774805) · **reviewed** <!-- coderabbit-ai-generated:v1 --> **Actionable comments posted: 1** <details> <summary>🧹 Nitpick comments: 1</summary><blockquote> <details> <summary>tests/ShaderRecompilerComputeTests.cpp: 1</summary><blockquote> `5406-5406`: **📐 Maintainability & Code Quality** | **🔵 Trivial** | **🏗️ Heavy lift** **Exercise invalidation through `BufferCache::ObtainBuffer`.** `CheckColorClearCheck` calls `TextureCache::ForgetColorMetaChecks` directly. Its overlap assertion can pass even if `BufferCache::ObtainBuffer` stops invalidating checked metadata for `is_written` requests. Use a mapped buffer fixture and issue an overlapping write through `context.GetBufferCache().ObtainBuffer(..., true, ...)`, then keep the assertion that only the overlapping entry was removed. <!-- cr-comment:v1:68e87abc816d537c795958a2 --> </blockquote></details> </blockquote></details> --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `f3c6ca8e-8e78-48d2-ae37-6858b2043ff1` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between c5016d9455fe52bdd090cef7d80beb15fad6a3a5 and c6f26c12013b4d5c42c654981943ac7615837938. </details> <details> <summary>📒 Files selected for processing: 10</summary> * `CMakeLists.txt` * `src/graphics/host_gpu/graphicContext.h` * `src/graphics/host_gpu/renderer/cache/bufferCache.cpp` * `src/graphics/host_gpu/renderer/cache/colorClearCheck.cpp` * `src/graphics/host_gpu/renderer/cache/colorClearCheck.h` * `src/graphics/host_gpu/renderer/cache/textureCache.cpp` * `src/graphics/host_gpu/renderer/cache/textureCache.h` * `src/graphics/host_gpu/shaders/color_clear_check.comp` * `src/graphics/presentation/window/vulkanWindow.cpp` * `tests/ShaderRecompilerComputeTests.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=205a2199-5fd1-4060-909a-6bf2de521861 attempt=6c3354f5-a770-4ed3-8d77-b40ff9392896 batch=1/1 -->
Author
Owner

@⁠Nmzik on GitHub · 2026-10-22 14:14 UTC · original

@⁠MrBigBritches Thanks! Sole authored & pushed to main b54057942d

**@⁠Nmzik** on GitHub · 2026-10-22 14:14 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1819#issuecomment-6342940377) @⁠MrBigBritches Thanks! Sole authored & pushed to main b54057942d6bb65e93969c78e79b5de0e9aa4514

Pull request closed

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