perf(vk): big ASTC textures become BC3 in one pass, and the two-pass path and its switches go #2473

Open
TrashPanda wants to merge 6 commits from TrashPanda/Longshot:feat/astc-bc-one-pass into main
Contributor

Known regression on AMD integrated graphics (Windows), measured by Jer9: on a Radeon 860M the conversion spans take 1.5 to
2.9 times main's GPU time, the worst frame of two of three loads is about 50% longer, and the 1% low while streaming in the
Market is 21% lower. The cheaper encode builds (BC3_LSQ_PASSES, BC3_BOX) recover only 11-18% of it. On an RTX 3090
(HumanBean) it is level or slightly faster; on a Steam Deck LCD (klikso, together with #2330) fps and long frames are level
and slow uploads fall 87%. Numbers under Measurements. The author's own PC has not run it in the game.

For that regression, commits 5-6 add a lighter two-step route behind RX_VK_ASTC_BC_SPLIT (0, the default: the one pass
everywhere; 1: two steps; 2: two steps with a cheaper encode half) and a game-free benchmark to compare the routes on any
GPU.
It has not run in the game or on an AMD GPU under Windows; whether it fixes the 860M is for a tester to measure
(commands under Still to test).

This is the first part (M1) of the handed-over plan "Textures without hitches"; its later milestones (the format chooser,
ahead conversion by default, groups from the game, the per-platform defaults) follow.

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 a
second time with ASTC_TO_BC3; the RGBA8 route's build is unchanged word for word) and encodes the tile's 4x4 blocks straight
into 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 AMD
resize, Eden's bc_encoder.comp and 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 (the ASTC_TO_BC3 lines and the converter's main),
gpu/vk/astc_convert.h (the tiles), gpu/vk/host_shaders/bc3_encode.glsl, then upload_astc_gpu, bc3_regions, bc3_copy
and texture_copy_into_bc in gpu/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, and
that again with BC3_LSQ_PASSES=0, BC3_BOX=0), with their lavapipe fixture; (6) RX_VK_ASTC_BC_SPLIT uses them inside the
existing 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 --bench times the routes.

