AGC: textures refused by a full sampled-texture cache are rebuilt on every lookup within the same present (RESIDENT EVIL requiem) #12190
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Imported from boykopovar/AnyPS5. Originally posted by QRMOE on 2026-10-28T02:45:16Z.
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.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):
Evidence
Draw committer stack sample (
APS5_SAMPLE_COMMITTER, about 40 min in, 152,433 samples). The time goes toShaderResources::buildComplete→resolveImageTables→cachedTexture→Texture::Texture.prepareAddressBindings, the import and address-space work, is only about 3%.[texture]counters (APS5_PROFILE_DRAW):allocate+imagereached 169.5 s.The budget lines in the same run:
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.cpponmain):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.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_MIBvkAllocateMemoryfailed 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.jsonlfrom the default-budget run (APS5_TRACE_SUMMARY_EVERY=30). These are interval lines, not a trace capture:1232-1269 s, 4 presents, frame p50 6974 ms, GPU 421 ms per present;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_SECONDScapture. The slowdown builds over tens of minutes, which a short trace window wouldn't show.Capture
Build:
main74acfad65bwith #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 (offlinelibSceHttp2, and a bypass of the single-sampleMSAA_ENABLEline 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).