fix(vk): keep the 97% texture squeeze past the driver's allowance (#2… #2585
Closed
SadTransGirl wants to merge 1 commit from
SadTransGirl/fix/texture-squeeze-past-allowance into main
pull from: SadTransGirl/fix/texture-squeeze-past-allowance
merge into: MagicBeanDev:main
MagicBeanDev:main
MagicBeanDev:github/pr/2893
MagicBeanDev:github/pr/2890
MagicBeanDev:github/pr/2887
MagicBeanDev:github/pr/2878
MagicBeanDev:github/pr/2875
MagicBeanDev:github/pr/2874
MagicBeanDev:github/pr/2873
MagicBeanDev:github/pr/2871
MagicBeanDev:github/pr/2756
MagicBeanDev:github/pr/2897
MagicBeanDev:github/pr/2896
MagicBeanDev:github/pr/2718
MagicBeanDev:github/pr/2842
MagicBeanDev:github/pr/2691
MagicBeanDev:github/pr/2895
MagicBeanDev:github/pr/2743
MagicBeanDev:github/pr/2765
MagicBeanDev:github/pr/2708
MagicBeanDev:github/pr/2732
MagicBeanDev:github/pr/2755
MagicBeanDev:github/pr/2817
MagicBeanDev:github/pr/2876
MagicBeanDev:release-please--branches--main
MagicBeanDev:release-please--branches--main--release-notes
MagicBeanDev:github/pr/2778
MagicBeanDev:github/pr/2888
MagicBeanDev:github/pr/2866
MagicBeanDev:github/pr/2877
MagicBeanDev:github/pr/2800
MagicBeanDev:github/pr/2829
MagicBeanDev:github/pr/2850
MagicBeanDev:github/pr/2889
MagicBeanDev:github/pr/2882
MagicBeanDev:github/pr/2860
MagicBeanDev:github/pr/2849
MagicBeanDev:github/pr/2886
MagicBeanDev:github/pr/2794
MagicBeanDev:github/pr/2840
MagicBeanDev:github/pr/2830
MagicBeanDev:github/pr/2834
MagicBeanDev:github/pr/2719
MagicBeanDev:github/pr/2742
MagicBeanDev:github/pr/2741
MagicBeanDev:github/pr/2820
MagicBeanDev:github/pr/2771
MagicBeanDev:github/pr/2859
MagicBeanDev:github/pr/2858
MagicBeanDev:github/pr/2823
MagicBeanDev:github/pr/2757
MagicBeanDev:github/pr/2769
MagicBeanDev:github/pr/2844
MagicBeanDev:github/pr/2843
MagicBeanDev:github/pr/2673
MagicBeanDev:github/pr/2855
MagicBeanDev:github/pr/2739
MagicBeanDev:github/pr/2807
MagicBeanDev:github/pr/2851
MagicBeanDev:github/pr/2789
MagicBeanDev:github/pr/2814
MagicBeanDev:github/pr/2818
MagicBeanDev:github/pr/2774
MagicBeanDev:github/pr/2772
MagicBeanDev:github/pr/2750
MagicBeanDev:github/pr/2786
MagicBeanDev:github/pr/2785
MagicBeanDev:github/pr/2782
MagicBeanDev:github/pr/2779
MagicBeanDev:github/pr/2775
MagicBeanDev:github/pr/2706
MagicBeanDev:github/pr/2766
MagicBeanDev:github/pr/2747
MagicBeanDev:github/pr/2759
MagicBeanDev:github/pr/2745
MagicBeanDev:github/pr/2740
MagicBeanDev:github/pr/2733
MagicBeanDev:github/pr/2725
MagicBeanDev:github/pr/2727
MagicBeanDev:github/pr/2728
MagicBeanDev:github/pr/2729
MagicBeanDev:github/pr/2721
MagicBeanDev:github/pr/2722
MagicBeanDev:github/pr/2715
MagicBeanDev:github/pr/2714
MagicBeanDev:github/pr/2707
MagicBeanDev:github/pr/2703
MagicBeanDev:github/pr/2705
MagicBeanDev:github/pr/2697
MagicBeanDev:github/pr/2679
MagicBeanDev:github/pr/2676
MagicBeanDev:github/pr/2669
MagicBeanDev:docs/what-hookshot-connects-to
MagicBeanDev:fix/hdr-encode-test
MagicBeanDev:fix/main-tests
MagicBeanDev:fix/play-cache-files
MagicBeanDev:perf/game-barrier-order
MagicBeanDev:feat/heap-lazy
MagicBeanDev:feat/texture-detail
MagicBeanDev:perf/astc-opaque-bc1
MagicBeanDev:fix/fs-dir-lock
MagicBeanDev:fix/framegen-native-kept
MagicBeanDev:fix/update-no-downgrade
MagicBeanDev:port/k10-gcn-f16-mirrors
MagicBeanDev:fix/framegen-mult-cap
MagicBeanDev:chore/release-as-2.1.1
MagicBeanDev:perf/pcache-load-switch
MagicBeanDev:fix/prepare-progress-log
MagicBeanDev:fix/update-closes-stale-game
MagicBeanDev:fix/hdr-scaled-sampled
MagicBeanDev:perf/first-start-preset
MagicBeanDev:perf/zero-upload
MagicBeanDev:fix/vcore-escape-2s
MagicBeanDev:test/fake-gh-atomic
MagicBeanDev:perf/batch-idle-flush
MagicBeanDev:test/finish-stub-a
MagicBeanDev:chore/record-2.1.0
MagicBeanDev:fix/main-red-tests
MagicBeanDev:fix/test-display-startup-driver-cache
MagicBeanDev:feat/mesh-shader-mode
MagicBeanDev:fix/menu-probes-at-startup
MagicBeanDev:fix/fps-counter-classic
MagicBeanDev:fix/test-log-batch-flake
MagicBeanDev:fix/narrow-screen-hud
MagicBeanDev:ci/prereleases
MagicBeanDev:release/v2.0.15
MagicBeanDev:hotfix/v2.0.15
MagicBeanDev:fix/present-ahead-replay
MagicBeanDev:release/v2.0.13
MagicBeanDev:fix/bracket-paths-2013
MagicBeanDev:fix/hdr-overlays-2013
MagicBeanDev:fix/fps-counter-scale-2013
MagicBeanDev:fix/stick-seen-at-rest
MagicBeanDev:hotfix/menu-fits-screen
MagicBeanDev:fix/f1-always-opens-menu
MagicBeanDev:fix/ini-keep-lines
MagicBeanDev:claude/cranky-pike-7cf247
MagicBeanDev:perf/texture-answer-flat
MagicBeanDev:fix/stamp-test-modules
MagicBeanDev:fix/appimage-fonts
MagicBeanDev:fix/display-awake
MagicBeanDev:release/v2.0.12
MagicBeanDev:fix/discord-windows
MagicBeanDev:rc/v2.0.12-tests
MagicBeanDev:fix/dlss-keep-feature
MagicBeanDev:rc/v2.0.12
MagicBeanDev:button-icons
No reviewers
Labels
Clear labels
accessibility
Barrier affecting people with disabilities
autorelease: pending
autorelease: tagged
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
duplicate
This issue or pull request already exists
enhancement
New feature or request
github_actions
Pull requests that update GitHub Actions code
good first issue
Good for newcomers
help wanted
Extra attention is needed
invalid
This doesn't seem right
question
Further information is requested
testing wanted
wontfix
This will not be worked on
No labels
accessibility
autorelease: pending
autorelease: tagged
bug
dependencies
documentation
duplicate
enhancement
github_actions
good first issue
help wanted
invalid
question
testing wanted
wontfix
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
No assignees
2 participants
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Hookshot!2585
Loading…
Reference in a new issue
No description provided.
Delete branch "SadTransGirl/fix/texture-squeeze-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?
On 8 GB cards that run past what the driver allows, the driver pages VRAM out to system memory and the frame rate falls (#2156: an RTX 5050 8 GB at 7,602 MB used of 6,982 allowed ran at 14-25 fps). #1506 made the 97% texture squeeze wait while VMA's blocks hold an eighth of the allowance free. This keeps that wait only while the driver's count is within the allowance, so past it the squeeze runs again, as in v2.0.14.
Cause. #1506's wait stops a ratchet: evicting textures frees space inside blocks the driver still counts, so the count doesn't drop and the squeeze ran again ten frames later (a 4 GB RX 5500M lost 1,700 MB of textures while paused). But the wait held past the allowance too, where the driver pages and room in the blocks doesn't help: #2156's card had 1,649 MB free in its blocks.
Change (
gpu/vk/vk_texture.cpp,texture_frame, one condition):room_in_blocksholds only whileused <= allowed: past the allowance, the squeeze runs whatever the blocks hold.kept_only), where no eviction can bring the count down. So past the allowance it squeezes only where an eviction can help, as hckrman101 and Joey-Magnus asked.RX_VK_SQUEEZE_ALWAYS=1still squeezes as before. Ported from Revens2's a4c7cb3.Measured so far. None of it is yet on a card that really pages, on top of #2711:
RX_VK_TEST_ALLOWED_MB=6900), before #2711: the "room in the blocks: not squeezed" lines went (26 to 0), but VRAM stayed past the allowance as much (27 of 29 lines, worst +1,393 MB, against 26 of 28 and +1,641 MB on main), at 58.9 against 58.7 fps. The texture budget was already 0 MB there: the excess was the image pool's blocks made at the start (#2438), which #2711 has since fixed. At a 6 GB allowance, Castle Town to the field: 4 of 6 lines past either way, 51.2 fps both. Rows indocs/tested-configurations.md.Wanted before merge. A before/after on a card that really pages (an 8 GB one, ideally from #2156's or #2690's reporters), same scene, on current main (which has #2711), with fps and the
vk: VRAM:lines. That shows whether this adds anything past #2711.Tests.
tests/test_texture_squeeze.pychecks that the wait for room in the blocks holds only within the allowance and that #2711'skept_onlygate is still on the squeeze; it fails without the change.Not tested. A card that pages (every run above is a lower allowance on a larger card, or a card at but not past its limit); Linux; Intel.
Part of #993.
See #2690.
Assisted-by: Claude Opus 5.5, Claude Mythos 5.2
🤖 Generated with Claude Code
WIP: fix(vk): keep the 97% texture squeeze past the driver's allowance (#2…to fix(vk): keep the 97% texture squeeze past the driver's allowance (#2…Please test
Tested #2585 on my RTX 4070 SUPER (12 GB), Windows 11, DLAA 1440p, main
c544828f, default settings, as an 8 GB card (RX_VK_TEST_ALLOWED_MB=6900, 5 min Hyrule Field walk) and a 6 GB one (6144, Castle Town to the field):That's the same thing #2690 / #2711 found, so #2711 looks like the bigger fix for 8 GB cards; this run is a Windows data point for it. #2585 touches the same room_in_blocks line as #2711 (a small text conflict, no conflict in meaning: past the allowance it squeezes, unless #2711's kept_only says an eviction can't lower the count). I'll rebase #2585 on #2711 once it lands; there's also a follow-up ready that makes the squeeze count only the textures' own free space (#2412).
Past the allowance this squeezes even with an eighth of the allowance free in the blocks. Evicting there frees space inside blocks the driver still counts, so
usedstays put and the budget shrinks again on the next pass: #1506's ratchet, now past the allowance. In your 4070 SUPER run the excess was the image pool's preallocated blocks, which no texture eviction can release. Gating this on #2711'skept_only(squeeze only when an eviction can lower the count) after the rebase would avoid draining the cache for nothing.Thanks for this, and for testing it yourself straight away. The change does what the description says: the
used <= allowedterm only lifts #1506's wait once the driver's count is past the allowance, the RX 5500M case (3337 of 3337) keeps waiting,RX_VK_SQUEEZE_ALWAYS=1is unchanged, and the test pins the new term in the right expression.What holds me back is your own run: the "not squeezed" lines go away (26 to 0), but VRAM stays over the allowance just as much as on main, because the texture budget is already 0 MB there and what holds the memory is the image pool's blocks made at the start (#2438, kept by minBlockCount). So on this data the PR changes the log but not the count, and the fix for #2156 / #2690 is #2711. I agree with your plan: let #2711 land first, rebase this on it (with its
kept_onlycheck, so that past the allowance it only squeezes when an eviction can actually lower the count), and then measure again.One thing to keep in mind for that rebase (inline): past the allowance with room in the blocks, evicting textures frees space inside blocks the driver still counts, so the count doesn't drop and the squeeze runs again ten frames later. That's the ratchet #1506 stopped, now allowed once the count passes the allowance. When the excess isn't textures, it can drain the cache to nothing and have it re-made, on exactly the 8 GB cards this is for.
For merging (the maintainer's rule from #2712): a fix needs to be shown in the game with numbers in the description. Here that's a before/after on a card that really pages (an 8 GB one, ideally from the #2156 / #2690 reporters, same scene, fps and the VRAM log lines), on top of #2711, showing this adds something past what #2711 does. The 4070 SUPER run is a useful data point, but as you say it can't page, so it can't show the fps side.
CI: the two red jobs fail only
tests/test_env_on.pyonHOS_FPS_LOGinhost/oot_high_fps.c, which this PR doesn't touch; main has since fixed it (latest main runs are green), so a rebase clears it.Setup: RX 5600 XT 6 GB (RDNA1, no mesh shaders), Adrenalin 26.10.1, Windows 11, Ryzen 5 5600X, 24 GB, 1920x1080, frame generation off. Every run starts from the same copied save and follows a scripted route through the control bridge (Kokiri Forest and Hyrule Field: settle 15 s, then 60 s standing); fps are the medians of the log's
N presentslines. Run-to-run noise on mainde866017(4 runs): Kokiri 31.5-34.6 fps, Hyrule Field 32.1-34.8.A real 6 GB card, to go with the emulated ones above. Merged on main
de866017:So on this card too, the squeeze changes nothing visible at these two spots. On main the texture budget there is 300-390 MB with ~1,100 MB of textures held, and the buffer pools' mirror budget is full as well (
pool ... (160 MB) stays in system memory: the mirrors have 688 MB of 734), so the textures are not the only thing at the allowance.I merged this into current main and tests/test_texture_squeeze.py passes. The change at gpu/vk/vk_texture.cpp:4302 does what it says: past the allowance it no longer waits for room in the blocks.
hckrman101's points still stand at this head, and you agreed with them. Both your 4070 SUPER run and Waryxxful's RX 5600 XT run show the log lines going away but VRAM staying where it was. So on the data so far this changes the log, not the count. The inline point is also still open: past the allowance, evicting textures frees space inside blocks the driver still counts, so
useddoesn't move and the squeeze runs again ten frames later. That is #1506's ratchet, now allowed above the allowance.#2711 is still open. The plan in the thread looks right to me: rebase on #2711 once it lands, gate the squeeze on its
kept_only, and add a before/after from a card that really pages (same scene, fps and VRAM lines) to the description. The red CI is test_env_on on HOS_FPS_LOG, which main fixed since, so the rebase clears it as well.Tested the one-line #2585 condition on a real RTX 4050 Laptop GPU (6 GB), Windows 11, NVIDIA 621.14, i5-13420H, 32 GB RAM. I backported only that line to the v2.1.0 renderer source (
633eb435, API 14) so it could run with my installed v2.1.0 game. Base and patched Vulkan DLLs were built the same way. The game executable, graphics options, and manual Kokiri Forest save were the same; caches were left warm across runs. Output 2048x1152, 50% render resolution, handheld profile on, DLSS and frame generation off.For each arm, I loaded the same save, let the scene settle, sent the same eight timed stick inputs (
LRIGHT,LLEFT,LUP,LDOWN, repeated), then left Link standing. These are one A/B pair per condition, not repeat-range measurements. FPS below comes fromRX_VK_FRAME_LOG: the 24 s scripted route and the following 45 s standing window.RX_VK_TEST_ALLOWED_MB=4300room in the blocks: not squeezedlines. Patched: 2/16 over, with the solenot squeezedline at 4257/4300 MB (within allowance). During gameplay, base stayed around 4369/4300 MB; patched was mostly 4209/4300 MB after squeezing.The lower allowance exercises this PR's condition on this card: it reduces the renderer's over-limit samples in this scene. I cannot infer a real FPS gain from one pair; route FPS is effectively unchanged here. The 4300 MB cap is a renderer test switch, not a real 4.3 GB Windows VRAM budget, so this does not test WDDM paging. No game files or derived assets are attached.
#2711 merged at 16:50 today, so this can move to the plan from the thread. As it stands, it conflicts with main in gpu/vk/vk_texture.cpp, at the same squeeze condition #2711 changed.
What I'd want in the update:
used, so the squeeze comes back ten frames later.The red test_env_on was main's HOS_FPS_LOG failure, so the merge clears it too.
Merged main in ca082cd1 now that #2711 has landed (#2826 came with it), and added the tested-configurations rows in f385fe47. As you both suggested:
kept_onlygate stays on the squeeze, so past the allowance it squeezes only where an eviction can lower the count.The test checks both the allowance term and the
kept_onlygate. The description now has the runs so far (mine at an emulated 8 GB allowance, Rogasse's RTX 4050 6 GB, Waryxxful's RX 5600 XT) and what's still wanted: a before/after on a card that really pages, on current main. My card can't page, so that has to come from someone with an 8 GB card.