renderer: do not adopt a depth image as a stencil association #1751
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!1751
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1751"
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?
@0xcrstn on GitHub · 2026-10-20 04:21 UTC · original
0xcrstn:fix/ufc6-slot-freed→main· +67 −1 · 2 files · 1 commits · openGame and problem
EA SPORTS UFC 6 (PPSA23566, 01.004.000), Windows 11, RTX 5090 (driver 617.42). After a few minutes in the menus (main menu, Fight Now, Select Corner, fighter select, back and forth) Kyty exits with
condition (!is_allocated(id)) is true in slotVector.h:41. Seen on several builds, after 6 to 8 minutes. The game reaches this point with #1738 applied; the bug is inmain.Cause
The host backtrace goes
TextureCache::DeleteImage<-ResolveOverlap(one run) or <-TextureCache::UnmapMemory(another run). In both, the failing access ism_slot_images[image->depth_id]: a registered stencil association whose depth owner's slot has already been erased.I logged
AssociateStencilandDeleteImage. In the crashing run:Small tiled depth and stencil planes are one 64 KiB block each (
TileGetDepthSize(32, 32, ...)gives 0x10000 for both), so a pooled depth surface can sit exactly on another target's stencil plane.AssociateStencilreuses any image with the same range and extent, so it turned the depth image into an S8 stencil record (inforeplaced,depth_idset) and kept itsstencil_ids.DeleteImagefreesstencil_idsonly for images withoutdepth_id, so deleting the adopted image leaves its old association registered with adepth_idthat is erased afterwards. The next deletion of that association indexes the erased slot.Change
AssociateStencilno longer reuses an image thatIsDepth(); it inserts a separate association instead, as it already does when the extent differs. One condition intextureCache.cpp.This also removes an HTile side effect with #1743 applied. There,
DeleteImagedrops a surface's HTile clear state (them_surface_metasentries whosedepth_addressis the image's address) only for an image thatIsDepth()and has nodepth_id. An adopted depth image has itsinforeplaced by the S8 plane anddepth_idset, so deleting it would have left those entries behind.Not changed: the depth image and the new association now both cover the stencil range, and stencil writes do not invalidate the depth image. This is the same coexistence
AssociateStencilalready has with other images at a reused stencil range (see the existing "stencil address reuse preserves color" check). A CPU read of that range could still publish the stale depth image instead of the stencil. I have not seen that happen in UFC 6.Also a consequence of the two images at one range: a compute fill of that stencil plane is no longer turned into a native stencil clear.
ClearImageFromBuffersees two owners and returns false, so the shader's own dispatch runs, as it already does for other ambiguous ranges. I have not checked that the cached stencil picks up a fill made that way.Testing
CheckUnifiedTextureCacheFlow(--htile-clear-only) gets a case where a depth image's range equals another depth target's stencil range (same extent). The case also checks that small depth and stencil footprints are both 0x10000. Onmainit fails with "a depth image was adopted as another target's stencil association". With that check disabled, the rest of the case (unmap the depth range, flush, unmap its stencil range) exits with the sameslotVector.h:41error and exit code as the game. With the change, both checks pass.shader_recompiler_compute_tests: all cases pass on this branch rebased ontomain1a053f9e(Windows, clang-cl, RTX 5090). The Claude, Codex and CodeRabbit reviews ran on the same commit before the rebase (98e6912b onf186b357);git range-diffshows the commit unchanged.--redzone, my main-menu save. Without this change, the menu loop above exited withslotVector.h:41after 356 s on one build and after about 7 minutes on another (the logged run above).f186b357+ #1738 + #1748 + #1743 + this branch), same menu loop plus a local fight: noslotVector.h:41for 856 s. That run then ended in a separate, known crash inPthreadGetprio(a joined thread's stale winpthread handle), which is being fixed separately.slotVector.h:41.AI use
Claude Code did the investigation (rebuilt the crashing commit to map the backtrace to the failing access, added diagnostic logging, analysed the play-run log), wrote the change and the test, ran the tests, and ran the Claude, Codex and CodeRabbit reviews. CodeRabbit found nothing. Codex's finding is the stale-depth point under "Not changed". I reviewed the evidence and the change and played the game for the diagnostic run.
🤖 Generated with Claude Code
@coderabbitai[bot] on GitHub · 2026-10-20 04:24 UTC · original
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
feae1a10-d7b2-4a06-95c2-3feb0b5bb6d8📥 Commits
Reviewing files that changed from the base of the PR and between
1a053f9e13andbd50bc74fb.📒 Files selected for processing: 2
src/graphics/host_gpu/renderer/cache/textureCache.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.
📝 Walkthrough
AssociateStencilnow excludes depth-image candidates when it reuses a stencil association. The regression test covers overlapping depth and stencil ranges, verifies that each depth target retains the expected association, and checks that unmapping removes the orphaned association without removing the second depth target.Suggested reviewers:
nmzikPriority: ⬆️ High
Change: Bug fix
Merge Risk: ⚪ Minimal · up to
bd50bThe change prevents a depth image from being adopted as a stencil association, which caused the reported orphaned-slot exit. No actionable merge-blocking risk was found in the supplied context.
Pre-merge checks:
4 ·
1
Full details: Docstring Coverage
Explanation
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. (1 skipped: 1 too large.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
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.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.