fix(vk): past the allowance the textures' floors give way, so a 6 GB card's VRAM comes back under it #2082
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
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2082
Loading…
Reference in a new issue
No description provided.
Delete branch "HumanBean/Longshot:fix/vram-floor-past-allowance"
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
On cards the driver allows under 8 GB, the texture cache has a floor: the 90% rule, the compaction's hold and reserve,
and the 97% rule never cut its budget below 1800 MB (
vram_compact::texture_min_floor), and the dynamic floor can beas high as half the allowance (#637). That stops a nearly full card from evicting the textures in use one pass after
another, which is right while the card is within its allowance. Past the allowance it means no rule can take a texture
once the textures are under the floor, whatever the rest of the renderer holds. The driver then pages VRAM out to
system memory, and every frame reads part of it over PCIe. In #939 a GTX 1060 6 GB sat at 6128 MB of the 5231 MB it
allowed with 1606 MB of textures, already under today's 1800 MB floor, and Hyrule Field went from 31 to 14 fps until a
restart.
With this change the floors apply only while the driver's count is within the allowance
(
vram_compact::floor_within, andcount_line_floorfor the 97% rule). Past it, the eviction's own rule still keepsevery texture used in the last 60 presents, and the textures that have gone unused longer go until the count is back
under the line. Within the allowance nothing changes.
How to see it on
main: a 6 GB card (orRX_VK_TEST_VRAM_MB=6144with anRX_VK_TEST_ALLOWED_MBlow enough that themirrors, shadows, render targets and blocks' free space take more than the allowance less 1800 MB). Tour a few areas.
The log's
vk: VRAM:line shows the count past the allowance andtextures ... (budget 1800 MB)while the textures sitat or under 1800 MB.
Why textures run over their budget in #939 and #1008: in those logs (nightly-189, rc.4, before #637 added today's
floor) the textures were over a budget the rest of VRAM had squeezed to 136-448 MB. Most of them had been used in the
last frames ("used in the last 8 presents 1668 MB" of 2358), so the eviction, which never takes a texture used in the
last 60 presents, could not meet it. The budget is enforced, but it can't go below the working set. On
maintodaythe same squeeze stops at the floor instead. This PR lets it go on past the allowance, down to the working set.
Read first:
floor_withinandcount_line_flooringpu/vk/vram_compact.h, then the two call sites intexture_frame(gpu/vk/vk_texture.cpp:active_floor, and the 97% rule'sfloor).See #939, #1008, #861, #1443. It does not fix the render-target growth (#1462, merged), the shadow map's size (#1367)
or the target pool's churn (#1996). Those are other parts of the same VRAM.
Testing
Tested: Linux, RTX 3090, NVIDIA 620.70.06,
main@9dd41326only. I ran a memory tour (scripts/memtour.py,repository save
kokiri-start, Zora's Domain, Hyrule Field, Kakariko, Market, Kokiri Forest, Lost Woods, DeathMountain Trail, Goron City, two laps, 60 s each) at
RX_VK_TEST_VRAM_MB=6144 RX_VK_TEST_ALLOWED_MB=5200, a 6 GBcard's whole policy. 106
vk: VRAM:samples: median 4815 MB, peak 5227 MB, 2 over 5200. Textures sat at about the1800 MB floor (
budget 1800 MBin most samples) beside mirrors 550-1250 MB, shadows up to 364 MB, 340-1355 MB free inthe blocks, and 350-610 MB unaccounted. So on this PC the rest of the renderer still fits beside the floor. The GTX 1060
of #939 runs at 2560x1440, with Windows' own overhead on top, and there it does not fit.
This PR, in the game: this PR @
f42ab627as a pack over the same base, through the job queue: a memory tour of 8 areas (Zora's Domain, Hyrule Field, Kakariko, Market, Kokiri Forest, Lost Woods, Death Mountain Trail, Goron City), 40 s each, atRX_VK_TEST_VRAM_MB=6144 RX_VK_TEST_ALLOWED_MB=4600, where the floor binds on this PC. 149vk: budget:samples: the driver's count median 4379 MB, peak 4765 MB, 11 samples over 4600; textures median 1818 MB, down to 142 MB at the lowest when it gave way. No crash, no device loss, no texture errors seen, clean quit.mainat 4600 MB is queued for the comparison (Measurements).Still to test:
mainand on this PR atRX_VK_TEST_ALLOWED_MB=4600 RX_VK_TEST_VRAM_MB=6144,expecting
mainpast 4600 MB withbudget 1800 MBand this PR back under it, with textures below 1800 MB.@Beanstalk This changes the texture cache's budget on cards with less than 8 GB of video memory: once the driver says
the game is past the video memory it allows, the textures are no longer held at a floor of 1800 MB, so unused ones are
let go until it is back under the allowance. Please run main and this PR on Windows with NVIDIA on a 6 GB card and on
Windows with AMD on a 6 to 8 GB card, at the driver's default settings, 1440p output where the card allows it. Play
Hyrule Field for two minutes, then Kokiri Forest, Kakariko, the Market and Death Mountain Trail for two minutes each
turning the camera, then Hyrule Field again for two minutes. Expect the log's
vk: VRAM:lines to stay at or underthe allowance on this PR where main goes past it, and the second Hyrule Field visit to keep its fps and 1% low near the
first one where main's falls. Expect no textures flashing, black, garbled or missing, and no crash or device lost.
Please report the peak
vk: VRAM:used and allowed, thetextures ... (budget ...)values, fps and 1% low on bothHyrule Field visits, and the Windows "shared GPU memory" of the game if you can read it.
Measurements
Verdict: at a 6 GB card's 4600 MB allowance the driver's count peaks 574 MB lower (4765 against 5339 MB) and goes over the allowance less often (11 against 15 of 149 samples); the median moves 78 MB down. One run each way, in turn, on the same PC and tour: a single pair, so the peak is the clear part, the counts are close.
Setup: Linux, RTX 3090, NVIDIA 620.70.06; repository save
kokiri-start, headless memory tour of 8 areas (Zora's Domain, Hyrule Field, Kakariko, Market, Kokiri Forest, Lost Woods, Death Mountain Trail, Goron City), 40 s each, default options;RX_VK_TEST_VRAM_MB=6144 RX_VK_TEST_ALLOWED_MB=4600(where the floor binds on this PC); thevk: budget:lines, 149 samples each.9dd41326f42ab627An earlier
maintour at 5200 MB (106 samples: median 4815, peak 5227, 2 over) showed the floor doesn't bind on this PC at that allowance.Risks
Past the allowance more textures may be let go than before, down to those used in the last 60 presents (about 2 s at
30 fps). A texture brought back soon after costs an upload and, for ASTC, a decode: a short hitch when turning back to
something, where
mainpaged instead. Within the allowance nothing changes. Cards with 8 GB allowed or more areaffected only past their allowance. No switch; a revert is enough. Nothing changes for players' files or caches.
Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named). (Not run on this PC; CI runs it.)main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here. (tests/test_vram_compact.py: theheld_budgetchecks past the allowance fail onmain; not run here, CI runs it.)tests/that reads changed source is updated, not weakened.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
https://claude.ai/code/session_017vw8e2uxGKQxzDeQ15jjNK
Tested in game: Linux, RTX 3090, NVIDIA 620.70.06, this PR @
f42ab627over main 9dd41326's base, through the job queue: memory tour of 8 areas at RX_VK_TEST_VRAM_MB=6144 RX_VK_TEST_ALLOWED_MB=4600 (a 6 GB card's policy). Driver count median 4379 MB, peak 4765 MB against 4600 allowed; textures gave way down to 142 MB when needed; no crash or texture errors, clean quit.@Beanstalk This changes the texture cache's budget on cards with less than 8 GB of video memory: once the driver says
the game is past the video memory it allows, the textures are no longer held at a floor of 1800 MB, so unused ones are
let go until it is back under the allowance. Please run main and this PR on Windows with NVIDIA on a 6 GB card and on
Windows with AMD on a 6 to 8 GB card, at the driver's default settings, 1440p output where the card allows it. Play
Hyrule Field for two minutes, then Kokiri Forest, Kakariko, the Market and Death Mountain Trail for two minutes each
turning the camera, then Hyrule Field again for two minutes. Expect the log's
vk: VRAM:lines to stay at or underthe allowance on this PR where main goes past it, and the second Hyrule Field visit to keep its fps and 1% low near the
first one where main's falls. Expect no textures flashing, black, garbled or missing, and no crash or device lost.
Please report the peak
vk: VRAM:used and allowed, thetextures ... (budget ...)values, fps and 1% low on bothHyrule Field visits, and the Windows "shared GPU memory" of the game if you can read it.
Beanstalk test farm
Commit
6781926· approved by nobody yet · dashboardA member of
BigBeanscan review this commit and comment@Beanstalkto test it.Measured main against this PR at a 6 GB card's 4600 MB allowance, same tour, one run each in turn: the driver's VRAM peak 5339 → 4765 MB, samples over the allowance 15 → 11 of 149. Measurements updated.
@Beanstalk
f42ab6276a6781926dd7Rebased onto main
4c8210e7. One conflict, text only (a code comment / the architecture doc's section beside main's new 'Each heap's budget'): kept main's text and this PR's. No code change from the tested head. No tests run on this PC (CI runs them).WIP: fix(vk): past the allowance the textures' floors give way, so a 6 GB card's VRAM comes back under itto fix(vk): past the allowance the textures' floors give way, so a 6 GB card's VRAM comes back under it