WIP:perf(vk): 3-tier render target pool pressure (halve at >90%, flush at >97%) #1035
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1035
Loading…
Reference in a new issue
No description provided.
Delete branch "flix331/Longshot:perf/vk-target-pool-3tier"
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?
Type: perf · Risk: low · Tested on: Windows, NVIDIA GeForce RTX 3050 6GB Laptop GPU (driver 610.62) · Needs: none
Why
On constrained-VRAM GPUs (such as 6 GB laptops in Castle Town Market), VRAM pressure frequently sits between 90% and 97% of the driver's allowance. Previously,
pool_pressedwas binary: as soon as pressure crossed 90%,pool_trim()dropped the render-target pool cap from256 MBstraight to0 MB, destroying pooled render-target images only to recreate them shortly after.Changing this to a 3-tier policy (full
256 MBbelow 90%, halved128 MBbetween 90% and 97%, and full flush to0 MBabove 97%) preserves render-target reuse in the 90%–97% band without lowering the256 MBcap and without delaying emergency eviction above 97%.What changed
Replaced the binary
pool_pressedboolean with a 3-tierpool_pressurestate (0,1,2) while keepingpool_cap()at256 MB.bool pool_pressedwithuint8_t pool_pressure(0: normal,1: >90% allowed,2: >97% allowed) ingpu/vk/vk_texture.cpp.pool_trim()ingpu/vk/vk_texture.cppto keeppool_cap()below 90%, halve topool_cap() / 2above 90%, and flush to0above 97%.texture_frame()and itsvk: render target images:status log ingpu/vk/vk_texture.cppto reportVRAM short: halvedvsVRAM critical: given back.Measurements
Verdict: Works as intended: in the 90%–97% pressure band the pool now retains
102 MB(69images) instead of flushing to0 MB, with no FPS regression in heavy Castle Town Market (>= 1,800draws) and lower live texture usage (2,394 MBvs2,727 MB). Free space trapped in VMA blocks (1,202 MBvs874 MB) awaits follow-up PR (b).Hardware: Windows 11, NVIDIA GeForce RTX 3050 6GB Laptop GPU (
6,001 MBVRAM,5,233 MBdriver allowance, driver610.62), 16 GB RAM, 12 threadsScene: Castle Town Market (
>= 1,800draws),1920x1080, game's own upscaler (dlss=0), no frame rate cap, syncedlongshot_options.iniMethod:
logs/longshot_log.txtparsed across Market frames (>= 1,800draws, 16 samples each) onLongshot-mainvsperf/vk-target-pool-3tierHow to reproduce: Launch with
VK_ICD_FILENAMESpointing to NVIDIAnv-vk64.json, walk/stand in Castle Town Market, and inspectvk: render target images:andvk: VRAM:lines inlogs/longshot_log.txt.e090cc48102918862,3832,32821.54(15.2–31.6)19.48(16.5–22.7)22.44 ms/18.52 ms28.54 ms/18.99 msit holds 69 (102 MB), VRAM short: halved2,354 reused, 21,819 made, 21,522 destroyed; it holds 0 (0 MB), VRAM short: given back2,960 reused, 20,906 made, 20,752 destroyed; it holds 0 (0 MB), VRAM critical: given back5,423 MB used of 5,233 MB (874 MB free in blocks); textures 2,727 MB (budget 1,528 MB), 2,284 textures5,645 MB used of 5,233 MB (1,202 MB free in blocks); textures 2,394 MB (budget 1,375 MB), 1,916 texturesFlags and settings
None
Testing
Tested:
nx2/make_game.py --update(llvm-mingw,33,129graphics +9,925compute pipelines precompiled) and verified in Castle Town Market (longshot_log.txt).llvm-mingw\binonPATH:tests/test_vram_compact.py(PASS: the compaction's rules) andtests/test_vram_pressure.py(PASS: the shadows go by what is really allocated).Not tested: Linux, AMD, Intel Arc/iGPU, and full
tests/run_all.pyoutside sandbox (tests/run_all.pyhit sandbox/PATH skips when invoked withoutllvm-mingwonPATH).Must be tested:
vk_texture.cpppool-trimming change; preserves existing256 MBcap and>97%flush behavior).Risks
What could break: Between 90% and 97% driver allowance, up to
128 MB(pool_cap() / 2) remains in the render-target pool instead of being freed immediately; above 97% it flushes to0as before.Turning it off: Revert commit
10291886(or setRX_VK_TARGET_POOL_MB=0).Compatibility: Nothing changes (saves,
longshot_options.ini, shader/pipeline caches, and vk ABI are unaffected).Checklist
Everyone
type(scope): description) of the status line's type.main.python -I -B tests/run_all.pypasses (partially run in sandbox:test_vram_compact.py&test_vram_pressure.pypass; run fullrun_all.pylocally withllvm-mingw\binonPATHbefore marking ready).third_party/untouched (a new folder with aPROVENANCE.mdinstead).When it applies
Assisted-by:/Co-Authored-By:trailers.Possibly related, for context:
vk/texture: 3-tier render target pool pressure (halve at >90%, flush at >97%)to WIP:perf(vk): 3-tier render target pool pressure (halve at >90%, flush at >97%)102918864788c4d2125cResults are worst?
Tested on Linux, RTX 3090 (NVIDIA 620.70.06), under a 6 GB card's rules (
RX_VK_TEST_VRAM_MB=6144 RX_VK_TEST_ALLOWED_MB=5233). DLAA 2560x1440, threading on Auto, Hyrule Field then the Market (walking, then turning the camera).Rebase: this PR onto
main@60bf15bd. It conflicted in nothing, but it doesn't compile there. #568 (merged today) added two uses ofpool_pressed, which this PR renames topool_pressure:gpu/vk/vk_texture.cpp, the staging arenas' burst (!pool_pressed→!pool_pressure)pool_pressed = true;→pool_pressure = 2;)I made those two changes locally to measure it. You'll want them when you rebase.
Verdict: it does what it says, and on this card it changes nothing you can feel.
For comparison, a change I'm testing keeps only the images put in the pool in the last 2 presents while VRAM is short. It cut the churn by a quarter, not a half, and showed no fps change either.
🤖 Generated with Claude Code
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.