graphics: share image heap elements between views of one profile (Ghost of Yōtei) #2090
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!2090
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2090/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?
@Nawid3333 on GitHub · 2026-11-04 01:21 UTC · original
Nawid3333:fix/image-heap-pools→main· +423 −82 · 3 files · 4 commits · closed without mergingSummary
Ghost of Yōtei (PPSA26344) stops with
image heaps exceed 65536 resident images(imageHeap.cpp:389) while it loads the world. A lab counter at that stop (Radeon RX 9070 XT, warm shader store) found 65535 referenced elements, but only 33822 distinct (profile, kind, descriptor) keys, behind 30613 distinct images.The heap keeps one element per view and descriptor (
Interninterns intoview.elements), and the game reads its tables through several views:first0, 32 and 64,step32) holds 3 × 3995 elements, and a second table of the same size at another base holds another 3 × 3995;Assassin's Creed Black Flag stops the same way: 8 views of one 14 MB table hold 59875 elements, about 7481 per view (posted on #1967).
An element's binding depends only on the view's profile, the element's kind and the descriptor value.
Rebindresolves every element withResolveTexture(IR::ImageHeapResource(profile, kind), value), andImageHeapResource(root, 0u)keeps only the dimension,unfiltered_access_only,depth_compareandr128. So views with the same profile can share elements.Change
Pool. The value-to-element map, the pending, released, held, DCC and away lists, and the resolve, layout and held epochs move fromViewtoPool.Element::refscounts the slots of all views of the pool.Dropreleases a table's slots one by one, since other views may select the same elements.Retirealso prunes freed indices frompending,dccandaway, because an index can now be reused by another view before the pool's next discovery.Burymarks the elements over unmapped memory (every element with references), then nulls only those, in every view.Tests
New
ImageHeapSharedElements(--image-heap-only, and in the indirect-image group next toResidentImageHeap). It checks that:first0 and 32, and a copy of the table at another base, select the same elements;On main it fails at "shifted view": the second view interns its descriptors again.
ResidentImageHeappasses unchanged.On a Radeon RX 9070 XT (AMD Windows driver 26.10.1), with #2038 (#2036), the indirect-image group gives the same results as on main. Both stop at
IndirectImageQueryDimensions, which fails on main too, and the rest of the group passes on both.Ghost of Yōtei, warm shader store, with #1967, #1758, #1878 and #2062 (needed to get this far):
Rebind105 µs per heap draw on main and 12 µs with this change, since there are fewer elements to scan and resolve.Fork CI builds pass on Linux, Windows and macOS (
e0a34f693).#1899 also changes
Acquire(itsrequires_materializationcheck), and #1961 changesRunGarbageCollector; neither touches the interning. #1495 changesAcquire,Intern,Bury,RetireandRebindtoo: it maps only the mapped prefix of a table and falls back to enumeration when the heap runs out of elements, still with elements per view. That fallback and this change don't replace each other, but the two touch the same lines.If you'd prefer another approach, for example sharing only within one table or keeping the lists per view, tell me and I'll change it.
Written with Claude Code (AI): it wrote the change and the tests, and ran the tests and the game runs on my PC (Windows 11, RX 9070 XT).
🤖 Generated with Claude Code
@coderabbitai[bot] on GitHub · 2026-11-04 01:25 UTC · original
No actionable comments were generated in the recent review.
Walkthrough
ImageHeap now shares descriptor elements and resolution state through pools keyed by resource profile. Views with the same profile use shared element allocation and lifecycle tracking. Rebind and Commit process active pools, and Bury clears slots that select elements overlapping unmapped ranges. New tests cover sharing, profile separation, element reuse, unmapping, burying, and table size changes.
Suggested reviewers:
nmzikChange: Bug fix
Merge Risk:
Minimal · up to
e0a34No confirmed issue currently blocks merging.
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 with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 10 functions across 2 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
a754588d-b335-44fb-acd8-20eb5cfd4c74Reviewing files that changed from the base of the PR and between
eecd982193ande0a34f693f.src/graphics/host_gpu/renderer/pipeline/imageHeap.cppsrc/graphics/host_gpu/renderer/pipeline/imageHeap.htests/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.
@Nawid3333 on GitHub · 2026-11-12 23:34 UTC · original
Game evidence: in #2204, Ben-Dash confirmed that with this PR, Ghost of Yōtei no longer stops at
image heaps exceed 65536 resident images(imageHeap.cpp:389): #2204The build offered to them was fork CI run https://github.com/Nawid3333/KytyPS5/actions/runs/43150025508: main
bc934ef03with #2219 (968329263) and this PR's heade0a34f693merged in.@Nawid3333 on GitHub · 2026-11-15 15:01 UTC · original
Main has this now:
b99fb4398("graphics: share image heap elements across tables and queue resident image changes") keys heap elements by descriptor and profile, so one element serves a descriptor and profile in every view and table. That covers the elements this PR shares between views of one profile, so I'm closing it in favour of that commit.Pull request closed