renderer: apply fast clears to texture views and metadata-only fills #1200
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!1200
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1200"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@NeySlim on GitHub · 2026-10-08 10:10 UTC · original
NeySlim:fix/metadata-clear-texture-view→main· +339 −12 · 7 files · 10 commits · openProblem
Kyty materializes a CMASK/DCC fast clear only when the target is bound as a color target for a draw. Two patterns in God of War Ragnarök (PPSA08332, 05.005) never get there:
CB_COLORn_*for it, and never draws into it before reading it as a texture.In both cases the compute shader reads stale contents (the output of an unrelated pass from the previous frame) as distortion vectors, displaces the scene by up to 1280 px per pixel, and characters turn into a grainy cloud.
Change
MaterializeColorClearalso handles texture and storage views of an image whose last color-target binding recorded metadata and clear registers. The clear is decoded through the target's format (ImageMetadataInfo::clear_format), not the view's.RebindImagescallsMaterializeViewClearfor cached texture bindings, so a clear that arrives after the lookup is still seen.DecodePackedColorClearalso decodesR16G16B16A16_UNORMandR32G32_UINTregister clears from both clear words. This is what was left of #1188; the rest of it landed in31b7be9fand3c9da9c3.Test
RenderExecutorColorMetadataCleargains checks: a texture view (with or without metadata) of a fast-cleared target reads the clear color, also through a cached binding and through a view in another format; a metadata-less rebind forgets the old clear; a metadata fill by a direct or indirect dispatch clears a programmed target without a draw, including two slots sharing one CMASK;R16G16B16A16_UNORMandR32G32_UINTregister clears keep both words. Each fails when the corresponding part of the change is removed.Validation
Linux, AMD Radeon 8060S, Mesa RADV 26.2.3, rebased on
9e41d832.RenderExecutorColorMetadataClearand the CPU suites pass.shader_recompiler_compute_testsone case per process gives the same results as main (627 of 637; the same 10 fail on main on this setup).Not measured precisely: the cost of reading back the CMASK once per frame per matching target. Not tested on Windows/macOS (platform-independent renderer code).
AI use
I used Claude Code (AI agent) to capture and analyze the frames in RenderDoc, trace the stale input back to the missing clears, write the change and the test, and run the tests above on my machine. I reviewed the diff and the results before opening this PR.
@coderabbitai[bot] on GitHub · 2026-10-08 10:15 UTC · original · edited 2026-10-19 04:36 UTC
📝 Walkthrough
Register-based color clears now decode both clear-register words for supported formats. TextureCache can materialize clears for existing views from matching cached color-target metadata. Compute dispatches track eligible written-buffer addresses and resolve matching color targets. Tests cover clear decoding, cached texture views, and repeated metadata fills.
Suggested reviewers:
nmzikPriority: ➖ Normal
Change: Bug fix
Merge Risk: 🟡 Moderate · up to
a7844The fix applies pending color clears only after direct compute dispatches. Indirect dispatches skip it, so a texture read after one may still show stale pixels. A target that shares its metadata address with another slot can also be missed. The new tests can pass without exercising some of the intended paths. Resolve or explicitly accept these gaps before merging.
Pre-merge checks:
4 ·
1
Full details: Docstring Coverage
Explanation
Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 20 functions across 7 files. (1 skipped: 1 too large.)
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 helpto get the list of available commands.@coderabbitai[bot] on GitHub · 2026-10-08 10:15 UTC · original · edited 2026-10-08 10:43 UTC
On
src/graphics/host_gpu/renderer/cache/textureCache.cppline 1166 (outdated):🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 21238
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 19729
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 21684
Validate the cached image layout before using its metadata.
FindImagecan reuse a cached image with more mip levels or layers thandesc, andResolveOverlapcan reuse one with a larger data range. The texture/storage path then uses the cachedmetadata.rangebut divides it bydesc.info.TransferLayers(). This can produce an invalid metadata slice size, reach the alignment or boundsEXIT, or clear the wrong slices.Require the cached image to have one mip, the same data size, and the same layer count:
Proposed guard
📝 Committable suggestion
✅ Confirmed as addressed by @NeySlim
@ -827,2 +827,4 @@BindImage(images[i].image_id,images[i].desc.type == TextureCache::BindingType::Storage);} else {texture_cache.MaterializeViewClear(images[i].image_id, images[i].desc);@coderabbitai[bot] on GitHub · 2026-10-08 10:15 UTC · original · edited 2026-10-08 10:43 UTC
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 14168
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 5226
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 7911
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 23590
Preserve target metadata for cached DCC views.
FindImagedoes not change the descriptor type or metadata kind. A cached texture view can therefore reachMaterializeColorClearwith DCC metadata and a texture or storage binding. The currentfrom_targetbranch replaces the cached target metadata and does not setclear_desc.typetoRenderTarget.DecodeColorClearthen rejects register clears, so the view can retain stale pixels.Treat DCC metadata as
from_targetonly for aRenderTargetdescriptor. This preserves the cached target metadata for texture and storage views and uses the existingRenderTargetconversion path.🐛 Suggested fix
Add a focused regression test for a cached DCC view after a target fast clear.
✅ Addressed in commit 322e6f3
@coderabbitai[bot] on GitHub · 2026-10-08 10:15 UTC · original · edited 2026-10-08 10:42 UTC
On
src/graphics/host_gpu/renderer/renderCompute.cppline 465 (outdated):🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Keep pending CMASK addresses until the target can use them.
If
cmask_fast_clear_enableis set on a multisampled target, this check accepts the target and Line 465 removes its pending address. The color-target resolver accepts CMASK metadata only for a single-sample target with FMASK compression and VRS-to-CMASK disabled. In that state,ResolveRenderColorTargetcannot attach the rewritten CMASK metadata, but the pending fill is lost. Match the resolver’s CMASK eligibility before erasing the address, or retain the address when resolution does not consume the metadata. citenone✅ Addressed in commit 322e6f3
@coderabbitai[bot] on GitHub · 2026-10-08 10:15 UTC · original · reviewed
Actionable comments posted: 3
ℹ️ Review info
⚙️ Run configuration
74372638-44ae-44fc-bfd3-342418c9f373📥 Commits
Reviewing files that changed from the base of the PR and between
5a8808086aand 76399168e8afee3323f203e5ace3e57b397e368e.📒 Files selected for processing (8)
src/graphics/host_gpu/renderer/cache/textureCache.cppsrc/graphics/host_gpu/renderer/cache/textureCache.hsrc/graphics/host_gpu/renderer/colorRenderTarget.cppsrc/graphics/host_gpu/renderer/image/imageInfo.hsrc/graphics/host_gpu/renderer/pipeline/descriptors.cppsrc/graphics/host_gpu/renderer/render.hsrc/graphics/host_gpu/renderer/renderCompute.cpptests/ShaderRecompilerComputeTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.
@NeySlim on GitHub · 2026-10-08 10:38 UTC · original
On
src/graphics/host_gpu/renderer/cache/textureCache.cppline 1166 (outdated):Agreed, fixed in 322e6f3. The texture/storage path now uses the cached target metadata only when the cached image has one mip, the same data range and the same layer count as the view, and is not a volume. Anything else keeps the previous behavior.
@ -827,2 +827,4 @@BindImage(images[i].image_id,images[i].desc.type == TextureCache::BindingType::Storage);} else {texture_cache.MaterializeViewClear(images[i].image_id, images[i].desc);@NeySlim on GitHub · 2026-10-08 10:38 UTC · original
Agreed, fixed in 322e6f3. For texture and storage views, the target's recorded metadata and clear registers now take precedence over the view's own DCC/CMASK metadata, and the decode goes through the
RenderTargetpath. The view's metadata no longer overwrites the target's, andclear_formatis only recorded from a color-target binding. New check inRenderExecutorColorMetadataClear, "metadata texture view sees target clear": a texture view carrying the target's metadata without clear registers, with the target unprogrammed during the fill so only the view can apply the clear. It fails without the change.@NeySlim on GitHub · 2026-10-08 10:39 UTC · original
On
src/graphics/host_gpu/renderer/renderCompute.cppline 465 (outdated):Agreed, fixed in 322e6f3.
ResolvePendingMetaClearsnow uses the same eligibility asResolveRenderColorTarget(DCC with an address, or CMASK only for a single-sample target without FMASK compression or VRS-to-CMASK) and keeps the pending address otherwise.@coderabbitai[bot] on GitHub · 2026-10-08 10:43 UTC · original
On
src/graphics/host_gpu/renderer/cache/textureCache.cppline 1166 (outdated):@NeySlimThanks for the fix in322e6f3. The updated guards address the cached metadata layout mismatch.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-08 10:43 UTC · original
On
src/graphics/host_gpu/renderer/renderCompute.cppline 465 (outdated):@NeySlim, thanks for the fix. The updatedResolvePendingMetaClearschecks metadata eligibility before erasing the pending address. Ineligible targets retain the pending address, which addresses this finding.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.
@ -827,2 +827,4 @@BindImage(images[i].image_id,images[i].desc.type == TextureCache::BindingType::Storage);} else {texture_cache.MaterializeViewClear(images[i].image_id, images[i].desc);@coderabbitai[bot] on GitHub · 2026-10-08 10:43 UTC · original
@NeySlim, thanks for the fix and clarification. The change in322e6f3addresses the metadata precedence andRenderTargetdecode concerns. The regression check covers a metadata-bearing texture view when the target is unprogrammed.✏️ Learnings added
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-08 13:19 UTC · original · edited 2026-10-08 13:25 UTC
On
src/graphics/host_gpu/renderer/cache/textureCache.cppline 1149 (outdated):🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Clear cached metadata when a render target has no color metadata.
If a cached render target is rebound without DCC or CMASK,
desc_metadatais false. The early return leaves the previousimage.info.metadataand its valid clear registers in place. A later texture view can select that stale target metadata and clear the native image from old metadata bytes. Update the cached metadata for a metadata-less render-target binding before returning.✅ Confirmed as addressed by @NeySlim
@coderabbitai[bot] on GitHub · 2026-10-08 13:19 UTC · original · reviewed
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
3b5d183b-6266-4a76-aa5a-75efad187dd8📥 Commits
Reviewing files that changed from the base of the PR and between 322e6f3b6b59be12a43e3a201c09105b009c3e48 and e5a64a5973b701802e284597fd88b9ba35775b9b.
📒 Files selected for processing (1)
src/graphics/host_gpu/renderer/cache/textureCache.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
@NeySlim on GitHub · 2026-10-08 13:25 UTC · original
On
src/graphics/host_gpu/renderer/cache/textureCache.cppline 1149 (outdated):Agreed, fixed in 9b6c9ba: a render-target binding without color metadata now drops the previous DCC/CMASK metadata and clear registers before the early return. New check in
RenderExecutorColorMetadataClear, "metadata-less rebind forgets the clear": fresh clear keys, a metadata-less rebind, drawn texels, then a texture view must keep them. It fails without the change.@coderabbitai[bot] on GitHub · 2026-10-08 13:25 UTC · original
On
src/graphics/host_gpu/renderer/cache/textureCache.cppline 1149 (outdated):@NeySlim, thanks for the fix. The supplied code drops the cached DCC/CMASK metadata and clear registers before the early return. The reported regression check covers the stale-clear sequence that triggered this finding.🧠 Learnings used
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.
@NeySlim on GitHub · 2026-10-09 19:53 UTC · original
Rebased on main (
59183dbf) together with #1188. The only conflict was an include inrenderCompute.cppthat main removed. Rechecked each part againstRenderExecutorColorMetadataClear: removing the texture-view path, the pending metadata fills, or the metadata-less rebind reset each makes it fail. Full GPU suite, one case per process: 602/612, same as main.@ -458,0 +474,4 @@const auto d = DecodeNativeDescriptor<ShaderBufferResource>(resources.buffers[i]);if (d.Base48() != 0 && d.GetSize() <= 0x40000) m_pending_meta_fills.insert(d.Base48());}ResolvePendingMetaClears(buffer);@coderabbitai[bot] on GitHub · 2026-10-09 19:57 UTC · original · edited 2026-10-09 20:47 UTC
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
Track metadata writes from indirect dispatches.
If
DispatchIndirectfills DCC or CMASK through a written buffer, it does not add that buffer address tom_pending_meta_fills. Its path at Lines 481-539 also does not callResolvePendingMetaClears. A later texture read can therefore observe the unmaterialized clear. Apply the same eligible-write tracking and resolution to indirect dispatches.✅ Addressed in commits 7afa1ef to 4d58b55
@coderabbitai[bot] on GitHub · 2026-10-09 19:57 UTC · original · edited 2026-10-09 20:47 UTC
On
src/graphics/host_gpu/renderer/renderCompute.cppline 477 (outdated):🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Resolve every slot that matches a pending address.
If two programmed color slots use the same DCC or CMASK address,
erasesucceeds for the first slot only. The second slot is skipped, even if it names a different image or layer that also needs resolution. Keep the address available throughout this scan, then remove it after all matching slots have been resolved.✅ Addressed in commits 7afa1ef to 4d58b55
@coderabbitai[bot] on GitHub · 2026-10-09 19:57 UTC · original · edited 2026-10-09 20:47 UTC
On
tests/ShaderRecompilerComputeTests.cppline 10862 (outdated):🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Keep the target unprogrammed during the metadata fill.
The target is still programmed when
fill_metadata()runs. The new dispatch path can resolve that target beforeFindTexture()runs. This check can therefore pass even if a metadata-less texture view fails to materialize the clear. Set the color base to zero for the fill, then restore it before acquiring the view.✅ Addressed in commits 7afa1ef to 4d58b55
@coderabbitai[bot] on GitHub · 2026-10-09 19:57 UTC · original · edited 2026-10-09 20:47 UTC
On
tests/ShaderRecompilerComputeTests.cppline 10922 (outdated):🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Check every painted texel after the metadata-less rebind.
retains_painted_texel()succeeds when just one texel still has the painted value. A stale clear that changes the rest of the selected layer would pass this new check. Compare the complete selected layer with the repeatedpaintedvalue.✅ Addressed in commits 7afa1ef to 4d58b55
@ -12058,0 +12207,4 @@RenderExecutorTestAccess::ResetBindings(executor);fill_metadata(metadata_words);Require(name, "metadata fill clears without a draw",read_texel() == expected,@coderabbitai[bot] on GitHub · 2026-10-09 19:57 UTC · original · edited 2026-10-09 20:47 UTC
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Check the first metadata fill before the second dispatch.
The assertion runs only after two fills. It can pass if the first dispatch leaves painted texels and the second dispatch resolves them. Add a separate first-fill readback, then repaint before the existing two-dispatch check so that the latter still tests consecutive dispatches without an intervening readback.
✅ Addressed in commits 7afa1ef to 4d58b55
@coderabbitai[bot] on GitHub · 2026-10-09 19:57 UTC · original · reviewed
Actionable comments posted: 5
ℹ️ Review info
⚙️ Run configuration
4d53f7fa-7982-45e5-9cc3-d443a879719a📥 Commits
Reviewing files that changed from the base of the PR and between 9b6c9baf40683cd05c02f1c628465cb129f3bae9 and a7844441e50bddcf648caecc48e5fa890a32db3f.
📒 Files selected for processing (5)
src/graphics/host_gpu/renderer/cache/textureCache.hsrc/graphics/host_gpu/renderer/pipeline/descriptors.cppsrc/graphics/host_gpu/renderer/render.hsrc/graphics/host_gpu/renderer/renderCompute.cpptests/ShaderRecompilerComputeTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 3 remain after this review.
@ -458,0 +474,4 @@const auto d = DecodeNativeDescriptor<ShaderBufferResource>(resources.buffers[i]);if (d.Base48() != 0 && d.GetSize() <= 0x40000) m_pending_meta_fills.insert(d.Base48());}ResolvePendingMetaClears(buffer);@NeySlim on GitHub · 2026-10-09 20:46 UTC · original
Agreed, fixed in 7afa1ef.
DispatchIndirectnow resolves pending fills before the dispatch and records its written buffers after it, through the sameTrackMetaFillshelper asDispatchDirect. New check "indirect metadata fill clears" fails without it.@NeySlim on GitHub · 2026-10-09 20:46 UTC · original
On
src/graphics/host_gpu/renderer/renderCompute.cppline 477 (outdated):Agreed, fixed in 7afa1ef. Matching addresses are collected during the scan and erased after it, so every slot naming the address is resolved. New check "shared metadata clears every slot" (two slots on different layers of one CMASK) fails without it.
@NeySlim on GitHub · 2026-10-09 20:46 UTC · original
On
tests/ShaderRecompilerComputeTests.cppline 10862 (outdated):Agreed, fixed in 7afa1ef. The target is now unprogrammed during the fill, and the check fails when the texture view path is disabled. This also showed that the view path does not apply to a cached mip chain (the one-mip guard from the earlier review), so that case skips this check.
@NeySlim on GitHub · 2026-10-09 20:46 UTC · original
On
tests/ShaderRecompilerComputeTests.cppline 10922 (outdated):Agreed, fixed in 7afa1ef: the check now compares every texel of the selected layer with the painted value.
@ -12058,0 +12207,4 @@RenderExecutorTestAccess::ResetBindings(executor);fill_metadata(metadata_words);Require(name, "metadata fill clears without a draw",read_texel() == expected,@NeySlim on GitHub · 2026-10-09 20:46 UTC · original
Agreed, fixed in 7afa1ef. A single fill is checked first, then the target is repainted before the two-dispatch check. The single-fill check fails without the post-dispatch resolve.
@coderabbitai[bot] on GitHub · 2026-10-09 20:47 UTC · original
On
src/graphics/host_gpu/renderer/renderCompute.cppline 477 (outdated):@NeySlim, thanks for the fix. The updated scan resolves every matching slot before it erases the shared metadata address. The new “shared metadata clears every slot” check covers the reported case.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.
@ -12058,0 +12207,4 @@RenderExecutorTestAccess::ResetBindings(executor);fill_metadata(metadata_words);Require(name, "metadata fill clears without a draw",read_texel() == expected,@coderabbitai[bot] on GitHub · 2026-10-09 20:47 UTC · original
@NeySlimThanks for the fix in7afa1ef. The single-fill check covers the first dispatch. Repainting preserves the separate two-dispatch check without an intervening readback.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.
@ -458,0 +474,4 @@const auto d = DecodeNativeDescriptor<ShaderBufferResource>(resources.buffers[i]);if (d.Base48() != 0 && d.GetSize() <= 0x40000) m_pending_meta_fills.insert(d.Base48());}ResolvePendingMetaClears(buffer);@coderabbitai[bot] on GitHub · 2026-10-09 20:47 UTC · original
@NeySlim, thanks for the fix. The supplied code confirms thatDispatchIndirectresolves pending fills before dispatch and tracks written buffers afterward throughTrackMetaFills, matchingDispatchDirect.🧠 Learnings used
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-09 20:47 UTC · original
On
tests/ShaderRecompilerComputeTests.cppline 10862 (outdated):@NeySlimThanks for the fix and clarification. Leaving the target unprogrammed during the fill isolates the texture-view path. The reported failure with that path disabled confirms the check covers it. Skipping cached mip chains matches the one-mip guard.✏️ Learnings added
🧠 Learnings used
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-09 20:47 UTC · original
On
tests/ShaderRecompilerComputeTests.cppline 10922 (outdated):@NeySlimThanks for fixing this. Comparing every texel of the selected layer with the painted value addresses the incomplete check.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.
@NeySlim on GitHub · 2026-10-14 07:04 UTC · original
Rebased on main and folded in what was left of #1188 (R16G16B16A16_UNORM and R32G32_UINT register clears); the rest of #1188 landed in
31b7be9fand3c9da9c3. Also added checks for a clear seen through a cached texture binding and through a view in another format.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.Merge
Merge the changes and update on Forgejo.