WIP: perf(vk): texture RAM cache, a proof of concept with its diagnostics (not for merging as is) #2273

Draft
Veix wants to merge 1 commit from Veix/Longshot:wip/texture-ram-cache into main
Contributor

Summary

A diagnostic and proof-of-concept branch, not for merging as is: a texture RAM cache that removes the GPU re-conversion of evicted textures, behind the drops when the camera turns with a full VRAM budget. Handed over so someone can read it, try it and make a clean pull request of it.

When the VRAM budget evicts a converted texture (ASTC decoded to RGBA8 or re-encoded to BC3, or a texture unswizzled on the CPU) and the game uses it again, it is converted again on the GPU, at about 0.8 ms a MB, in front of the frame's draws. The cache reads the converted result back into RAM (on a thread of its own, without a wait), keyed by the hash of its storage and its shape, and a texture used again is filled by one plain copy from there.

It is one commit: a local test branch of 14 commits (on main 89c3d21e, 2026-11-20) squashed, with current main merged into it. It carries everything the measurements were made with. What belongs to what:

The cache (the proof of concept):

  • RX_VK_TEXRAM_MB=<MB>: the cache's size. Off by default in this branch (0): set it to try it. The measurements used 4096.
  • RX_VK_TEXRAM_RGBA_MB (1.5 by default; the runs used 1000), RX_VK_TEXRAM_RATIO, RX_VK_TEXRAM_STEP_MB (what one read-back takes at most, 8 MB): which textures are worth keeping, and the read-back's pace.
  • In vk_texture.cpp: the LRU, the read-back worker and its segment workers, the entries as GPU-read buffers, the whole-upload lookup (a texture uploaded whole again is filled from the cache too).

On by default, each worth a pull request of its own (separable from the cache):

  • RX_VK_HASH_MEMO (=0 off): a texture's hash remembered by its storage and shape; made again over storage none of whose pages was written since, it takes the hash without reading the storage again (a turn in Kokiri hashed about 1.8 ms a frame).
  • RX_VK_DEPTH_ZERO (=0 off): a depth buffer read before the GPU drew it, its storage all zero, is cleared on the GPU instead of unswizzled on the CPU (in Kokiri 15 of 25 such reads).
  • RX_VK_EXACT_STALE (=0 off, the one switch with a row in switches.def): a resolved texture handle is stale only when its own texture went.

