AGC: textures refused by a full sampled-texture cache are rebuilt on every lookup within the same present (RESIDENT EVIL requiem) #12190

Open
opened 2026-10-28 02:45:16 +00:00 by QRMOE · 0 comments
QRMOE commented 2026-10-28 02:45:16 +00:00 (Migrated from github.com)
Contributor

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:

  • SampledTextureBudget keeps the sampled cache at its 2 GiB floor. It reserves max(heap/4, storage bytes) for storage (4,076 MiB on a 16 GB card) and counts idle BufferPool device memory as used.
  • Refused textures are rebuilt on every lookup. Once the cache is full of textures used this present, admitTexture refuses 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+image reached 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.
  • SampledTextureBudget reserves max(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, admitTexture first 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.
  • ReleaseTextureCaches can 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 74acfad65b 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).

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:6071569815 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/12190). Originally posted by [QRMOE](https://github.com/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: - **`SampledTextureBudget` keeps the sampled cache at its 2 GiB floor.** It reserves `max(heap/4, storage bytes)` for storage (4,076 MiB on a 16 GB card) and counts idle `BufferPool` device memory as used. - **Refused textures are rebuilt on every lookup.** Once the cache is full of textures used this present, `admitTexture` refuses 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+image` reached 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. - **`SampledTextureBudget` reserves `max(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, `admitTexture` first 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. - `ReleaseTextureCaches` can 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 - [x] 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 - [x] Captures compared here come from the same machine, scene and settings **Build:** `main` 74acfad65b 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).
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5#12190
No description provided.