WIP: fix(vk): memory is added up and given back under pressure, host writes are marked, and late pages are found when a capture is taken #1339
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
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1339
Loading…
Reference in a new issue
No description provided.
Delete branch "HumanBean/Longshot:feat/mem-account"
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: fix · Risk: medium · Tested on: Linux, RTX 3090 · Needs: a card of 8 GB or less; an integrated GPU; a Windows run
Why
Tracks A and B of the renderer rework plan: memory. Nine of 55 grouped crash reports end at a memory limit and ten more are VRAM-full during play, yet nothing added up what the renderer holds and only the texture cache answered to pressure; and 'stale data after the GPU writes' kept being fixed one case at a time. This is the one pull request for memory; it took in #1360. Stacked on #1309: review the commits after it. See #1034, which fixes the same host writes with its measurement tools.
What changed
Read the commits in order; each stands alone.
vk: budget:), against the driver's count, in two ledgers.RX_VK_MEM_CHECK=1counts where the sync breaks its rules.Measurements
Verdict: no change in fps without pressure; under a simulated 6.5 GB allowance the arbiter gave back 192 to 232 MB at a time and textures settled at 3 GB.
Testing
Tested:
python -I -B tests/run_all.py: 663 passed, 44 failed, 19 skipped.tests/test_mirror_budget.py, which fails onmain, passes here. Onmainat8e9cfc3athis PC has 46 checks failing (648 pass, 19 skipped); none of them is new here.RX_VK_TEST_ALLOWED_MB=8000and6500, withRX_VK_MEM_CHECK=1, and withRX_VK_LATE_AT_REPLAY=0against on.Not tested:
mainunder the same allowance.Must be tested:
scripts/memtour.py: VRAM and fps as on main or better,unaccountednot growing.@Beanstalk windows nvidia and windows amd: main against this PR, Kokiri Forest, Hyrule Field, the Market, three area changes).Risks
What could break: a small card with 256 MB of mirrors reads pools over PCIe that fitted before; staging freed on entering pressure is made again at the next load; on Windows freed imported pages cost a memset.
Turning it off:
RX_VK_LATE_AT_REPLAY=0for the late-page fix;RX_VK_MIRROR_MBfor the mirrors; the arbiter has no switch.Compatibility: none: no cache is rebuilt,
MKWVK_API_VERSIONstays.Issues
See #1034
Checklist
Everyone
type(scope): description) of the status line's type.main.python -I -B tests/run_all.pypasses (any failure that also fails onmainis named).third_party/untouched (a new folder with aPROVENANCE.mdinstead).When it applies
Assisted-by:/Co-Authored-By:trailers.tests/that reads changed source updated in this PR, not weakened.🤖 Generated with Claude Code
https://claude.ai/code/session_017vw8dzCsAL3UdW7ft8ptL9
Tested in game: Linux, RTX 3090, NVIDIA 620.70: one session through Kokiri Forest and Hyrule Field at 2560x1440; seven vk: budget: lines, sums within 427 MB of the driver's count, scenes drew as main.
A second commit is on this branch: the budget's next step. It changes behaviour under VRAM pressure and on small cards.
What it adds
other buffers). On the RTX 3090unaccountedfalls from 426 MB to about 280 MB: what the driver and the upscalers' libraries hold themselves.mirror_rule::auto_bytesagain. Cards of 4.5 GB or less get 256 MB of mirrors, asmirror_budget.hargues, where they had a third of the card (1365 MB on 4 GB). 5 to 6.5 GB cards keep 1700 MB.tests/test_mirror_budget.py, which could not pass on main, is back in line with the source.docs/development/memory-budget.md(new).Run in the game (RTX 3090, 1440p;
RX_VK_TEST_ALLOWED_MBstands in for a smaller card's allowance, not its heap):No give-back line without pressure, no device lost. Not tested: a real small card (the mirror change cannot be seen here at all), an integrated GPU, Windows, long play, and
tests/run_all.py. The Market's long frames under pressure were not compared with main under the same allowance.The renderer rework plan's track A, step 1. Every buffer made through the allocator is counted ('other buffers'), so 'unaccounted' is what the driver and the upscalers' libraries hold themselves (426 -> 280 MB on an RTX 3090). When VRAM pressure begins, by the texture cache's own 90% and 97% lines, an arbiter asks the pools that hold memory for reuse in a stated order (capture spares, staging, free blocks, the target pool) and credits what they give against the textures' excess. Nothing is asked without pressure. mirror_rule::auto_bytes holds the whole mirror rule: cards of 4.5 GB or less get 256 MB again (they had up to 1536), 5 to 6.5 GB keep 1700. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_017vw8dzCsAL3UdW7ft8ptL926b67469408d13734772WIP: feat(vk): one log line adds up what every pool of the renderer holds, against VRAM and RAMto WIP: fix(vk): memory is added up and given back under pressure, host writes are marked, and late pages are found when a capture is takenView 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.