WIP: fix(vk): prioritize driver-returning frees and bound synchronous block-share drains in reap_now (#2905) #3097
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
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
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!3097
Loading…
Reference in a new issue
No description provided.
Delete branch "Jer9/Longshot:fix/vk-vma-reap-stall-2905"
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?
Summary
What a player notices: When texture memory approaches the driver budget (for example, entering Kakariko Village or Hyrule Market on 8 GB GPUs or integrated GPUs), frame times no longer hitch from draining every queued block-allocated texture synchronously on the render thread.
26.10.1) hittingmem_accountarbiter pressure (#2905).reap_now.Root Cause & Fix (
gpu/vk/vk_vma.cpp)Under VRAM pressure (
mem_accountarbiter level 1/2),reap_now(want, vram)looped whilegot < want, incrementinggot += it->returns[l]. For block-allocatedReapedimages,returns[l] == 0, sogotstayed0 < wantandreap_nowstole and synchronously destroyed every queued block-allocated image on the render thread in a single frame instead of letting the backgroundmkw_vk reaperthread drain them, and destroyed block-allocated images ahead of dedicated allocations that actually return VRAM to the driver.returns_to_driver(l)) first untilgot >= want.got < want): For normal arbiter pressure (want < UINT64_MAX), bound synchronous block-share frees toblock_freed < want - gotand at mostkReapNowBlockCap = 16entries per call, leaving the remainder for the background reaper thread.want == UINT64_MAX,memory_refused): Setsdrain_all = trueand still drains 100% of the ledger unconditionally.RX_VK_REAPER=0andcompact_in_passguards are unchanged.Testing
RX_VK_TEST_ALLOWED_MB=2800on Radeon 860M or 8 GB dGPU in Market / Hyrule Field).0VK_ERROR_DEVICE_LOST/ OOM and lowercreate_ms/>50 msframe spikes.tests/test_image_reaper_threads.py): Added 4 cases inbccf053ac(150-image burst cap, small-wantbyte bound, dedicated-first priority,UINT64_MAXOOM full drain; fails onforge/main, passes withc46174be5).tests/test_image_reaper.py(6/6),tests/test_image_reaper_threads.py,tests/test_submit_oom.py, andpython -I -B tests/run_all.py --changed forge/main(21 passed, 0 failed, 5 skipped) all pass.Measurements
Measured standalone on Windows 11, AMD Ryzen AI 7 350 / Radeon 860M (RDNA 3.5, Adrenalin 26.10.1), windowed
1920x1080(100% render scale),RX_VK_TEST_ALLOWED_MB=2800(1260 MBtexture budget):Where it makes a difference
Market_Child/HyruleField_Adult)forge/main(b4d56f526)fix/vk-vma-reap-stall-2905(c46174be5)Market_ChildMean FPS / 1% LowMarket_Childp99 / max frame timeHyruleField_Adult1% LowHyruleField_Adult>50 msspikesHyruleField_Adultcreate_msp99 / maxWhere it does NOT make a difference (within run-to-run variance)
forge/main(b4d56f526)fix/vk-vma-reap-stall-2905(c46174be5)HyruleField_AdultMean FPSChecklist
main(b4d56f526)tests/test_image_reaper_threads.py, failing onmain, passing here)python -I -B tests/run_all.py --changed forge/mainpasses (21 passed, 0 failed, 5 skipped)mise run test/tests/run_all.pyon this branchAssisted-by: Antigravity (Gemini 4 Neon)
Co-Authored-By: Antigravity [email protected]
Tested in game: Windows 11 Radeon 860M 1920x1080 RX_VK_TEST_ALLOWED_MB=2800: Hyrule +13.5% 1% low, >50ms spikes -80%, 0 DEVICE_LOST
Possibly related, for context:
Closing this WIP PR after adversarial self-review:
6110/6920 MB=88.3% < 90%VRAM allowance,vk: reaper: 205 images destroyed, 0 of them where they were handed over) confirmsreap_now()was not active during #2905's Kakariko/Market stalls.kReapNowBlockCap = 16under genuine>= 90%VRAM pressure risks starvingtexture_poolblock reuse (when smalltexture_small_poolentries sit ahead of large textures) and double-counting queuedreaper_images[VRAM]insidetexture_frame'spressurecalculation.Will investigate #2905's actual
< 90%VRAM stall path separately if warranted.Pull request closed