Added switch: RX_VK_ASTC_BC_SPLIT (0 by default on every PC; for measuring on integrated GPUs; its default per GPU class
is 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 new
encoder), 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_BC and RX_VK_UNEVEN_RGBA8 (with RX_VK_UNEVEN_BC=0 a 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:

  • HumanBean, Linux, RTX 3090 (NVIDIA driver): house, Kokiri Forest, Hyrule Field, 30 s each, main and this PR: exit 0, no
    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.
  • Jer9, Windows 11, Radeon 860M (Adrenalin 26.10.1), llvm-mingw clang 23.1.5: longshot_vk.dll builds with no warning; 47
    runs over three saves with exit 0, no device loss, no upload failed; no black edges or seams on the terrain's small levels
    with the per-layer copies (#2006/#2107/#2228); test_astc_decoder_gpu.py --device Radeon passes on the hardware (9,388
    vector decodes exact, 62,244 of 62,244 image-encoder blocks equal to the converter, all 56 PSNR floors).
    test_astc_upload_gpu.py started on the Radeon and stopped at its self-test (no synchronization validation layer there).
  • klikso, Steam Deck LCD (RADV, Mesa 26.2.0-devel), this PR together with #2330: 6 scenes x 3 rounds, converted and drew
    correctly, no upload failure, crash or device loss.

Tested by the author at 102e1cab4, rebased on main be663a08a (one conflict, both sides appending rows to switches.def):
test_astc_upload_chunking.py and test_astc_upload_gpu.py --device llvmpipe with 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.py runs 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 real upload_astc_gpu, texture_copy_into_bc, bc_ready, the batch, full_barrier
    and the recording's upload command buffer, cut out of vk_texture.cpp and run on a Vulkan device with synchronization
    validation (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.
  • The checks that read the changed functions, one at a time: all pass. vk_texture.cpp, vk_xfer.cpp, vk_main.cpp compiled
    alone with the game build's flags.
  • The full suite at 102e1cab4 against main be663a08a: 842 checks, no check failing only here (56 game-side checks fail the same
    on both sides on this PC, 13 skipped on both).
  • Commits 5-6 (the two-step route), run during their development on lavapipe with g++, before testing on this PC was
    stopped: test_astc_decoder_gpu.py (492 levels through the two steps: texels the exact decode, BC3 byte-equal to the
    converter's, nothing written outside the buffers, the cheaper encode half within the floors); test_astc_upload_gpu.py on
    all 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 --check matches; the RGBA8 decoder's, the converter's
    and the image encoder's SPIR-V are unchanged.
  • Compiled only, never run: test_astc_upload_chunking.py's three new two-step modes, test_device_policy.py's new
    cases, 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.
  • Not run by the author: the game (another session holds this PC's GPU).

Still to test:

  • Windows, a Radeon integrated GPU (the 860M above): 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 the
    game unset against RX_VK_ASTC_BC_SPLIT=1 and =2 with RX_VK_PASS_TIMING=1, expecting the terrain array upload and
    worst frames back at or under main's (by hand)
  • Linux: the full suite, 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)
  • The game's textures: BC3 quality of RX_VK_ASTC_BC_SPLIT=2 against 1, before 2 is offered as anything but a measurement
    (by hand)
  • Windows, llvm-mingw clang 23: the two upload tests again at 102e1cab4, expecting PASS (fixed here, checked only with clang
    21 and g++ 15) (by hand)
  • Any hardware GPU with the synchronization validation layer: test_astc_upload_gpu.py, expecting every PASS line (by hand)
  • Intel Arc, and a Steam Deck with this PR alone (klikso's numbers are with #2330): textures right, no failed uploads, the
    worst frames of a load against main (by hand)
  • Linux, any GPU, the game: RX_VK_TEXDECODE_CHECK=3 read-back, expecting every texel equal to texdecode (by hand)
  • A human review of settings-graphics.png's sources (scripts/check_guide_screenshots.py --review-sources flags
    gpu/vk/device_policy.h and gpu/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.

Before: main @ 8aa5ab87 (RTX 3090 rows: 6123c76a) After: this PR @ c8294011b
RTX 3090, house, fps (2 runs a side, HumanBean) 120.8 / 116.2 124.6 / 122.9
RTX 3090, house, 1% low 79.9 / 72.1 fps 90.7 / 86.3 fps
RTX 3090, frame uploading the two terrain arrays (one sample) 146 ms 165 ms
Radeon 860M, worst frame, kokiri-start (median of 3, Jer9) 660.7 ms 1,002.1 ms
Radeon 860M, worst frame, castle-gate 815.1 ms 828.5 ms
Radeon 860M, worst frame, market-entrance 1,053.2 ms 1,578.4 ms
Radeon 860M, terrain array slow upload, kokiri-start 214.4 ms 472.0 ms
Radeon 860M, slow-upload lines, market-entrance 8 40
Radeon 860M, 1% low, streaming walk in the Market 19.68 fps 15.57 fps
Radeon 860M, GPU time of the conversion spans 1.5 to 2.9 times main's
Radeon 860M, title-screen VRAM 488 MB 448 MB
Steam Deck LCD with #2330, fps, mean of 6 scenes (klikso) 40.0 39.7
Steam Deck LCD with #2330, p99 frame 55.1 ms 57.6 ms
Steam Deck LCD with #2330, slow-upload lines a run 29.9 3.9

Jer9's sweep of the encode builds: even BC3_LSQ_PASSES=0, BC3_BOX=0 trims only 11-18% and leaves the 860M 1.7 to 2.2 times
slower 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 the
one pass's):

Raphael iGPU (RADV), 1 Raphael, 2 RTX 4070 Ti, 1
1365 x 1365 x 16 0.42-0.63 (255-293 ms to 124-170 ms) 0.34-0.53 0.56-0.63
2048 x 2048 0.42-0.61 0.35-0.52 0.57-0.66
1024 x 1024 0.39-0.63 0.32-0.49 0.70-0.79
512 x 512 0.43-0.62 0.35-0.52 0.84-1.07

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

  • AMD integrated graphics on Windows get slower (top of this description, Measurements). Not fixed here. The ways out
    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.
  • Two things in this code worth a reviewer's eye: a BC3 run's size (kBc3OutBlocks / level_blocks) is safe only because
    textures 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.
  • A converter or wiring bug would show wrong colours or garbled blocks in every BC3-kept texture on GPUs without ASTC; the
    ways back for a tester: the menu's ASTC as RGBA8 (Developer section) or RX_VK_ASTC_RGBA8=1 keeps every ASTC texture RGBA8
    through the unchanged decoder (more video memory); RX_VK_ASTC_CPU=1 decodes on the CPU. A converter pipeline a driver
    refuses is logged and does the same by itself. The old path is removed, so a revert is the way back for everyone.
  • Copies into BC3 levels not a multiple of 4 on AMD's Windows driver keep their per-layer regions (#2228), now one call a batch.
  • Shared memory: the converter declares 10,560 or 14,400 bytes a workgroup against the decoder's 4,160 (fewer resident
    workgroups where that limits), under the 16,384 every Vulkan device gives.
  • Image quality: BC3 blocks change (better on average; 0.5% of blocks over 1 dB worse than the old encoder's, more in seven small
    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.
  • After updating: nothing in saves, longshot_options.ini or the caches; the new pipelines are made once into the pipeline cache
    before the game; a run that sets a removed switch is told what it gets. VRAM: 4-40 MB less.

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit. (rebased on be663a08a)
  • Tested on my own PC, in the game for a change the game runs, as Testing says. (not on my own PC: in the game by HumanBean, Jer9 and klikso on theirs)
  • mise run test passes (any failure that also fails on main is named). (not re-run at f1187f556; tests/run_all.py at 102e1cab4 against main be663a08a on 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.py to test_wide_ui.py, which looks like this PC's setup since #2411; 13 skipped on both)
  • Measured against main, or Measurements says why there is nothing to measure. (by the three reviewers; it shows a regression on AMD integrated graphics)
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A switch added or changed: it ships at the default the measurements chose, with its row in gpu/vk/switches.def. (six GONE rows; two rows reworded; RX_VK_ASTC_BC_SPLIT added, 0 until measured on integrated GPUs)
  • A check under 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)
  • The SPIR-V headers regenerated (a shader changed). (scripts/shaders.py host, glslang 16.6.0; --check matches)
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. (Linux by the author; Windows llvm-mingw by Jer9, no warning)
  • Screenshots of the same spot on main and here, for a change that shows on screen. (none attached; HumanBean and Jer9 compared screenshots with main and found the textures matching)
  • Docs updated. (the switches reference, the profiling row, the AMD workaround's wording)
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.

🤖 Generated with Claude Code

> **Known regression on AMD integrated graphics (Windows), measured by Jer9:** on a Radeon 860M the conversion spans take 1.5 to > 2.9 times main's GPU time, the worst frame of two of three loads is about 50% longer, and the 1% low while streaming in the > Market is 21% lower. The cheaper encode builds (`BC3_LSQ_PASSES`, `BC3_BOX`) recover only 11-18% of it. On an RTX 3090 > (HumanBean) it is level or slightly faster; on a Steam Deck LCD (klikso, together with #2330) fps and long frames are level > and slow uploads fall 87%. Numbers under Measurements. The author's own PC has not run it in the game. > > **For that regression, commits 5-6 add a lighter two-step route behind `RX_VK_ASTC_BC_SPLIT` (0, the default: the one pass > everywhere; 1: two steps; 2: two steps with a cheaper encode half) and a game-free benchmark to compare the routes on any > GPU.** It has not run in the game or on an AMD GPU under Windows; whether it fixes the 860M is for a tester to measure > (commands under Still to test). > > This is the first part (M1) of the handed-over plan "Textures without hitches"; its later milestones (the format chooser, > ahead conversion by default, groups from the game, the per-platform defaults) follow. ## 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 a second time with `ASTC_TO_BC3`; the RGBA8 route's build is unchanged word for word) and encodes the tile's 4x4 blocks straight into 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 AMD resize, Eden's `bc_encoder.comp` and 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` (the `ASTC_TO_BC3` lines and the converter's `main`), `gpu/vk/astc_convert.h` (the tiles), `gpu/vk/host_shaders/bc3_encode.glsl`, then `upload_astc_gpu`, `bc3_regions`, `bc3_copy` and `texture_copy_into_bc` in `gpu/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, and that again with `BC3_LSQ_PASSES=0, BC3_BOX=0`), with their lavapipe fixture; (6) `RX_VK_ASTC_BC_SPLIT` uses them inside the existing 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 --bench` times the routes. Added switch: `RX_VK_ASTC_BC_SPLIT` (0 by default on every PC; for measuring on integrated GPUs; its default per GPU class is 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 new encoder), `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_BC` and `RX_VK_UNEVEN_RGBA8` (with `RX_VK_UNEVEN_BC=0` a 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: - HumanBean, Linux, RTX 3090 (NVIDIA driver): house, Kokiri Forest, Hyrule Field, 30 s each, main and this PR: exit 0, no `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. - Jer9, Windows 11, Radeon 860M (Adrenalin 26.10.1), llvm-mingw clang 23.1.5: `longshot_vk.dll` builds with no warning; 47 runs over three saves with exit 0, no device loss, no `upload failed`; no black edges or seams on the terrain's small levels with the per-layer copies (#2006/#2107/#2228); `test_astc_decoder_gpu.py --device Radeon` passes on the hardware (9,388 vector decodes exact, 62,244 of 62,244 image-encoder blocks equal to the converter, all 56 PSNR floors). `test_astc_upload_gpu.py` started on the Radeon and stopped at its self-test (no synchronization validation layer there). - klikso, Steam Deck LCD (RADV, Mesa 26.2.0-devel), this PR together with #2330: 6 scenes x 3 rounds, converted and drew correctly, no upload failure, crash or device loss. **Tested by the author** at 102e1cab4, rebased on main be663a08a (one conflict, both sides appending rows to `switches.def`): `test_astc_upload_chunking.py` and `test_astc_upload_gpu.py --device llvmpipe` with 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.py` runs 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 real `upload_astc_gpu`, `texture_copy_into_bc`, `bc_ready`, the batch, `full_barrier` and the recording's upload command buffer, cut out of `vk_texture.cpp` and run on a Vulkan device with synchronization validation (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`. - The checks that read the changed functions, one at a time: all pass. `vk_texture.cpp`, `vk_xfer.cpp`, `vk_main.cpp` compiled alone with the game build's flags. - The full suite at 102e1cab4 against main be663a08a: 842 checks, no check failing only here (56 game-side checks fail the same on both sides on this PC, 13 skipped on both). - Commits 5-6 (the two-step route), run during their development on lavapipe with g++, before testing on this PC was stopped: `test_astc_decoder_gpu.py` (492 levels through the two steps: texels the exact decode, BC3 byte-equal to the converter's, nothing written outside the buffers, the cheaper encode half within the floors); `test_astc_upload_gpu.py` on all 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 --check` matches; the RGBA8 decoder's, the converter's and the image encoder's SPIR-V are unchanged. - **Compiled only, never run:** `test_astc_upload_chunking.py`'s three new two-step modes, `test_device_policy.py`'s new cases, 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. - Not run by the author: the game (another session holds this PC's GPU). **Still to test:** - Windows, a Radeon integrated GPU (the 860M above): `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 the game unset against `RX_VK_ASTC_BC_SPLIT=1` and `=2` with `RX_VK_PASS_TIMING=1`, expecting the terrain array upload and worst frames back at or under main's (by hand) - Linux: the full suite, `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) - The game's textures: BC3 quality of `RX_VK_ASTC_BC_SPLIT=2` against 1, before 2 is offered as anything but a measurement (by hand) - Windows, llvm-mingw clang 23: the two upload tests again at 102e1cab4, expecting PASS (fixed here, checked only with clang 21 and g++ 15) (by hand) - Any hardware GPU with the synchronization validation layer: `test_astc_upload_gpu.py`, expecting every PASS line (by hand) - Intel Arc, and a Steam Deck with this PR alone (klikso's numbers are with #2330): textures right, no failed uploads, the worst frames of a load against main (by hand) - Linux, any GPU, the game: `RX_VK_TEXDECODE_CHECK=3` read-back, expecting every texel equal to texdecode (by hand) - A human review of `settings-graphics.png`'s sources (`scripts/check_guide_screenshots.py --review-sources` flags `gpu/vk/device_policy.h` and `gpu/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. | | Before: main @ 8aa5ab87 (RTX 3090 rows: 6123c76a) | After: this PR @ c8294011b | |---|---|---| | RTX 3090, house, fps (2 runs a side, HumanBean) | 120.8 / 116.2 | 124.6 / 122.9 | | RTX 3090, house, 1% low | 79.9 / 72.1 fps | 90.7 / 86.3 fps | | RTX 3090, frame uploading the two terrain arrays (one sample) | 146 ms | 165 ms | | Radeon 860M, worst frame, `kokiri-start` (median of 3, Jer9) | 660.7 ms | 1,002.1 ms | | Radeon 860M, worst frame, `castle-gate` | 815.1 ms | 828.5 ms | | Radeon 860M, worst frame, `market-entrance` | 1,053.2 ms | 1,578.4 ms | | Radeon 860M, terrain array slow upload, `kokiri-start` | 214.4 ms | 472.0 ms | | Radeon 860M, slow-upload lines, `market-entrance` | 8 | 40 | | Radeon 860M, 1% low, streaming walk in the Market | 19.68 fps | 15.57 fps | | Radeon 860M, GPU time of the conversion spans | | 1.5 to 2.9 times main's | | Radeon 860M, title-screen VRAM | 488 MB | 448 MB | | Steam Deck LCD with #2330, fps, mean of 6 scenes (klikso) | 40.0 | 39.7 | | Steam Deck LCD with #2330, p99 frame | 55.1 ms | 57.6 ms | | Steam Deck LCD with #2330, slow-upload lines a run | 29.9 | 3.9 | Jer9's sweep of the encode builds: even `BC3_LSQ_PASSES=0, BC3_BOX=0` trims only 11-18% and leaves the 860M 1.7 to 2.2 times slower 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 the one pass's): | | Raphael iGPU (RADV), 1 | Raphael, 2 | RTX 4070 Ti, 1 | |---|---|---|---| | 1365 x 1365 x 16 | 0.42-0.63 (255-293 ms to 124-170 ms) | 0.34-0.53 | 0.56-0.63 | | 2048 x 2048 | 0.42-0.61 | 0.35-0.52 | 0.57-0.66 | | 1024 x 1024 | 0.39-0.63 | 0.32-0.49 | 0.70-0.79 | | 512 x 512 | 0.43-0.62 | 0.35-0.52 | 0.84-1.07 | 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 - **AMD integrated graphics on Windows get slower** (top of this description, Measurements). Not fixed here. The ways out 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. - Two things in this code worth a reviewer's eye: a BC3 run's size (`kBc3OutBlocks / level_blocks`) is safe only because textures 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. - A converter or wiring bug would show wrong colours or garbled blocks in every BC3-kept texture on GPUs without ASTC; the ways back for a tester: the menu's ASTC as RGBA8 (Developer section) or `RX_VK_ASTC_RGBA8=1` keeps every ASTC texture RGBA8 through the unchanged decoder (more video memory); `RX_VK_ASTC_CPU=1` decodes on the CPU. A converter pipeline a driver refuses is logged and does the same by itself. The old path is removed, so a revert is the way back for everyone. - Copies into BC3 levels not a multiple of 4 on AMD's Windows driver keep their per-layer regions (#2228), now one call a batch. - Shared memory: the converter declares 10,560 or 14,400 bytes a workgroup against the decoder's 4,160 (fewer resident workgroups where that limits), under the 16,384 every Vulkan device gives. - Image quality: BC3 blocks change (better on average; 0.5% of blocks over 1 dB worse than the old encoder's, more in seven small 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. - After updating: nothing in saves, `longshot_options.ini` or the caches; the new pipelines are made once into the pipeline cache before the game; a run that sets a removed switch is told what it gets. VRAM: 4-40 MB less. ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. (rebased on be663a08a) - [ ] Tested on my own PC, in the game for a change the game runs, as Testing says. (not on my own PC: in the game by HumanBean, Jer9 and klikso on theirs) - [x] `mise run test` passes (any failure that also fails on `main` is named). (not re-run at f1187f556; `tests/run_all.py` at 102e1cab4 against main be663a08a on 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.py` to `test_wide_ui.py`, which looks like this PC's setup since #2411; 13 skipped on both) - [x] Measured against `main`, or Measurements says why there is nothing to measure. (by the three reviewers; it shows a regression on AMD integrated graphics) - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] A switch added or changed: it ships at the default the measurements chose, with its row in `gpu/vk/switches.def`. (six GONE rows; two rows reworded; `RX_VK_ASTC_BC_SPLIT` added, 0 until measured on integrated GPUs) - [x] A check under `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) - [x] The SPIR-V headers regenerated (a shader changed). (`scripts/shaders.py host`, glslang 16.6.0; `--check` matches) - [x] Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. (Linux by the author; Windows llvm-mingw by Jer9, no warning) - [ ] Screenshots of the same spot on `main` and here, for a change that shows on screen. (none attached; HumanBean and Jer9 compared screenshots with main and found the textures matching) - [x] Docs updated. (the switches reference, the profiling row, the AMD workaround's wording) - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
astc_decoder.comp built with ASTC_TO_BC3 is a one-pass converter: a 64-lane workgroup
decodes a tile of ASTC blocks (a whole number of 4x4 BC blocks both ways; the table
in gpu/vk/astc_convert.h) into shared memory with the same DecompressBlock, then
encodes the tile's BC blocks into a buffer, with no RGBA8 image and no barrier between
the halves but the workgroup's own. The decoder's build is unchanged word for word
(scripts/shaders.py host --check). The encode half (host_shaders/bc3_encode.glsl) is
Longshot's own BC3 encoder from the texture-shader work, every step kept; on lavapipe
its blocks equal that standalone encoder's byte for byte. bc3_encoder.comp runs the same
encode half on an RGBA8 image region (for copies into BC3 textures). Nothing in the
renderer uses them yet.

scripts/shaders.py host gains HOST_VARIANTS (a shader built again with defines).

tests/astc_decoder_gpu.cpp runs both on the same levels as the decoder (not a fork of
its data): the converter's tile against texdecode with no tolerance (9,388 vector
decodes, 114 whole and hand-built levels, 374 tile-edge levels in every footprint and
size, both tile classes), its BC3 byte-equal to the same encode half fed texdecode's
decode, within stated PSNR floors per footprint (vectors, gradients, flats, edges),
and the image encoder. Its "validation: enabled" line, which run_vulkan_fixtures.py took
for a validation error (the fixture failed there on main), is now "Khronos validation
layer: enabled".

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The BC3 route now runs the one-pass converter (astc_decoder.comp built with ASTC_TO_BC3) in
upload_astc_gpu: each run of layers of a level is one dispatch writing its BC3 blocks into a 16 MB
output buffer (bc3_out, made once, VRAM or system memory), and a texture's levels and layers go into
one batch, copied into the image between two full barriers (bc3_regions keeps the explicit block
pitch and AMD's per-layer regions, bc3_copy the barriers). The batch closes before a chunk flush and
when bc3_out would overflow; a failed upload with blocks not yet copied leaves a barrier
(Bc3FailureBarrier). texture_copy_into_bc encodes the decoded source in place through its UINT
storage view with bc3_encoder.comp (the same encode half) instead of copying it into the scratch.
bc_ready makes the converter's two pipelines (tile classes) and the image encoder's through
texture_compute_pipeline, with the same decline conditions; a refused pipeline leaves every ASTC
texture RGBA8 through the plain decoder, as a refused encoder did. create() makes BC3 only (no BC7),
and with RX_VK_UNEVEN_BC=0 a texture that would need resizing stays RGBA8 (the resize needed the
scratch). The RGBA8 route is unchanged. The two-pass functions stay compiled, unused, until the
next commit removes them with their switches.

tests/test_astc_upload_gpu.py is a new lavapipe fixture that cuts the real upload_astc_gpu,
texture_copy_into_bc, astc_ready, bc_ready, the batch, full_barrier, the recording's upload command
buffer, the views and level_geo out of vk_texture.cpp and runs them on a Vulkan device with
validation and synchronization validation (its shader-access tracking on; a self-test proves it
reports a missing barrier after a dispatch): seven textures across chunk flushes and a full output
buffer, every level read back (BC3 byte-equal to the converter alone, RGBA8 equal to texdecode), a
copy into BC3, per-layer regions, repacked levels, a failed upload. test_astc_upload_chunking.py's
spy harness is rewritten for the batch (a terrain array: 24 dispatches and 16 copies where the two
passes made 1,980 dispatches; no submission ends with blocks not yet copied; the failure barrier).
The checks that read the changed lines follow them; the scratch checks keep only the scratch's own
making until it goes.

Not run in the game or on a hardware GPU.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
refactor(vk): the two-pass ASTC to BC path, its encoders and its switches go
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
Website / Website builds (pull_request_target) Has been skipped
Website / Website preview, build (pull_request_target) Has been skipped
Website / Website preview, upload (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Failing after 14s
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
Website / Website on Cloudflare (pull_request) Has been cancelled
Website / Website builds (pull_request) Has been cancelled
Website / Website preview, build (pull_request) Has been cancelled
Website / Website preview, upload (pull_request) Has been cancelled
c8294011b3
What the one-pass converter left unused goes: the RGBA8 scratch images (the 2048 x 2048 one, the
small one, the AMD resize's second one) and their views, the old output buffer, the level groups,
bc_encode_into and bc_encode_resized, bc_scratch_make/layout/idle, Eden's bc_encoder.comp and the
BC7 encoder with their headers, Texture::bc_resized (and astc_reuse's Shape field),
DevicePolicy::bc_small_runs, and vk_xfer.cpp's resized-source branch. Six switches become GONE rows
(RX_VK_ASTC_BC7, RX_VK_BC_IDLE_S, RX_VK_BC_LAYERS, RX_VK_BC_LEVELS, RX_VK_BC_POOL,
RX_VK_BC_SMALL_LAYERS): none had a menu row or an options-file key. RX_VK_UNEVEN_BC and
RX_VK_UNEVEN_RGBA8 stay with their meaning without the resize; RX_VK_BC_COPY_PER_LAYER, RX_VK_ASTC_RGBA8
(the menu's ASTC as RGBA8, the way back for a tester), RX_VK_ASTC_CPU and RX_VK_ASTC_CHUNK_MPX stay.

The scratch's checks go with it (test_bc_scratch_layers.py, bc_scratch_batches_test.cpp,
test_bc_small_scratch.py); their promises for the runs moved to test_astc_upload_chunking.py and
test_astc_upload_gpu.py in the previous commit. test_device_policy.py loses the field,
test_mem_trim.py checks the output buffer is taken for made only once made, test_astc_reuse the
Shape without the resize. Docs: the switches reference, the profiling row, the AMD workaround's
wording.

Open: scripts/check_guide_screenshots.py --review-sources flags settings-graphics.png because
gpu/vk/device_policy.h and gpu/vk/vk_texture.h changed (a field removed from each, no menu row):
a human review records it; the hashes are not updated here.

Not run in the game or on a hardware GPU.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
HumanBean left a comment

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's ASTC_TO_BC3 half, bc3_encode.glsl, bc3_encoder.comp, astc_convert.h, upload_astc_gpu, bc3_regions, bc3_copy, texture_copy_into_bc, the bc_candidate and 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

  • Tiling: every row of tile_of is 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_y clip the decode so no texel is stored outside the level (so TileStore never aliases), and the encode's last_x/last_y repeat only texels the level has. Output index (layer * rows + by) * columns + bx matches the copy regions' bufferRowLength and bufferImageHeight. No lane returns before barrier().
  • Encoder: alpha index packing across the 32-bit word, the six-value mode (indices, 0 and 255 slots), the colour index permutation ({0,2,3,1}), the endpoint swap with idx ^= 0x55555555, and the least-squares normal equations all check out by hand.
  • Synchronization: the batch is full_barrier, copy, full_barrier; a chunk flush copies the batch first, then flushes, then re-barriers the re-begun command buffer; the overflow test batch_at + level_blocks * n > kBc3OutBlocks can never be hit by a single run (bc_run is bounded by it, and the biggest level is 262,144 of the 1,048,576 blocks); the destructor barrier covers a failure after dispatches. n is bounded by maxComputeWorkGroupCount[2] and the storage range as before. texture_copy_into_bc barriers each run.
  • AMD per-layer regions are kept (bc3_regions), also for the copy-into path. The removed AMD resize leaves the default as it was: RX_VK_UNEVEN_BC was off by default, so the default path never used it; behind the =0 opt-in a texture needing a resize now stays RGBA8.
  • Switch removals: six GONE rows with a reason each; no leftover reader of any of them in the tree (only frozen guide source-review pages mention bc_small_runs). Nothing is added. RX_VK_ASTC_RGBA8 stays the way back.

What blocks the merge (the PR says so itself)

  • Integrated GPUs: astc_bc_policy::all keeps 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 is RX_VK_ASTC_RGBA8=1, which costs 4 times the memory, on GPUs whose memory is shared with the game. BC3_LSQ_PASSES and BC3_BOX are 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.
  • The Measurements table is empty and the Testing lists are all still "by hand". Per the standards a perf PR with no numbers is Unproven.

Smaller

  • Code comments cite "invariant 3, 4, 8, 11, 12, 17, 18, 19" and a 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 under docs/dev/reference/ (or the architecture page) and link them, or say the rule in the comment.
  • The fixture's mode 1 and 2 are compiled into the shipping converter (a branch per workgroup and a loop nobody takes). A second HOST_VARIANTS entry for the fixture would keep the shipped SPIR-V to the one route.
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`'s `ASTC_TO_BC3` half, `bc3_encode.glsl`, `bc3_encoder.comp`, `astc_convert.h`, `upload_astc_gpu`, `bc3_regions`, `bc3_copy`, `texture_copy_into_bc`, the `bc_candidate` and 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** - Tiling: every row of `tile_of` is whole 4x4 BC blocks, within the shared-memory cap (14,400 B of 16,384), `static_assert`ed against the rule. Edge handling is right: `max_x/max_y` clip the decode so no texel is stored outside the level (so `TileStore` never aliases), and the encode's `last_x/last_y` repeat only texels the level has. Output index `(layer * rows + by) * columns + bx` matches the copy regions' `bufferRowLength` and `bufferImageHeight`. No lane returns before `barrier()`. - Encoder: alpha index packing across the 32-bit word, the six-value mode (indices, 0 and 255 slots), the colour index permutation (`{0,2,3,1}`), the endpoint swap with `idx ^= 0x55555555`, and the least-squares normal equations all check out by hand. - Synchronization: the batch is `full_barrier`, copy, `full_barrier`; a chunk flush copies the batch first, then flushes, then re-barriers the re-begun command buffer; the overflow test `batch_at + level_blocks * n > kBc3OutBlocks` can never be hit by a single run (`bc_run` is bounded by it, and the biggest level is 262,144 of the 1,048,576 blocks); the destructor barrier covers a failure after dispatches. `n` is bounded by `maxComputeWorkGroupCount[2]` and the storage range as before. `texture_copy_into_bc` barriers each run. - AMD per-layer regions are kept (`bc3_regions`), also for the copy-into path. The removed AMD resize leaves the default as it was: `RX_VK_UNEVEN_BC` was off by default, so the default path never used it; behind the `=0` opt-in a texture needing a resize now stays RGBA8. - Switch removals: six `GONE` rows with a reason each; no leftover reader of any of them in the tree (only frozen guide source-review pages mention `bc_small_runs`). Nothing is added. `RX_VK_ASTC_RGBA8` stays the way back. **What blocks the merge (the PR says so itself)** - Integrated GPUs: `astc_bc_policy::all` keeps 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 is `RX_VK_ASTC_RGBA8=1`, which costs 4 times the memory, on GPUs whose memory is shared with the game. `BC3_LSQ_PASSES` and `BC3_BOX` are 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. - The Measurements table is empty and the Testing lists are all still "by hand". Per the standards a perf PR with no numbers is Unproven. **Smaller** - Code comments cite "invariant 3, 4, 8, 11, 12, 17, 18, 19" and a `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 under `docs/dev/reference/` (or the architecture page) and link them, or say the rule in the comment. - The fixture's `mode` 1 and 2 are compiled into the shipping converter (a branch per workgroup and a loop nobody takes). A second `HOST_VARIANTS` entry 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) {
Owner

mode == 2u here and mode == 1u at line 1323 are the fixture's, but they are in the shipped converter: a loop and a branch no game run takes, and mode read in the hot encode loop. A third HOST_VARIANTS entry (-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.

`mode == 2u` here and `mode == 1u` at line 1323 are the fixture's, but they are in the shipped converter: a loop and a branch no game run takes, and `mode` read in the hot encode loop. A third `HOST_VARIANTS` entry (`-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_PASSES
Owner

These 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 int for 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.

These 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 int` for 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 the
Owner

This points at longshot-one-pass-design.md as '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 into docs/dev/reference/ (the architecture page's texture section, with a // doc: anchor on upload_astc_gpu if you like) and link it here, or write the rule in each comment.

This points at `longshot-one-pass-design.md` as '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 into `docs/dev/reference/` (the architecture page's texture section, with a `// doc:` anchor on `upload_astc_gpu` if you like) and link it here, or write the rule in each comment.
Owner

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-start save in Link's house, then teleports to Kokiri Forest and Hyrule Field, 30 s at each stop.

  • Both runs exited with code 0. There was no 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.
  • In the screenshots of the three stops, the textures match main's: no garbled blocks, wrong colours or black edges, and the terrain's 1365×1365×90 arrays look right. The only differences are Navi, Link's idle pose and exposure.

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.

main (A1 / A2) PR (B1 / B2)
House, fps 120.8 / 116.2 124.6 / 122.9
House, p99 frame 12.5 / 13.9 ms 11.0 / 11.6 ms
House, 1 % low 79.9 / 72.1 fps 90.7 / 86.3 fps
House, frames ≥ 50 ms 0 / 2 0 / 3
Hyrule Field, fps 122.6* / 120.1 127.1 / 121.5
Field, p99 frame 13.5* / 14.7 ms 11.1 / 12.6 ms
Field, 1 % low 74.2* / 67.9 fps 90.4 / 79.7 fps
Field, frames ≥ 50 ms 3* / 5 1 / 1

* 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: 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-start` save in Link's house, then teleports to Kokiri Forest and Hyrule Field, 30 s at each stop. - Both runs exited with code 0. There was no `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. - In the screenshots of the three stops, the textures match main's: no garbled blocks, wrong colours or black edges, and the terrain's 1365×1365×90 arrays look right. The only differences are Navi, Link's idle pose and exposure. ### 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. | | main (A1 / A2) | PR (B1 / B2) | |---|---|---| | House, fps | 120.8 / 116.2 | 124.6 / 122.9 | | House, p99 frame | 12.5 / 13.9 ms | 11.0 / 11.6 ms | | House, 1 % low | 79.9 / 72.1 fps | 90.7 / 86.3 fps | | House, frames ≥ 50 ms | 0 / 2 | 0 / 3 | | Hyrule Field, fps | 122.6\* / 120.1 | 127.1 / 121.5 | | Field, p99 frame | 13.5\* / 14.7 ms | 11.1 / 12.6 ms | | Field, 1 % low | 74.2\* / 67.9 fps | 90.4 / 79.7 fps | | Field, frames ≥ 50 ms | 3\* / 5 | 1 / 1 | \* 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.
HumanBean added this to the WIP project 2026-11-24 22:35:01 +00:00
Contributor

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)

  • Branch tested: #2473 @ c8294011 vs main @ 8aa5ab87 (MKWVK_API_VERSION = 45; zero gpu/ diff between 8aa5ab87 and 9046a8d7; git merge-tree --write-tree 9046a8d7 c8294011 merged cleanly with 0 conflicts).
  • Windows llvm-mingw (clang 23.1.5) standalone longshot_vk.dll build: PASS, 0 warnings/errors (169.7 s, exports checked).
  • Game-free checks (tests/run_all.py --strict, Windows llvm-mingw clang 23.1.5):
    • PASS (6/8): 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.
    • FAIL (2/8 — new -Werror,-Wunused-but-set-global failures on llvm-mingw clang 23.1.5 from 8b90ed75):
      • tests/test_astc_upload_chunking.py: last_astc_blocks_x, last_astc_blocks_y set but unused (passes on main, and passes on #2473 with -Wno-unused-but-set-global).
      • tests/test_astc_upload_gpu.py: epoch, st_astc, st_bytes set but unused in the generated C++ harness.
    • Hardware Radeon 860M Vulkan fixtures:
      • tests/test_astc_decoder_gpu.py --device Radeon --table: PASS (9,388 ASTC vector decodes bit-exact vs astcenc/texdecode across 14 footprints linear+sRGB, 62,244/62,244 image-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.
  • In-game correctness (kokiri-start, castle-gate, market-entrance, 47 total runs across Phases 1–3):
    • Exit code 0, 0 VK_ERROR_DEVICE_LOST, 0 upload failed, confirmed vk: big ASTC textures are kept as BC3, converted on the GPU in one pass with astc_bc_all=1 and bc_copy_per_layer=1.
    • Visuals / #2006/#2107/#2228 mip-tail check: Clean on both castle-gate (1365x1365 x90 terrain arrays) and market-entrance — no black edges, dark mip-tail seams, or grid lines at (2, 1) or (0, 0).

Load Hitch, Upload Spans & VRAM A/B (main vs #2473 default LSQ=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 s post-load settle + short walk/pan, 3 strictly interleaved rounds (main -> PR), medians reported (min–max).

Metric Before (main @ 8aa5ab87) After (#2473 default (2,1)) Delta
Title-screen VRAM (121 identical textures, scratch-drop check) 488 MB 448 MB -40 MB
kokiri-start: Load-start -> in-play (frames.csv at_ns) 15.87 s (15.30–18.15) 15.49 s (13.84–15.94) -0.37 s (flat)
kokiri-start: #130 1365x1365x90 terrain slow 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 + BC GPU 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 slower
castle-gate (Hyrule Field): 1365x1365x90 terrain slow 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 (+9 frames >= 50 ms)
castle-gate: astc decode + BC GPU 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 slower
market-entrance: #130 terrain slow upload 309.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 + BC GPU 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 slower
market-entrance: Total slow upload (>= 16 ms) log lines 8 (8–9) 40 (40–45) 5.0x more spikes
Settled Mean FPS / 1% low (market-entrance, streaming walk): 38.29 / 19.68 fps 37.55 / 15.57 fps -0.74 fps / -20.9% 1% low

(Notes: Settled driver VRAM in-play tracks scene streaming texture count — market-entrance 3,277 MB @ 2,140 tex vs 3,429 MB @ 2,275 tex; castle-gate 2,730 MB @ 1,350 tex vs 2,914 MB @ 1,695 tex; kokiri-start hit streaming-spot variance 1,102–1,175 vs 1,522–1,551 tex — while the identical-121-texture title screen confirms the exact -40 MB RGBA8 scratch savings 488 -> 448 MB. Per-round terrain slow upload ms: kokiri-start main [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-gate main [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-entrance main [152.5, 309.5, 328.3] vs PR [509.3, 669.5, 610.5].)

BC3_LSQ_PASSES × BC3_BOX iGPU Speed-vs-Quality Sweep (castle-gate & market-entrance)

(2 strictly interleaved rounds per preset on castle-gate and market-entrance, plus Radeon 860M hardware PSNR from tests/test_astc_decoder_gpu.py --device Radeon --table across all 14 ASTC footprints.)

Preset (LSQ, BOX) castle-gate terrain upload (max) market-entrance terrain upload market-entrance BC3 span (never / budget) market-entrance worst frame (>= 50 ms) Radeon 860M Fixture PSNR (grad / vec mean dB) & Visuals
main (two-pass Eden bc_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) main baseline
(2, 1) #2473 default 471.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 on castle-gate)

Verdict & Actionable Feedback for #2473

  1. Specialization constants (BC3_LSQ_PASSES, BC3_BOX) alone will NOT recover AMD iGPU speed:
    • Even dropping all the way to (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 860M 1.7–2.2x slower on 1365x1365 x90 terrain uploads (386 / 509 ms vs main's 177 / 294 ms) and 2.3–3.1x slower per astc decode + BC span (11,905 / 1,398 us vs 5,254 / 450 us), turning dozens of 512x512–1024x1024 streaming textures into 17–48 ms slow upload hitches (visible as -20.9% streaming 1% low FPS in Market).
    • That strongly points to fused-shader occupancy / register & LDS pressure on AMD LLPC (10,560–14,400 B LDS vs 4,160 B in decoder, plus per-thread t[16]/a[16] arrays and bc3_solid[256]) as the primary bottleneck on 8 CUs, rather than the LSQ refinement loop alone.
    • Note that (0, 0) still passes all 56 PSNR floors in test_astc_decoder_gpu.py (-0.41 dB gradients, -0.67 dB vectors) and looks visually clean on castle-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.
  2. Windows AMD correctness & llvm-mingw build:
    • longshot_vk.dll builds cleanly on Windows llvm-mingw (clang 23.1.5) with 0 warnings, and bc_copy_per_layer=1 passes in-game with zero DEVICE_LOST and zero #2006/#2107/#2228 black terrain mip seams.
    • Small CI fix needed for Windows llvm-mingw clang 23.1.5: silence/remove the unused-but-set globals (-Werror,-Wunused-but-set-global) in tests/test_astc_upload_chunking.py (last_astc_blocks_x, last_astc_blocks_y) and tests/test_astc_upload_gpu.py (epoch, st_astc, st_bytes).
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) - **Branch tested:** `#2473` @ `c8294011` vs `main` @ `8aa5ab87` (`MKWVK_API_VERSION = 45`; zero `gpu/` diff between `8aa5ab87` and `9046a8d7`; `git merge-tree --write-tree 9046a8d7 c8294011` merged cleanly with 0 conflicts). - **Windows `llvm-mingw` (`clang 23.1.5`) standalone `longshot_vk.dll` build:** **PASS**, 0 warnings/errors (`169.7 s`, exports checked). - **Game-free checks (`tests/run_all.py --strict`, Windows `llvm-mingw` `clang 23.1.5`):** - **PASS (6/8):** `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`. - **FAIL (2/8 — new `-Werror,-Wunused-but-set-global` failures on `llvm-mingw` `clang 23.1.5` from `8b90ed75`):** - `tests/test_astc_upload_chunking.py`: `last_astc_blocks_x`, `last_astc_blocks_y` set but unused (passes on `main`, and passes on `#2473` with `-Wno-unused-but-set-global`). - `tests/test_astc_upload_gpu.py`: `epoch`, `st_astc`, `st_bytes` set but unused in the generated C++ harness. - **Hardware Radeon 860M Vulkan fixtures:** - `tests/test_astc_decoder_gpu.py --device Radeon --table`: **PASS** (`9,388` ASTC vector decodes bit-exact vs `astcenc`/`texdecode` across 14 footprints linear+sRGB, `62,244/62,244` image-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. - **In-game correctness (`kokiri-start`, `castle-gate`, `market-entrance`, 47 total runs across Phases 1–3):** - Exit code `0`, `0` `VK_ERROR_DEVICE_LOST`, `0` `upload failed`, confirmed `vk: big ASTC textures are kept as BC3, converted on the GPU in one pass` with `astc_bc_all=1` and `bc_copy_per_layer=1`. - **Visuals / `#2006`/`#2107`/`#2228` mip-tail check:** Clean on both `castle-gate` (`1365x1365 x90` terrain arrays) and `market-entrance` — no black edges, dark mip-tail seams, or grid lines at `(2, 1)` or `(0, 0)`. ### Load Hitch, Upload Spans & VRAM A/B (`main` vs `#2473` default `LSQ=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 s` post-load settle + short walk/pan, 3 strictly interleaved rounds (`main -> PR`), medians reported (`min–max`). | Metric | Before (`main @ 8aa5ab87`) | After (`#2473` default `(2,1)`) | Delta | |---|---:|---:|---:| | **Title-screen VRAM (`121` identical textures, scratch-drop check)** | `488 MB` | `448 MB` | **`-40 MB`** | | **`kokiri-start`:** Load-start -> in-play (`frames.csv` `at_ns`) | `15.87 s (15.30–18.15)` | `15.49 s (13.84–15.94)` | `-0.37 s` (flat) | | **`kokiri-start`:** `#130` `1365x1365x90` terrain `slow 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 + BC` GPU 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 slower`** | | **`castle-gate` (Hyrule Field):** `1365x1365x90` terrain `slow 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` (`+9` frames `>= 50 ms`) | | **`castle-gate`:** `astc decode + BC` GPU 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 slower`** | | **`market-entrance`:** `#130` terrain `slow upload` | `309.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 + BC` GPU 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 slower`** | | **`market-entrance`:** Total `slow upload` (`>= 16 ms`) log lines | `8 (8–9)` | `40 (40–45)` | **`5.0x more spikes`** | | **Settled Mean FPS / 1% low (`market-entrance`, streaming walk):** | `38.29 / 19.68 fps` | `37.55 / 15.57 fps` | `-0.74 fps` / **`-20.9%` 1% low** | *(Notes: Settled driver VRAM in-play tracks scene streaming texture count — `market-entrance` `3,277 MB` @ `2,140` tex vs `3,429 MB` @ `2,275` tex; `castle-gate` `2,730 MB` @ `1,350` tex vs `2,914 MB` @ `1,695` tex; `kokiri-start` hit streaming-spot variance `1,102–1,175` vs `1,522–1,551` tex — while the identical-121-texture title screen confirms the exact `-40 MB` RGBA8 scratch savings `488 -> 448 MB`. Per-round terrain `slow upload` ms: `kokiri-start` main `[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-gate` main `[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-entrance` main `[152.5, 309.5, 328.3]` vs PR `[509.3, 669.5, 610.5]`.)* ### `BC3_LSQ_PASSES` × `BC3_BOX` iGPU Speed-vs-Quality Sweep (`castle-gate` & `market-entrance`) *(2 strictly interleaved rounds per preset on `castle-gate` and `market-entrance`, plus Radeon 860M hardware PSNR from `tests/test_astc_decoder_gpu.py --device Radeon --table` across all 14 ASTC footprints.)* | Preset (`LSQ, BOX`) | `castle-gate` terrain upload (max) | `market-entrance` terrain upload | `market-entrance` BC3 span (`never` / `budget`) | `market-entrance` worst frame (`>= 50 ms`) | Radeon 860M Fixture PSNR (`grad / vec` mean dB) & Visuals | |---|---:|---:|---:|---:|---| | `main` (two-pass Eden `bc_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`) | `main` baseline | | `(2, 1)` `#2473` default | `471.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 on `castle-gate`) | ### Verdict & Actionable Feedback for `#2473` 1. **Specialization constants (`BC3_LSQ_PASSES`, `BC3_BOX`) alone will NOT recover AMD iGPU speed:** - Even dropping all the way to **`(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 860M **`1.7–2.2x` slower on `1365x1365 x90` terrain uploads** (`386 / 509 ms` vs `main`'s `177 / 294 ms`) and **`2.3–3.1x` slower per `astc decode + BC` span** (`11,905 / 1,398 us` vs `5,254 / 450 us`), turning dozens of `512x512`–`1024x1024` streaming textures into `17–48 ms` `slow upload` hitches (visible as `-20.9%` streaming 1% low FPS in Market). - That strongly points to **fused-shader occupancy / register & LDS pressure on AMD LLPC** (`10,560–14,400 B` LDS vs `4,160 B` in decoder, plus per-thread `t[16]`/`a[16]` arrays and `bc3_solid[256]`) as the primary bottleneck on 8 CUs, rather than the LSQ refinement loop alone. - Note that `(0, 0)` still passes all 56 PSNR floors in `test_astc_decoder_gpu.py` (`-0.41 dB` gradients, `-0.67 dB` vectors) and looks visually clean on `castle-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. 2. **Windows AMD correctness & `llvm-mingw` build:** - `longshot_vk.dll` builds cleanly on Windows `llvm-mingw` (`clang 23.1.5`) with 0 warnings, and `bc_copy_per_layer=1` passes in-game with zero `DEVICE_LOST` and zero `#2006`/`#2107`/`#2228` black terrain mip seams. - **Small CI fix needed for Windows `llvm-mingw` `clang 23.1.5`:** silence/remove the unused-but-set globals (`-Werror,-Wunused-but-set-global`) in `tests/test_astc_upload_chunking.py` (`last_astc_blocks_x`, `last_astc_blocks_y`) and `tests/test_astc_upload_gpu.py` (`epoch`, `st_astc`, `st_bytes`).
First-time contributor

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 says small_vram_textures=1 astc_bc_all=1, so every big ASTC texture goes to BC3.

Builds:

  • A = main @ 8aa5ab87 + local feature ports + #2439 + #2436 + #2308/#2235.
  • B = A + #2330 + #2473. The only conflict was in 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.

Scene A: fps / p99 / slow uploads B: fps / p99 / slow uploads
Hyrule Field, turning 42.6 / 46 / 23.7 43.2 / 42 / 4.7
Kakariko, turning 40.7 / 47 / 25.3 41.0 / 45 / 3.3
Hyrule Field, arriving 39.8 / 60 / 32.7 39.9 / 56 / 5.0
Kakariko, arriving 38.4 / 73 / 29.3 37.8 / 85 / 2.7
Kokiri Forest (child), arriving 41.6 / 51 / 42.3 41.7 / 53 / 5.0
Hyrule Field, running forward 36.8 / 54 / 26.3 34.7 / 64 / 3.0
  • No failures: both builds converted correctly (BC3 converter yes) and drew correctly, with no upload failures and no crashes. No device loss on the two-teleport routes.
  • Where the time went instead: in the slow-submit lines (the first 80 after the first load), the time uploads lost largely turned up as memory 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.
  • Running forward was the one scene where B looked worse (-5.7 %). That is 3 runs each.

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.

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 says `small_vram_textures=1 astc_bc_all=1`, so every big ASTC texture goes to BC3. **Builds:** - A = main @ 8aa5ab87 + local feature ports + #2439 + #2436 + #2308/#2235. - B = A + #2330 + #2473. The only conflict was in `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. | Scene | A: fps / p99 / slow uploads | B: fps / p99 / slow uploads | |---|---|---| | Hyrule Field, turning | 42.6 / 46 / 23.7 | 43.2 / 42 / 4.7 | | Kakariko, turning | 40.7 / 47 / 25.3 | 41.0 / 45 / 3.3 | | Hyrule Field, arriving | 39.8 / 60 / 32.7 | 39.9 / 56 / 5.0 | | Kakariko, arriving | 38.4 / 73 / 29.3 | 37.8 / 85 / 2.7 | | Kokiri Forest (child), arriving | 41.6 / 51 / 42.3 | 41.7 / 53 / 5.0 | | Hyrule Field, running forward | 36.8 / 54 / 26.3 | 34.7 / 64 / 3.0 | - **No failures:** both builds converted correctly (`BC3 converter yes`) and drew correctly, with no upload failures and no crashes. No device loss on the two-teleport routes. - **Where the time went instead:** in the slow-submit lines (the first 80 after the first load), the time `uploads` lost largely turned up as `memory 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. - **Running forward** was the one scene where B looked worse (-5.7 %). That is 3 runs each. 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.*
TrashPanda force-pushed feat/astc-bc-one-pass from c8294011b3
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
Website / Website builds (pull_request_target) Has been skipped
Website / Website preview, build (pull_request_target) Has been skipped
Website / Website preview, upload (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Failing after 14s
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
Website / Website on Cloudflare (pull_request) Has been cancelled
Website / Website builds (pull_request) Has been cancelled
Website / Website preview, build (pull_request) Has been cancelled
Website / Website preview, upload (pull_request) Has been cancelled
to 102e1cab4e
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
Website / Website builds (pull_request_target) Has been skipped
Website / Website preview, build (pull_request_target) Has been skipped
Website / Website preview, upload (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Failing after 5s
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test) (pull_request) Has been cancelled
CI / longshot-builder end to end (synthetic game) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
Website / Website on Cloudflare (pull_request) Has been cancelled
Website / Website builds (pull_request) Has been cancelled
Website / Website preview, build (pull_request) Has been cancelled
Website / Website preview, upload (pull_request) Has been cancelled
2026-11-25 13:37:53 +00:00
Compare
Author
Contributor

Rebased on main (be663a08a; one conflict, both sides appending rows to switches.def) and added one commit: the two upload tests now build under clang 23's -Wunused-but-set-global, the failure Jer9 found. Head is 102e1cab4.

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.

Rebased on main (be663a08a; one conflict, both sides appending rows to `switches.def`) and added one commit: the two upload tests now build under clang 23's `-Wunused-but-set-global`, the failure Jer9 found. Head is 102e1cab4. 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.
TrashPanda changed title from WIP: perf(vk): big ASTC textures become BC3 in one pass, and the two-pass path and its switches go to perf(vk): big ASTC textures become BC3 in one pass, and the two-pass path and its switches go 2026-11-25 13:38:48 +00:00
Author
Contributor

Full suite run at 102e1cab4 against main be663a08a on 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.

Full suite run at 102e1cab4 against main be663a08a on 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.
Two more builds of the existing shaders, for a two-step ASTC to BC3 route: astc_decoder.comp
with ASTC_TO_TEXELS (the decoder as it is, its workgroup and its 4,160 bytes of shared memory,
storing packed texels in a buffer) and bc3_encoder.comp with BC3_FROM_TEXELS (the same encode
half reading them). The decoder's and the converter's SPIR-V are unchanged word for word.

The lavapipe fixture runs the two steps on its 558 levels: the texels the exact decode, the
BC3 blocks the one-pass converter's byte for byte, nothing written around either.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Off on every PC. With the switch, a BC3 texture's upload decodes into a 16 MB texel buffer with
the decoder's own light shader and encodes from it with the image encoder's, where the one-pass
converter does both in a workgroup holding 10,560 or 14,400 bytes of shared memory. The one pass
took 1.5 to 2.9 times the two-pass path's GPU time on a Radeon 860M (#2473); on a Ryzen 9800X3D's
graphics (RADV) the two steps take 0.41 to 0.64 of the one pass's time in the game-free benchmark.

The batch stays: a batch is what the texel buffer holds, three full barriers each (texels,
blocks, copy), no image and no view; the same BC3 bytes, the same copy regions, the same chunk
bound, the same failure barrier. The texel buffer is made only when the switch is on.

The upload fixture runs again with the route on (validation and synchronization validation
clean, BC3 equal to the converter's); the spy test holds its batch order and bounds.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
test(vk): a game-free benchmark of the ASTC to BC3 routes on a Vulkan device
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
Website / Website builds (pull_request_target) Has been skipped
Website / Website preview, build (pull_request_target) Has been skipped
Website / Website preview, upload (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Failing after 4s
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test) (pull_request) Has been cancelled
CI / longshot-builder end to end (synthetic game) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
Website / Website on Cloudflare (pull_request) Has been cancelled
Website / Website builds (pull_request) Has been cancelled
Website / Website preview, build (pull_request) Has been cancelled
Website / Website preview, upload (pull_request) Has been cancelled
7ccf65a2f1
tests/test_astc_bc3_bench.py --device <name> times the one-pass converter against the two-step
route (RX_VK_ASTC_BC_SPLIT) on synthetic textures built from astcenc's test blocks, every mip
level, batched as the renderer batches an upload: medians by GPU timestamps and by the wall
clock, after checking that the routes give the same BC3 bytes. Without a device it only builds.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Author
Contributor

Three more commits (head 7ccf65a2f), for the AMD integrated-GPU slowdown: a two-step route behind RX_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), for the AMD integrated-GPU slowdown: a two-step route behind `RX_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.
Author
Contributor

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):

fused two steps
Ryzen iGPU (RADV), 1365x1365x90, 5x5 1,392 ms 834 ms
Ryzen iGPU, 1365x1365x16, 8x8 297.1 ms 120.7 ms
RTX 4070 Ti, 1365x1365x16, 5x5 8.71 ms 4.88 ms

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):

python -I -B tests/test_astc_bc3_bench.py --headers <Vulkan-Headers\include> --cxx <llvm-mingw clang++> --device Radeon
python -I -B tests/test_astc_bc3_bench.py --headers <...> --cxx <...> --device Radeon --textures 1365x1365x90 --footprints 5x5 --reps 3 --routes fused,split

and, if that looks good, your earlier A/B in the game with RX_VK_ASTC_BC_SPLIT=1 against without (the log says RX_VK_ASTC_BC_SPLIT=1: ASTC to BC3 in two steps when 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.

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): | | fused | two steps | |---|---|---| | Ryzen iGPU (RADV), 1365x1365x90, 5x5 | 1,392 ms | 834 ms | | Ryzen iGPU, 1365x1365x16, 8x8 | 297.1 ms | 120.7 ms | | RTX 4070 Ti, 1365x1365x16, 5x5 | 8.71 ms | 4.88 ms | 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): ``` python -I -B tests/test_astc_bc3_bench.py --headers <Vulkan-Headers\include> --cxx <llvm-mingw clang++> --device Radeon python -I -B tests/test_astc_bc3_bench.py --headers <...> --cxx <...> --device Radeon --textures 1365x1365x90 --footprints 5x5 --reps 3 --routes fused,split ``` and, if that looks good, your earlier A/B in the game with `RX_VK_ASTC_BC_SPLIT=1` against without (the log says `RX_VK_ASTC_BC_SPLIT=1: ASTC to BC3 in two steps` when 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.
TrashPanda force-pushed feat/astc-bc-one-pass from 7ccf65a2f1
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
Website / Website builds (pull_request_target) Has been skipped
Website / Website preview, build (pull_request_target) Has been skipped
Website / Website preview, upload (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Failing after 4s
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test) (pull_request) Has been cancelled
CI / longshot-builder end to end (synthetic game) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
Website / Website on Cloudflare (pull_request) Has been cancelled
Website / Website builds (pull_request) Has been cancelled
Website / Website preview, build (pull_request) Has been cancelled
Website / Website preview, upload (pull_request) Has been cancelled
to f1187f556e
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
Website / Website builds (pull_request_target) Has been skipped
Website / Website preview, build (pull_request_target) Has been skipped
Website / Website preview, upload (pull_request_target) Has been skipped
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Rust (rustfmt, clippy, cargo test) (pull_request) Blocked by required conditions
CI / longshot-builder end to end (synthetic game) (pull_request) Blocked by required conditions
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request) Blocked by required conditions
Website / Website builds (pull_request) Blocked by required conditions
Website / Website preview, build (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Website / Website preview, upload (pull_request) Blocked by required conditions
PR description / Description follows the template (pull_request_target) Failing after 7s
2026-11-25 14:10:30 +00:00
Compare
Author
Contributor

Correction 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 ending 7ccf65a2f are 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:

  • The switch is RX_VK_ASTC_BC_SPLIT with 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.
  • The benchmark command changed. There is no tests/test_astc_bc3_bench.py any more; it is python -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).

Correction 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 ending 7ccf65a2f are 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: - The switch is `RX_VK_ASTC_BC_SPLIT` with 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. - **The benchmark command changed.** There is no `tests/test_astc_bc3_bench.py` any more; it is `python -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).
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
Website / Website builds (pull_request_target) Has been skipped
Website / Website preview, build (pull_request_target) Has been skipped
Website / Website preview, upload (pull_request_target) Has been skipped
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Rust (rustfmt, clippy, cargo test) (pull_request) Blocked by required conditions
CI / longshot-builder end to end (synthetic game) (pull_request) Blocked by required conditions
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request) Blocked by required conditions
Website / Website builds (pull_request) Blocked by required conditions
Website / Website preview, build (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Website / Website preview, upload (pull_request) Blocked by required conditions
PR description / Description follows the template (pull_request_target) Failing after 7s
This pull request doesn't have enough approvals yet. 0 of 1 approvals granted.
Some workflows are waiting to be reviewed.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'feat/astc-bc-one-pass:TrashPanda-feat/astc-bc-one-pass'
git switch 'TrashPanda-feat/astc-bc-one-pass'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
4 participants
Notifications
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/Longshot!2473
No description provided.