graphics: find stencil associations without scanning every image #1388
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!1388
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1388/head"
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?
@overlordxrz-source on GitHub · 2026-10-10 22:40 UTC · original
overlordxrz-source:gtav/stencil-associations→main· +22 −7 · 2 files · 2 commits · closed without mergingGame
Grand Theft Auto V (PPSA04263 / PPSA04264).
Problem
GTA V gets slower the longer a session runs. Players on main report it "laggy when in open world" (#888) and "minor stutters, lags and fps drops" (#971). One cause: deleting a depth image looked for the stencil-association images pointing at it by walking every slot of the texture cache (
TextureCache::DeleteImage, them_slot_images.ForEachscan). GTA V deletes a few images per frame while it streams Los Santos, and the cache holds thousands of images after a while (8000 after 25 minutes). So each deletion gets more expensive as the session goes on: 15 µs per deletion at the start, 60 µs after 12 minutes.Change
AssociateStencil()records each association in a per-depth-image map (m_stencil_associations).DeleteImage()reads that map instead of scanning every image.DeleteImage()therefore still checksassociated->depth_id == idbefore freeing, as the scan did, so the set of images freed is unchanged.textureCache.{h,cpp}. No behaviour change beyond the lookup.Evidence
Validation
947627d10. Main'sAssociateStencil()now rebuilds the stencil plane when the association changes, so the map update is placed in front of that block.textureCache.cppcompiles for x86_64-linux-gnu (zig 0.17 clang,-std=c++20 -Wall -Wextra, no new warnings).Credit
Ported from TheCruZ/KytyPS5-GTA dec15d520 with his permission (#1241). Co-authored-by: TheCruZ.
AI-assisted: yes.
@coderabbitai[bot] on GitHub · 2026-10-10 22:44 UTC · original · edited 2026-10-11 15:46 UTC
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
da745208-d33c-4775-bc98-099f80034556📥 Commits
Reviewing files that changed from the base of the PR and between
54b2a07824and8f78f6b402.📒 Files selected for processing (1)
src/graphics/host_gpu/renderer/cache/textureCache.hIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.
📝 Walkthrough
Walkthrough
TextureCacheadds an index from depth-image IDs to associated stencil-image IDs.AssociateStencilprunes stale or reassigned entries before recording an association.DeleteImageuses the index to find associated images and frees only images that still reference the deleted depth image.Suggested reviewers:
nmzikPriority: ➖ Normal
Change: Refactor
Merge Risk: ⚪ Minimal · up to
8f78fStencil-image cleanup validates indexed entries against current image state. No merge-blocking risk is established by the reviewed change.
Pre-merge checks |
4 |
1
❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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.@overlordxrz-source on GitHub · 2026-10-16 18:52 UTC · original
Closing as superseded by
f4692a450, which removes the full-cache scan in DeleteImage with per-depth stencil_ids (thanks for carrying the co-authorship).Pull request closed