fix(vk): the graphics in AMD's desktop CPUs decode ASTC on the CPU, so Kokiri Forest no longer resets the GPU #489
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/upscaling
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/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
testing wanted
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!489
Loading…
Reference in a new issue
No description provided.
Delete branch "Yeetbot90/Longshot:fix/amd-igpu-astc-cpu"
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?
Why
On the graphics built into AMD's desktop CPUs (a Ryzen 9 7900X's Radeon Graphics: 2 CUs, the iGPU of a CPU, not an APU; Windows) the game lost the GPU device (
VK_ERROR_DEVICE_LOST, then FATAL) within seconds of Kokiri Forest loading in 7 runs of 8. With the ASTC textures decoded on the CPU it loaded Kokiri Forest 4 times of 4 (the last with this PR's own build), at the cost of a pause of about 12 s as the area loads.What changed
The cause, from the runs' logs: as Kokiri Forest loads, the terrain's two material arrays (1365 x 1365 x 90 layers, 11 levels, ASTC 8x8, 57 MB each) are decoded by the GPU and re-encoded as BC3, one layer and one level at a time. All of it goes into the recording's single upload command buffer: some 2000 dispatches in one submission. On a 2-CU GPU that runs for seconds: in every lost run the game's wait for the GPU took 4-6 s (
nvn: GPU waits in 5 s: 1 sync waits (4176-6305 ms)) before Windows reset the GPU. Decoded on the CPU, each array took 5.9-6.7 s on the replay thread, and the device was not lost.astc_on_cpu()ingpu/vk/vk_texture.cpp, asked byastc_ready().RX_VK_ASTC_CPUalready sent ASTC to the CPU decoder; unset, it is now on, on Windows, for the iGPU of AMD's Ryzen 7000 (Raphael, PCI0x164E, the one tested) and Ryzen 9000 (Granite Ridge,0x13C0) desktop CPUs: the same 2-CU RDNA 2 part. The APUs' larger iGPUs (680M, 780M, 890M) and every other AMD GPU keep the GPU decoder.RX_VK_ASTC_CPU=0gives the GPU decoder back. The switch is read by the switches' rule (env_value_off), and the log says when the CPU decodes.docs/development.md,RX_VK_ASTC_CPU.Flags and settings
RX_VK_ASTC_CPU(existing; new default)1: ASTC decoded on the CPU, kept as RGBA8.0: the GPU decoder, big textures re-encoded as BC30x13C0); Linux (default off)Measurements
main:
f804b7b8(2026-11-14)this PR: fix/amd-igpu-astc-cpu @
105bb206Rebased from
9c9d69edontof804b7b8(#385: the build's split of giant lifted functions, no renderer file); the measurements and the run_all numbers are from9c9d69edand still hold, the renderer being the sameBaseline: main @
f804b7b8. In the game its side is the GPU decoder, this PR's sideRX_VK_ASTC_CPU=1, both with a renderer built frome072164e(#404's branch: main @0caf0618plus two Intel commits) swapped into one game folder: a renderer from a newer main changes the shader translator and would restart the shader preparation each run.astc_on_cpu()is the only change; the code it switches is the same on both bases.Hardware: Ryzen 9 7900X's AMD Radeon(TM) Graphics (RDNA 2, 2 CUs), AMD proprietary driver 26.10.1 (Vulkan driver 0x800161), no mesh shaders (the compute fallback), Windows 11; the screen on an RX 9070 XT, so the iGPU's frames are presented across adapters
Scene: New Game or a save, then Kokiri Forest (
map: KokiriForest_Child); output resolution 2048x1152Method: played by hand, one Kokiri Forest load per run, until the device was lost or the game was closed; the numbers are lines from each run's
longshot_log.txt. The checks:tests/run_all.pyon main and on this PRHow to reproduce: on a Ryzen 7000 or 9000 desktop CPU's iGPU on Windows, walk into Kokiri Forest with
RX_VK_ASTC_CPU=0(main's decoder), then with this PR and no switchf804b7b8(GPU decoder)105bb206(RX_VK_ASTC_CPU=1)tests/run_all.pyThe eight runs with the GPU decoder also had other switches (markers, a skipped program, the VRAM mirrors, the issue 817 task shader skipped); none of them kept the device, and the one that did keep it (110 min, markers before every command) uploaded the two arrays at different moments. The three runs with
RX_VK_ASTC_CPU=1had markers before every command on (a build of the closed #466); markers alone did not keep the device (#466's last run). The fourth is this PR's own build with no switch and no markers: Kokiri Forest loaded, about 28 minutes, no device lost.Testing
Tested: On the iGPU above, the twelve Kokiri Forest loads in Measurements, played by hand.
tests/run_all.pyon main and on this PR, Windows 11, llvm-mingw fromnightly-132-5e072fc8: the same 5 fail on both.test_env_oncaught the switch read as set-means-on in a first version; it now uses the switches' rule. The renderer (RX_VK_ONLY) builds on9c9d69edand one072164e. With no switch, the log on the iGPU says ASTC is decoded on the CPU.This PR's own build with no switch: Kokiri Forest loaded (5934 and 6466 ms for the two arrays) and the game ran about 28 minutes (101760 presents) with no device lost.
Not tested: Frame rate against main: main loses the device in Kokiri Forest. Hyrule Field and the other areas with the same arrays. A PC with 16 GB of RAM or less (a smaller texture budget, with the arrays at 4x their BC3 size). Ryzen 9000's iGPU (the same 2-CU part,
0x13C0: on by default, not run) and newer drivers. AMD's APUs are left as they are. A Linux build was not run: the change is standard C++ under#ifdef _WIN32, so Linux keeps main's behaviour.Needs other testers:
RX_VK_ASTC_CPU=1says whether APUs need the same (request to open)Screenshots
Nothing on screen beyond the pause as the area loads: the textures are the same ASTC decoded, kept as RGBA8 instead of BC3.
Risk and rollback
RX_VK_ASTC_CPU=0restores the GPU decoder; reverting the commit restores main's behaviour.Reviewer notes
The proper fix is in the upload path: split a big array's decode and re-encode over several submissions (or frames), so that no single submission holds a weak GPU for seconds, and then let these GPUs decode on the GPU again. This PR only keeps the game from crashing on them until then. It replaces #466 (markers before every command), whose last run lost the device all the same: closed.
Issues
See the Kokiri Forest device loss on AMD integrated graphics (#466; no issue on the tracker yet).
Checklist
For everyone
type(scope): description).main.python -I -B tests/run_all.pyrun and passing (any failure that also fails onmainis named above).third_party/untouched (a new folder with aPROVENANCE.mdinstead).If applicable
Assisted-by:/Co-Authored-By:trailers.WIP: fix(vk): AMD's integrated GPUs decode ASTC on the CPU, so Kokiri Forest no longer resets the GPUto fix(vk): AMD's integrated GPUs decode ASTC on the CPU, so Kokiri Forest no longer resets the GPUTested this PR's own build (56ae077e's change on the game folder's renderer), no switch, no markers, on the Ryzen 9 7900X's Radeon Graphics: the log says
ASTC decoded on the CPU, Kokiri Forest loaded (the terrain arrays in 5934 and 6466 ms on the replay thread) and the game ran about 28 minutes (101760 presents) with no device lost. With the GPU decoder 7 of 8 loads lost it; with the CPU decoder 0 of 4. Marked ready.d29f8038d8dc0b9c05aedc0b9c05ae105bb206c1fix(vk): AMD's integrated GPUs decode ASTC on the CPU, so Kokiri Forest no longer resets the GPUto fix(vk): the graphics in AMD's desktop CPUs decode ASTC on the CPU, so Kokiri Forest no longer resets the GPUView command line instructions
Checkout
From your project repository, check out a new branch and test the changes.