Experiments, probably not for a clean version:

  • The disk cache: RX_VK_TEXCACHE, RX_VK_TEXCACHE_BAKE, RX_VK_TEXCACHE_TAIL, RX_VK_TEXCACHE_TOP_MB (converted textures baked to disk and filled by a copy, small levels first): the idea's first form, before the RAM cache.
  • Tuning knobs tried along the way: RX_VK_HOLD_UNUSED, RX_VK_RESERVE_UNUSED, RX_VK_FLOOR_ALL (the hold's ages and the floor on every card), RX_VK_SHADOW_ROUND (_MIN, _MAX: shadow images rounded to fewer sizes), RX_VK_TARGET_BLOCKS_MIN, RX_VK_IMAGE_BLOCK_MB, RX_VK_UPLOAD_BUDGET_MB, RX_VK_UPLOAD_BUDGET_MS, RX_VK_ASTC_BC_FINE_MB, RX_VK_TARGET_DEDICATED_DEPTH (depth targets in memory of their own).
  • Host side: HOS_NVN_SYNC_SKIP / HOS_NVN_SYNC_BLOCK (host/nvn_native.c) and HOS_CHAIN / HOS_CHAIN_CAP_M (host/hos_chain.c).

Diagnostics only, not for a clean version:

  • The frame trace's extra columns after pool_resized in vk_replay.cpp (rm_*, k_*, cache_*, rt_cpu_ms, job_*, p_*, prof_*, views_*, desc_builds, tg_*): what making textures cost by step and kind, the render thread's own time. rm_create_ms and its three neighbours were named create_ms and so on before; main has columns of those names now, with other values.
  • RX_VK_UPLOAD_TIMING, RX_VK_UPLOAD_REPORT_MS, RX_VK_LOG_UPLOADS (_MIN_KB), RX_VK_LOG_TARGET_MISSES, RX_VK_IMAGE_SPLIT (a render target's image made in three timed steps), HOS_SIZE_TRACE_SQ, RX_VK_SAVE_TEX (_DIR), the render targets' block log in vk_vma.cpp, the "target made" log of the first 400 targets.

Most of these switches are plain getenv reads without a row in switches.def.

Testing

Please no automatic fixes on this branch (@fix, bot pushes): it is a hand-over, and its next form is a clean branch.

Tested: Windows 11, RTX 4070 SUPER 12 GB, driver 621.24: the 14 commits on main 89c3d21e, measured on the walking route (below), 2026-11-20. After merging main 67ba729d it builds (Windows, llvm-mingw); the merge kept main's new render-target pool path (pool_take_memory, create_image_in_class) and step timers, with this branch's timers and logs around them.

Still to test:

  • Its cache on today's main: the walking route at the 60 % VRAM line, RX_VK_TEXRAM_MB=4096 RX_VK_TEXRAM_RGBA_MB=1000 against the same build without them (by hand)
  • The castle entry, slower with the cache (below), with the read-backs held back for a moment after an area change (by hand)

Measurements

Verdict: on main 89c3d21e, the cache took the second Market stay's frames over 25 ms from 26 to 17 and its late frames from 5.19 to 2.95 %; the castle entry got worse (p99.9 29 to 48 ms).

Setup: Windows 11, RTX 4070 SUPER 12 GB, driver 621.24, Ryzen 9 9900X. 3840x2160, the walking route (Castle Town, the castle, Castle Town again), the 60 % VRAM line (RX_VK_COMPACT_PCT=60, as on a smaller card), 90 fps cap, the frame gate off, HOS_NATIVE_ZSTD=1 on both sides. 3 runs against 3, interleaved. "main" is this build with the cache off and RX_VK_HASH_MEMO=0 RX_VK_DEPTH_ZERO=0 RX_VK_EXACT_STALE=0.

main with the cache
Second Market stay, frames over 25 ms 26 17
Market entry, frames over 25 ms 19 12
Second Market stay, frames late (16.7 ms or more) 5.19 % 2.95 %
Frames within 2 ms of the median 88.4 % 92.2 %
Castle entry, p99.9 29 ms 48 ms

Not measured on today's main: about 150 commits came since, several of them on textures and VRAM.

Risks

  • Not for merging: three of its changes are on by default (RX_VK_HASH_MEMO, RX_VK_DEPTH_ZERO, RX_VK_EXACT_STALE), and the diagnostics cost time when their switches are set.
  • The castle entry is slower with the cache on (above).

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says.
  • mise run test passes (any failure that also fails on main is named).
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A fix: a game-free test that fails on main and passes here.
  • A switch added or changed: it ships at the default the measurements chose, with its row in gpu/vk/switches.def.
  • A check under tests/ that reads changed source is updated, not weakened.
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.
## Summary **A diagnostic and proof-of-concept branch, not for merging as is: a texture RAM cache that removes the GPU re-conversion of evicted textures, behind the drops when the camera turns with a full VRAM budget. Handed over so someone can read it, try it and make a clean pull request of it.** When the VRAM budget evicts a converted texture (ASTC decoded to RGBA8 or re-encoded to BC3, or a texture unswizzled on the CPU) and the game uses it again, it is converted again on the GPU, at about 0.8 ms a MB, in front of the frame's draws. The cache reads the converted result back into RAM (on a thread of its own, without a wait), keyed by the hash of its storage and its shape, and a texture used again is filled by one plain copy from there. It is one commit: a local test branch of 14 commits (on `main` 89c3d21e, 2026-11-20) squashed, with current `main` merged into it. It carries everything the measurements were made with. What belongs to what: **The cache (the proof of concept):** - `RX_VK_TEXRAM_MB=<MB>`: the cache's size. **Off by default in this branch (0)**: set it to try it. The measurements used 4096. - `RX_VK_TEXRAM_RGBA_MB` (1.5 by default; the runs used 1000), `RX_VK_TEXRAM_RATIO`, `RX_VK_TEXRAM_STEP_MB` (what one read-back takes at most, 8 MB): which textures are worth keeping, and the read-back's pace. - In `vk_texture.cpp`: the LRU, the read-back worker and its segment workers, the entries as GPU-read buffers, the whole-upload lookup (a texture uploaded whole again is filled from the cache too). **On by default, each worth a pull request of its own (separable from the cache):** - `RX_VK_HASH_MEMO` (=0 off): a texture's hash remembered by its storage and shape; made again over storage none of whose pages was written since, it takes the hash without reading the storage again (a turn in Kokiri hashed about 1.8 ms a frame). - `RX_VK_DEPTH_ZERO` (=0 off): a depth buffer read before the GPU drew it, its storage all zero, is cleared on the GPU instead of unswizzled on the CPU (in Kokiri 15 of 25 such reads). - `RX_VK_EXACT_STALE` (=0 off, the one switch with a row in `switches.def`): a resolved texture handle is stale only when its own texture went. **Experiments, probably not for a clean version:** - The disk cache: `RX_VK_TEXCACHE`, `RX_VK_TEXCACHE_BAKE`, `RX_VK_TEXCACHE_TAIL`, `RX_VK_TEXCACHE_TOP_MB` (converted textures baked to disk and filled by a copy, small levels first): the idea's first form, before the RAM cache. - Tuning knobs tried along the way: `RX_VK_HOLD_UNUSED`, `RX_VK_RESERVE_UNUSED`, `RX_VK_FLOOR_ALL` (the hold's ages and the floor on every card), `RX_VK_SHADOW_ROUND` (`_MIN`, `_MAX`: shadow images rounded to fewer sizes), `RX_VK_TARGET_BLOCKS_MIN`, `RX_VK_IMAGE_BLOCK_MB`, `RX_VK_UPLOAD_BUDGET_MB`, `RX_VK_UPLOAD_BUDGET_MS`, `RX_VK_ASTC_BC_FINE_MB`, `RX_VK_TARGET_DEDICATED_DEPTH` (depth targets in memory of their own). - Host side: `HOS_NVN_SYNC_SKIP` / `HOS_NVN_SYNC_BLOCK` (`host/nvn_native.c`) and `HOS_CHAIN` / `HOS_CHAIN_CAP_M` (`host/hos_chain.c`). **Diagnostics only, not for a clean version:** - The frame trace's extra columns after `pool_resized` in `vk_replay.cpp` (`rm_*`, `k_*`, `cache_*`, `rt_cpu_ms`, `job_*`, `p_*`, `prof_*`, `views_*`, `desc_builds`, `tg_*`): what making textures cost by step and kind, the render thread's own time. `rm_create_ms` and its three neighbours were named `create_ms` and so on before; `main` has columns of those names now, with other values. - `RX_VK_UPLOAD_TIMING`, `RX_VK_UPLOAD_REPORT_MS`, `RX_VK_LOG_UPLOADS` (`_MIN_KB`), `RX_VK_LOG_TARGET_MISSES`, `RX_VK_IMAGE_SPLIT` (a render target's image made in three timed steps), `HOS_SIZE_TRACE_SQ`, `RX_VK_SAVE_TEX` (`_DIR`), the render targets' block log in `vk_vma.cpp`, the "target made" log of the first 400 targets. Most of these switches are plain `getenv` reads without a row in `switches.def`. ## Testing **Please no automatic fixes on this branch (`@fix`, bot pushes): it is a hand-over, and its next form is a clean branch.** **Tested:** Windows 11, RTX 4070 SUPER 12 GB, driver 621.24: the 14 commits on `main` 89c3d21e, measured on the walking route (below), 2026-11-20. After merging `main` 67ba729d it builds (Windows, llvm-mingw); the merge kept `main`'s new render-target pool path (`pool_take_memory`, `create_image_in_class`) and step timers, with this branch's timers and logs around them. **Still to test:** - Its cache on today's `main`: the walking route at the 60 % VRAM line, `RX_VK_TEXRAM_MB=4096 RX_VK_TEXRAM_RGBA_MB=1000` against the same build without them (by hand) - The castle entry, slower with the cache (below), with the read-backs held back for a moment after an area change (by hand) ## Measurements **Verdict:** on `main` 89c3d21e, the cache took the second Market stay's frames over 25 ms from 26 to 17 and its late frames from 5.19 to 2.95 %; the castle entry got worse (p99.9 29 to 48 ms). Setup: Windows 11, RTX 4070 SUPER 12 GB, driver 621.24, Ryzen 9 9900X. 3840x2160, the walking route (Castle Town, the castle, Castle Town again), the 60 % VRAM line (`RX_VK_COMPACT_PCT=60`, as on a smaller card), 90 fps cap, the frame gate off, `HOS_NATIVE_ZSTD=1` on both sides. 3 runs against 3, interleaved. "main" is this build with the cache off and `RX_VK_HASH_MEMO=0 RX_VK_DEPTH_ZERO=0 RX_VK_EXACT_STALE=0`. | | main | with the cache | |---|---|---| | Second Market stay, frames over 25 ms | 26 | 17 | | Market entry, frames over 25 ms | 19 | 12 | | Second Market stay, frames late (16.7 ms or more) | 5.19 % | 2.95 % | | Frames within 2 ms of the median | 88.4 % | 92.2 % | | Castle entry, p99.9 | 29 ms | 48 ms | Not measured on today's `main`: about 150 commits came since, several of them on textures and VRAM. ## Risks - Not for merging: three of its changes are on by default (`RX_VK_HASH_MEMO`, `RX_VK_DEPTH_ZERO`, `RX_VK_EXACT_STALE`), and the diagnostics cost time when their switches are set. - The castle entry is slower with the cache on (above). ## Checklist ### Ready for review - [ ] One topic, on current `main`; the title is a Conventional Commit. - [ ] Tested on my own PC, in the game for a change the game runs, as Testing says. - [ ] `mise run test` passes (any failure that also fails on `main` is named). - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [ ] A fix: a game-free test that fails on `main` and passes here. - [ ] A switch added or changed: it ships at the default the measurements chose, with its row in `gpu/vk/switches.def`. - [ ] A check under `tests/` that reads changed source is updated, not weakened. - [ ] Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold.
wip(vk): texture RAM cache, a proof of concept with its diagnostics (not for merging as is)
Some checks are pending
CI / Website build and checks (pull_request) Blocked by required conditions
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 15s
c8430046dd
Converted textures (ASTC decoded, or re-encoded to BC3; textures unswizzled on the CPU) that the VRAM budget evicts are
kept in RAM and filled again by one plain copy when the game uses them again, instead of being converted again on the GPU
(about 0.8 ms a MB, in front of the frame's draws: the drops when the camera turns at a full VRAM budget).

Squashed from a local test branch (14 commits on main 89c3d21e, 2026-11-20) with current main merged into it. It carries
the test switches, trace columns and logs the measurements were made with; the pull request lists which part is the
cache and which part is diagnostics or other experiments.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Member

Possibly related, for context:

  • issue #939 Game: on a 6 GB card VRAM goes over the driver's allowance after a few area changes, Hyrule Field falls from 31 to 14 fps until a restart (GTX 1060, nightly-189) — VRAM pressure and post-area-change slowdown on a 6 GB GPU
  • issue #1268 Game: 200-470 ms stutters when many new textures arrive: the main thread waits ~0.3 s on a GPU fence after a frame of uploads (RTX 3090, Linux) — Stalls during bursts of texture uploads; mechanism differs
  • PR #944 WIP: fix(vk): a texture whose upload failed is tried again, not left empty or stale — Open Vulkan texture-upload retry work; possible overlap in vk_texture.cpp
Possibly related, for context: - issue #939 Game: on a 6 GB card VRAM goes over the driver's allowance after a few area changes, Hyrule Field falls from 31 to 14 fps until a restart (GTX 1060, nightly-189) — VRAM pressure and post-area-change slowdown on a 6 GB GPU - issue #1268 Game: 200-470 ms stutters when many new textures arrive: the main thread waits ~0.3 s on a GPU fence after a frame of uploads (RTX 3090, Linux) — Stalls during bursts of texture uploads; mechanism differs - PR #944 WIP: fix(vk): a texture whose upload failed is tried again, not left empty or stale — Open Vulkan texture-upload retry work; possible overlap in vk_texture.cpp
Member

Comment only — your handover asks for no bot fixes, and this is the cross-check you asked for against our BC3 caching work.

We built our own implementation of the disk half last week on the Deck LCD bench, before seeing this branch: same content key (the reuse_upload XXH64 plus shape), same writer discipline (temp+rename, background thread), but the file is written by one copy-out at the texture's first whole upload rather than a later-present bake, so nothing in the frame path waits. Deck numbers, including post-#2194, are in our comment on #2292 rather than repeated here; short version: after #2194's 5.3x decode speedup the warm disk cache still takes −42% hitch frames and −61% bytes staged on a Vangogh, and 62 minutes of normal play ran at 0.067% frames over 150 ms.

Where that leaves your branch, part by part:

  • The disk variant (TEXCACHE/_BAKE): you flag it as the idea's first form and it regressed castle entry; our read is that the bake-with-GPU-wait path is what bit you there. Since #2292 already carries the same idea with a stamp, checksum, cost model and size policy, a clean branch of this handover doesn't need to carry the disk half at all. It's being done properly over there.

  • The RAM cache is the part nobody else covers — and our Deck data says nothing about it, honestly: our arms never press the VRAM budget (the texture census sat at 2,096 MB against a 2,560 MB budget, no eviction churn), so the evicted-reconversion path your cache targets never fired on our route. The trace frames your ~0.8 ms/MB re-conversion cost exactly as you describe, so the bug class is real; it just needs a churn scenario to show it, not an entry scenario.

  • Castle-entry regression (p99.9 29 → 48 ms): reads like read-backs competing with the load's own uploads. Your _STEP_MB and _TAIL knobs point the right way; when a clean branch paces read-backs against the load, the castle arms here are ready.

  • The three separable switches (RX_VK_HASH_MEMO, RX_VK_DEPTH_ZERO, RX_VK_EXACT_STALE) read as straightforward and Deck-relevant — hashing and CPU unswizzle work sit in the same stall profile we keep measuring on Vangogh, though we didn't isolate either cost separately in our traces.

One Deck caution for the RAM tier's sizing: on 16 GB of shared LPDDR5 with the emulator already swapping several GB, a 4 GB TEXRAM default sized from a 12 GB discrete card wants a Deck-sized default, and on Linux a RAM tier double-stores bytes the page cache already holds warm.

Offer: when the clean branch (or just those three switches) rebases onto main, we'll run it on a Deck LCD with scripted Castle Town arms, cold and warm, with traces.

Comment only — your handover asks for no bot fixes, and this is the cross-check you asked for against our BC3 caching work. We built our own implementation of the disk half last week on the Deck LCD bench, before seeing this branch: same content key (the `reuse_upload` XXH64 plus shape), same writer discipline (temp+rename, background thread), but the file is written by one copy-out at the texture's first whole upload rather than a later-present bake, so nothing in the frame path waits. Deck numbers, including post-#2194, are in our comment on #2292 rather than repeated here; short version: after #2194's 5.3x decode speedup the warm disk cache still takes −42% hitch frames and −61% bytes staged on a Vangogh, and 62 minutes of normal play ran at 0.067% frames over 150 ms. Where that leaves your branch, part by part: - **The disk variant** (`TEXCACHE`/`_BAKE`): you flag it as the idea's first form and it regressed castle entry; our read is that the bake-with-GPU-wait path is what bit you there. Since #2292 already carries the same idea with a stamp, checksum, cost model and size policy, a clean branch of this handover doesn't need to carry the disk half at all. It's being done properly over there. - **The RAM cache is the part nobody else covers** — and our Deck data says nothing about it, honestly: our arms never press the VRAM budget (the texture census sat at 2,096 MB against a 2,560 MB budget, no eviction churn), so the evicted-reconversion path your cache targets never fired on our route. The trace frames your ~0.8 ms/MB re-conversion cost exactly as you describe, so the bug class is real; it just needs a churn scenario to show it, not an entry scenario. - **Castle-entry regression** (p99.9 29 → 48 ms): reads like read-backs competing with the load's own uploads. Your `_STEP_MB` and `_TAIL` knobs point the right way; when a clean branch paces read-backs against the load, the castle arms here are ready. - **The three separable switches** (`RX_VK_HASH_MEMO`, `RX_VK_DEPTH_ZERO`, `RX_VK_EXACT_STALE`) read as straightforward and Deck-relevant — hashing and CPU unswizzle work sit in the same stall profile we keep measuring on Vangogh, though we didn't isolate either cost separately in our traces. One Deck caution for the RAM tier's sizing: on 16 GB of shared LPDDR5 with the emulator already swapping several GB, a 4 GB `TEXRAM` default sized from a 12 GB discrete card wants a Deck-sized default, and on Linux a RAM tier double-stores bytes the page cache already holds warm. **Offer:** when the clean branch (or just those three switches) rebases onto main, we'll run it on a Deck LCD with scripted Castle Town arms, cold and warm, with traces.
Member

Deck LCD test of this handover at pinned c8430046: it works on the Deck, and the three separable switches are the strongest Deck signal in the branch. Bench claim posted to team updates at 18:45; nothing was pushed to your branch, everything below ran your pinned head plus one bench-local build shim.

Build, Linux. One error on Linux: the frame-trace block at vk_replay.cpp:5046 calls QueryThreadCycleTime(GetCurrentThread(), &cyc) with no _WIN32 guard (ULONG64, GetCurrentThread: Win32 APIs; the file guards every other such block with #ifdef _WIN32, the PR lists Windows builds only, so Linux was likely never attempted). The bench shim (a local commit over your pin, not a push): CLOCK_THREAD_CPUTIME_ID under #ifndef _WIN32, ns_per_cycle = 1.0, keeps the rt_cpu trace column live. A clean branch needs the guard, or the column goes. Renderer-only Deck build is otherwise clean; it runs on our v3.1.1 host unchanged (ABI fine).

Setup. Steam Deck LCD (Vangogh, 16 GB shared LPDDR5), Castle Town from the Market save, scripted walk+turn, 20 cycles, RX_VK_FRAME_LOG, hitch = frame over 60 ms. Churn scenario: RX_VK_COMPACT_PCT=60 against the Deck's ~2,560 MB allowance with a ~2,100 MB working set. Note for your notes: GLOBAL_MIN_GRAPHICS_REQ is 8,192 MB, so the dynamic-floor path RX_VK_FLOOR_ALL forces on big cards is already live on the Deck, no test switch needed there.

The cache under churn (cache off vs 4096 MB vs 1536 MB, same scenario):

cache off TEXRAM 4096 TEXRAM 1536
frames >60 ms 146 129 136
frames >150 ms 10 7 7
slow-frame seconds 14.1 12.2 12.4
staged MB 1617 1530 1424
fills (n / MB / ms) — 1229 / 400 / 101 725 / 250 / 70
ASTC decodes 2135 1231 1245

Real but modest on this hardware: −12% hitch frames, −13% slow-frame seconds, ~900 decodes removed. Smaller than your 4K/12 GB scenario because the Deck working set nearly fits the allowance, so churn is gentler than your forced 60% line.

Sizing on shared memory: the 4096 number does not port. With TEXRAM_MB=4096 the Deck's swap grew from 1.1 to 4.5 GB during the arm. The 1536 arm matched 4096's frame effect (136 vs 129 hitches, within noise) at a third of the fills, with fills costing only ~70-100 ms per 20-minute arm either way. On 16 GB UMA, 1024-1536 looks like the right ceiling for a clean branch default.

The mechanism fires without churn too. Default budgets, TEXRAM_MB=4096: fills of 1,099 textures / 366 MB, and ASTC decodes fell 3,209 to 1,233, so the RAM cache is catching re-created textures in-session, not only evicted ones. Frame effect at default budgets was within boot-to-boot variance (paired boots: 219 vs 142 hitches, repeat pair 175 vs 212, honest read: no clear frame win without churn), but the decode-skip itself was consistent across both pairs (roughly −1,850 decodes each). Worth keeping the whole-upload lookup in the clean version.

The three separable switches are the best Deck numbers here. Same churn scenario, cache off in both arms, RX_VK_HASH_MEMO=0 RX_VK_DEPTH_ZERO=0 RX_VK_EXACT_STALE=0 against them as shipped in your branch:

switches as shipped switches forced off
frames >60 ms 146 263
slow-frame seconds 14.1 21.5
staged MB 1617 3067
ASTC decodes 2135 4266
CPU conversions 2377 4771
depth-zero reads 469 2

44% fewer hitch frames and 47% less staged data from the switches alone, and the doubling of both conversion kinds with EXACT_STALE=0 matches your own write-up of what that counter does. One pair, so a strong signal rather than a measurement, but on Deck this is the branch's first PR in waiting: RX_VK_EXACT_STALE above all, the other two alongside or next.

Correctness: screenshots at churn with 4096 MB of fills, before and after the scripted camera turn, clean: no magenta or black rectangles, no mosaic, no smeared textures, no wrong colors.

One squash artifact: the trace's cache_n/cache_mb columns stayed at zero in every arm where k_cache_n/k_cache_mb fired (0 vs 1,229). One of the two is miswired; a clean branch should keep just one.

Happy to re-run the churn pair and the switch arms against a clean branch, on this Deck, same protocol. Traces and score JSON archived on our side (18 files, hash-manifested) if you want any raw CSV.

Deck LCD test of this handover at pinned c8430046: it works on the Deck, and the three separable switches are the strongest Deck signal in the branch. Bench claim posted to team updates at 18:45; nothing was pushed to your branch, everything below ran your pinned head plus one bench-local build shim. **Build, Linux.** One error on Linux: the frame-trace block at `vk_replay.cpp:5046` calls `QueryThreadCycleTime(GetCurrentThread(), &cyc)` with no `_WIN32` guard (`ULONG64`, `GetCurrentThread`: Win32 APIs; the file guards every other such block with `#ifdef _WIN32`, the PR lists Windows builds only, so Linux was likely never attempted). The bench shim (a local commit over your pin, not a push): `CLOCK_THREAD_CPUTIME_ID` under `#ifndef _WIN32`, `ns_per_cycle = 1.0`, keeps the `rt_cpu` trace column live. A clean branch needs the guard, or the column goes. Renderer-only Deck build is otherwise clean; it runs on our v3.1.1 host unchanged (ABI fine). **Setup.** Steam Deck LCD (Vangogh, 16 GB shared LPDDR5), Castle Town from the Market save, scripted walk+turn, 20 cycles, `RX_VK_FRAME_LOG`, hitch = frame over 60 ms. Churn scenario: `RX_VK_COMPACT_PCT=60` against the Deck's ~2,560 MB allowance with a ~2,100 MB working set. Note for your notes: `GLOBAL_MIN_GRAPHICS_REQ` is 8,192 MB, so the dynamic-floor path `RX_VK_FLOOR_ALL` forces on big cards is already live on the Deck, no test switch needed there. **The cache under churn** (cache off vs 4096 MB vs 1536 MB, same scenario): | | cache off | TEXRAM 4096 | TEXRAM 1536 | |---|---|---|---| | frames >60 ms | 146 | 129 | 136 | | frames >150 ms | 10 | 7 | 7 | | slow-frame seconds | 14.1 | 12.2 | 12.4 | | staged MB | 1617 | 1530 | 1424 | | fills (n / MB / ms) | — | 1229 / 400 / 101 | 725 / 250 / 70 | | ASTC decodes | 2135 | 1231 | 1245 | Real but modest on this hardware: −12% hitch frames, −13% slow-frame seconds, ~900 decodes removed. Smaller than your 4K/12 GB scenario because the Deck working set nearly fits the allowance, so churn is gentler than your forced 60% line. **Sizing on shared memory: the 4096 number does not port.** With `TEXRAM_MB=4096` the Deck's swap grew from 1.1 to 4.5 GB during the arm. The 1536 arm matched 4096's frame effect (136 vs 129 hitches, within noise) at a third of the fills, with fills costing only ~70-100 ms per 20-minute arm either way. On 16 GB UMA, 1024-1536 looks like the right ceiling for a clean branch default. **The mechanism fires without churn too.** Default budgets, `TEXRAM_MB=4096`: fills of 1,099 textures / 366 MB, and ASTC decodes fell 3,209 to 1,233, so the RAM cache is catching re-created textures in-session, not only evicted ones. Frame effect at default budgets was within boot-to-boot variance (paired boots: 219 vs 142 hitches, repeat pair 175 vs 212, honest read: no clear frame win without churn), but the decode-skip itself was consistent across both pairs (roughly −1,850 decodes each). Worth keeping the whole-upload lookup in the clean version. **The three separable switches are the best Deck numbers here.** Same churn scenario, cache off in both arms, `RX_VK_HASH_MEMO=0 RX_VK_DEPTH_ZERO=0 RX_VK_EXACT_STALE=0` against them as shipped in your branch: | | switches as shipped | switches forced off | |---|---|---| | frames >60 ms | 146 | 263 | | slow-frame seconds | 14.1 | 21.5 | | staged MB | 1617 | 3067 | | ASTC decodes | 2135 | 4266 | | CPU conversions | 2377 | 4771 | | depth-zero reads | 469 | 2 | 44% fewer hitch frames and 47% less staged data from the switches alone, and the doubling of both conversion kinds with `EXACT_STALE=0` matches your own write-up of what that counter does. One pair, so a strong signal rather than a measurement, but on Deck this is the branch's first PR in waiting: `RX_VK_EXACT_STALE` above all, the other two alongside or next. **Correctness:** screenshots at churn with 4096 MB of fills, before and after the scripted camera turn, clean: no magenta or black rectangles, no mosaic, no smeared textures, no wrong colors. **One squash artifact:** the trace's `cache_n`/`cache_mb` columns stayed at zero in every arm where `k_cache_n`/`k_cache_mb` fired (0 vs 1,229). One of the two is miswired; a clean branch should keep just one. Happy to re-run the churn pair and the switch arms against a clean branch, on this Deck, same protocol. Traces and score JSON archived on our side (18 files, hash-manifested) if you want any raw CSV.
Some checks are pending
CI / Website build and checks (pull_request) Blocked by required conditions
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 15s
This pull request has changes conflicting with the target branch.
  • gpu/vk/vk_draw.cpp
  • gpu/vk/vk_replay.cpp
  • gpu/vk/vk_texture.cpp
  • gpu/vk/vk_texture.h
Some workflows are waiting to be reviewed.
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'wip/texture-ram-cache:Veix-wip/texture-ram-cache'
git switch 'Veix-wip/texture-ram-cache'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!2273
No description provided.