texture cache: queue a heap change when a stencil association adopts an image #2407
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!2407
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2407"
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?
@Mcm190 on GitHub · 2026-11-19 12:17 UTC · original
Mcm190:texture-cache-stencil-heap-change→main· +50 −0 · 2 files · 1 commits · openFixes #2297.
Problem
TextureCache::AssociateStencilcan reuse any registered image whose range and extent match the stencil memory, for example an R8 texture that a resident image heap sampled before the depth image was associated. It then rewritesrecord.infoand setsrecord.depth_idwithout callingHeapChanged(). The heap keeps sampling the old R8 backing while stencil writes go to the depth image, until some other change of that record queues it.Change
AssociateStencilcallsrecord.HeapChanged()right before the rewrite. The record'sheap_refsstill belong to the pinned image, so the change is queued. For an image no heap references (a stencil plane that was just inserted, or one found byFindStencilPlane),HeapChanged()does nothing.Tests
shader_recompiler_compute_tests --image-overlap-only,UnifiedTextureCacheFlow, two new checks: an R8 image that exactly matches a stencil range and extent, with a heap reference held, is adopted as the depth target's stencil plane ("stencil plane adopts an exact R8 image"), and the adoption queues exactly one heap change for that image ("adopted stencil plane queues a heap change"). The test removes its heap reference and queued changes afterwards.On an RX 9070 XT (Linux, RADV, clang), the harness does not reach these checks as written: device setup needs the relaxed robustness check from #2036, and
UnifiedTextureCacheFlowthen stops earlier at a 2x D24S8 image (format=129) that RADV does not support. With the robustness check relaxed and a copy of the two checks run right after the flow's setup, they pass with this change and fail without it (failed at adopted stencil plane queues a heap change). The checks have not run in their place in the flow; CI is their first full run. Not tested in a game.AI Assistance: Claude Opus 5.5.
@coderabbitai[bot] on GitHub · 2026-11-19 12:22 UTC · original · edited 2026-11-20 06:13 UTC
No actionable comments were generated in the recent review.
Walkthrough
AssociateStencilnow callsrecord.HeapChanged()after linking an associated stencil record to the depth image. A new test checks exact-range R8 image lookup, thedepth_idassociation, and that heap-pinned adoption queues exactly one heap change.Suggested reviewers:
claxten10,thecruzChange: Bug fix · Severity of issue fixed: Medium
Merge Risk:
Minimal · up to
ef912This change queues a heap update when a stencil plane adopts a heap-pinned image, so the heap stops sampling the old backing. No concrete merge-blocking risk was found; CI will provide the first full run of the new test.
Pre-merge checks:
4
#2297requires a call to record.HeapChanged() before AssociateStencil rewrites record.info and record.depth_id for a registered image that a heap may pin. The whole-PR summary st…Full details: Title check
Explanation
The title names the main change: a stencil association that adopts a registered image now queues a heap change. It matches the code change, which adds a HeapChanged() call in AssociateStencil. The title is specific and concise.
Full details: Linked Issues check
Explanation
Directly linked issue
#2297requires a call to record.HeapChanged() before AssociateStencil rewrites record.info and record.depth_id for a registered image that a heap may pin. The whole-PR summary states that AssociateStencil now calls record.HeapChanged() when it updates the adopted image's plane metadata and ownership. The PR description gives the same mechanism: the call runs right before the rewrite, and the pinned image's heap_refs are queued. The requirement is a single coding change, and the summary shows it. Limits: the textureCache.cpp diff could not be read, and the file read was truncated before AssociateStencil. The exact placement is therefore confirmed only by the summary. That summary says the call runs after linking to the depth image, while the issue says right before the rewrite. The author's test results (failing without the change, passing with it) are reported, not verified here. The new tests ('stencil plane adopts an exact R8 image', 'adopted stencil plane queues a heap change') are consistent with the issue but were not run by this review.Full details: Out of Scope Changes check
Explanation
The change set consists of a small addition in TextureCache::AssociateStencil (summary: +3/-0, one HeapChanged() call) and a test addition in tests/ShaderRecompilerComputeTests.cpp (summary: +47/-0). The test checks the adoption of an exact-match R8 image and the queued heap change that
#2297describes. Both changes connect directly to#2297. No unrelated files or behavior changes appear in the supplied evidence. The unread diff remains a limit on this verdict: the review could not confirm the full set of changed files beyond the summary.Full details: Description check
Explanation
The description states the problem (AssociateStencil reuses a registered image and rewrites record.info and record.depth_id without calling HeapChanged()), the change (a HeapChanged() call before the rewrite), and the tests added (two new checks in UnifiedTextureCacheFlow). This matches the changeset, so the description is related to the changes and the check passes.
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
51591561-f54f-4319-9deb-4237ff18044aReviewing files that changed from the base of the PR and between
a90be8dd73and ef91293e9ffd3c728747c5bf4bc6a54aea2b0126.src/graphics/host_gpu/renderer/cache/textureCache.cpptests/ShaderRecompilerComputeTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.