Repository navigation
Description
Update 2026-10-28: the diagnosis changed; the original report below is kept for the record. Storage over budget was not the cause. An idle storage trim kept storage within budget but made things worse (159 vs 63 s/frame at 45 min). The two causes:
SampledTextureBudgetkeeps the sampled cache at its 2 GiB floor. It reservesmax(heap/4, storage bytes)for storage (4,076 MiB on a 16 GB card) and counts idleBufferPooldevice memory as used.- Refused textures are rebuilt on every lookup. Once the cache is full of textures used this present,
admitTexturerefuses new ones, and each refused texture is rebuilt on every later lookup in the same present: ~117 rebuilds per texture per present in the level at default settings.
A local prototype keeps refused textures alive for the rest of their present. That cut creations to about 1 per texture per present, and in the level (the rainy street) the frame time held at 10.5 to 13.6 s/frame, flat for 45 minutes (one 75-minute run, RX 9070 XT). At default settings the same street climbs to 30 to 60 s/frame within 26 minutes and reaches about 150 s. Details: #11599. The late climb in the earlier prototype run was the game moving from the level's loading card into the level, which has a larger texture set.
Original report (superseded in part):
Title and scene
RESIDENT EVIL requiem (PPSA31246, 01.200.000), the first gameplay area after the opening cutscene: the rainy street, objective "Head to the Wrenwood Hotel". Bring-up thread: #11599.
What is slow or what changed
In this area the frame time keeps rising. The cause is that the storage-image cache stays above its own budget, so the sampled-texture cache is pinned at its 2,048 MiB floor and rebuilds the area's textures every frame.
Median frame time, by time since launch (the area loads at about 20 min):
| Since launch | 20 min | 25 min | 30 min | 37 min | 45 min | 52 min | 90 min |
|---|---|---|---|---|---|---|---|
| Frame time | 7 s | 21 s | 32 s | 48 s | 63 s | 81 s | 159 s |
Evidence
Draw committer stack sample (APS5_SAMPLE_COMMITTER, about 40 min in, 152,433 samples). The time goes to ShaderResources::buildComplete → resolveImageTables → cachedTexture → Texture::Texture. prepareAddressBindings, the import and address-space work, is only about 3%.
[texture] counters (APS5_PROFILE_DRAW):
- About 10,000 textures were created by the end of the opening cutscene.
- By about 40 min the total was 882,800 (880,221 of them uploads), nearly all in this area.
allocate+imagereached 169.5 s.
The budget lines in the same run:
sampled texture cache budget 2048 MiB (was 2048 MiB): device-local heap 1 has a VK_EXT_memory_budget budget of 14266 MiB and uses 13470 MiB, 2446 MiB of it sampled textures (2047 MiB in the cache) and 4751 MiB cached storage images; storage image cache budget 3764 MiB (was 3331 MiB)
Cached storage images hold 4,751 MiB against a storage budget of 3,764 MiB, while the sampled cache sits at its floor.
How the code gets there (ShaderResources.cpp on main):
- The storage cache evicts only when a new storage image is inserted (
while (... cache.bytes + entry.accounted > budget) evictStorage(...)). When the game keeps reusing the same storage images, nothing brings the cache back to its budget after the budget falls. SampledTextureBudgetreservesmax(TextureCacheBudget(memory), storageBytes)for storage. So whatever the storage cache holds above its budget comes out of the sampled budget, which ends at its 2 GiB floor.- At the floor,
admitTexturefirst evicts textures from earlier frames. Once everything left was used in the current frame, it refuses the incoming one (counts.uncached): that texture is built for its draw and released, and the next draw builds it again. When the area's working set is larger than the budget, this happens every frame. ReleaseTextureCachescan evict idle (non-dirty) storage images, but only when an allocation is being reclaimed, not as a trim to the budget.
What changing the budget does (APS5_TEXTURE_CACHE_MIB, which sets both budgets). One run each, same route:
APS5_TEXTURE_CACHE_MIB |
Frame time in the area | Outcome |
|---|---|---|
| unset | 7 s, rising to 63 s at 45 min | ran 90 min |
| 3072 | about 5 s for about 5 min, then up to 27 s, then 15-17 s at 45 min | no allocation failure in 45 min |
| 6144 | flat at 6-7 s for about 10 min | at 31 min a 128 MiB vkAllocateMemory failed with -2 (host-visible heap 15,291/15,388 MiB) and the title stopped |
#10256 (one texture per dynamic-resolution variant) changed neither the storage bytes (4,408 MiB over a 3,647 MiB budget) nor the trend. The storage images here aren't dynamic-resolution variants of the #6099 kind.
A possible direction: when the sampled cache is at its floor and refusing textures while the storage cache is over its own budget, evict idle storage images (not dirty, not referenced elsewhere) down to that budget. The memory goes to the sampled cache instead of being held by the storage cache and rebuilt in the sampled one. By the numbers above, that would free about 760 MiB to 1 GiB for the sampled cache here, roughly what the 3072 setting did.
Related: #6194 (grows the storage budget under pressure, the opposite trade), #10472 (suballocates sampled and storage memory), #5961 and #6099 (Wolverine's storage churn).
Summary lines
aps5-summary.jsonl from the default-budget run (APS5_TRACE_SUMMARY_EVERY=30). These are interval lines, not a trace capture:
- the interval where the area starts:
1232-1269 s, 4 presents, frame p50 6974 ms, GPU 421 ms per present; - the last interval:
5373-5532 s, 1 present, frame p50 158955 ms, GPU 2885 ms per present.
Traces
Not attached: the runs above used summary intervals and a redirected log, not an APS5_TRACE_SECONDS capture. The slowdown builds over tens of minutes, which a short trace window wouldn't show.
Capture
- The caches were warm (the scene ran once and the title was restarted)
- No other APS5_TRACE_* or APS5_PROFILE_* switch was set and the log was not redirected
- Captures compared here come from the same machine, scene and settings
Build: main 74acfad with #10935, #10304, #9950, #11199, #11369, #11485, #11580, #11357, #12074 (needed to get through the post-intro load) and #9999 (needed for correct images), plus two title-run workarounds (offline libSceHttp2, and a bypass of the single-sample MSAA_ENABLE line refusal) and an address-space change of mine. Settings: APS5_LAZY_SHADER_PREPARE=1 APS5_NO_GPL=1.
System: RX 9070 XT (AMD 26.6.2, 16 GB), Ryzen 7 9800X3D, 32 GB RAM, Windows 11 26200, WinLibs GCC 15.2.0, Release.
AI-assisted: yes (Claude Code).
Activity
MarcZX10 commentedon Oct 28, 2026
I checked the current
upstream/mainimplementation. The report’s cache-path explanation still matches:cachedStorageTexture()recomputesstorageBudget()and evicts storage entries only on a cache miss that inserts a new image; a hit only refreshes and moves the entry to the front.ReleaseTextureCaches()can trim storage entries, but it is called through allocation-reclamation paths, so a budget drop while the same image set is being reused does not itself trigger trimming. That supports the proposed idle-trim direction.One safety detail for a fix:
evictStorage()flushes the image and removes its resource-cache references, while recorded batches may still retain images/resources. A budget trim should therefore preserve dirty or externally held images (or account for their retained bytes) and avoid treating a successful cache-map removal as immediately reclaimed Vulkan memory. The existing long-run same-scene measurements are useful evidence; a focused test for lowering the budget after population and then issuing cache hits would help lock down the missing trim behavior.QRMOE commentedon Oct 28, 2026
@MarcZX10 Thanks for checking the code path. I tried the idle-trim direction in a 45-minute run of the title (the level's loading card, then the level itself from about 20 min). It kept storage inside its budget, but the sampled cache stayed at its 2 GB floor and frame time got worse: 159 vs 63 s/frame at 45 min. So I'm not opening it as a PR. The floor comes from
SampledTextureBudgetreservingmax(heap/4, storage)for storage images whatever they use, plus idleBufferPooldevice-tier memory counted as used. The details, a per-call-site breakdown of the device-local heap and a prototype that lifts the floor are here: #11599 (comment)AI-assisted: yes (Claude Code)
MarcZX10 commentedon Oct 28, 2026
Thanks for the newer controlled runs and the correction. They change the diagnosis materially: the idle storage trim kept storage within budget but made the 45-minute result worse (159 s/frame versus 63 s/frame on the same build), while the later prototype points to the sampled cache refusing textures once the per-present working set exceeds its capacity. Repeated lookups then rebuild those uncached textures many times within that same present. The heap/texture counts and timings are useful evidence, but the prototype is still one run and its late slowdown remains unexplained.
My earlier suggestion to trim idle storage images is superseded by this evidence; it should not be treated as the next fix. The current issue title and top-level description still present storage-cache over-budget as the cause, though, so please update them to reflect the revised sampled-cache/per-present churn diagnosis, or close this report and link a correctly scoped follow-up if that is clearer. I have not independently reproduced either experiment.
[-]AGC: the storage-image cache stays over its budget, so the sampled cache sits at its 2 GiB floor and rebuilds textures every frame (RESIDENT EVIL requiem gameplay)[/-][+]AGC: textures refused by a full sampled-texture cache are rebuilt on every lookup within the same present (RESIDENT EVIL requiem)[/+]QRMOE commentedon Oct 28, 2026
Draft PR #12575 implements the per-present reuse of refused textures described in the update above, with tests (13/13 with the validation layer, 0 VUID; the new assertion fails on
main). A cleantrace_digestA/B ofmainagainst the PR alone is still to come.AI-assisted: yes (Claude Code)
brajankw commentedon Dec 5, 2026
Root cause
In
ShaderResources.cpp,SampledTextureBudgetcomputes headroom from the heap report after budgeting for storage. The updated measurements show the sampled cache at 2,048 MiB, with about 4,076 MiB reserved for storage on a 16 GB heap and idleBufferPoolallocations still charged as live heap use. Once the cache hits its floor,admitTexturecan refuse a texture while the cached entries have already been used during the same present.lookupSampledTexturemay still build that refused image for the current lookup. Repeating the lookup rebuilds it again, measured here at about 117 creations per texture per present.Our PR(s)
#29080 exposes an idle device-buffer reclaim by heap through
BufferPool::ReclaimIdleDeviceOnHeap. #29081 bounds reclaim of whole buffers, and #29082 integrates it into the budget path insampledBudgetandlookupSampledTexture. It reclaims eligible idle buffers before falling to the floor, reads the heap again, credits sampled and storage backing to the heap it actually occupies and bounds host-backed admission using the original report. The stack order is #29080, #29081, #29082. #12575 is the separate proposal that retains an image refused by the cache for the present.Evidence
The focused pressure fixture reclaimed 8 MiB and re-read the budget while keeping host-backed admission at 2 GiB. Main with the new fixtures dropped to the floor on one marginal report and credited an off-heap allocation to the selected heap. On the RTX 3060, eight focused cases passed on the change. The six common tests also passed on main, and Vulkan validation loaded with zero VUIDs on both revisions. The in-game result in the thread, about one creation per texture per present and 10.5–13.6 s/frame over 45 minutes, belongs to the per-present prototype. We have no corresponding scene run on #29082.
How to verify
Use the original rainy-street scene on matching builds, same budgets and input. Record the
sampled texture cache budgetlines withAPS5_TRACE_MEMORY_BUDGET=1and the texture and creation counters withAPS5_PROFILE_DRAW=1. Compare the heap immediately before the first floor event, idle buffers reclaimed from that heap, the refreshed budget and creations per texture per present. Measure #12575 separately and then on the reclaim stack to attribute each change.Not covered / open questions
If there is no reclaimable idle backing, or the sampled working set still exceeds the refreshed budget, the refusal and repeat-build path remains.