fix(vk): make the blocks at the start in the pool the textures are made in (#2690) #2711
Closed
github-sync
wants to merge 1 commit from
github/pr/2711 into main
pull from: github/pr/2711
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
1 participant
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!2711
Loading…
Reference in a new issue
No description provided.
Delete branch "github/pr/2711"
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 an 8 GB card the image blocks made at the start (#2438) sit empty and are counted against the textures, so the texture budget is cut by about their size: #2690 measured Castle Town Market at 31-36 fps on an RTX 3070 against 54-56 with
RX_VK_IMAGE_PREALLOC=0. This makes those blocks in the pool the textures are actually made in.Fixes #2690
What was wrong
#2438 makes 15% of the card's memory (2 to 24 blocks of 128 MB) when
image_poolis made, so that play makes fewer blocks: each is avkAllocateMemoryon the replay thread, ~170 ms on AMD's Windows driver. It was measured on v2.0.5-v2.0.12, where the sampled textures were made in that pool.Since the compaction is on by default (#2198), sampled textures are made in
texture_pooland render targets intarget_image_pool.image_poolis left with DLSS's, the frame interpolation's, the menu's and the scratch images. So:vram_compact::reclaimable), which is right: nothing else can be given back. So the empty blocks stay in the count and the hold cuts the texture budget by about as much.texture_pool.The fix
The blocks are made in the pool the sampled textures are made in:
texture_pool, orimage_poolwithRX_VK_COMPACT=0. The count (15%, 2 to 24) andRX_VK_IMAGE_PREALLOCare unchanged, and the rule is the same for every vendor. On by default; no new switch.minBlockCount), so two rules are told about them:vram_compact::returnable);vram_compact::kept_only): an eviction there takes nothing off the count, the ratchet that rule'sroom_in_blockswait already guards against.textures from a pool of their own, 128 MB blocks (RX_VK_COMPACT), 9 made at the start, andimages from a pool of ... 0 made at the start.Test
tests/test_blocks_at_start.py(withtests/test_blocks_at_start.cpp): compilesvram_compact.hand checks the block count for 2 to 32 GB cards (8 GB: 9, 12 GB: 14, 16 GB: 19, 24 GB: 24; none in a pool that holds no textures),returnable,kept_only, and what the budget's hold leaves the textures with the blocks in either pool (an 8 GB card with 7000 MB allowed, 3700 MB of other VRAM and 2300 MB of textures: 2250 MB with the blocks in the textures' pool or with none, 1098 MB with them in a pool no texture is made in). It also checks thatvk_vma.cppandvk_texture.cppuse the rules. It fails on the parent and passes here.test_vram_compact,test_texture_squeeze,test_target_image_pool,test_preset_texture_budgetandtest_vram_pressurepass; the full suite was not run.Measured
RTX 3090 24 GB, Linux, NVIDIA, 2560x1440, modelling an 8 GB card with
RX_VK_TEST_ALLOWED_MB=7000(the allowance) andRX_VK_IMAGE_PREALLOC=9(an 8 GB card's count; the count follows the real heap, 24 here). Castle Town Market, standing, 60 s settle, 120 s measured, one session a run, in the order D Z F F Z D. This reproduces the renderer's own eviction logic only, not Windows paging VRAM out on a real 8 GB card.D = before the fix, 9 blocks at the start. Z = before the fix,
RX_VK_IMAGE_PREALLOC=0. F = the fix, 9 blocks at the start. The renderer for F is this change on the commit the test folder's game was built from (maina016b7a6plus two unrelated local commits;vk_vma.cpp,vk_texture.cppandvram_compact.hare the same there as on main).image_pooltextures from a pool of their own, 128 MB blocks (RX_VK_COMPACT), 9 made at the startandimages from a pool of 128 MB blocks (memory type 1), 0 made at the start.Without the cap (24 GB, 24 blocks, 60 s measured), one run each: the fix 9601 MB used of 21814 (594 MB free in the blocks, textures 5736 MB, budget 6144 MB), before it 13089 MB used of 21846 (3782 MB free, textures 6057 MB, budget 6144 MB): the same budget, 3.5 GB less counted. GPU time 10.4 ms (fix) against 9.4 ms and fps 44.4 against 52.7 in that single pair, both with swap-in (54,000 and 63,000 pages); a second pair is being run to see whether that difference is real.
Not tested
vkAllocateMemorycalls on the replay thread. That needs a run on an AMD card on Windows: the count oftexture_poolblocks made in play, and the frame times when new ground comes in.RX_VK_IMAGE_PREALLOC=0) it would not.Tested #2711 on Windows 11, RTX 4070 SUPER (12 GB), NVIDIA, DLAA 2560x1440, default settings, nothing else running on the PC. Your model:
RX_VK_TEST_ALLOWED_MB=7000andRX_VK_IMAGE_PREALLOC=9; Castle Town Market standing (walked in from the south gate, the last 120 s measured); order D Z F F Z D, one run each. D = mainc544828f, Z = main withRX_VK_IMAGE_PREALLOC=0, F = #2711 (2124d15c).F's log: "textures from a pool of their own, 128 MB blocks (RX_VK_COMPACT), 9 made at the start" and "images from a pool of 128 MB blocks (memory type 1), 0 made at the start".
A 5-minute Hyrule Field walk under the same cap, one run each:
Without the cap (12 GB card, 14 blocks at the start), Market, one pair (the second pair you asked about): F 58.1 fps over the whole run, GPU 9.1 ms, textures 4322 MB (budget 6144); D 49.4 fps, GPU 10.7 ms, textures 2944 MB (budget 2890), 4.4 GB of textures uploaded against 1.0 GB. Both at 60 fps in the last 60 s. So here no sign of F costing GPU time; the other way round.
So on Windows/NVIDIA: F matches Z on VRAM and the texture budget, and is at least as fast. The one thing F didn't match was frames over 25 ms standing in the Market (28-33 against Z's 14-27); in the walk F had the fewest. Not tested: AMD, a real 8 GB card, Linux.
Tested on a real 8 GB card: with this PR the default is as fast as
RX_VK_IMAGE_PREALLOC=0, and both are well abovemain.Windows 11, RTX 3060 Ti 8 GB (driver 32.0.16.2114), Ryzen 5 5600X, 2560x1440 DLSS.
mainba005ca4with this PR merged locally; 40 s with the camera turning after a settle,RX_VK_FRAMEGEN=0,HOS_FPS_MAX=240; arms alternated D Z D Z D Z.The log says what it should:
images from a pool of 128 MB blocks (memory type 1), 0 made at the startandtextures from a pool of their own, 128 MB blocks (RX_VK_COMPACT), 9 made at the start(D),0 made at the startfor both with Z.RX_VK_IMAGE_PREALLOC=0)For reference,
main5b96a55awithout this PR in the same Hyrule Field test (my comment on #2690): 44.9 / 46.5 / 46.0 fps mean, 30-53 frames over 50 ms, texture budget ~1 GB. The third D run in the field is the slowest of the six; the rest are within each other's noise, and the Market's GPU time moves from launch to launch on this card, so I read it as no difference between D and Z.@hckrman101 I'll take this one over, since you offered it in the team room and nobody has picked it up there or here.
What I'll do, on a branch that keeps your commits as they are with mine on top (it has to be a new pull request, as I can't push to yours; I'll link it here and you can close this one then):
RX_VK_TEST_ALLOWED_MB=7000 RX_VK_IMAGE_PREALLOC=9), Castle Town Market: main, preallocation off, and the fix, with the pool line, the budget, retired textures, compactions and pictures; then one alternated timing hold, main against the fix;Not something this PC can give: AMD, and a real 8 GB card; those stay listed as not tested by me.
Tested on a real 24+ GB card (
RTX 5090, 32 GB VRAM, Windows 11, 98 GB RAM, NVIDIA 621.14) as part of isolatingmain's +5.86 GB Private Bytes / +2.51 GB Working Set increase since49f75dc8.Setup & method:
origin/main(c544828f) built withRX_RELEASE=1(17,888 programs, 25,303 graphics and 799 compute pipelines precompiled at startup), 2048x1152 uncapped (RX_VK_FRAMEGEN=0,HOS_FPS_MAX=240), Kokiri Forest autosave (80 s run: 40 s settle + 30 s measurement window), compared againstmaincontrol,main + RX_VK_IMAGE_PREALLOC=0(the zero-preallocation bound), and #2759.Why
mainhas +2.94 GB of stranded VMA blocks on 24+ GB cards:On
main,images_pool()pre-allocatesminBlockCount = 24(3,072 MBon a >=20 GB allowance), whileRX_VK_COMPACT(textures_pool()) andRX_VK_TARGET_BLOCKS(target_images_pool()) are on by default. In Kokiri Forest, only 8 images (33 MB, 1 block) go intoimage_pool, leaving 23 of 24 blocks (2,944 MB/2.88 GB) permanently empty whiletextures_poolallocates another 18 blocks (2,304 MBfor 1,208 textures /2,192 MB) on top (24 + 18 = 42 blocks = 5,376 MBacross both pools).RX_RELEASE=1, 25,303 pipelines)mainimage_pool/target/textureblocksp95/p99ms)maincontrol9,357 MB)24 (3072 MB)/6 (768 MB)/18 (2304 MB)17.07/19.61)main+RX_VK_IMAGE_PREALLOC=0(bound)main2)6,477 MB)1 (128 MB)/7 (896 MB)/18 (2304 MB)18.06/19.40)hckrman101)7,021 MB)1 (128 MB)/5 (640 MB)/24 (3072 MB)16.79/20.25)Hinkiii)6,237 MB)1 (128 MB)/6 (768 MB)/18 (2304 MB)17.38/19.98)Verdict on a 24+ GB card:
minBlockCount = 24fromimages_pool()totextures_pool()dropsimage_poolfrom24 blocks (3,072 MB)to1 block (128 MB, 8 images 33 MB)and places the 18 active Kokiri Forest texture blocks (2,192 MB) inside the 24 pre-allocatedtextures_poolblocks (1 + 24 = 25 blocks = 3,200 MBinstead of24 + 18 = 42 blocks = 5,376 MB).2,176 MB(2.13 GB) of device pool memory and-2,217 MB(-2.17 GB) of Peak Private Bytes (74%of the2,944 MBstrandedimage_poolpre-allocation in this scene), while keeping 6 spare blocks (768 MB) pre-allocated ahead of demand intextures_pool(at the title screen, where only 1 texture block is used, 23 blocks =2,944 MBremain pre-allocated intextures_pool, whereasRX_VK_IMAGE_PREALLOC=0/ #2759 allocate texture blocks on demand with 0 frames > 50 ms here).github-sync referenced this pull request2026-11-12 16:54:48 +00:00
A note on my measurements in this thread: this PC's DLSS model row was on Transformer 2 (L), not the default K, for all of them. L costs ~4 ms more GPU time a frame on this card and more VRAM (#2836), so my absolute fps are ~10 lower than the default would give in Hyrule Field and the card was shorter of memory than a default setup. The comparisons were all made with the same setting in both arms, so their direction stands, but their size is for that harder case.
Linux numbers for the record, now that this is merged. My Linux correctness runs predate the merge: main
51da0464, the fix build234f72a3(your unchanged patch plus tests/docs), and the combined experiment3972579c(+#2624).RTX 4090 24 GB, NVIDIA 615.78.08, Arch Linux 7.2.15-1-omarchy; Castle Town Market, 2560×1440, DLSS model K (the default model), DLAA/100%, FG off, cap 240. Klikso's measurements used model L.
Under
RX_VK_TEST_ALLOWED_MB=7000 RX_VK_IMAGE_PREALLOC=9 RX_VK_MIRROR_MB=2048, main kept nine utility-image blocks for 102 MiB of images; the fix kept one for the same images and started nine texture blocks.Final texture budgets: main 835 MiB, main with preallocation off 2003 MiB, fix 1771 MiB, fix+#2624 1921 MiB. These are different-population snapshots from ordinary 150-second runs, not a timing or an isolated subtraction.
No fatal/device/driver fault; eight inspected Market frames showed no obvious missing or garbled textures.
The small-card model does not reproduce Windows paging or a real 8-GB heap. No speed claim: the exclusive timing holds were cancelled after the merge, before either was queued.
A small test-only follow-up is coming as its own pull request: it runs the real pool constructors, including a refused first allocation, which the merged test checks by source text only.