Repository navigation
perf(agc): let the sampled texture cache grow into host memory while a frame's textures don't fit - #12684
perf(agc): let the sampled texture cache grow into host memory while a frame's textures don't fit#12684milescoviello wants to merge 3 commits into
Conversation
…a frame's textures don't fit When every entry the sampled texture cache could evict was used in the current or previous present, it turns new textures away, and a frame larger than its budget makes those textures again at every use. Ghost of Tsushima's brightness screen does this with a 27,000-texture image table on a 12 GB GPU, where the budget sits at its 2 GiB floor. The budget now grows by 256 MiB at each read while textures are turned away, up to 2 GiB past the reported share, when the device has a non-device-local heap, and shrinks again after 10 s without a turned-away texture. While it is grown, the out-of-memory recovery of an allocation that can fall back to host memory no longer releases sampled textures used in the last two presents, so the extra textures go to host memory instead of pushing the frame's own textures out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
This pull request is labeled |
|
On the overlap with #6194 (@Thunderhawkk, opened 10-15): that PR grows the storage image cache's budget while it evicts under its own budget, and this one grows the sampled texture cache's budget. They're separate changes, but they edit neighbouring code in One data point from Ghost of Tsushima that may matter for #6194: raising only the storage budget to 4 GiB (a local override) gave 6 and 5 presents over 300-590 s, against 5 and 5 with defaults, so in that title the storage cache wasn't the limit. With this PR, the recovery releases storage images where it used to release the frame's sampled textures (about 50,000 re-created over 210-600 s), which a storage-side rule like #6194's could address next. AI-assisted: yes (Claude Code) |
adriadam10
left a comment
There was a problem hiding this comment.
Thanks, the change is bounded (256 MiB steps, 2 GiB cap, given back after 10 quiet seconds) and the docs follow it. Before it can merge:
- This PR is labelled
perf, so it needs theaps5-summary.jsonlline of a capture onmainand one with the change, from the same title, scene and machine, plus the output oftools/trace_digest.pyon both (AGENTS.md, GAME_TESTING.md "Pull requests labelledperf"). The present counts in Tested are not a substitute;tools/performance_compare.pycan produce the comparison. Attach both traces to the PR. - The new test (
spill-cpu) pins onlySampledTextureSpill. The part that changes behaviour,ReleaseTextureCachesstopping at an entry used in the last two presents whenReclaimHasHostFallback()is set andcache.spill != 0(ShaderResources.cpp:1469-1482), andBufferPool::AllocateMemorysetting the flag (BufferPool.cpp:94-97), has no test that fails without it. Please add one toagc_driver_sampled_cache_budget(sampled entries from the current present, a host-fallback reclaim keeps them; without fallback they are released).
#6194 conflicts textually with this one, as you noted; whichever lands second rebases.
|
@adriadam10 thanks, working on both:
AI-assisted: yes (Claude Code) |
|
@milescoviello the mechanism is well bounded (256 MiB per read, 2 GiB cap, a step back after 10 quiet seconds only while the cache leaves two steps unused, nothing at all without a non-device-local heap), the thread-local flag around the recovery call is scoped correctly, and
|
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
…e GPUs, up to a quarter of the host heap The room grew on any device with a heap outside device-local memory, up to a fixed 2 GiB. An integrated GPU under RADV reports a GTT heap that is not device-local, but that heap is the system memory the title itself uses, so `SampledSpillCeiling` now gives no room unless the device is a discrete GPU. On a discrete GPU the room is at most a quarter of the largest non-device-local heap's VK_EXT_memory_budget budget (its size without the extension), in whole 256 MiB steps, and still at most 2 GiB. `SampledTextureSpill` takes that ceiling and clamps the room to it. The room now has its own debt entry, and the texture cache budgets entry is back to its text on main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…he room's growth New modes of agc_driver_sampled_cache_budget_tests, run without a fixed cache budget and with a reported 64 GiB heap budget: - recover-sampled-recent: with room past the device's share, a recovery for an allocation that can go to host memory keeps the current present's texture, and the new texture is placed in host memory. - recover-sampled-recent-noroom: with no room, the same recovery releases that texture, and the next budget read is one 256 MiB step past the device's share. - recover-sampled-recent-device: with every heap device-local, the recovery releases it. - spill-growth (agc_driver_sampled_cache_spill_growth): a texture turned away by a cache full of the current present's textures adds one step at the next budget read; a read with nothing turned away keeps it; a GPU that is not discrete gets none. It adds a host heap no memory type uses, so it runs on devices without one. The two host-heap recovery modes skip on a device with no memory type outside its device-local heaps (lavapipe). SetSampledSpillForTest also restarts the quiet time, so the first budget read doesn't give the room straight back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@oneandonlydean thanks. I pushed two commits on top of
Each piece of the change, taken out on its own, fails its test (one run each on the RTX 4070 Ti):
At the head, the 19 tests matching The room now has its own debt entry (under 1000 characters), and the texture cache budgets entry is back to its text on AI-assisted: yes (Claude Code) |
|
Overlap note: #12575 (QRMOE, opened 2026-10-28 21:15Z, before this PR) also changes
Keeping both, #12575's loop first, resolves it. A refused texture still goes through the refusal in Order: #12575 first, since it was first. If it merges before this PR, I'll rebase this onto it and rerun the tests in Tested. AI-assisted: yes (Claude Code) |
adriadam10
left a comment
There was a problem hiding this comment.
Thanks, the new head covers Dean's points (discrete GPUs only, room bounded by a quarter of the host heap's budget) and the tests: recover-sampled-recent, -noroom, -device and spill-growth each pin a piece that changes behaviour (the stop at recent entries, the flag set in BufferPool::AllocateMemory, the count of a refused texture), and your table shows each failing without it.
One point is still open:
- This PR is labelled
perf: it needs theaps5-summary.jsonlline of a capture onmainand one with the change, from the same title, scene and machine, plus the output oftools/trace_digest.pyon both, andtools/performance_compare.pyoutput. You said they are running; please attach them to the PR. Also add theVK_LAYER_KHRONOS_validationcomparison ofmainvs the change for the focused tests (AGENTS.md, AGC changes), confirming no newVUID-errors.
Once those are in, this is ready from my side. #12575 conflicts in ReleaseTextureCaches; whichever lands second rebases.
|
@adriadam10 the captures are attached as the release pr12684-got-captures. It has each run's trace, Setup. Ghost of Tsushima Director's Cut (PPSA02225 02.024.000), RTX 4070 Ti 12 GB, NVIDIA 615.71.09, Ubuntu 26.04.1, i7-13700K, 32 GB.
Window summary lines (B3 without, S4 with){"commit":"a1012e1e4976","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_PROFILE_DRAW":"1","APS5_TRACE_SECONDS":"300:60","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"NVIDIA GeForce RTX 4070 Ti","driver":"NVIDIA 615.71.09","os":"Linux 7.0.0-38-generic","cpu":"13th Gen Intel(R) Core(TM) i7-13700K","cpu_threads":24,"memory_mib":30993,"title_id":"PPSA02225","title":"Ghost of Tsushima","content_version":"02.024.000","resolution":"3840x2160","window":{"spec":"seconds 300:60","first_present":1114,"ms":105220.220},"presents":2,"frame_ms":{"p50":53147.830,"p90":53147.830,"p99":53147.830,"max":53147.830},"gpu_busy_ms_per_present":3649.549,"worker_busy_pct":{"queue worker 0x0":98.253,"queue worker 0x40":3.968,"queue worker 0x20":44.113,"queue worker 0x48":4.638,"queue worker 0x38":49.913,"queue worker 0x52":36.444,"queue worker 0x30":48.364,"queue worker 0x50":54.543,"queue worker 0x51":0.431},"top_phases_ms_per_frame":{"Driver.Packet":178959.343,"Driver.Packet.memory_wait":113281.201,"Driver.Packet.draw":31037.760,"Driver.Draw":31032.087,"Driver.Packet.dispatch":30506.648,"Graphics.Draw":27787.900,"Graphics.Draw.draw_and_resource_release":27414.661,"Resources.Complete":23039.212},"trace_dropped":false,"trace":"aps5-trace-a1012e1e4976-3.json.gz"}
{"commit":"ee55f9064948","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_PROFILE_DRAW":"1","APS5_TRACE_SECONDS":"300:60","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"NVIDIA GeForce RTX 4070 Ti","driver":"NVIDIA 615.71.09","os":"Linux 7.0.0-38-generic","cpu":"13th Gen Intel(R) Core(TM) i7-13700K","cpu_threads":24,"memory_mib":30993,"title_id":"PPSA02225","title":"Ghost of Tsushima","content_version":"02.024.000","resolution":"3840x2160","window":{"spec":"seconds 300:60","first_present":1135,"ms":77332.978},"presents":2,"frame_ms":{"p50":55476.022,"p90":55476.022,"p99":55476.022,"max":55476.022},"gpu_busy_ms_per_present":2839.650,"worker_busy_pct":{"queue worker 0x0":98.440,"queue worker 0x40":0.039,"queue worker 0x20":83.704,"queue worker 0x48":4.271,"queue worker 0x38":95.761,"queue worker 0x52":64.682,"queue worker 0x30":95.265,"queue worker 0x50":31.903,"queue worker 0x51":1.539},"top_phases_ms_per_frame":{"Driver.Packet":183402.453,"Driver.Packet.memory_wait":141407.974,"Driver.Packet.draw":34488.846,"Driver.Draw":34483.803,"Graphics.Draw":29326.788,"Graphics.Draw.draw_and_resource_release":29001.811,"Driver.Draw.draw_enqueued":22792.961,"Resources.Complete":21990.619},"trace_dropped":false,"trace":"aps5-trace-ee55f9064948-3.json.gz"}
|
| # | seconds | presents | p50 | p90 | p99 | max | GPU busy | busiest worker | largest phase |
|---|---|---|---|---|---|---|---|---|---|
| 1 | 0-10 | 234 | 16.7 | 87.7 | 306.3 | 2703.3 | 10.0 | 61 % | Driver.Packet 67.8 |
| 2 | 10-20 | 126 | 78.9 | 82.5 | 92.1 | 93.1 | 39.0 | 87 % | Driver.Packet 173.7 |
| 3 | 20-32 | 207 | 16.7 | 16.7 | 163.9 | 6455.0 | 3.8 | 11 % | Shader.PrepareArtifact 94.4 |
| 4 | 32-42 | 241 | 23.8 | 68.4 | 388.1 | 420.9 | 12.6 | 51 % | Driver.Packet 47.5 |
| 5 | 42-60 | 113 | 52.7 | 78.9 | 114.7 | 12696.7 | 19.5 | 81 % | Driver.Packet 360.6 |
| 6 | 60-71 | 18 | 540.9 | 1120.2 | 1253.0 | 1253.0 | 193.9 | 92 % | Driver.Packet 2384.2 |
| 7 | 71-81 | 22 | 430.4 | 493.8 | 791.0 | 791.0 | 126.0 | 91 % | Driver.Packet 1798.8 |
| 8 | 81-91 | 23 | 433.5 | 488.3 | 812.6 | 812.6 | 134.4 | 91 % | Driver.Packet 1773.8 |
| 9 | 91-101 | 24 | 431.7 | 453.8 | 460.3 | 460.3 | 116.9 | 91 % | Driver.Packet 1677.7 |
| 10 | 101-112 | 24 | 418.7 | 446.4 | 517.7 | 517.7 | 118.2 | 91 % | Driver.Packet 1646.3 |
| 11 | 112-122 | 23 | 430.9 | 471.6 | 759.2 | 759.2 | 117.8 | 92 % | Driver.Packet 1757.4 |
| 12 | 122-132 | 22 | 451.0 | 495.8 | 514.0 | 514.0 | 121.1 | 92 % | Driver.Packet 1750.3 |
| 13 | 132-143 | 20 | 439.3 | 1774.3 | 1832.6 | 1832.6 | 199.3 | 86 % | Driver.Packet 2052.6 |
| 14 | 143-155 | 10 | 1061.5 | 2109.3 | 2109.3 | 2109.3 | 434.8 | 95 % | Driver.Packet 4481.1 |
| 15 | 155-177 | 2 | 14303.3 | 14303.3 | 14303.3 | 14303.3 | 2831.2 | 100 % | Driver.Packet 52683.0 |
| 16 | 177-195 | 1 | 17445.6 | 17445.6 | 17445.6 | 17445.6 | 7986.4 | 92 % | Driver.Packet 73487.3 |
| 17 | 195-210 | 1 | 14951.9 | 14951.9 | 14951.9 | 14951.9 | 2328.4 | 99 % | Driver.Packet 70805.9 |
| 18 | 210-220 | 1 | 10525.8 | 10525.8 | 10525.8 | 10525.8 | 3594.2 | 99 % | Driver.Packet 50519.9 |
| 19 | 220-268 | 1 | 47997.5 | 47997.5 | 47997.5 | 47997.5 | 2660.8 | 100 % | Driver.Packet 168004.8 |
| 20 | 268-311 | 1 | 42737.1 | 42737.1 | 42737.1 | 42737.1 | 3761.6 | 80 % | Driver.Packet 135191.3 |
| 21 | 311-363 | 1 | 52072.4 | 52072.4 | 52072.4 | 52072.4 | 3672.4 | 97 % | Driver.Packet 207706.1 |
| 22 | 363-416 | 1 | 53147.8 | 53147.8 | 53147.8 | 53147.8 | 3626.7 | 100 % | Driver.Packet 150212.6 |
| 23 | 416-498 | 1 | 81685.8 | 81685.8 | 81685.8 | 81685.8 | 4116.0 | 100 % | Driver.Packet 234335.8 |
| 24 | 498-562 | 1 | 64219.4 | 64219.4 | 64219.4 | 64219.4 | 4809.6 | 95 % | Driver.Packet 182923.1 |
29 intervals, 0.0 to 539.3 s, 1142 presents
NVIDIA GeForce RTX 4070 Ti, NVIDIA 615.71.09, Linux 7.0.0-38-generic, 3840x2160, commit ee55f9064948
| # | seconds | presents | p50 | p90 | p99 | max | GPU busy | busiest worker | largest phase |
|---|---|---|---|---|---|---|---|---|---|
| 1 | 0-10 | 249 | 16.7 | 80.7 | 224.1 | 1379.5 | 13.9 | 59 % | Driver.Packet 60.0 |
| 2 | 10-20 | 125 | 79.9 | 82.7 | 86.8 | 90.3 | 40.7 | 87 % | Driver.Packet 176.0 |
| 3 | 20-32 | 207 | 16.7 | 16.7 | 188.2 | 6248.0 | 4.0 | 11 % | Shader.PrepareArtifact 94.0 |
| 4 | 32-42 | 227 | 20.2 | 74.0 | 396.0 | 429.0 | 13.7 | 50 % | Driver.Packet 50.4 |
| 5 | 42-61 | 135 | 47.9 | 71.8 | 76.7 | 13145.7 | 17.4 | 81 % | Driver.Packet 315.2 |
| 6 | 61-71 | 17 | 460.7 | 762.8 | 2138.6 | 2138.6 | 207.4 | 91 % | Driver.Packet 2609.2 |
| 7 | 71-82 | 21 | 424.0 | 694.4 | 770.4 | 770.4 | 128.1 | 92 % | Driver.Packet 1980.6 |
| 8 | 82-92 | 24 | 420.6 | 448.4 | 478.4 | 478.4 | 122.4 | 91 % | Driver.Packet 1657.3 |
| 9 | 92-102 | 24 | 433.4 | 450.0 | 450.4 | 450.4 | 123.6 | 91 % | Driver.Packet 1669.0 |
| 10 | 102-112 | 24 | 428.8 | 456.0 | 502.6 | 502.6 | 119.1 | 91 % | Driver.Packet 1671.7 |
| 11 | 112-122 | 22 | 430.9 | 470.6 | 950.0 | 950.0 | 129.0 | 91 % | Driver.Packet 1821.3 |
| 12 | 122-133 | 23 | 449.2 | 484.0 | 516.0 | 516.0 | 125.4 | 92 % | Driver.Packet 1735.2 |
| 13 | 133-144 | 18 | 444.5 | 1342.7 | 2665.9 | 2665.9 | 250.7 | 93 % | Driver.Packet 2328.9 |
| 14 | 144-156 | 9 | 901.5 | 3103.5 | 3103.5 | 3103.5 | 416.4 | 96 % | Driver.Packet 5399.9 |
| 15 | 156-176 | 2 | 14267.4 | 14267.4 | 14267.4 | 14267.4 | 1173.5 | 99 % | Driver.Packet 48080.1 |
| 16 | 176-194 | 1 | 17912.1 | 17912.1 | 17912.1 | 17912.1 | 10777.5 | 92 % | Driver.Packet 75603.6 |
| 17 | 194-212 | 1 | 18465.2 | 18465.2 | 18465.2 | 18465.2 | 2639.1 | 99 % | Driver.Packet 87935.2 |
| 18 | 212-231 | 1 | 19088.9 | 19088.9 | 19088.9 | 19088.9 | 3896.2 | 99 % | Driver.Packet 88460.1 |
| 19 | 231-247 | 1 | 15487.4 | 15487.4 | 15487.4 | 15487.4 | 2401.7 | 99 % | Driver.Packet 72602.3 |
| 20 | 247-263 | 1 | 16730.6 | 16730.6 | 16730.6 | 16730.6 | 2478.3 | 99 % | Driver.Packet 77263.3 |
| 21 | 263-279 | 1 | 15442.1 | 15442.1 | 15442.1 | 15442.1 | 2301.4 | 99 % | Driver.Packet 70603.2 |
| 22 | 279-299 | 1 | 20275.1 | 20275.1 | 20275.1 | 20275.1 | 2688.9 | 100 % | Driver.Packet 93474.0 |
| 23 | 299-317 | 1 | 17945.9 | 17945.9 | 17945.9 | 17945.9 | 3116.0 | 100 % | Driver.Packet 83318.7 |
| 24 | 317-339 | 1 | 21857.0 | 21857.0 | 21857.0 | 21857.0 | 3061.2 | 99 % | Driver.Packet 100475.5 |
| 25 | 339-394 | 1 | 55476.0 | 55476.0 | 55476.0 | 55476.0 | 2618.1 | 98 % | Driver.Packet 266329.4 |
| 26 | 394-409 | 1 | 15000.5 | 15000.5 | 15000.5 | 15000.5 | 14390.3 | 99 % | Driver.Packet 67248.6 |
| 27 | 409-450 | 2 | 35303.3 | 35303.3 | 35303.3 | 35303.3 | 1727.4 | 100 % | Driver.Packet 96614.9 |
| 28 | 450-499 | 1 | 49503.2 | 49503.2 | 49503.2 | 49503.2 | 6928.4 | 98 % | Driver.Packet 229080.4 |
| 29 | 499-539 | 1 | 40077.7 | 40077.7 | 40077.7 | 40077.7 | 13938.6 | 100 % | Driver.Packet 183142.2 |
trace_digest.py on the traces, first lines (B3 without, S4 with)
seconds 300:60 from present 1114: 2 presents, frame p50 53147.8 / p90 53147.8 / p99 53147.8 / max 53147.8 ms, GPU busy 3649.5 ms per present
NVIDIA GeForce RTX 4070 Ti, NVIDIA 615.71.09, Linux 7.0.0-38-generic, 3840x2160, commit a1012e1e4976, dropped: no
seconds 300:60 from present 1135: 2 presents, frame p50 55476.0 / p90 55476.0 / p99 55476.0 / max 55476.0 ms, GPU busy 2839.7 ms per present
NVIDIA GeForce RTX 4070 Ti, NVIDIA 615.71.09, Linux 7.0.0-38-generic, 3840x2160, commit ee55f9064948, dropped: no
The full outputs, with thread and phase tables, are in the release.
performance_compare.py, B3 against S4
Performance comparison
| Capture | Commit | Trace | Presents | Window (ms) |
|---|---|---|---|---|
| baseline | a1012e1e4976 | aps5-trace-a1012e1e4976-3.json.gz | 2 | 105220.220 |
| candidate | ee55f9064948 | aps5-trace-ee55f9064948-3.json.gz | 2 | 77332.978 |
- Compare captures from the same machine, title, content version and scene; matching recorded metadata cannot verify the physical machine or scene.
- Changes are candidate minus baseline. A negative frame-time change means a shorter frame interval.
- A missing top phase is unreported, not zero; its change is unavailable.
Frame and GPU times (ms)
| Metric | Baseline | Candidate | Change | Change (%) |
|---|---|---|---|---|
| frame_ms.p50 | 53147.830 | 55476.022 | +2328.192 | +4.381 |
| frame_ms.p90 | 53147.830 | 55476.022 | +2328.192 | +4.381 |
| frame_ms.p99 | 53147.830 | 55476.022 | +2328.192 | +4.381 |
| frame_ms.max | 53147.830 | 55476.022 | +2328.192 | +4.381 |
| mean_frame_ms | 52610.110 | 38666.489 | -13943.621 | -26.504 |
| gpu_busy_ms_per_present | 3649.549 | 2839.650 | -809.899 | -22.192 |
Top phases (ms per frame)
| Metric | Baseline | Candidate | Change | Change (%) |
|---|---|---|---|---|
| Driver.Draw | 31032.087 | 34483.803 | +3451.716 | +11.123 |
| Driver.Draw.draw_enqueued | n/a | 22792.961 | n/a | n/a |
| Driver.Packet | 178959.343 | 183402.453 | +4443.110 | +2.483 |
| Driver.Packet.dispatch | 30506.648 | n/a | n/a | n/a |
| Driver.Packet.draw | 31037.760 | 34488.846 | +3451.086 | +11.119 |
| Driver.Packet.memory_wait | 113281.201 | 141407.974 | +28126.773 | +24.829 |
| Graphics.Draw | 27787.900 | 29326.788 | +1538.888 | +5.538 |
| Graphics.Draw.draw_and_resource_release | 27414.661 | 29001.811 | +1587.150 | +5.789 |
| Resources.Complete | 23039.212 | 21990.619 | -1048.593 | -4.551 |
performance_compare.py, B1 against S5
Performance comparison
| Capture | Commit | Trace | Presents | Window (ms) |
|---|---|---|---|---|
| baseline | a1012e1e4976 | aps5-trace-a1012e1e4976-3.json.gz | 2 | 121721.544 |
| candidate | ee55f9064948 | aps5-trace-ee55f9064948-3.json.gz | 4 | 62001.788 |
- Compare captures from the same machine, title, content version and scene; matching recorded metadata cannot verify the physical machine or scene.
- Changes are candidate minus baseline. A negative frame-time change means a shorter frame interval.
- A missing top phase is unreported, not zero; its change is unavailable.
Frame and GPU times (ms)
| Metric | Baseline | Candidate | Change | Change (%) |
|---|---|---|---|---|
| frame_ms.p50 | 64700.771 | 15336.243 | -49364.528 | -76.297 |
| frame_ms.p90 | 64700.771 | 20203.742 | -44497.029 | -68.774 |
| frame_ms.p99 | 64700.771 | 20203.742 | -44497.029 | -68.774 |
| frame_ms.max | 64700.771 | 20203.742 | -44497.029 | -68.774 |
| mean_frame_ms | 60860.772 | 15500.447 | -45360.325 | -74.531 |
| gpu_busy_ms_per_present | 4130.639 | 2880.145 | -1250.494 | -30.274 |
Top phases (ms per frame)
| Metric | Baseline | Candidate | Change | Change (%) |
|---|---|---|---|---|
| Driver.Draw | 38973.784 | 12452.928 | -26520.856 | -68.048 |
| Driver.Draw.shader_compile_and_link | n/a | 10612.571 | n/a | n/a |
| Driver.Packet | 195032.712 | 71014.811 | -124017.901 | -63.588 |
| Driver.Packet.dispatch | 31047.547 | n/a | n/a | n/a |
| Driver.Packet.draw | 38980.192 | 12457.554 | -26522.638 | -68.041 |
| Driver.Packet.memory_wait | 123483.089 | 52928.066 | -70555.023 | -57.137 |
| Graphics.Draw | 38131.856 | 4950.903 | -33180.953 | -87.016 |
| Graphics.Draw.draw_and_resource_release | 37713.130 | n/a | n/a | n/a |
| Resources.Complete | 27914.987 | n/a | n/a | n/a |
| Shader.DrawStage | n/a | 10207.633 | n/a | n/a |
| Shader.DrawStage.capture_resources | n/a | 7012.988 | n/a | n/a |
The validation-layer comparison is in Tested: main 5 of 5, the head 9 of 9, no VUID- messages on either side. I also started longer trace windows over 210-540 s; I will add them if those runs get past the 120 s spike.
AI-assisted: yes (Claude Code)
|
@adriadam10 we'll merge this once the requests above are addressed and exact-head CI is green, unless you'd rather merge it yourself. |
|
Overlap note: #10472 (@nikhilpanchal1, opened 2026-10-24, before this PR) suballocates sampled and storage image memory, and the two heads conflict in four hunks, all mechanical (
The two don't change the same behaviour: #10472 changes where image memory comes from, and this PR changes how much the sampled cache may keep and where its recovery stops. With suballocation, the fallback flag still describes the allocation being tried. As with #12575, whichever lands second rebases. If #10472 lands first, I'll rebase this PR onto it and rerun its tests. AI-assisted: yes (Claude Code) |
|
@adriadam10 both items from your review are in, for when you have a moment to re-check:
Order notes since then: #12575 and #10472 (overlap note above): whichever lands second rebases. AI-assisted: yes (Claude Code) |
✅ NVIDIA GPU test: passedPR head
Intermittent validation messages (1, seen once in the parallel run, not reproduced when the test was re-run alone 2 times; not counted against this PR)Failing on main too (4, not counted against this PR)Passed on retry (1, failed in the parallel run, passed when re-run with a 360 s timeout; not counted against this PR)Validated but not compared (5, not in the main baseline's validation pass)Validation IDs already present on main (4 IDs in 436 tests)Skipped (39)ReproduceAutomated build and test on a contributor's NVIDIA machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs. |
|
A data point from Ghost of Yōtei (PPSA26344, 02.002.000), which shares the sampled-cache thrash this targets. Same machine and settings for every run: RTX 4070 SUPER 12 GB (615.78.08,
Over the first 41
So in this title the spill engages ( Both runs with this PR aborted; both base runs ran the full 15 minutes:
Only two runs per arm, so this is a data point, not a measurement. I can rerun with more rounds, or with a capture, if that helps. AI-assisted: yes (Claude Code) |
|
@Tehshortbus thanks, that's useful, and it matches what I'm seeing on Ghost of Tsushima (PPSA02225) today on an RTX 4070 Ti with a 9.3 GB budget. With the room at its 2048 MiB limit, the sampled cache takes VRAM the storage images then lack. Right before the host-memory kills, I'm testing @QRMOE's #12575 on the same GoT stack now. It keeps refused textures through the present instead of growing the budget, and touches the same function. If it holds up there, I'll narrow this PR so the room can't take the share the storage cache needs, or close it in favour of #12575. I'll post the GoT numbers here either way. AI-assisted: yes (Claude Code) |
|
As promised, the Ghost of Tsushima (PPSA02225) numbers. They're from an RTX 4070 Ti (12 GB, 10.5 GB
These aren't matched pairs: the stack and the save state changed between them, so they don't measure this PR on its own. Still, the extra room doesn't buy presents in either GoT or @Tehshortbus's Ghost of Yōtei runs, and in GoT it costs the storage images their VRAM. #12575 deals with the refused-texture churn without growing the budget. So I'm closing this in favour of #12575. Thanks @adriadam10 and @Tehshortbus for the reviews and data. AI-assisted: yes (Claude Code) |
What
Ghost of Tsushima Director's Cut (PPSA02225 02.024.000) runs its brightness screen and opening at about one frame per 30 to 50 seconds on an RTX 4070 Ti (12 GB) here. The draws are CPU bound in their resource builds. The sampled texture cache's budget sits at its 2 GiB floor: the device-local heap's
VK_EXT_memory_budgetbudget is about 9.2 GB, because other processes hold about 2.2 GB of the card, and about 6.4 GB of it is in use outside the texture caches.A frame's sampled textures don't fit in 2 GiB. One draw binds a 27,130-element image table, and the frame uses about 2.5 GiB of textures in all.
admitTexturethen finds every entry it could evict used in this or the previous present, so it turns the new texture away ("used uncached"), and the texture is made again at its next use. Over 210-600 s of a default run, the driver made 157,000 to 165,000 sampled textures. With this change, that stretch presents 20 frames instead of 6 and 9 (two runs each, see Tested).How
sampledBudgetadds room past the reported share while a frame's textures don't fit, when the device has a heap outside device-local memory. Two things count as a frame that doesn't fit:admitTextureturning a texture away, and an out-of-memory recovery for an allocation that could go to host memory reaching a sampled entry used in the last two presents. In Ghost of Tsushima the second is the common one: the cache stays at its budget, and the recoveries release the frame's own textures.VK_EXT_memory_budgetbudget (its size without the extension) in whole steps (SampledSpillCeiling). Only a discrete GPU gets room at all.SampledTextureSpillis that step, as a function of the previous room, whether the frame didn't fit since the last read, whether the cache is quiet, and the ceiling; room above a ceiling that fell is brought down to it.While the budget has that room,
ReleaseTextureCachesstops at the first sampled entry used in the last two presents when the allocation that ran out of device memory can go to host memory (ReclaimHasHostFallback, set byBufferPool::AllocateMemoryaround its recovery call). The allocation then goes to host memory through its existing fallback.Without that second part the grown cache only fills the device-local heap sooner. Each out-of-memory recovery then releases about 270 MiB of the frame's own textures, and the frame rate doesn't change. So the two parts are one change. The textures past the device's share also go to host memory once the heap is at its reported budget, through the existing placement in
Context::DeviceMemoryType.The
[gpu] sampled texture cache budgetline now says how much of the budget is past the device's share, and the[gpu] texture caches releasedline says when a recovery stopped at a recently used entry. Those stops come several times a second in Ghost of Tsushima, so the line is printed for the first five and then at each power of two, with the running count.A device whose frame fits its budget never turns textures away, so its budget doesn't change. That matters because USAGE.md records a title that got slower with a fixed larger budget (PPSA16064 with
APS5_TEXTURE_CACHE_MIB=3072on an 8 GB card). A GPU that isn't discrete gets no room: an integrated GPU's non-device-local heap (an APU's GTT heap under RADV, for example) is the same system memory the title uses. Neither does a device whose heaps are all device-local. On a discrete GPU the quarter bounds the room by what the host can give: here the host heap is 22.7 GiB of a 32 GB host, so the ceiling is the 2 GiB cap, and a host heap with a 6 GiB budget would get 1.5 GiB.APS5_TEXTURE_CACHE_MIBstill fixes the budget.The storage image cache is left as it is. In the experiments below, raising only its budget didn't change the frame rate.
USAGE.md describes the room. It has its own debt entry, which says where the step, the cap, the quarter and the 10 s came from; the texture cache budgets entry is as on
main.Tested
Linux (Ubuntu 26.04.1, GCC 15.2), RTX 4070 Ti 12 GB (NVIDIA 615.71.09), with about 2.2 GB of the card held by other processes. On
mainc9207624bcunless noted:New
agc_sampled_cache_spill(CPU only):SampledTextureSpillgrows by 256 MiB per read while the frame doesn't fit, stops at the ceiling (2 GiB or a lower one), keeps its room on a read that is neither, gives a step back on a quiet read (the rest when less than a step is left), and brings room above a lowered ceiling down to it.SampledSpillCeilingis 2 GiB for a 22 GiB host heap and 1.5 GiB for a 6 GiB host budget. It uses the heap's size without a reported budget, rounds down to whole steps, and gives 0 for a heap whose quarter is under a step, for a GPU that isn't discrete and when every heap is device-local.New execution modes of
agc_driver_sampled_cache_budget_tests. They run without a fixed cache budget and with a fakeVK_EXT_memory_budgethook reporting 64 GiB per heap:agc_driver_recover_sampled-recent_allocation: with room, a host-fallback recovery keeps the current present's texture, and the new texture goes to host memory.agc_driver_recover_sampled-recent-noroom_allocation: with no room, the same recovery releases the texture, and the next budget read is the device's share plus 256 MiB.agc_driver_recover_sampled-recent-device_allocation: with every heap device-local, the recovery releases it.agc_driver_sampled_cache_spill_growth: a texture turned away by a cache full of the current present's textures adds 256 MiB at the next read, a read with nothing turned away keeps it, and a GPU that isn't discrete gets none.Each piece taken out alone fails its test (one run each). Without the stop at recent entries,
recover_sampled-recentfails. With the stop regardless of room,recover_sampled-recent-noroomfails. WithoutadmitTexture's count,spill_growthfails. Without the recovery's count,recover_sampled-recent-noroomfails. Without the discrete-GPU check,agc_sampled_cache_spillandspill_growthfail.Area: at this head (
ba0eaedff6), the 19 tests matching^agc_driver_recover_|^agc_sampled_cache|^agc_driver_sampled_cache|^agc_driver_storage_cache|^agc_buffer_poolpass 3 of 3.Validation layer (Khronos
VK_LAYER_KHRONOS_validation1.4.363, LunarG SDK), onmainc9207624bcand at this head:VK_LAYER_PATH=<sdk>/layers VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 ctest -R '^agc_driver_sampled_cache_budget$|^agc_driver_recover_|^agc_driver_sampled_cache_spill_growth$' -Vmainpasses 5 of 5 (the new modes don't exist there) and the head 9 of 9. Neither log containswas not found but was requested by env var VK_INSTANCE_LAYERS.VUID-messages on either side.b31f5f73d9, the earlier comparison over^agc_driver_sampled_cache_budget$|^agc_driver_sampled_cache_budget_memory$|^agc_driver_storage_cache_budget$|^agc_driver_image_table_reusewas also clean: 5 of 5 on each side, with 3 devices checked.Ghost of Tsushima (PPSA02225 02.024.000). Plain
mainstops 9-29 s in onnative multisample stencil or depth format import is not implemented(feat(agc): sample the stencil plane of a native multisampled D32S8 target #9717). So this was a local stack that runs it, with and without this change:maind5ef780bb4with feat(agc): sample the stencil plane of a native multisampled D32S8 target #9717 (fix(agc): import native multisample D32S8 targets with a separate stencil plane and a depth-only HTILE #9533 inside it), fix(agc): accept a colour alias over a native multisample depth plane when HTILE proves its clear #9742, fix(agc): build a partially committed sampled 3D view from its committed slices #10064, fix(agc): keep a registered shader's register state as a sorted list #10727, fix(agc): bound the SPIR-V that background compute pipeline builds compile at once #12147, feat(agc): store the pipeline journal's modules compressed #8365, fix(agc): build one compute pipeline when results differ only in a table's size #8212, fix(shader): read a 2D MSAA T# through image_sample_a as its sample 0 #12561, feat(agc): read sample 0 of a native multisampled depth surface through a 2D image #12612, fix(agc): take a storage image's writes to the stencil plane when a depth target binds #12617 and env-gated diagnostics (a1012e1e49), then this change on top (fd488704ff, the same code as662b49d7b7;b31f5f73d9adds only the rate limit of its log line, and the head's ceiling is the 2 GiB cap on this machine). Runs alternate with and without, 600 s each, pad input, defaults otherwise. The brightness screen and opening start about 200 s in; I count presents from 210 to 600 s:MemAvailable(32 GB host) was 4.2 and 4.5 GB with this change, and 2.7 and 4.5 GB without it.admitTextureturned textures away gave 10 and 7 presents, against 9 and 6 without. In this scene the cache rarely turns textures away: the recoveries release them. That's why the recovery reaching a recent texture also counts.Trace captures (
APS5_TRACE_SUMMARY_EVERY=10 APS5_TRACE_SECONDS=300:60, the same stack without and with this PR's three commits,a1012e1e49andee55f90649), attached as a release. In the interval lines from 195 s, the runs without the change presented 7 and 7 frames, and the runs with it 13 and 22. The details and theperformance_compare.pyoutput are in this comment.Call of Duty: Black Ops II (PPSA34502), 300 s with pad input (
main+ fix(libSceVoice): report inactive input voice activity #9656): its sampled cache held 365 MiB of a 3693 MiB budget and never turned a texture away. This change doesn't grow its budget.Windows 11 VM (GeForce GT 1030, WinLibs GCC 15.2, Release), at this head: the 17 tests matching
^agc_buffer_pool|^agc_sampled_cache|^agc_driver_sampled_cache|^agc_driver_recover_pass 3 of 3. Onmainc9207624bc, the 12 that exist there pass 3 of 3.Not tested: AMD, and a title whose frame fits its budget on a smaller card, such as PPSA16064 from USAGE.md. I don't have those here.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)ShaderResources.cpp/.hppand the debt entry), and perf(agc): reuse a texture the sampled cache refuses while frames keep using it #12575, which keeps refused textures for their present (one hunk inReleaseTextureCaches). The order is in the comments below.🤖 Generated with Claude Code