fix(vk): raise the integrated GPU texture budget when ASTC is decoded on the CPU #1559
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
5 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1559
Loading…
Reference in a new issue
No description provided.
Delete branch "Jer9/Longshot:fix/igpu-cpu-astc-texture-budget"
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: low · Tested on: Windows 11, AMD Ryzen AI 7 350 / Radeon 860M (2x2 interleaved A/B + windowed startup + game-free C++/Python checks) · Needs: Windows Ryzen 7000/9000 desktop iGPU (> 16 GB RAM); any iGPU with 24 GB RAM; Linux full suite
TL;DR
On integrated graphics with over 16 GB of memory, decoding ASTC textures on the CPU stores them uncompressed at roughly four times the size, overflowing the default 4,096 MB texture budget in Kokiri Forest and forcing continuous evictions and slow CPU re-decodes. When CPU ASTC decoding is active above 16 GB of RAM, this change raises the texture share cap to 8,192 MB and the RAM cap to 6,144 MB (up to 24 GB) or 8,192 MB (above 24 GB). On a 32 GB Radeon 860M laptop, budget evictions drop from 3,060 to 0, upload stalls fall 33%, Kokiri initial FPS rises 44%, and revisit FPS rises 91%; tests fail on main and pass here.
Breakdown
RX_VK_ASTC_CPU=1).3,584 MBon 24 GB), causing constant eviction thrashing and multi-second CPU re-decode stalls.astc_on_cpu=0), systems with 16 GB RAM or less, explicitRX_VK_VRAM_MBoverrides, saves, and options files.origin/main(ef6038ab) vs8dd2987(0vs3,060median budget evictions,+43.9%Kokiri initial FPS,+91.4%Kokiri revisit FPS), normal windowed startup log check (8192 MB),test_texture_budget.py&test_device_policy.py(g++andclang+++ mutant checks), andtests/run_all.py.tests/run_all.pyvia Test Farm.RX_VK_VRAM_MB=4096orRX_VK_ASTC_CPU=0restores the old cap, and the 90% driver count line and Windows commit headroom guard remain active.Why
PR #489 enabled CPU ASTC decoding (
astc_on_cpu=1) on Windows for Ryzen 7000 (0x164E) and Ryzen 9000 (0x13C0) desktop iGPUs, and PR #1296 extended that default to the AMD Radeon 860M (0x1114) for Part 1 of #1040, eliminating Kokiri ForestVK_ERROR_DEVICE_LOSTresets. However, CPU ASTC decoding stores textures as uncompressed RGBA8 (~4x the memory of BC3), pushing Kokiri Forest's texture working set to ~5.0–5.7 GB and Kokiri + Zora's Domain to ~7.0–7.1 GB.On a 32 GB laptop with 6 GB Variable Graphics Memory (
26,283 MBWindows-usable RAM,12,214 MBdriver allowance),texture_rule::integrated_bytes()capped the allowance share at6,144 MBandpolicy_rule::integrated_texture_budget()further capped RAM<= 32 GBat4,096 MB. As a result, once Kokiri Forest loaded, the renderer continuously evicted hundreds of textures per burst and immediately re-decoded them on the CPU (14+ smax single-frame stalls, ~75 s total upload stalls across a Kokiri + Zora + Kokiri run). Raising the cap only whenastc_on_cpuis active andram > 16 GBresolves Part 2 of #1040 without tightening memory safety on 8–16 GB handhelds/laptops or changing GPU-decoded iGPUs.prior work: none found (
integrated_texture_budget,"texture budget" "astc_on_cpu", #1040)See #1040
How to reproduce
Seen on: Windows 11 (build 26200), AMD Ryzen AI 7 350 / Radeon 860M (1002:1114, Adrenalin 26.10.1 LLPC), 32 GB RAM (
26,283 MBusable with 6 GB Variable Graphics Memory,12,214 MBdriver-allowed video memory)Settings and switches: defaults (
quality_preset=6Auto,RX_VK_VRAM_MBunset,RX_VK_ASTC_CPUunset ->astc_on_cpu=1default)Steps:
longshot_env.txt(vk: switches set: nonein play).kokiri-start, teleport toKokiriForest_Child(0), thenZoraDomain_Child(13), then return toKokiriForest_Child(0).Expected: Kokiri Forest and Zora's Domain textures remain cached within an
8,192 MBbudget with zero budget evictions and no re-decode thrashing.Actual:
vk: integrated GPU texture budget: 4096 MBlogs at startup, Kokiri Forest overflows4,096 MBto~5.3 GB, and the renderer evicts ~3,060 textures across 20 budget-eviction events, causing ~75.4 s of CPU ASTC upload stalls and halving Kokiri revisit FPS (18.39vs35.20 fps).What changed
Thread
astc_on_cpufromDevicePolicyandvk_texture.cpp'sastc_on_cpu()into bothtexture_rule::integrated_bytes()andpolicy_rule::integrated_texture_budget(), raising the integrated share cap from 6 GB to 8 GB and the> 16 GBRAM caps to 6 GB (<= 24 GB) and 8 GB (> 24 GB) when ASTC is decoded on the CPU, while recomputingp.texture_budgetafter readingRX_VK_ASTC_CPUindevice_policy_env().gpu/vk/texture_budget.h: addedbool astc_on_cpu = falsetotexture_rule::integrated_bytes(uint64_t allowed, uint64_t vram, bool astc_on_cpu = false), raising the 70% allowance share cap from6144 * kMBto8192 * kMBwhenastc_on_cpuis true (keeping the2200 * kMBsmall-heap cap and4096 * kMBunknown-allowance fallback unchanged).gpu/vk/device_policy.h: addedbool astc_on_cpu = falsetopolicy_rule::integrated_texture_budget()andpolicy_rule::texture_budget(), raisingcapwhenastc_on_cpu && ram > 16 * kGBto6144 * kMB(<= 24 * kGB) and8192 * kMB(> 24 * kGB) while preservingavailable = ram - integrated_reserved(ram)andshareclamps; passedp.astc_on_cpuindevice_policy()and recomputedp.texture_budgetafterflag(Sw::astc_on_cpu, "RX_VK_ASTC_CPU", p.astc_on_cpu)indevice_policy_env().gpu/vk/vk_texture.cpp: passedastc_on_cpu()totexture_rule::integrated_bytes(a, device_vram_bytes(), astc_on_cpu())andpolicy_rule::integrated_texture_budget(driver_budget, system_ram, astc_on_cpu())intexture_frame(), and updated the nearby comments onastc_on_cpu()andintegrated_texture_budget.docs/development.md: updated theRX_VK_VRAM_MBdefault description for the raised integrated share/RAM caps when ASTC is decoded on the CPU.tests/test_texture_budget.cpp&tests/test_device_policy.py: added unit/edge/env/source checks (12214 MBshare withfalse/true,RAPHAEL7162 MBdefault andRX_VK_ASTC_CPU=0->4096 MB,UHDRX_VK_ASTC_CPU=1staying2560 MB, and16384/24576/26283 MBRAM rules), failing onorigin/main(ef6038ab) and passing after the fix.docs/tested/: added2026-11-18-igpu-cpu-astc-texture-budget-jer9-old.mdand2026-11-18-igpu-cpu-astc-texture-budget-jer9-new.md.Measurements
Verdict: Fixed Part 2 of #1040 on the 32 GB Radeon 860M laptop with zero environment switches set: texture budget rose from
4,096 MBto8,192 MB, budget evictions dropped from3,060(median across 20 events) to0, full-run CPU ASTC upload stalls fell by -33.1% (75,442 -> 50,457 ms),KokiriForest_Childinitial 360-present wall FPS rose +43.9% (14.71 -> 21.18 fps), andKokiriForest_Childrevisit FPS afterZoraDomain_Childrose +91.4% (18.39 -> 35.20 fps); settled stationaryZoraDomain_ChildFPS measured33.77 -> 31.77 fps(-5.9%) with7.0 GBkept resident instead of3.9 GB.Hardware: Windows 11 (build 26200), AMD Radeon(TM) 860M Graphics (integrated, 1002:1114, 8 CUs, RDNA 3.5, 12857 MB VRAM heap, 12214 MB allowed), AMD proprietary driver 26.10.1 (LLPC), AMD Ryzen AI 7 350 (8c/16t, znver5), 32 GB RAM (
26,283 MBusable, 6 GB Variable Graphics Memory)Scene:
KokiriForest_Child(initial 360 presents + revisit 360 presents afterZoraDomain_Child) andZoraDomain_Child(settled 360 presents after 180-present warm-up);2560x1440output,quality_preset=6Auto (resolution=450%,handheld_profile=0,upscaling=0,frame_generation=0,threaded_rendering=0),RX_VK_VRAM_MBunset,RX_VK_ASTC_CPUunset (astc_on_cpu=1)Method: Built
origin/main(ef6038ab) base and renderer packigpu-tex-budget(8dd2987, identical renderer tree to measured9858994) withscripts/dev_packs.py(seeded fromnightly, warmed on both runtimes), then ran 2x2 interleaved runs (0_old,1_new,2_old,3_new) viascripts/longshot_ctl.py --profile test --repo-save kokiri-startplus one normal windowed launch (windowed_new), taking the median of each pair.How to reproduce:
python -I scripts/longshot_ctl.py --run <dir> launch <RUNTIME> --profile test --repo-save kokiri-start --repo .(pressAuntilstate=play,wait present --frames 60),teleport 0 --timeout 60 --arrive 120,wait in_play,wait present --frames 360,teleport 13 --timeout 60 --arrive 120,wait in_play,wait present --frames 180,wait present --frames 360,teleport 0 --timeout 60 --arrive 120,wait in_play,wait present --frames 360.ef6038ab8dd29874096 MB8192 MB2992,3128(3060across20events)0,0(0)74,023,76,860 ms(75,442 ms)50,004,50,910 ms(50,457 ms)0_old/2_oldvs1_new/3_new)4064,4638 MB7037,7130 MBKokiriForest_Childinitial 360p wall FPS15.23,14.20(14.71 fps)20.71,21.65(21.18 fps)KokiriForest_Childrevisit 360p wall FPS18.22,18.56(18.39 fps)35.69,34.72(35.20 fps)ZoraDomain_Childsettled 360p wall FPS33.89,33.65(33.77 fps)30.90,32.63(31.77 fps)Redacted log lines (
0_oldvs1_new,HOS_HEADLESS=1,RX_VK_VRAM_MB&RX_VK_ASTC_CPUunset):Flags and settings
None
Testing
Tested:
fix-with-testcheck: Commit413e092compiles and fails at runtime onorigin/main(ef6038ab) (FAIL line 48: call_integrated_bytes(12214 * MB, 6 * GB, true) == 8192 * MBintest_texture_budget.py, andRAPHAEL: texture_budget is 4096, expected 7162/24576 MB3584 != 6144/26283 MB4096 != 8192intest_device_policy.pywith bothg++andclang++); Commit8dd2987passespython -I -B tests/test_texture_budget.py --cxx g++&--cxx clang++(PASS: the texture budget by the card),python -I -B tests/test_device_policy.py --cxx g++&--cxx clang++(ok: 19 PCs, each of DevicePolicy's 68 fields as the rules have it; 64 environments through the switches' one rule; 55 rule edges),python -I -B tests/test_astc_cpu_860m.py --cc gcc(ok), and mutant checks (reverting theastc_on_cpucaps intexture_budget.handdevice_policy.hfails both tests).python -I -B tests/test_tested_configurations.py Repository(Ran 1 test in 6.188s OK);python -I -B tests/run_all.py(656 passed, 57 failed, 57 skipped in 179 s, where all 57 failures are pre-existingorigin/main/ Windows host drift).scripts/dev_packs.py) acrossKokiriForest_Child(initial + revisit) andZoraDomain_Child(0_old,1_new,2_old,3_new) plus normal windowed startup (windowed_new) confirmingvk: integrated GPU texture budget: 8192 MBand0budget evictions.Not tested:
0x164E,0x13C0) or 24 GB RAM integrated-GPU PCs (only 32 GB Radeon 860M hardware is on this PC;RAPHAELand 16/24/32 GB boundaries are covered bytests/test_device_policy.py).tests/run_all.py(spirv-val,glslang, POSIX tests).Must be tested:
0x164Eor0x13C0, > 16 GB RAM): launch in Kokiri Forest withRX_VK_VRAM_MBandRX_VK_ASTC_CPUunset, expectingastc_on_cpu=1, the startup texture budget log line above4096 MB(up to8192 MB), and no budget eviction thrashing (by hand on a Ryzen 7000/9000 desktop iGPU)python -I -B tests/run_all.py, expectingtest_texture_budget.py,test_device_policy.py, andtest_tested_configurations.pyto pass cleanly (Test Farm:@Beanstalk linux)Risks
What could break: Raising the integrated GPU texture budget up to
6144 MB(at 24 GB RAM) or8192 MB(above 24 GB RAM) whenastc_on_cpuis enabled keeps more system RAM pinned in VMA texture allocations if another memory-heavy application runs concurrently or ifRX_VK_COMMIT_RESERVE_MBis disabled. The existing90%driver-allowance count line (count_line_pct = 90),available = ram - integrated_reserved(ram)clamp, Windows commit headroom guard (RX_VK_COMMIT_RESERVE_MB), and LinuxPressureHoldstill trim the budget if system memory tightens; iGPUs with<= 16 GBRAM and GPU-decoded iGPUs (astc_on_cpu = false) are unchanged.Turning it off: Set
RX_VK_VRAM_MB=4096(orRX_VK_ASTC_CPU=0where the GPU ASTC decoder is stable) inlongshot_env.txt, or revert commit8dd2987.Compatibility: Nothing changes for saves,
longshot_options.ini, shader translation stamps (device_policy.h,texture_budget.h, andvk_texture.cppare not intranslator_files), pipeline caches, orMKWVK_API_VERSION.Issues
See #1040
Checklist
Everyone
type(scope): description) of the status line's type.can't be run by hand is in Testing's Not testable by hand, with why.
in Risks.
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.docs/tested/for each new measured run (format indocs/tested-configurations.md).mainand passing here.tests/that reads changed source updated in this PR, not weakened.Tested in game: Windows 11 (build 26200), AMD Ryzen AI 7 350 w/ Radeon 860M (1002:1114, Adrenalin 26.10.1 LLPC, 32 GB RAM / 26,283 MB usable): 2x2 interleaved A/B in KokiriForest_Child and ZoraDomain_Child with no switches set; integrated GPU texture budget rose from 4096 MB to 8192 MB, budget evictions dropped from 3060 (20 events) to 0, and KokiriForest_Child wall FPS rose from 14.71 to 21.18 fps (+43.9% initial) and 18.39 to 35.20 fps (+91.4% revisit).
@Beanstalk linux
@Jer9 only members of
BigBeanscan start the farm. One of them can approve this request by reacting 👍 to it or to this comment.@Beanstalk let's test on 2 steam decks and more
Beanstalk test farm
Commit
9519ce0· tier reviewed · approved by HumanBean · dashboardWhat will be tested · AI plan (
gpt-6.1-terra)The plan compares CPU and GPU ASTC decoding during a Kokiri Forest–Zora’s Domain–Kokiri revisit, measuring frame times, memory, load times and visual differences against main. It requests reports from two Steam Decks, plus integrated GPUs with 24 GB and more than 24 GB of RAM; these targets are not currently listed online and will wait for matching testers. Each tester’s game runs take roughly 25 minutes. Crashes, device loss, substantial frame-time or system-memory regressions, and visual differences fail the plan. No tester online now matches steamdeck, igpu+ram24gb, igpu+ram-ge25gb: those targets wait for one.
0or1.kokiri-start, then teleport to Kokiri Forest, measure kokiri-initial for 20 s (after 5 s warm-up), take the picture kokiri-initial to compare with main, teleport to Zora's Domain, measure zora for 20 s (after 5 s warm-up), take the picture zora to compare with main, measure kokiri-revisit for 20 s (after 5 s warm-up), take the picture kokiri-revisit to compare with main; 1 run on each side for each of 2 cells (2 game starts a run).Started at 09:54 UTC.
Estimate: done in about 25 min, from the queue and the testers online now; some jobs can't start yet.
⚠ No tester has a PC for
igpu+ram24gb(none seen in 14 days): it waits until one signs in.AMD Radeon(TM) 860M Graphics, 2.0.416RX_VK_ASTC_CPU=0RX_VK_ASTC_CPU=0RX_VK_ASTC_CPU=0RX_VK_ASTC_CPU=1RX_VK_ASTC_CPU=1RX_VK_ASTC_CPU=1Measurements · igpu+ram-ge25gb
Verdict: queued on igpu+ram-ge25gb (1/1 report).
Hardware: 1: windows+amd+amd-proprietary+igpu
AMD Radeon(TM) 860M Graphics, 2.0.416AMD Ryzen AI 7 350 w/ Radeon 860M, 26 GB RAMScene: texture-revisit, from the repository's save kokiri-start; each cell's settings and switches as the table names them
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); texture-revisit: 1 game start a side, kokiri-initial 20 s after 5 s warm-up, zora 20 s after 5 s warm-up, kokiri-revisit 20 s after 5 s warm-up; each number the median of the runs, then of 1 report
How to reproduce: the farm's plan above (
@Beanstalkon this PR runs it again)Nothing was measured: no metric came back.
Flags and settings
RX_VK_ASTC_CPU0,1Markdown for the PR description
For the Steam Deck testers, a note from reading the diff at
9519ce0f, not yet run: this probably doesn't change the Deck's texture budget.device_policy.h. The Deck (Linux, RADV VANGOGH) decodes ASTC on the GPU, and has ~14.8 GB usable of 16 GB.RX_VK_ASTC_CPU=1.A Deck run of the PR should log the same
vk: integrated GPU texture budget:line as main. If a Deck tester sees a different value, that would be worth a look.Verdict: Request changes. The bigger texture cache eliminates the measured Kokiri eviction thrashing on the Radeon 860M. Both patched runs were slower in settled Zora’s Domain, and the higher budget can also take effect when ASTC still uploads compressed.
Reviewed
9519ce0fb0a0againstef6038abe489. Read the changed policy, budget and texture code, both fixtures and documentation, and checked the native format selection and memory-pressure paths. The measured renderer at8dd2987matches the reviewed renderer. Code review only. No changes pushed.Blocking
gpu/vk/device_policy.h:128increases the cap on the affected UMA path. The author’s interleaved 860M runs report settled Zora at 30.90 and 32.63 fps after versus 33.89 and 33.65 before, a 5.9% median drop. Peak texture residency rose from 4,064–4,638 MiB to 7,037–7,130 MiB. Please repeat the warm interleaved route on a current main base, with settled frame times and system-memory headroom. If the slowdown holds, tune the cap or eviction policy before merging. The earlier 6 GiB result in issue 1040 still had evictions in Zora, so a smaller cap needs measurement too.gpu/vk/vk_texture.cpp:4991and the corresponding startup estimate use the CPU-decode policy bit. Format selection picks a supported native ASTC format before it reaches the decode fallback. WithRX_VK_ASTC_CPU=1, native ASTC, more than 16 GiB usable RAM and sufficient driver allowance, the budget can rise while textures remain compressed. Gate both calculations on the same native-format capability and cover that combination in the fixture.The driver allowance and pressure clamps still apply, and the explicit override still bypasses the default. The tested 860M showed 3,060 to zero median evictions and strong gains on the two Kokiri visits. The Windows suite report should name its 57 baseline failures. The farm request still lacks conclusive metrics on affected desktop iGPUs and the lower RAM tier. The Deck is in the unchanged budget band even with CPU decode forced, so a Deck result alone cannot validate the increase.
No merge-order dependency found. Recheck the route if ASTC reuse hashing lands first.
@ -124,3 +125,4 @@const uint64_t available = ram > reserved ? ram - reserved : 0;uint64_t b = std::min(available, share);const uint64_t cap = ram <= 8 * kGB ? 1536 * kMB : ram <= 12 * kGB ? 2048 * kMB : ram <= 16 * kGB ? 2560 * kMB: astc_on_cpu ? (ram <= 24 * kGB ? 6144 * kMB : 8192 * kMB)Both patched 860M samples lost settled Zora FPS while peak residency grew by several GiB. Please replicate settled timing and memory headroom on the rebased pair, and tune the cap or policy if the loss holds.
@ -4987,3 +4989,3 @@const uint64_t reserved = policy_rule::integrated_reserved(system_ram); // (for the line below)const uint64_t driver_budget = own; // (its share of the allowance: texture_budget.h integrated_bytes)own = policy_rule::integrated_texture_budget(driver_budget, system_ram);own = policy_rule::integrated_texture_budget(driver_budget, system_ram, astc_on_cpu());Please gate the increased default on the actual decode path. A forced CPU policy bit can coexist with native compressed ASTC selected first in vk_formats.cpp. Keep the startup estimate aligned.
Independent Windows game-free check at
9519ce0f, with llvm-mingw Clang and Vulkan-Headers 1.4.345.test_texture_budget.pypassed, andtest_device_policy.pypassed its 19 PC profiles, 64 switch environments and 55 rule edges.These checks exercise the budget formulas and policy wiring. The live native-ASTC format case and the settled Zora's Domain result in the existing review still need coverage. The existing farm plan has the useful 24 GB and above-24 GB integrated-GPU targets. Steam Deck gives a control for the unchanged memory tier.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.