perf(vk): big ASTC textures become BC3 in one pass, and the two-pass path and its switches go #2473
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
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2473
Loading…
Reference in a new issue
No description provided.
Delete branch "TrashPanda/Longshot:feat/astc-bc-one-pass"
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
Big ASTC textures are kept as BC3 on GPUs that cannot sample ASTC. Until now each level was decoded into a 2048 x 2048 RGBA8
scratch image, re-encoded by a second shader into a buffer and copied into the texture, with three full barriers each time
(about 630 for one of the terrain's 1365 x 1365 x 90 arrays), and the scratch images held 20-56 MB of VRAM. Now one compute
pass does both: a workgroup decodes a tile of ASTC blocks into shared memory with the same decoder (
astc_decoder.comp, built asecond time with
ASTC_TO_BC3; the RGBA8 route's build is unchanged word for word) and encodes the tile's 4x4 blocks straightinto a 16 MB output buffer; a texture's levels and layers are copied into the image together, between two barriers (that array:
24 dispatches and 16 copies where there were 1,980 dispatches). It is on by default wherever big ASTC textures were re-encoded;
which textures become BC3, and the RGBA8 route, do not change. A copy from a decoded ASTC texture into a BC3 one encodes the
source in place (
bc3_encoder.comp, the same encode half). The scratch images, the level groups, the small scratch, the AMDresize, Eden's
bc_encoder.compand the BC7 encoder go, with six switches.The encode half is Longshot's own BC3 encoder (principal axis, least squares, a one-colour table, the 6- and 8-value alpha
modes; byte for byte the encoder measured on the game's textures at 33.2-33.5 dB colour against the old 31.8-32.3, alpha equal
or better). So BC3 blocks change: better on average, 0.5% of blocks more than 1 dB worse than the old encoder's.
Read first:
gpu/vk/host_shaders/astc_decoder.comp(theASTC_TO_BC3lines and the converter'smain),gpu/vk/astc_convert.h(the tiles),gpu/vk/host_shaders/bc3_encode.glsl, thenupload_astc_gpu,bc3_regions,bc3_copyand
texture_copy_into_bcingpu/vk/vk_texture.cpp.Commits: (1) the converter shader, the image encoder and the shader fixture, nothing using them; (2) the renderer uses them,
with the new upload-path fixture; (3) the two-pass path, its encoders and switches removed, with docs; (4) the two upload tests
build under clang 23's
-Wunused-but-set-global(the failure Jer9 reported); (5) three more builds of the existing shaders(
ASTC_TO_TEXELS: the plain decoder storing texels in a buffer;BC3_FROM_TEXELS: the same encode half reading them, andthat again with
BC3_LSQ_PASSES=0, BC3_BOX=0), with their lavapipe fixture; (6)RX_VK_ASTC_BC_SPLITuses them inside theexisting batch: decode a run into a 16 MB texel buffer, barrier, encode, barrier, then the existing copy; the same BC3 bytes at
1; the buffer and pipelines are made only with the switch set, and a failure to make them falls back to the one pass and is
logged;
tests/test_astc_upload_gpu.py --benchtimes the routes.Added switch:
RX_VK_ASTC_BC_SPLIT(0 by default on every PC; for measuring on integrated GPUs; its default per GPU classis to be chosen from testers' numbers).
Removed switches (none had a menu row or an options-file key; each is a
GONE(...)row saying what a run that sets it gets):RX_VK_ASTC_BC7(BC7 measured 8.7 dB worse in alpha at ten times the GPU time; it returns with the format chooser and a newencoder),
RX_VK_BC_LAYERS,RX_VK_BC_SMALL_LAYERS,RX_VK_BC_LEVELS,RX_VK_BC_POOL,RX_VK_BC_IDLE_S. Kept:RX_VK_ASTC_RGBA8(the menu's ASTC as RGBA8, key unchanged),RX_VK_ASTC_CPU,RX_VK_ASTC_CHUNK_MPX,RX_VK_BC_COPY_PER_LAYER,RX_VK_UNEVEN_BCandRX_VK_UNEVEN_RGBA8(withRX_VK_UNEVEN_BC=0a texture that would need resizing now stays RGBA8).Part of the plan "Textures without hitches" (its M1). See #2292, which its ahead conversion (M2) is to supersede.
Testing
Tested: in the game by three reviewers at
c8294011b(their comments below have the full tables), not by the author:upload failed, no validation error, no device loss, no log line on one side only; textures match main's in screenshots,the terrain's 1365 x 1365 x 90 arrays included.
longshot_vk.dllbuilds with no warning; 47runs over three saves with exit 0, no device loss, no
upload failed; no black edges or seams on the terrain's small levelswith the per-layer copies (#2006/#2107/#2228);
test_astc_decoder_gpu.py --device Radeonpasses on the hardware (9,388vector decodes exact, 62,244 of 62,244 image-encoder blocks equal to the converter, all 56 PSNR floors).
test_astc_upload_gpu.pystarted on the Radeon and stopped at its self-test (no synchronization validation layer there).correctly, no upload failure, crash or device loss.
Tested by the author at
102e1cab4, rebased on mainbe663a08a(one conflict, both sides appending rows toswitches.def):test_astc_upload_chunking.pyandtest_astc_upload_gpu.py --device llvmpipewith g++ 15 and clang++ 21,test_device_policy.py,the switches check. Before the rebase, on lavapipe (llvmpipe, Mesa 26.0.8, LLVM 21.1.8, 4 threads,
Khronos validation layer 1.4.341), Linux, as
tests/run_vulkan_fixtures.pyruns them:tests/test_astc_decoder_gpu.py: the decoder as before (9,388 astcenc vector decodes, 58 whole levels, 56 hand-built levels,exact); the converter's tile (each BC block's 16 texels as the encode half reads them) equal to texdecode with no tolerance on
the same corpus and on 374 tile-edge levels (every footprint, 1 x 1 to past two tiles, 1 and 3 layers, both tile classes),
nothing written around a level's blocks; its BC3 byte-equal to the same encode half fed texdecode's decode as a separate pass
(558 levels); BC3 within stated PSNR floors per footprint (vectors 25.0 dB colour, gradients 43.5, flats 51.5, edges 27.5);
the image encoder within the same floors and its three promises; 16 mutations of the shader each failing it.
tests/test_astc_upload_gpu.py(new): the realupload_astc_gpu,texture_copy_into_bc,bc_ready, the batch,full_barrierand the recording's upload command buffer, cut out of
vk_texture.cppand run on a Vulkan device with synchronizationvalidation (shader accesses tracked; a self-test proves a missing barrier after a dispatch is reported): seven textures,
1,259,077 texels, across four chunk flushes and a full output buffer; BC3 byte-equal to the converter alone, RGBA8 equal to
texdecode, the copy into BC3 equal to the image encoder alone with the rest of the level unchanged, the AMD per-layer regions,
repacked levels, a failed upload followed by a correct texture; no validation or synchronization error. Ten mutations of the
wiring: nine fail it; the failure barrier, which synchronization validation cannot see, fails
test_astc_upload_chunking.py.vk_texture.cpp,vk_xfer.cpp,vk_main.cppcompiledalone with the game build's flags.
102e1cab4against mainbe663a08a: 842 checks, no check failing only here (56 game-side checks fail the sameon both sides on this PC, 13 skipped on both).
stopped:
test_astc_decoder_gpu.py(492 levels through the two steps: texels the exact decode, BC3 byte-equal to theconverter's, nothing written outside the buffers, the cheaper encode half within the floors);
test_astc_upload_gpu.pyonall three routes (1 equal to the converter alone, 2 equal to the cheaper encode half alone, synchronization validation
clean); seven mutations of the wiring, each caught.
shaders.py host --checkmatches; the RGBA8 decoder's, the converter'sand the image encoder's SPIR-V are unchanged.
test_astc_upload_chunking.py's three new two-step modes,test_device_policy.py's newcases, both GPU fixtures with clang++. Never run at this head: the full suite, the switch table checks, the mutation
check of the new shader builds, the game.
Still to test:
python -I -B tests/test_astc_upload_gpu.py --headers <Vulkan headers> --device Radeon --bench --reps 7, expecting the rows for 1 and 2 under the one pass's and "same blocks" for 1; then thegame unset against
RX_VK_ASTC_BC_SPLIT=1and=2withRX_VK_PASS_TIMING=1, expecting the terrain array upload andworst frames back at or under main's (by hand)
test_astc_upload_chunking.py,test_device_policy.py, the switch table checks and both fixtures(g++ and clang++) at
f1187f556, expecting no check failing only here (by hand)RX_VK_ASTC_BC_SPLIT=2against 1, before 2 is offered as anything but a measurement(by hand)
102e1cab4, expecting PASS (fixed here, checked only with clang21 and g++ 15) (by hand)
test_astc_upload_gpu.py, expecting every PASS line (by hand)worst frames of a load against main (by hand)
RX_VK_TEXDECODE_CHECK=3read-back, expecting every texel equal to texdecode (by hand)settings-graphics.png's sources (scripts/check_guide_screenshots.py --review-sourcesflagsgpu/vk/device_policy.handgpu/vk/vk_texture.h: a field removed from each, no menu row changed) (by hand)Measurements
Verdict: level or slightly faster on a discrete NVIDIA GPU, level on the Steam Deck with far fewer slow uploads, and
slower on AMD integrated graphics under Windows: about 50% longer worst frames in two of three loads. All numbers are the
reviewers', at
c8294011b; the author has measured nothing in the game.8aa5ab87(RTX 3090 rows:6123c76a)c8294011bkokiri-start(median of 3, Jer9)castle-gatemarket-entrancekokiri-startmarket-entranceJer9's sweep of the encode builds: even
BC3_LSQ_PASSES=0, BC3_BOX=0trims only 11-18% and leaves the 860M 1.7 to 2.2 timesslower on the terrain uploads, so the cost is in the fused shader itself (shared memory and registers a workgroup), not the
refinement loop. klikso: on the Deck the time uploads lost reappeared as memory sync in the slow-submit lines, and running
forward in Hyrule Field was 5.7% lower (3 runs).
The two-step route, game-free only, on one shared PC, indicative (
--bench --layers 16 --reps 3; GPU time as a share of theone pass's):
Why the one pass is slow there (RADV pipeline statistics on Raphael): the converter needs 168 or 240 vector registers and 11 or
15 KB of shared memory a workgroup, so 6 or 4 waves fit a SIMD where the decoder and the old encoder fit 12. At 2048 x 2048,
5x5: main's two passes 11.1 ms, the one pass 26.2 ms; about 11 ms of the difference is the merge, about 4 ms the heavier
encoder. Not measured in the game, not on the 860M, and the 90-layer case was not run.
Risks
are a lighter converter for integrated GPUs (less shared memory and fewer registers a workgroup) or keeping a separate
encode pass there; the old two-pass path is removed by commit 3, so dropping that commit is the quick one.
kBc3OutBlocks / level_blocks) is safe only becausetextures stop at 2048 and nothing asserts it; and the fixtures require the two-step route's blocks to equal the one pass's
byte for byte, which held on lavapipe, RADV and an RTX 4070 Ti but a driver that contracts floats differently between
shader modules could fail without a real fault.
ways back for a tester: the menu's ASTC as RGBA8 (Developer section) or
RX_VK_ASTC_RGBA8=1keeps every ASTC texture RGBA8through the unchanged decoder (more video memory);
RX_VK_ASTC_CPU=1decodes on the CPU. A converter pipeline a driverrefuses is logged and does the same by itself. The old path is removed, so a revert is the way back for everyone.
workgroups where that limits), under the 16,384 every Vulkan device gives.
formats; alpha's worst level 0.3 dB under).
RX_VK_UNEVEN_BC=0(off by default) now keeps a texture that would need resizing as RGBA8 (more memory) instead of resizing it.longshot_options.inior the caches; the new pipelines are made once into the pipeline cachebefore the game; a run that sets a removed switch is told what it gets. VRAM: 4-40 MB less.
Checklist
Ready for review
main; the title is a Conventional Commit. (rebased onbe663a08a)mise run testpasses (any failure that also fails onmainis named). (not re-run atf1187f556;tests/run_all.pyat102e1cab4against mainbe663a08aon the author's Linux PC: 842 checks, none failing only here; 56 fail identically on both sides, all game-side checks outside this change,test_camera_centering.pytotest_wide_ui.py, which looks like this PC's setup since #2411; 13 skipped on both)main, or Measurements says why there is nothing to measure. (by the three reviewers; it shows a regression on AMD integrated graphics)third_party/untouched; nothing GPL-incompatible.When it applies
gpu/vk/switches.def. (six GONE rows; two rows reworded;RX_VK_ASTC_BC_SPLITadded, 0 until measured on integrated GPUs)tests/that reads changed source is updated, not weakened. (the scratch's checks removed with the scratch; their promises moved to test_astc_upload_chunking.py and test_astc_upload_gpu.py)scripts/shaders.py host, glslang 16.6.0;--checkmatches)mainand here, for a change that shows on screen. (none attached; HumanBean and Jer9 compared screenshots with main and found the textures matching)Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
Wait: nothing in the code that I can show wrong, but this must not leave WIP before the runs it lists, and its default needs a way to be cheaper on integrated GPUs.
I read the whole converter and wiring (
astc_decoder.comp'sASTC_TO_BC3half,bc3_encode.glsl,bc3_encoder.comp,astc_convert.h,upload_astc_gpu,bc3_regions,bc3_copy,texture_copy_into_bc, thebc_candidateand uneven-level code, the switch rows). Code only; nothing run. Every claim in the description is lavapipe and game-free; nothing ran on a hardware GPU or in the game, as the description says.Checked and fine
tile_ofis whole 4x4 BC blocks, within the shared-memory cap (14,400 B of 16,384),static_asserted against the rule. Edge handling is right:max_x/max_yclip the decode so no texel is stored outside the level (soTileStorenever aliases), and the encode'slast_x/last_yrepeat only texels the level has. Output index(layer * rows + by) * columns + bxmatches the copy regions'bufferRowLengthandbufferImageHeight. No lane returns beforebarrier().{0,2,3,1}), the endpoint swap withidx ^= 0x55555555, and the least-squares normal equations all check out by hand.full_barrier, copy,full_barrier; a chunk flush copies the batch first, then flushes, then re-barriers the re-begun command buffer; the overflow testbatch_at + level_blocks * n > kBc3OutBlockscan never be hit by a single run (bc_runis bounded by it, and the biggest level is 262,144 of the 1,048,576 blocks); the destructor barrier covers a failure after dispatches.nis bounded bymaxComputeWorkGroupCount[2]and the storage range as before.texture_copy_into_bcbarriers each run.bc3_regions), also for the copy-into path. The removed AMD resize leaves the default as it was:RX_VK_UNEVEN_BCwas off by default, so the default path never used it; behind the=0opt-in a texture needing a resize now stays RGBA8.GONErows with a reason each; no leftover reader of any of them in the tree (only frozen guide source-review pages mentionbc_small_runs). Nothing is added.RX_VK_ASTC_RGBA8stays the way back.What blocks the merge (the PR says so itself)
astc_bc_policy::allkeeps every large ASTC texture as BC3 on them, so they run the converter for the most textures, and the description measures its encode half at about 4.4 times the old encoder per block there. The only way back isRX_VK_ASTC_RGBA8=1, which costs 4 times the memory, on GPUs whose memory is shared with the game.BC3_LSQ_PASSESandBC3_BOXare build-time defines, so a per-GPU choice (the standards' "chosen per platform from measurements") is impossible. See the inline comment: make them specialization constants beside the tile size one, picked by device policy once the RADV and RTX numbers are in.Smaller
longshot-one-pass-design.md"not in the repository; the PR's description has them", but the description has no invariants. Put them in a doc underdocs/dev/reference/(or the architecture page) and link them, or say the rule in the comment.mode1 and 2 are compiled into the shipping converter (a branch per workgroup and a loop nobody takes). A secondHOST_VARIANTSentry for the fixture would keep the shipped SPIR-V to the one route.@ -1210,0 +1278,4 @@tile_bcw = tile_texels_w >> 2u;tile_nbc = tile_bcw * ((tile_h * block_dims.y) >> 2u);image_extent = ivec3(int(width), int(height), 0x40000000);if (mode == 2u) {mode == 2uhere andmode == 1uat line 1323 are the fixture's, but they are in the shipped converter: a loop and a branch no game run takes, andmoderead in the hot encode loop. A thirdHOST_VARIANTSentry (-DASTC_TO_BC3 -DASTC_FIXTURE, not embedded in the renderer) would keep the shipped SPIR-V to the one route, with the fixture running the variant. Not a bug.@ -0,0 +20,4 @@// BC3_LSQ_PASSES (0 to 2, default 2) and BC3_BOX (0 or 1, default 1) are build-time choices for measuring cheaper encoders; the// renderer's headers are built with the defaults (scripts/shaders.py host), which the fixture's quality floors hold.#ifndef BC3_LSQ_PASSESThese two being build-time defines is what stops a per-GPU default. If the RADV iGPU run needs a cheaper encode half (the description's 4.4x), the choice has to be per device (device policy, as the tile class already is through specialization constant 0), not a second set of headers.
layout(constant_id = N) const intfor the LSQ passes and the box candidate,if (BC3_BOX != 0)in place of the#if, and the loop bound is a constant to the driver's compiler anyway. Then the default can be chosen per platform from the timing table, which the standards ask for.@ -1059,0 +864,4 @@// workgroup decodes a tile of ASTC blocks into shared memory and encodes its 4x4 blocks to BC3 (bc3_encode.glsl) into bc3_out,// which is copied into the texture, a texture's levels and layers together (a batch, upload_astc_gpu). No RGBA8 image between// the two halves, no barrier between them but the workgroup's own. bc3_encoder.comp runs the same encode half on an RGBA8 image// region (texture_copy_into_bc). Design and the invariants the two-pass path kept: longshot-one-pass-design.md (not in theThis points at
longshot-one-pass-design.mdas 'not in the repository; the PR's description has them', and several comments cite 'invariant 3, 4, 8, 11, 12, 17, 18, 19' (lines 885, 941, 950, 1253, 1220-1230, 2650, 3925). The description has no invariants, so a reader has nothing to look the numbers up in. Move the list intodocs/dev/reference/(the architecture page's texture section, with a// doc:anchor onupload_astc_gpuif you like) and link it here, or write the rule in each comment.Tested in the game: Linux, RTX 3090 (NVIDIA proprietary driver), BC3 path on (
vk: big ASTC textures are kept as BC3, converted on the GPU in one pass).Correctness: clean
One run each of main and this PR: the
kokiri-startsave in Link's house, then teleports to Kokiri Forest and Hyrule Field, 30 s at each stop.upload failed, no validation error and no device loss. No warning, error or failure line appears in one side's log and not the other's.Timing A/B: no regression, slightly faster in the house
Timing mode, interleaved A, B, A, B. A is main @
6123c76a, B is this PR @c8294011. Each run measured the house for 45 s after a 10 s warm-up, then teleported to Hyrule Field and did the same. Fixed resolution; no cap, V-Sync, upscaler or frame generation.* A1's Field window still had pipeline compiles after the 10 s warm-up. Every other window had settled.
Verdict (RTX 3090): about 4 % faster in the house, with the two sides' ranges not overlapping, but with only 2 runs a side. In Hyrule Field the difference is within the spread. The p99 and 1 % lows lean towards this PR in both places. These are steady-state numbers, so they don't measure the load hitch this PR targets. In the one-run correctness test, the frame that uploads the two terrain arrays took 165 ms here against 146 ms on main (GPU time 158 against 144 ms), from a single sample.
Still untested here: integrated GPUs. This PC has none, and the description names them as the main risk.
Tested in the game on Windows 11 + AMD Radeon 860M (8 CUs, RDNA 3.5 iGPU, Adrenalin 26.10.1 LLPC, 6 GB VGM / 12,212 MB allowed VRAM,
astc_bc_all=1,bc_copy_per_layer=1).Build & Correctness (Windows
llvm-mingw+ Adrenalin LLPC)#2473@c8294011vsmain@8aa5ab87(MKWVK_API_VERSION = 45; zerogpu/diff between8aa5ab87and9046a8d7;git merge-tree --write-tree 9046a8d7 c8294011merged cleanly with 0 conflicts).llvm-mingw(clang 23.1.5) standalonelongshot_vk.dllbuild: PASS, 0 warnings/errors (169.7 s, exports checked).tests/run_all.py --strict, Windowsllvm-mingwclang 23.1.5):test_astc_pass_timing.py,test_bc_copy_layer_pitch.py,test_bc_upload_retry.py,test_device_policy.py,test_mem_trim.py,test_astc_decoder_gpu.py.-Werror,-Wunused-but-set-globalfailures onllvm-mingwclang 23.1.5from8b90ed75):tests/test_astc_upload_chunking.py:last_astc_blocks_x,last_astc_blocks_yset but unused (passes onmain, and passes on#2473with-Wno-unused-but-set-global).tests/test_astc_upload_gpu.py:epoch,st_astc,st_bytesset but unused in the generated C++ harness.tests/test_astc_decoder_gpu.py --device Radeon --table: PASS (9,388ASTC vector decodes bit-exact vsastcenc/texdecodeacross 14 footprints linear+sRGB,62,244/62,244image-encoder blocks equal to converter, all 56 PSNR floors passed).tests/test_astc_upload_gpu.py --device Radeon(with-Wno-unused-but-set-global): initialized Radeon 860M cleanly (vk: big ASTC textures are kept as BC3, converted on the GPU in one pass), then stopped on its intentional self-test because Khronos synchronization validation layers are not installed on this Windows host.kokiri-start,castle-gate,market-entrance, 47 total runs across Phases 1–3):0,0VK_ERROR_DEVICE_LOST,0upload failed, confirmedvk: big ASTC textures are kept as BC3, converted on the GPU in one passwithastc_bc_all=1andbc_copy_per_layer=1.#2006/#2107/#2228mip-tail check: Clean on bothcastle-gate(1365x1365 x90terrain arrays) andmarket-entrance— no black edges, dark mip-tail seams, or grid lines at(2, 1)or(0, 0).Load Hitch, Upload Spans & VRAM A/B (
mainvs#2473defaultLSQ=2, BOX=1)Setup:
1680x1048,67% render scale, Game upscaler, FG Off, Uncapped, VSync Off,RX_VK_PRECOMPILE=1,RX_VK_PASS_TIMING=1,13.0 spost-load settle + short walk/pan, 3 strictly interleaved rounds (main -> PR), medians reported (min–max).main @ 8aa5ab87)#2473default(2,1))121identical textures, scratch-drop check)488 MB448 MB-40 MBkokiri-start: Load-start -> in-play (frames.csvat_ns)15.87 s (15.30–18.15)15.49 s (13.84–15.94)-0.37 s(flat)kokiri-start:#1301365x1365x90terrainslow upload(max)214.4 ms (140.4–230.7)472.0 ms (328.3–480.5)+257.6 ms (+120%)kokiri-start: Worst frame / frames>= 50 ms(>= 100 ms)660.7 ms / 59 (5)1,002.1 ms / 77 (8)+341.4 ms (+52%)kokiri-start:astc decode + BCGPU span (never/budget)0.705 / 0.146 ms(4,028 / 542 us/span)2.066 / 0.359 ms(11,373 / 1,353 us/span)2.9x / 2.5x slowercastle-gate(Hyrule Field):1365x1365x90terrainslow upload(max)278.2 ms (164.0–432.4)372.2 ms (364.7–467.3)+94.0 ms (+34%)castle-gate: Worst frame / frames>= 50 ms(>= 100 ms)815.1 ms / 84 (7)828.5 ms / 93 (7)+13.4 ms(+9frames>= 50 ms)castle-gate:astc decode + BCGPU span (never/budget)1.047 / 0.386 ms(8,058 / 643 us/span)1.601 / 0.878 ms(12,156 / 3,414 us/span)1.5x / 2.3x slowermarket-entrance:#130terrainslow upload309.5 ms (152.5–328.3)610.5 ms (509.3–669.5)+301.0 ms (+97%)market-entrance: Worst frame / frames>= 50 ms(>= 100 ms)1,053.2 ms / 51 (8)1,578.4 ms / 72 (7)+525.2 ms (+50%)market-entrance:astc decode + BCGPU span (never/budget)0.735 / 0.454 ms(6,584 / 462 us/span)1.625 / 1.280 ms(14,554 / 1,317 us/span)2.2x / 2.8x slowermarket-entrance: Totalslow upload(>= 16 ms) log lines8 (8–9)40 (40–45)5.0x more spikesmarket-entrance, streaming walk):38.29 / 19.68 fps37.55 / 15.57 fps-0.74 fps/-20.9%1% low(Notes: Settled driver VRAM in-play tracks scene streaming texture count —
market-entrance3,277 MB@2,140tex vs3,429 MB@2,275tex;castle-gate2,730 MB@1,350tex vs2,914 MB@1,695tex;kokiri-starthit streaming-spot variance1,102–1,175vs1,522–1,551tex — while the identical-121-texture title screen confirms the exact-40 MBRGBA8 scratch savings488 -> 448 MB. Per-round terrainslow uploadms:kokiri-startmain[140.4/135.9, 214.4/121.6, 230.7/189.9]vs PR[480.5/466.3, 317.4/328.3, 472.0/427.2];castle-gatemain[278.2/237.6, 432.4/345.9, 164.0/145.2]vs PR[364.7/344.6, 362.6/372.2, 467.3/352.8];market-entrancemain[152.5, 309.5, 328.3]vs PR[509.3, 669.5, 610.5].)BC3_LSQ_PASSES×BC3_BOXiGPU Speed-vs-Quality Sweep (castle-gate&market-entrance)(2 strictly interleaved rounds per preset on
castle-gateandmarket-entrance, plus Radeon 860M hardware PSNR fromtests/test_astc_decoder_gpu.py --device Radeon --tableacross all 14 ASTC footprints.)LSQ, BOX)castle-gateterrain upload (max)market-entranceterrain uploadmarket-entranceBC3 span (never/budget)market-entranceworst frame (>= 50 ms)grad / vecmean dB) & Visualsmain(two-pass Edenbc_encoder)176.8 ms(140.5–213.2)294.0 ms(293.4–294.7)0.595 / 0.442 ms(5,254 / 450 us)1,049.8 ms(56)mainbaseline(2, 1)#2473default471.5 ms(439.9–503.2)574.0 ms(567.0–581.0)1.409 / 1.033 ms(12,716 / 1,173 us)1,345.8 ms(57)44.32 / 30.33 dB(PASS 56/56; clean visuals)(1, 1)421.0 ms(348.0–494.0)529.5 ms(509.2–549.8)1.284 / 1.187 ms(11,582 / 1,215 us)1,268.9 ms(57)44.31 / 30.27 dB(PASS 56/56)(1, 0)492.6 ms(427.2–558.0)547.0 ms(523.0–570.9)1.521 / 1.522 ms(13,092 / 1,500 us)1,414.7 ms(70)44.20 / 30.23 dB(PASS 56/56)(0, 1)512.8 ms(452.6–573.0)513.2 ms(509.5–516.9)1.494 / 1.825 ms(13,582 / 1,869 us)1,406.3 ms(75)44.08 / 29.89 dB(PASS 56/56)(0, 0)386.2 ms(380.6–391.9)508.8 ms(498.8–518.7)1.320 / 1.361 ms(11,905 / 1,398 us)1,382.6 ms(56)43.91 / 29.66 dB(PASS 56/56; clean oncastle-gate)Verdict & Actionable Feedback for
#2473BC3_LSQ_PASSES,BC3_BOX) alone will NOT recover AMD iGPU speed:(0, 0)(zero LSQ passes, zero inset bbox) only trims ~11–18% off(2, 1)and still leaves the 8-CU RDNA 3.5 Radeon 860M1.7–2.2xslower on1365x1365 x90terrain uploads (386 / 509 msvsmain's177 / 294 ms) and2.3–3.1xslower perastc decode + BCspan (11,905 / 1,398 usvs5,254 / 450 us), turning dozens of512x512–1024x1024streaming textures into17–48 msslow uploadhitches (visible as-20.9%streaming 1% low FPS in Market).10,560–14,400 BLDS vs4,160 Bin decoder, plus per-threadt[16]/a[16]arrays andbc3_solid[256]) as the primary bottleneck on 8 CUs, rather than the LSQ refinement loop alone.(0, 0)still passes all 56 PSNR floors intest_astc_decoder_gpu.py(-0.41 dBgradients,-0.67 dBvectors) and looks visually clean oncastle-gate, so specialization constants help modestly — but closing the remaining ~2x gap on integrated GPUs (astc_bc_all=1) will likely need reducing fused VGPR/LDS pressure or keeping a lighter path available on iGPUs.llvm-mingwbuild:longshot_vk.dllbuilds cleanly on Windowsllvm-mingw(clang 23.1.5) with 0 warnings, andbc_copy_per_layer=1passes in-game with zeroDEVICE_LOSTand zero#2006/#2107/#2228black terrain mip seams.llvm-mingwclang 23.1.5: silence/remove the unused-but-set globals (-Werror,-Wunused-but-set-global) intests/test_astc_upload_chunking.py(last_astc_blocks_x,last_astc_blocks_y) andtests/test_astc_upload_gpu.py(epoch,st_astc,st_bytes).Steam Deck numbers for #2330 and #2473 together (posted on both). #2473 lists RADV and the Deck as untested, and #2330 lists Linux RADV.
Setup: Steam Deck LCD (Van Gogh APU, RADV Mesa 26.2.0-devel git-5c65d4fc31, SteamOS 3.9.5), 1280x800, render resolution 50 %, Threaded rendering On,
MESA_VK_ENABLE_SUBMIT_THREAD=1. The policy line sayssmall_vram_textures=1 astc_bc_all=1, so every big ASTC texture goes to BC3.Builds:
8aa5ab87+ local feature ports + #2439 + #2436 + #2308/#2235.tests/test_device_policy.py.Method: the control bridge, 30 s windows, 6 scenes x 3 rounds, A and B alternating first. The scenes stress loading: arriving by teleport with no settle, and running forward through Hyrule Field.
Verdict: "slow upload" lines -87 % (29.9 -> 3.9 a run), with fps and long frames unchanged within noise: 40.0 -> 39.7 fps, p99 55.1 -> 57.6 ms, frames over 50 ms 16.9 -> 18.3 a run.
BC3 converter yes) and drew correctly, with no upload failures and no crashes. No device loss on the two-teleport routes.uploadslost largely turned up asmemory sync, mostly in its capture part. B had 479 slow submits led by memory sync against 131 for A. On this GPU the stall seems to move rather than go away.Not tested: each PR alone (a try2 + #2330-only build exists but was not run), long sessions, and the Deck OLED.
Measured and written up with Claude Code.
c8294011b3102e1cab4eRebased on main (
be663a08a; one conflict, both sides appending rows toswitches.def) and added one commit: the two upload tests now build under clang 23's-Wunused-but-set-global, the failure Jer9 found. Head is102e1cab4.The description is rewritten around the three in-game reports here (thank you HumanBean, Jer9 and klikso): the testing and measurement sections now carry your results, and the top states the regression Jer9 measured on the Radeon 860M under Windows (conversion spans 1.5 to 2.9 times main's GPU time, worst frame about 50% longer in two of three loads). That is not fixed by this push.
Marked ready for review at the owner's request. Three boxes are honestly not ticked and say why: it has not run in the game on my own PC (another job holds its GPU), the full suite is running now, and no screenshots are attached. I would not merge it as it stands for AMD integrated graphics; how to handle that (a lighter converter there, or keeping a separate encode pass on integrated GPUs) is the open question for review.
WIP: perf(vk): big ASTC textures become BC3 in one pass, and the two-pass path and its switches goto perf(vk): big ASTC textures become BC3 in one pass, and the two-pass path and its switches goFull suite run at
102e1cab4against mainbe663a08aon my Linux PC: 842 checks, none failing only on this PR. 56 game-side checks fail identically on both sides here (unrelated to this change; it looks like my PC's setup since #2411), 13 skipped on both. Description updated and the suite box ticked.Three more commits (head
7ccf65a2f), for the AMD integrated-GPU slowdown: a two-step route behindRX_VK_ASTC_BC_SPLIT=1(the plain decoder into a 16 MB texel buffer, then the same BC3 encoder; same BC3 bytes, batching kept, no scratch image), off everywhere, and a game-free benchmark,tests/test_astc_bc3_bench.py --device <name>, that times both routes on any GPU. Pushed as code only: nothing was re-run at this head (no suite, no fixtures, no game), and it has never run on an AMD GPU under Windows. One indicative number from development: on a Ryzen 9800X3D's integrated GPU (RADV) the two steps took 0.41 to 0.64 of the one pass's GPU time in the benchmark. If someone with a Radeon iGPU can run the benchmark, that decides whether the switch becomes the default there.Three more commits (head
7ccf65a2f), aimed at the slowdown @Jer9 measured on the Radeon 860M.What they add:
RX_VK_ASTC_BC_SPLIT=1, off by default, converts in two steps instead of one fused shader: the plain decoder writes texels into a buffer, then the same BC3 encoder reads them. The batching stays, so it is three barriers a batch, not three a level as on main. The BC3 bytes are identical to the fused route's.Why: Jer9's reading was right. On my Ryzen integrated GPU (RADV) the decode half runs about twice as slow inside the fused shader as alone, and the cost follows the shared memory a workgroup declares, not the encoder's arithmetic.
Numbers so far (game-free benchmark, GPU time, indicative: a shared PC):
Two steps took 41-64% of the fused time in all 25 cases on the iGPU.
Not done: the full suite on these three commits, anything in the game, any Windows build. The shader and upload fixtures passed on lavapipe, RADV and the RTX.
The ask, Jer9, if you have time (game closed, a few minutes):
and, if that looks good, your earlier A/B in the game with
RX_VK_ASTC_BC_SPLIT=1against without (the log saysRX_VK_ASTC_BC_SPLIT=1: ASTC to BC3 in two stepswhen it is on). If two steps win on AMD's Windows driver as well, I would make it the only route and drop the fused shader rather than keep a switch.7ccf65a2f1f1187f556eCorrection to the two comments above: the two-step route on this branch has been replaced by a second implementation of the same design (head is now
f1187f556, force-pushed; the earlier three commits ending7ccf65a2fare gone from the branch). Two were written in parallel by mistake and this is the one being kept. Sorry for the churn.What differs for anyone testing:
RX_VK_ASTC_BC_SPLITwith three values: unset or 0 is the one pass (the default everywhere), 1 is two steps with the same BC3 bytes, 2 is two steps with a cheaper encode half.tests/test_astc_bc3_bench.pyany more; it ispython -I -B tests/test_astc_upload_gpu.py --headers <Vulkan headers> --device <name> --bench --reps 7.Still code only: nothing was re-run at this head (no suite, no game), some new test modes have only been compiled, and it has never run on an AMD GPU under Windows. The description lists exactly what ran and what did not, and has the indicative numbers from development (two steps at 0.42 to 0.63 of the one pass's GPU time on a Ryzen 9800X3D's integrated GPU, 0.56 to 0.79 on an RTX 4070 Ti).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.