perf(vk): cut zone-entry ASTC upload spikes on non-ASTC GPUs via async chunk submits #2860
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
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!2860
Loading…
Reference in a new issue
No description provided.
Delete branch "HumanBean/Longshot:perf/vk-async-astc-upload-main"
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 GPUs without native ASTC (AMD, NVIDIA, Intel desktop), large ASTC textures are decoded on the GPU in 16M-texel chunks (
RX_VK_ASTC_CHUNK_MPX). Each chunk boundary blocked the presentation thread onvkWaitForFencesjust to reuse one upload command buffer, so entering a zone (Hyrule Field's 1365 x 1365 x 90 terrain arrays) froze the frame: 68 ms ofastc_flush_msin one frame of a nightly-937 Kakariko capture on an RX 9070 XT, withuploads_msof 185 ms in the worst frame.This is Jer9's #2330, merged into mod-api, ported to main unchanged (a clean cherry-pick, author kept): each recording keeps a pool of up to 64 upload command buffers, each finished chunk is submitted at once without a fence, and all chunks retire together when the frame slot is reused. No new switch; it does nothing on GPUs that sample ASTC natively or with
RX_VK_ASTC_CPU=1.Read first:
replay_flush_upload()ingpu/vk/vk_replay.cpp, thenupload_astc_gpu()ingpu/vk/vk_texture.cpp.Testing
Tested: not run in the game on this PC; opened with
--forceat the person's request. Game-free on Linux:tests/test_async_astc_upload_chunks.py(fails on main, passes here),test_astc_upload_chunking,test_astc_pass_timing,test_vk_braces,test_utf8_paths,test_doc_anchors,test_switches_removed. Three C++ checks (draw_stream_visibility,fsr_image_retirement,fsr_uniform_ownership) were skipped here for want of the Vulkan headers, and the renderer was not compiled on this PC. On mod-api, Jer9 ran it on Windows 11, Radeon 860M (Adrenalin 26.10.1): 3-zone tour, 0 device losses.Still to test:
astc_flush_msunder 2 ms and noVK_ERROR_DEVICE_LOST(@Beanstalk)Measurements
Verdict: from #2330 on mod-api, on a Radeon 860M: worst
astc_flush_ms332 ms -> 1.6 ms, total 1580 -> 12 ms,vk: slow uploadlines 25 -> 3, a 1365 x 1365 x 90 upload about 158-295 ms -> 18-29 ms. Not re-measured on main.Setup: Windows 11, Ryzen AI 7 350 + Radeon 860M, 1600x1000, 67 % scale, 3-zone tour (numbers from #2330).
astc_flush_msRisks
A GPU or driver that mishandled many unfenced submits could lose the device; a revert is enough, nothing is saved or cached differently. Chunks past 64 per frame fall back to a bounded wait.
Checklist
Ready for review
main; the title is a Conventional Commit.--force), see Testing.mise run testpasses: the targeted checks pass; three skipped for lack of Vulkan headers.main: numbers are #2330's on mod-api.third_party/untouched.When it applies
tests/that reads changed source is updated, not weakened.Co-Authored-By:trailers.WIP: perf(vk): cut zone-entry ASTC upload spikes on non-ASTC GPUs via async chunk submitsto perf(vk): cut zone-entry ASTC upload spikes on non-ASTC GPUs via async chunk submitsMeasured on an RX 6650 XT (Navi 23, RDNA2, Windows 10, driver 26.10.1 / 0x800161), 1920x1080 native, no frame generation, 30 fps cap, 2.800-3.300 draws:
So this cut the zone-entry stall roughly in half on this card, but it did not go away: it also happens on re-entry, not only the first visit after a build. When it triggers, the texture budget is exactly at its cap (2442 MB of 2443 MB) and VRAM is at 85-88% (5.8-6.1 of 6.8-7.2 GB allowed), with the reaper destroying 150-205 images (217-417 MB) per 10 s while the new view's textures decode.
RX_VK_TEX_MAX_DIM=1024is set in the profile (it brought the in-play worst frame from 182-260 ms to 40-110 ms), so the textures that remain are already the reduced ones.Full write-up, settings and log excerpts: #2905
HumanBean referenced this pull request2026-11-30 17:13:13 +00:00