perf(vk): 2.7 GB less VRAM on textures, render targets and buffers #3259

Merged
HumanBean merged 9 commits from neotoxic/Longshot:perf/vk-vram into main 2026-12-05 22:04:10 +00:00
Contributor

Summary

A run through five areas kept 2-3 GB of VRAM it never drew from: ASTC textures re-encoded as BC3 when half of them
are opaque (BC1 is half the size) or gray (BC5), dead three-layer shadow arrays and stale aliases kept alive,
oversized pools and buffers. On a 6 GB laptop GPU the same waste pushed textures out and made loads hitch. This
trims each of those, with a switch per part and its default set from A/B runs:

  • BC1 for opaque ASTC textures (RX_VK_ASTC_BC1, on): the blocks are read at creation (their endpoints, on the
    helper threads from 256 KB; a block whose colour modes have no alpha is opaque from its header alone); an upload
    that brings non-opaque blocks makes the texture BC3 again. 1600-1800 textures, 640-740 MB on the RTX 5080.
    What a content's blocks were found to be is kept in cache/longshot_astc_kinds.bin by its whole hash
    (astc_kinds_file.h): from the second run on, the blocks are only hashed, as their first upload does anyway, and
    the reads at creation fall from ~600 ms a run to 40-60 ms on the RTX 5080 and to 5 ms on the laptop.
  • BC5 for gray ASTC textures (RX_VK_ASTC_BC5, on): the gray in red, the alpha in green, the views swizzled back.
  • Copies (texture_for_copy): a BC1 or BC5 texture a copy writes, or reads into another BC image (or, for BC5,
    into any image), is made BC3 first and uploaded whole; copies from uncompressed colour textures into a BC-kept one
    go through the encoder.
  • Trimmed ASTC stays BC (RX_VK_ASTC_BC_TRIMMED, on), and ASTC textures of any size go BC (astc_bc_min_mb Auto
    is now 0 MB, was 1).
  • Render targets: a multi-layer target goes once newer targets drew over 7/8 of it (RX_VK_TARGET_LAYERS_OVER),
    a texture never drawn goes once a target from the same address drew over it (RX_VK_STALE_ALIAS): the 3072² x3
    shadow arrays, 216-270 MB.
  • Native BC textures lose their top levels where decoded ASTC does on small cards (RX_VK_BC_NATIVE_MIPS).
  • Textures made ahead: the BC textures an earlier load drew are made and uploaded in light frames
    (RX_VK_TEX_AHEAD, on): the worst frames of a teleport 25 ms shorter, ~250 MB more VRAM held.
  • Pools and buffers: compaction starts at a 64th of the VRAM allowance, 64-128 MB (was a 16th, 64-512); the
    images' pool takes 8 MB blocks; the first stream buffer is 512 KB (RX_VK_STREAM_KB); bc3t_out is 4 MB; a
    texture goes to the small pool by the size the driver gives it (RX_VK_SIZE_CLASS_REAL); pack images are kept up
    to a 32nd of the VRAM (RX_VK_PACK_KEEP_MB).
  • Windows: the all-zero check of a big texture skips the pages never touched (RX_VK_ZERO_UNTOUCHED): the
    12288² target is checked in 3.8 ms, was 31-51 ms, 288 MB less read.
  • Terrain arrays: a texture under 64 MB whose guest pool is not imported is unswizzled on the CPU rather than
    imported for the GPU (RX_VK_UNSWIZZLE_IMPORT_MB): the terrain's R16 arrays (21-38 MB) took 15-29 ms each.
  • In, off (measured negative here, kept for smaller GPUs): sparse write-back shadows (RX_VK_SHADOW_SPARSE,
    RX_VK_SHADOW_GRAIN_KB) and the one-pass ASTC-to-BC shader (RX_VK_ASTC_BC_FUSED: astc_decoder.comp built with
    ASTC_TO_BC, the encoder moved to bc3_encode.glsl, which gen-shaders now passes -I for).

Read first: gpu/vk/vk_texture.cpp (storage_kinds, kinds_file_load, bc1_to_bc3, upload_unswizzle_gpu), gpu/vk/vk_memory.cpp
(target retention), gpu/vk/switches.def.

Testing

Tested: Windows 11, RTX 5080, NVIDIA 617.42: 6 timed runs through Market, Kakariko, Kokiri Forest, Lost Woods and
Hyrule Field (dev.py ab, 150 s each), no artefact; Kokiri and Kakariko screenshots with BC1 on and off identical.
CachyOS Linux, RTX 3060 Laptop 6 GB, NVIDIA 620.85: the same 6 runs. The one-pass shader's output is byte for
byte the two passes' on the RTX 5080 (tests/astc_decoder_gpu.cpp, 288 levels, BC3/BC1/BC5). mise run test: the
checks this touches pass, tests/test_astc_kinds_file.py new; the 19 that fail here fail on main too on this PC
(test_check_third_party, test_ci_source_times, test_coverage_run, test_dev_vcs, test_dlssg, test_fsr4_tune,
test_helpers_extract, test_lifter, test_longshot_builder, test_no_game_title, test_no_map_reload,
test_present_acquire_ahead, test_present_geometry_trace, test_present_held_image, test_present_image_free,
test_run_all_output, test_sync_watch_event, test_turf_budget, test_ui_renderer: tools this PC lacks, or out of date on
main), and test_dev_cargoenv fails only beside the others in a worktree (it passes alone).

After the review fix-ups and the rebase onto main @ bb5a5682 (HumanBean, CachyOS, RTX 3090): the renderer compiles
for Linux and Windows (llvm-mingw) with no warnings; the GPU fixture (test_astc_decoder_gpu.py --device) passes;
run_all.py had 13 failures, 12 of them on main alone too (test_lifter, test_present_acquire_ahead,
test_present_semaphores, test_present_held_image, test_input_background, test_dlssg, test_i18n_complete,
test_present_image_free, test_sandbox_windows, test_settings_area_keys, test_vk_draw_overhead_lean, test_walk_key),
the 13th, test_bc_scratch_layers, fixed in a200c870 and passing.

AMD, a200c870: CachyOS Linux, RX 580 8 GB (Polaris), Mesa RADV: 3 timed A/B pairs through the five areas, no device
loss; screenshots of Kokiri Forest, Kakariko, Market and Hyrule Field look the same as main's; the GPU fixture
passes there with validation on.

Still to test:

  • Steam Deck: the five areas, expecting less VRAM and no more hitches than main; and RX_VK_ASTC_BC_FUSED=1,
    expecting less GPU time on ASTC uploads or not (@Beanstalk)
  • AMD RX 6000-9000 on Windows: the five areas, expecting no artefact on BC1/BC5 textures (@Beanstalk)
  • Intel Arc: the same (@Beanstalk)
  • A 4 GB card: the five areas, RX_VK_SHADOW_SPARSE=1 against unset (@Beanstalk)

Measurements

Verdict: 2.7 GB less VRAM (-28%) on an RTX 5080 with fps, 1% low and frames of 50 ms or more the same as main
(within the spread); on a 6 GB RTX 3060 Laptop +1.5% fps (within the spread), 1% low +3.5%, 8 fewer frames of 50 ms
or more. These NVIDIA runs are on the older main and the head before the fix-ups, which change copies, failed
remakes, error blocks and pack views, none of them the paths those tours spend time in; not re-measured. On an 8 GB
RX 580 (current head): no VRAM saving (+155 MB), 690 MB less GTT, fps within the spread, and longer worst frames
(table below).

Setup: Windows 11, RTX 5080 16 GB, NVIDIA 617.42; Hyrule Field, child, then a teleport every 12 s through Market,
Kakariko, Kokiri Forest, Lost Woods and Hyrule Field; preset Custom, resolution 67%, 1280x720, uncapped; the frame trace,
150 s each after a warm-up until no frame waited for a pipeline, 3 interleaved pairs, the median; dev.py ab

Before: main @ 7bc53f84 After: this PR @ 66492ca3 Δ
fps (each run) 190.9 / 190.1 / 192.9 (median 190.9) 190.3 / 189.9 / 190.5 (median 190.3) -0.3% (within the spread)
1% low fps 107.2 107.1 -0.1%
median frame time 5.57 ms 5.58 ms +0.01 ms
p99 frame time 9.33 ms 9.34 ms +0.01 ms
frames of 50 ms or more (median) 11 11 0
VRAM by the driver, run average 9714 MB 7059 MB -2655 MB
textures, run average 7093 MB 4526 MB -2567 MB
blocks read at creation (B1, no file yet / B2 / B3) 609 / 60 / 41 ms

Setup: CachyOS Linux, RTX 3060 Laptop 6 GB, NVIDIA 620.85; the same tour, resolution 67%, 1440x900

Before: main @ 3a0f7d8f After: this PR @ 72c08218 Δ
fps (each run) 69.4 / 68.3 / 68.1 (median 68.3) 69.3 / 69.4 / 68.8 (median 69.3) +1.5% (within the spread)
1% low fps 15.4 15.9 +3.5%
p99 frame time 65.00 ms 62.80 ms -2.20 ms
frames of 50 ms or more (median) 145 137 -8
VRAM by the driver, run average 4308 MB 4248 MB the 6 GB card fills its budget either way
blocks read at creation (B1, no file yet / B2 / B3) 573 / 5 / 5 ms

72c08218 is this branch's tree on the laptop's older base, 3a0f7d8f (the one commit of main since, 7bc53f84,
changes mods, no file in common).

Before the file of kinds (1356eaf1 against main @ 3a0f7d8f, the same PC and tour): VRAM -2709 MB, but -0.4% fps
(every B run below every A run) and 5 more frames of 50 ms or more, the block reads at creation (~600 ms a run on the
replay thread): what astc_kinds_file.h now saves from the second run on.

Setup: CachyOS Linux, RX 580 8 GB, Mesa RADV, i7-9700K; 1280x720, resolution 67%, uncapped, headless; a teleport every
few seconds through the five areas for 90 s after one untimed lap; 3 interleaved pairs, the median (each run in
brackets)

Before: main @ bb5a5682 After: this PR @ a200c870 Δ
fps 60.8 (59.6 / 60.8 / 60.8) 59.0 (59.0 / 60.3 / 58.8) -2.9% (within the spread)
1% low fps 25.5 (28.3 / 25.5 / 25.5) 26.8 (27.8 / 26.8 / 23.5) within the spread
median frame time 15.82 ms 16.22 ms within the spread
p99 frame time 39.20 ms 37.34 ms within the spread
frames of 50 ms or more 31 (21 / 33 / 31) 28 (26 / 28 / 32) within the spread
frames of 100 ms or more 8 (9 / 8 / 8) 11 (11 / 11 / 14) +3, every run above main's
worst frame 173 ms (148 / 173 / 189) 228 ms (228 / 203 / 261) +55 ms, every run above main's
VRAM in use, mean 7024 MB 7179 MB +155 MB, every run above main's
GTT in use, mean 3895 MB 3207 MB -688 MB, every run below main's
major page faults 10 110 +100, every run above main's

The cause of the longer worst frames is not isolated (no per-switch A/B there yet).

The switches one by one (each its own A/B on the RTX 5080 or the laptop, the default it ships at):

Switch Default The numbers that chose it
RX_VK_ASTC_BC1 on PC: 640-740 MB less, fps 190.8 / 189.5 (in the spread); the block reads at creation, 50 ms frames +4 on a first run, kept between runs since (above)
RX_VK_ASTC_BC5 on PC: load frames +15 ms; laptop: part of the -450 MB below
RX_VK_ASTC_BC_TRIMMED on laptop: 328 MB RGBA8 → BC3, +300 ms of reads a run, fps equal
astc_bc_min_mb Auto 0 0 MB PC: -100 MB average, -230 MB at the tour's end, loads equal
RX_VK_TARGET_LAYERS_OVER, RX_VK_STALE_ALIAS on PC -216 MB, laptop -14 MB, never made again
RX_VK_BC_NATIVE_MIPS on PC with a small-card texture cap: textures -116 MB, frames in the noise
RX_VK_TEX_AHEAD on PC: worst teleport frames -25 ms, +250 MB VRAM held
compaction floor (RX_VK_COMPACT_MB Auto) a 64th, 64-128 MB laptop: driver -46 MB, 1% low 16.3 → 16.8, 50 ms frames 134 → 128
RX_VK_SIZE_CLASS_REAL on neutral on both
images' pool blocks while RX_VK_COMPACT is on 8 MB -24 MB, the pool held 6 MB in a 32 MB block
RX_VK_STREAM_KB 512 KB peak use 426 KB, 0 overflow, ~-24 MB
RX_VK_ZERO_UNTOUCHED 1 284 MB skipped, 0 non-zero page found (mode 2 checks), 3.8 ms against 31-51 ms
RX_VK_UNSWIZZLE_IMPORT_MB 64 PC: slow uploads (>15 ms) 7/1/2 → 0/0/0 a run, fps equal
RX_VK_SHADOW_SPARSE off PC: shadows 307 → 107 MB, fps +1.4%; laptop: fps 69.4 → 68.2, every B run below every A run; one device lost on the PC in the first runs with 1 MB grains
RX_VK_ASTC_BC_FUSED off -12 to -16 MB, but ASTC upload GPU time +7% (RTX 5080) and +35% (laptop), worst window 142-173 → 178-229 ms

Risks

  • On an 8 GB RX 580 the worst frames of area changes are longer than main's (above), with no VRAM saving there.
  • A BC5-kept texture sampled through an sRGB view would get no sRGB decode (BC5 has none); not checked whether the
    game does that.
  • A BC1 or BC5 texture whose later uploads bring non-opaque or coloured blocks is made BC3 and uploaded whole: one
    slower upload, logged (its blocks are not all opaque now). Wrong colours on BC1/BC5 textures would be the
    visible sign: RX_VK_ASTC_BC1=0 / RX_VK_ASTC_BC5=0.
  • On a big card that never runs short of VRAM, the reads at creation cost 0.4% fps and a few 50 ms frames for
    memory it doesn't need; on 4-8 GB cards and the Deck the saving is what keeps textures resident.
  • cache/longshot_astc_kinds.bin is new, up to ~3 MB, written every 300 frames when it has new entries. A file of
    another version, cut short or too big is read as none; a content's hash is 64 bits whole, so a wrong "opaque" from it
    would take a hash collision.
  • Each part turns off with its switch; a revert is enough. Nothing changes in saves or settings.toml; the
    ASTC to BC from and Compaction free space menu rows keep their keys, only their Auto values changed.

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says.
  • mise run test passes (any failure that also fails on main is named).
  • Measured against main, or Measurements says why there is nothing to measure.
  • 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.
  • A check under tests/ that reads changed source is updated, not weakened.
  • The SPIR-V headers regenerated (a shader changed).
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths.
  • 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

## Summary A run through five areas kept 2-3 GB of VRAM it never drew from: ASTC textures re-encoded as BC3 when half of them are opaque (BC1 is half the size) or gray (BC5), dead three-layer shadow arrays and stale aliases kept alive, oversized pools and buffers. On a 6 GB laptop GPU the same waste pushed textures out and made loads hitch. This trims each of those, with a switch per part and its default set from A/B runs: - **BC1 for opaque ASTC textures** (`RX_VK_ASTC_BC1`, on): the blocks are read at creation (their endpoints, on the helper threads from 256 KB; a block whose colour modes have no alpha is opaque from its header alone); an upload that brings non-opaque blocks makes the texture BC3 again. 1600-1800 textures, 640-740 MB on the RTX 5080. What a content's blocks were found to be is kept in `cache/longshot_astc_kinds.bin` by its whole hash (`astc_kinds_file.h`): from the second run on, the blocks are only hashed, as their first upload does anyway, and the reads at creation fall from ~600 ms a run to 40-60 ms on the RTX 5080 and to 5 ms on the laptop. - **BC5 for gray ASTC textures** (`RX_VK_ASTC_BC5`, on): the gray in red, the alpha in green, the views swizzled back. - **Copies** (`texture_for_copy`): a BC1 or BC5 texture a copy writes, or reads into another BC image (or, for BC5, into any image), is made BC3 first and uploaded whole; copies from uncompressed colour textures into a BC-kept one go through the encoder. - **Trimmed ASTC stays BC** (`RX_VK_ASTC_BC_TRIMMED`, on), and ASTC textures of any size go BC (`astc_bc_min_mb` Auto is now 0 MB, was 1). - **Render targets**: a multi-layer target goes once newer targets drew over 7/8 of it (`RX_VK_TARGET_LAYERS_OVER`), a texture never drawn goes once a target from the same address drew over it (`RX_VK_STALE_ALIAS`): the 3072² x3 shadow arrays, 216-270 MB. - **Native BC textures** lose their top levels where decoded ASTC does on small cards (`RX_VK_BC_NATIVE_MIPS`). - **Textures made ahead**: the BC textures an earlier load drew are made and uploaded in light frames (`RX_VK_TEX_AHEAD`, on): the worst frames of a teleport 25 ms shorter, ~250 MB more VRAM held. - **Pools and buffers**: compaction starts at a 64th of the VRAM allowance, 64-128 MB (was a 16th, 64-512); the images' pool takes 8 MB blocks; the first stream buffer is 512 KB (`RX_VK_STREAM_KB`); `bc3t_out` is 4 MB; a texture goes to the small pool by the size the driver gives it (`RX_VK_SIZE_CLASS_REAL`); pack images are kept up to a 32nd of the VRAM (`RX_VK_PACK_KEEP_MB`). - **Windows**: the all-zero check of a big texture skips the pages never touched (`RX_VK_ZERO_UNTOUCHED`): the 12288² target is checked in 3.8 ms, was 31-51 ms, 288 MB less read. - **Terrain arrays**: a texture under 64 MB whose guest pool is not imported is unswizzled on the CPU rather than imported for the GPU (`RX_VK_UNSWIZZLE_IMPORT_MB`): the terrain's R16 arrays (21-38 MB) took 15-29 ms each. - **In, off** (measured negative here, kept for smaller GPUs): sparse write-back shadows (`RX_VK_SHADOW_SPARSE`, `RX_VK_SHADOW_GRAIN_KB`) and the one-pass ASTC-to-BC shader (`RX_VK_ASTC_BC_FUSED`: `astc_decoder.comp` built with `ASTC_TO_BC`, the encoder moved to `bc3_encode.glsl`, which `gen-shaders` now passes `-I` for). Read first: `gpu/vk/vk_texture.cpp` (`storage_kinds`, `kinds_file_load`, `bc1_to_bc3`, `upload_unswizzle_gpu`), `gpu/vk/vk_memory.cpp` (target retention), `gpu/vk/switches.def`. ## Testing **Tested:** Windows 11, RTX 5080, NVIDIA 617.42: 6 timed runs through Market, Kakariko, Kokiri Forest, Lost Woods and Hyrule Field (`dev.py ab`, 150 s each), no artefact; Kokiri and Kakariko screenshots with BC1 on and off identical. CachyOS Linux, RTX 3060 Laptop 6 GB, NVIDIA 620.85: the same 6 runs. The one-pass shader's output is byte for byte the two passes' on the RTX 5080 (`tests/astc_decoder_gpu.cpp`, 288 levels, BC3/BC1/BC5). `mise run test`: the checks this touches pass, `tests/test_astc_kinds_file.py` new; the 19 that fail here fail on `main` too on this PC (test_check_third_party, test_ci_source_times, test_coverage_run, test_dev_vcs, test_dlssg, test_fsr4_tune, test_helpers_extract, test_lifter, test_longshot_builder, test_no_game_title, test_no_map_reload, test_present_acquire_ahead, test_present_geometry_trace, test_present_held_image, test_present_image_free, test_run_all_output, test_sync_watch_event, test_turf_budget, test_ui_renderer: tools this PC lacks, or out of date on `main`), and test_dev_cargoenv fails only beside the others in a worktree (it passes alone). After the review fix-ups and the rebase onto `main` @ `bb5a5682` (HumanBean, CachyOS, RTX 3090): the renderer compiles for Linux and Windows (llvm-mingw) with no warnings; the GPU fixture (`test_astc_decoder_gpu.py --device`) passes; `run_all.py` had 13 failures, 12 of them on `main` alone too (test_lifter, test_present_acquire_ahead, test_present_semaphores, test_present_held_image, test_input_background, test_dlssg, test_i18n_complete, test_present_image_free, test_sandbox_windows, test_settings_area_keys, test_vk_draw_overhead_lean, test_walk_key), the 13th, test_bc_scratch_layers, fixed in `a200c870` and passing. AMD, `a200c870`: CachyOS Linux, RX 580 8 GB (Polaris), Mesa RADV: 3 timed A/B pairs through the five areas, no device loss; screenshots of Kokiri Forest, Kakariko, Market and Hyrule Field look the same as `main`'s; the GPU fixture passes there with validation on. **Still to test:** - Steam Deck: the five areas, expecting less VRAM and no more hitches than `main`; and `RX_VK_ASTC_BC_FUSED=1`, expecting less GPU time on ASTC uploads or not (@Beanstalk) - AMD RX 6000-9000 on Windows: the five areas, expecting no artefact on BC1/BC5 textures (@Beanstalk) - Intel Arc: the same (@Beanstalk) - A 4 GB card: the five areas, `RX_VK_SHADOW_SPARSE=1` against unset (@Beanstalk) ## Measurements **Verdict:** 2.7 GB less VRAM (-28%) on an RTX 5080 with fps, 1% low and frames of 50 ms or more the same as `main` (within the spread); on a 6 GB RTX 3060 Laptop +1.5% fps (within the spread), 1% low +3.5%, 8 fewer frames of 50 ms or more. These NVIDIA runs are on the older `main` and the head before the fix-ups, which change copies, failed remakes, error blocks and pack views, none of them the paths those tours spend time in; not re-measured. On an 8 GB RX 580 (current head): no VRAM saving (+155 MB), 690 MB less GTT, fps within the spread, and **longer worst frames** (table below). **Setup:** Windows 11, RTX 5080 16 GB, NVIDIA 617.42; Hyrule Field, child, then a teleport every 12 s through Market, Kakariko, Kokiri Forest, Lost Woods and Hyrule Field; preset Custom, resolution 67%, 1280x720, uncapped; the frame trace, 150 s each after a warm-up until no frame waited for a pipeline, 3 interleaved pairs, the median; `dev.py ab` | | Before: main @ 7bc53f84 | After: this PR @ 66492ca3 | Δ | |---|---|---|---| | fps (each run) | 190.9 / 190.1 / 192.9 (median 190.9) | 190.3 / 189.9 / 190.5 (median 190.3) | -0.3% (within the spread) | | 1% low fps | 107.2 | 107.1 | -0.1% | | median frame time | 5.57 ms | 5.58 ms | +0.01 ms | | p99 frame time | 9.33 ms | 9.34 ms | +0.01 ms | | frames of 50 ms or more (median) | 11 | 11 | 0 | | VRAM by the driver, run average | 9714 MB | 7059 MB | -2655 MB | | textures, run average | 7093 MB | 4526 MB | -2567 MB | | blocks read at creation (B1, no file yet / B2 / B3) | | 609 / 60 / 41 ms | | Setup: CachyOS Linux, RTX 3060 Laptop 6 GB, NVIDIA 620.85; the same tour, resolution 67%, 1440x900 | | Before: main @ 3a0f7d8f | After: this PR @ 72c08218 | Δ | |---|---|---|---| | fps (each run) | 69.4 / 68.3 / 68.1 (median 68.3) | 69.3 / 69.4 / 68.8 (median 69.3) | +1.5% (within the spread) | | 1% low fps | 15.4 | 15.9 | +3.5% | | p99 frame time | 65.00 ms | 62.80 ms | -2.20 ms | | frames of 50 ms or more (median) | 145 | 137 | -8 | | VRAM by the driver, run average | 4308 MB | 4248 MB | the 6 GB card fills its budget either way | | blocks read at creation (B1, no file yet / B2 / B3) | | 573 / 5 / 5 ms | | `72c08218` is this branch's tree on the laptop's older base, `3a0f7d8f` (the one commit of `main` since, `7bc53f84`, changes mods, no file in common). Before the file of kinds (`1356eaf1` against `main` @ `3a0f7d8f`, the same PC and tour): VRAM -2709 MB, but -0.4% fps (every B run below every A run) and 5 more frames of 50 ms or more, the block reads at creation (~600 ms a run on the replay thread): what `astc_kinds_file.h` now saves from the second run on. Setup: CachyOS Linux, RX 580 8 GB, Mesa RADV, i7-9700K; 1280x720, resolution 67%, uncapped, headless; a teleport every few seconds through the five areas for 90 s after one untimed lap; 3 interleaved pairs, the median (each run in brackets) | | Before: main @ bb5a5682 | After: this PR @ a200c870 | Δ | |---|---|---|---| | fps | 60.8 (59.6 / 60.8 / 60.8) | 59.0 (59.0 / 60.3 / 58.8) | -2.9% (within the spread) | | 1% low fps | 25.5 (28.3 / 25.5 / 25.5) | 26.8 (27.8 / 26.8 / 23.5) | within the spread | | median frame time | 15.82 ms | 16.22 ms | within the spread | | p99 frame time | 39.20 ms | 37.34 ms | within the spread | | frames of 50 ms or more | 31 (21 / 33 / 31) | 28 (26 / 28 / 32) | within the spread | | frames of 100 ms or more | 8 (9 / 8 / 8) | 11 (11 / 11 / 14) | **+3, every run above main's** | | worst frame | 173 ms (148 / 173 / 189) | 228 ms (228 / 203 / 261) | **+55 ms, every run above main's** | | VRAM in use, mean | 7024 MB | 7179 MB | +155 MB, every run above main's | | GTT in use, mean | 3895 MB | 3207 MB | -688 MB, every run below main's | | major page faults | 10 | 110 | +100, every run above main's | The cause of the longer worst frames is not isolated (no per-switch A/B there yet). The switches one by one (each its own A/B on the RTX 5080 or the laptop, the default it ships at): | Switch | Default | The numbers that chose it | |---|---|---| | `RX_VK_ASTC_BC1` | on | PC: 640-740 MB less, fps 190.8 / 189.5 (in the spread); the block reads at creation, 50 ms frames +4 on a first run, kept between runs since (above) | | `RX_VK_ASTC_BC5` | on | PC: load frames +15 ms; laptop: part of the -450 MB below | | `RX_VK_ASTC_BC_TRIMMED` | on | laptop: 328 MB RGBA8 → BC3, +300 ms of reads a run, fps equal | | `astc_bc_min_mb` Auto 0 | 0 MB | PC: -100 MB average, -230 MB at the tour's end, loads equal | | `RX_VK_TARGET_LAYERS_OVER`, `RX_VK_STALE_ALIAS` | on | PC -216 MB, laptop -14 MB, never made again | | `RX_VK_BC_NATIVE_MIPS` | on | PC with a small-card texture cap: textures -116 MB, frames in the noise | | `RX_VK_TEX_AHEAD` | on | PC: worst teleport frames -25 ms, +250 MB VRAM held | | compaction floor (`RX_VK_COMPACT_MB` Auto) | a 64th, 64-128 MB | laptop: driver -46 MB, 1% low 16.3 → 16.8, 50 ms frames 134 → 128 | | `RX_VK_SIZE_CLASS_REAL` | on | neutral on both | | images' pool blocks while `RX_VK_COMPACT` is on | 8 MB | -24 MB, the pool held 6 MB in a 32 MB block | | `RX_VK_STREAM_KB` | 512 KB | peak use 426 KB, 0 overflow, ~-24 MB | | `RX_VK_ZERO_UNTOUCHED` | 1 | 284 MB skipped, 0 non-zero page found (mode 2 checks), 3.8 ms against 31-51 ms | | `RX_VK_UNSWIZZLE_IMPORT_MB` | 64 | PC: slow uploads (>15 ms) 7/1/2 → 0/0/0 a run, fps equal | | `RX_VK_SHADOW_SPARSE` | off | PC: shadows 307 → 107 MB, fps +1.4%; laptop: fps 69.4 → 68.2, every B run below every A run; one device lost on the PC in the first runs with 1 MB grains | | `RX_VK_ASTC_BC_FUSED` | off | -12 to -16 MB, but ASTC upload GPU time +7% (RTX 5080) and +35% (laptop), worst window 142-173 → 178-229 ms | ## Risks - On an 8 GB RX 580 the worst frames of area changes are longer than `main`'s (above), with no VRAM saving there. - A BC5-kept texture sampled through an sRGB view would get no sRGB decode (BC5 has none); not checked whether the game does that. - A BC1 or BC5 texture whose later uploads bring non-opaque or coloured blocks is made BC3 and uploaded whole: one slower upload, logged (`its blocks are not all opaque now`). Wrong colours on BC1/BC5 textures would be the visible sign: `RX_VK_ASTC_BC1=0` / `RX_VK_ASTC_BC5=0`. - On a big card that never runs short of VRAM, the reads at creation cost 0.4% fps and a few 50 ms frames for memory it doesn't need; on 4-8 GB cards and the Deck the saving is what keeps textures resident. - `cache/longshot_astc_kinds.bin` is new, up to ~3 MB, written every 300 frames when it has new entries. A file of another version, cut short or too big is read as none; a content's hash is 64 bits whole, so a wrong "opaque" from it would take a hash collision. - Each part turns off with its switch; a revert is enough. Nothing changes in saves or `settings.toml`; the `ASTC to BC from` and `Compaction free space` menu rows keep their keys, only their Auto values changed. ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. - [x] Tested on my own PC, in the game for a change the game runs, as Testing says. - [x] `mise run test` passes (any failure that also fails on `main` is named). - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [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`. - [x] A check under `tests/` that reads changed source is updated, not weakened. - [x] The SPIR-V headers regenerated (a shader changed). - [x] Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. - [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)
A big ASTC texture kept as BC3 spends half its VRAM on alpha, and in Ocarina most of them have none: on the PC 69% of the
BC3 bytes are textures whose every ASTC block decodes to alpha 255. RX_VK_ASTC_BC1=1 (attempt, off) reads a texture's
blocks at create() from their colour endpoints alone (astc_opaque.h, texdecode::astc_block_opaque: an LDR void extent of
alpha 255, or every partition's two endpoint alphas 255; the weights are not decoded) and keeps it as BC1 where all are.
The read is spread over helper threads for a large storage and remembered by storage and footprint with the memory
generation, as the blocks' hash is, so the first upload reads nothing again.

The texel route's encoder writes BC3's colour half alone for such a texture: a four-colour block (c0 > c1, or every texel
code 0), which BC1 decodes as BC3 does, so the colours are the same as before. Only where the texel route takes it: not BC7,
not resized for AMD, not sparse. An upload whose written blocks are no longer all opaque makes the image BC3 again first, in
place as compaction moves an image, and uploads it whole. A copy between a BC1 image and one that is not BC1 is skipped and
logged.

Measured on the PC (RTX 5080, Hyrule Field and the five-area tour, 3584 MB budget, 2 runs a side): 1600-1800 textures kept
as BC1, 644-744 MB less than BC3; none made BC3 again, no copy skipped; fps the same (190.8 against 189.5), 1412 textures
held in the budget against 1293. The blocks' reads: 1.1-1.4 s a run in all, 34 ms at most for one texture. Kokiri Forest
and Kakariko look the same in captures with and without.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A 3-4 MB storage was read on one thread at create(): 25-30 ms (34 ms at most on the PC, 60 ms on the laptop).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Read on dumps of the game's own textures, 84% of the blocks are of a single partition in an RGB or luminance mode (6, 8, 9; 0
and 1), whose alpha is 255 whatever their colour values: they are opaque without their values decoded. A single partition's
header (its low 17 bits and the footprint) is remembered for the thread, as a texture's blocks share a few. 39 ns a block
-> 7 ns on those dumps, the same verdicts; in the game the reads went from 600-700 ms a run (26-34 ms at most for one
texture) to 170 ms (8 ms at most). A storage goes on the helper threads from 1 MB, as their start now costs about what
the read of one does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Most of the decoded ASTC kept as RGBA8 in Ocarina is fine-footprint (5x5) gray
textures with alpha, 1536 x 1536 and 768 x 768: under the 64 MB a fine footprint
needs to go BC3, so they took 4 bytes a texel. A block is gray when its colour
modes are luminance ones or every partition's endpoints have red, green and
blue equal (a second plane weighing only alpha): every texel then decodes gray,
read from the endpoints as the opaque check does (astc_block_kind, one read of
the storage for both).

With RX_VK_ASTC_BC5=1 such a texture from astc_bc_min_mb (2 MB) is kept as BC5,
the gray in red and the alpha in green, its sampled views swizzled back to
(gray, gray, gray, alpha): a quarter of RGBA8. The texel route's encoder writes
the two BC4 halves (mode 2). Not sRGB, not sparse, not AMD-resized. An upload
whose blocks are no longer all gray makes the image BC3 (bc_remake, BC1's
fallback generalised), and copies into a BC5 image are left out as into BC1.

PC (RTX, default budget, five-area tour, BC1 on both sides): textures 8645 ->
5753 MB, the driver's VRAM 11227 -> 8686 MB, more textures held (4986 -> 5472).
Screenshots differ from BC1 alone less than two identical runs do.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A run through five areas on an RTX 5080 kept 2-3 GB of VRAM it never
drew from; on a 6 GB laptop GPU the same waste pushed textures out and
made loads hitch. Each part has its switch, its default set from A/B runs:

- dead three-layer shadow arrays and stale aliases go once newer targets
  drew over them (RX_VK_TARGET_LAYERS_OVER, RX_VK_STALE_ALIAS);
- a trimmed single-layer ASTC texture stays BC (RX_VK_ASTC_BC_TRIMMED), and
  ASTC textures of any size go BC (astc_bc_min_mb Auto now 0);
- the game's own BC textures lose their top levels where decoded ASTC does
  (RX_VK_BC_NATIVE_MIPS);
- the textures an earlier load drew are made ahead in light frames
  (RX_VK_TEX_AHEAD);
- compaction starts at a 64th of the VRAM allowance, 64-128 MB; the images'
  pool takes 8 MB blocks; the first stream buffer is 512 KB
  (RX_VK_STREAM_KB); bc3t_out is 4 MB; a texture goes to the small pool by
  the size the driver gives it (RX_VK_SIZE_CLASS_REAL);
- the pack images are kept up to a 32nd of the VRAM (RX_VK_PACK_KEEP_MB);
- under Windows the all-zero check skips pages never touched
  (RX_VK_ZERO_UNTOUCHED);
- a texture under 64 MB whose guest pool is not imported is unswizzled on
  the CPU rather than imported for the GPU (RX_VK_UNSWIZZLE_IMPORT_MB): the
  terrain's R16 arrays no longer take 15-29 ms each;
- BC1 for opaque and BC5 for gray ASTC textures (RX_VK_ASTC_BC1,
  RX_VK_ASTC_BC5, the commits before) ship on;
- sparse write-back shadows (RX_VK_SHADOW_SPARSE) and the one-pass ASTC to
  BC shader (RX_VK_ASTC_BC_FUSED) are in, off: both measured negative on a
  6 GB RTX 3060 Laptop (Linux), kept for the Test Farm to try on smaller GPUs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
test: the source checks follow the VRAM changes
Some checks failed
beanstalk/approval waiting for a BigBean's 👍 on the request
PR description / Title and description (pull_request_target) Has been cancelled
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
0a11cc3dd5
The checks that compile parts of vk_texture.cpp, vk_memory.cpp and
vk_vma.cpp get the new names (is_bc1, is_bc5, the sparse shadow fields,
the two retention switches), gone_note is cut at its definition rather
than its new declaration, the device policy expects the new compaction
floor and vk_texture.cpp has a fourth fork_join (the kinds check).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Contributor

Tested in game: Windows 11, RTX 5080, NVIDIA 617.42, and CachyOS Linux, RTX 3060 Laptop 6 GB, NVIDIA 620.85: 6 timed runs each through Market, Kakariko, Kokiri Forest, Lost Woods and Hyrule Field with every default of this branch, no artefact, no crash; BC1 textures in Kokiri and Kakariko look the same as BC3.

Tested in game: Windows 11, RTX 5080, NVIDIA 617.42, and CachyOS Linux, RTX 3060 Laptop 6 GB, NVIDIA 620.85: 6 timed runs each through Market, Kakariko, Kokiri Forest, Lost Woods and Hyrule Field with every default of this branch, no artefact, no crash; BC1 textures in Kokiri and Kakariko look the same as BC3.
Author
Contributor

@Beanstalk please run this branch against main on a Steam Deck, an AMD RX 6000-9000 on Windows, an Intel Arc and a 4 GB card: the five-area tour (Market, Kakariko, Kokiri Forest, Lost Woods, Hyrule Field), fps, 1% low, frames of 50 ms or more, VRAM by the driver. On the Deck and the 4 GB card, also RX_VK_SHADOW_SPARSE=1 and RX_VK_ASTC_BC_FUSED=1 against unset: both are off because they cost on a 6 GB RTX 3060 Laptop, and may pay on smaller GPUs. On AMD and Intel, a look at textures for wrong colours (BC1/BC5 are new formats here).

@Beanstalk please run this branch against main on a Steam Deck, an AMD RX 6000-9000 on Windows, an Intel Arc and a 4 GB card: the five-area tour (Market, Kakariko, Kokiri Forest, Lost Woods, Hyrule Field), fps, 1% low, frames of 50 ms or more, VRAM by the driver. On the Deck and the 4 GB card, also RX_VK_SHADOW_SPARSE=1 and RX_VK_ASTC_BC_FUSED=1 against unset: both are off because they cost on a 6 GB RTX 3060 Laptop, and may pay on smaller GPUs. On AMD and Intel, a look at textures for wrong colours (BC1/BC5 are new formats here).
Member

@neotoxic only members of BigBeans can start the farm.

One of them can approve this request by reacting 👍 to it or to this comment. This request was for 0a11cc3, and the PR has changed since (66492ca), so a 👍 no longer approves it. Comment @Beanstalk again to ask for the new commit.

@neotoxic only members of `BigBeans` can start the farm. ~~One of them can approve this request by reacting 👍 to it or to this comment.~~ This request was for `0a11cc3`, and the PR has changed since (`66492ca`), so a 👍 no longer approves it. Comment `@Beanstalk` again to ask for the new commit.
Member

Possibly related, for context:

  • PR #3183 WIP: perf(vk): keep an evicted BC-kept ASTC texture's image in system memory, taken back instead of a decode (opt-in, RX_VK_BC_KEEP_MB) — Related ASTC/BC texture memory optimization; coordinate texture code changes
  • issue #1295 Idea: the game's 12288 x 12288 D16 shadow map takes 288 MB of VRAM on every GPU; a half-size one on cards with little VRAM — Requests reducing the same oversized static shadow target's VRAM cost
  • issue #586 Idea: Smaller Texture Size for 4GB VRAM — Requests lower-VRAM textures and smaller shadow target
  • PR #2810 perf(vk): branchless cmov wb_learn, SIEVE texture eviction, and size-class VRAM pools — Merged Vulkan VRAM pool and texture size-class work; overlaps allocator changes
Possibly related, for context: - PR #3183 WIP: perf(vk): keep an evicted BC-kept ASTC texture's image in system memory, taken back instead of a decode (opt-in, RX_VK_BC_KEEP_MB) — Related ASTC/BC texture memory optimization; coordinate texture code changes - issue #1295 Idea: the game's 12288 x 12288 D16 shadow map takes 288 MB of VRAM on every GPU; a half-size one on cards with little VRAM — Requests reducing the same oversized static shadow target's VRAM cost - issue #586 Idea: Smaller Texture Size for 4GB VRAM — Requests lower-VRAM textures and smaller shadow target - PR #2810 perf(vk): branchless cmov wb_learn, SIEVE texture eviction, and size-class VRAM pools — Merged Vulkan VRAM pool and texture size-class work; overlaps allocator changes
Owner
@review
BeanBot requested changes 2026-12-05 17:18:21 +00:00
Dismissed
BeanBot left a comment

Recommendation: Request changes. The change saves substantial VRAM in the reported RTX 5080 runs, but some texture copies are skipped or produce incorrect channels, and failed format conversion can silently upload incorrect texture data. The default rendering changes also need the outstanding hardware runs.

The PR reduces texture and allocation sizes, changes target retention, and prepares some textures ahead of use. It adds several format-conversion and memory-management paths, with correctness costs in cases outside the reported tour.

Blocking (3): must change before merging.

  1. L1 gpu/vk/vk_xfer.cpp:318: Copies between differently encoded BC textures, or into a BC1 or BC5 texture, can be silently discarded. (more on the line) Do: Provide a conversion or remake path that performs these copies, and test copies among the new formats and the existing formats.
  2. L2 gpu/vk/vk_xfer.cpp:332: A blit out of a BC5-kept texture does not apply the channel mapping used by its sampled views. When: A gray ASTC texture kept as BC5 stores luminance in red and alpha in green. A copy from it to an uncompressed texture takes this raw image blit, producing red and green channels rather than the intended gray RGB and alpha. Do: Convert through a path that restores the BC5 channel mapping when copying to an uncompressed image, and cover that copy with a colored-alpha fixture.
  3. L4 gpu/vk/astc_opaque.h:33: The scan treats every all-zero block as padding, including blocks that occupy actual texels. (more on the line) Do: Use the texture layout to distinguish padding from actual blocks and classify actual zero blocks as errors; add a mixed opaque/error-block test.

Should fix (2): not blocking, but worth doing before merging.

  • L3 gpu/vk/vk_texture.cpp:3856: A failed BC3 remake falls through to an upload in the format that was just found unsuitable. (more on the line) Do: Do not upload or mark the update successful in the unsuitable format; provide a correct fallback or preserve the pending update and retry after making a suitable image.
  • L5 tests/test_astc_opaque.py:7: The new check hard-codes g++ instead of using the compiler selected by the test runner. (more on the line) Do: Pass the runner's {cxx} placeholder and use the selected compiler for direct invocation as well.

Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)

  • L6: The default rendering and memory changes have not been exercised on the affected AMD Tier 1 systems or Steam Deck. When: The new BC formats, image allocation and retention policies run on AMD drivers and the Deck, but the supplied game runs cover NVIDIA only. Do: Run the requested five-area comparison and visual checks on AMD Windows, RADV Linux and Steam Deck, including frame pacing and memory.

@fix can do L1, L2, L3, L4 and L5.

Questions (1) (not confirmed from the code; they don't hold the recommendation)

  • Is there a measured regression or unmet project requirement at automatic quality and native resolution that this comparison would investigate?

Checks: Still running: 11 checks.

More: does it help, other systems, switches, what was read

Does it help: Yes for VRAM on the reported RTX 5080: three interleaved pairs report a median reduction from 9,631 MB to 6,922 MB. On the 6 GB RTX 3060 Laptop, driver VRAM rose from 4,216 MB to 4,263 MB and FPS was within the run spread; the reported improvement in frame pacing needs confirmation on the affected hardware and at player settings.

Other systems: Both Windows and Linux use the changed texture conversion, copies, retention and allocation paths. The reported game runs cover NVIDIA on each OS; AMD Windows and RADV, Steam Deck, Intel Arc, smaller cards, texture packs and other game areas remain insufficiently covered. Windows also uses the new untouched-page optimization.

Switches: ASTC_BC1, ASTC_BC5, ASTC_BC_TRIMMED, TARGET_LAYERS_OVER, STALE_ALIAS, BC_NATIVE_MIPS, SIZE_CLASS_REAL and TEX_AHEAD default on; TEX_AHEAD changed from off. ASTC_BC_FUSED and SHADOW_SPARSE default off. SHADOW_GRAIN_KB defaults to 1024, STREAM_KB to 512, ZERO_UNTOUCHED to 1, UNSWIZZLE_IMPORT_MB to 64, and PACK_KEEP_MB to one thirty-second of the allowance clamped to 64–512 MB. STREAM_MB remains supported. The ASTC-to-BC Auto threshold changed from 1 MB to 0 and compaction Auto from one sixteenth clamped to 64–512 MB to one sixty-fourth clamped to 64–128 MB. Rows exist; the on defaults are not yet validated across affected hardware, and the copy defects make the format defaults unsafe as implemented.

Reviewed: 0a11cc3dd5 against 7bc53f8413: Read the repository instructions, contribution rules, standards and PR template; the review checklist was absent. Read the commit log, texture classification and remake paths, copy fallback, relevant shader and test changes, switch table and portions of the memory and allocator changes. The large texture and memory files, remaining changed tests, shader sources and generated-file claims were skimmed rather than read fully; this review is therefore incomplete.; nothing run (a code review).

Checked and fine:

  • All commits include AI-assistance trailers.
  • The new shader has a recipe entry, and generated SPIR-V headers are build outputs rather than tracked files.
  • The reported NVIDIA game runs use repeated interleaved comparisons and include frame pacing as well as VRAM.

Testing: No commands from the project or tests were run, as requested. All listed CI checks are still running.

Overlaps and merge order: Unknown; the network is closed.


Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.

**Recommendation: Request changes.** The change saves substantial VRAM in the reported RTX 5080 runs, but some texture copies are skipped or produce incorrect channels, and failed format conversion can silently upload incorrect texture data. The default rendering changes also need the outstanding hardware runs. The PR reduces texture and allocation sizes, changes target retention, and prepares some textures ahead of use. It adds several format-conversion and memory-management paths, with correctness costs in cases outside the reported tour. **Blocking (3)**: must change before merging. 1. **L1** `gpu/vk/vk_xfer.cpp:318`: Copies between differently encoded BC textures, or into a BC1 or BC5 texture, can be silently discarded. (more on the line) **Do:** Provide a conversion or remake path that performs these copies, and test copies among the new formats and the existing formats. 2. **L2** `gpu/vk/vk_xfer.cpp:332`: A blit out of a BC5-kept texture does not apply the channel mapping used by its sampled views. *When:* A gray ASTC texture kept as BC5 stores luminance in red and alpha in green. A copy from it to an uncompressed texture takes this raw image blit, producing red and green channels rather than the intended gray RGB and alpha. **Do:** Convert through a path that restores the BC5 channel mapping when copying to an uncompressed image, and cover that copy with a colored-alpha fixture. 3. **L4** `gpu/vk/astc_opaque.h:33`: The scan treats every all-zero block as padding, including blocks that occupy actual texels. (more on the line) **Do:** Use the texture layout to distinguish padding from actual blocks and classify actual zero blocks as errors; add a mixed opaque/error-block test. **Should fix (2)**: not blocking, but worth doing before merging. - **L3** `gpu/vk/vk_texture.cpp:3856`: A failed BC3 remake falls through to an upload in the format that was just found unsuitable. (more on the line) **Do:** Do not upload or mark the update successful in the unsuitable format; provide a correct fallback or preserve the pending update and retry after making a suitable image. - **L5** `tests/test_astc_opaque.py:7`: The new check hard-codes g++ instead of using the compiler selected by the test runner. (more on the line) **Do:** Pass the runner's {cxx} placeholder and use the selected compiler for direct invocation as well. **Testing before merging (1)** (runs on the systems it can change; it doesn't hold the recommendation) - **L6**: The default rendering and memory changes have not been exercised on the affected AMD Tier 1 systems or Steam Deck. *When:* The new BC formats, image allocation and retention policies run on AMD drivers and the Deck, but the supplied game runs cover NVIDIA only. **Do:** Run the requested five-area comparison and visual checks on AMD Windows, RADV Linux and Steam Deck, including frame pacing and memory. `@fix` can do L1, L2, L3, L4 and L5. **Questions (1)** (not confirmed from the code; they don't hold the recommendation) - Is there a measured regression or unmet project requirement at automatic quality and native resolution that this comparison would investigate? **Checks:** Still running: 11 checks. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Yes for VRAM on the reported RTX 5080: three interleaved pairs report a median reduction from 9,631 MB to 6,922 MB. On the 6 GB RTX 3060 Laptop, driver VRAM rose from 4,216 MB to 4,263 MB and FPS was within the run spread; the reported improvement in frame pacing needs confirmation on the affected hardware and at player settings. **Other systems:** Both Windows and Linux use the changed texture conversion, copies, retention and allocation paths. The reported game runs cover NVIDIA on each OS; AMD Windows and RADV, Steam Deck, Intel Arc, smaller cards, texture packs and other game areas remain insufficiently covered. Windows also uses the new untouched-page optimization. **Switches:** ASTC_BC1, ASTC_BC5, ASTC_BC_TRIMMED, TARGET_LAYERS_OVER, STALE_ALIAS, BC_NATIVE_MIPS, SIZE_CLASS_REAL and TEX_AHEAD default on; TEX_AHEAD changed from off. ASTC_BC_FUSED and SHADOW_SPARSE default off. SHADOW_GRAIN_KB defaults to 1024, STREAM_KB to 512, ZERO_UNTOUCHED to 1, UNSWIZZLE_IMPORT_MB to 64, and PACK_KEEP_MB to one thirty-second of the allowance clamped to 64–512 MB. STREAM_MB remains supported. The ASTC-to-BC Auto threshold changed from 1 MB to 0 and compaction Auto from one sixteenth clamped to 64–512 MB to one sixty-fourth clamped to 64–128 MB. Rows exist; the on defaults are not yet validated across affected hardware, and the copy defects make the format defaults unsafe as implemented. **Reviewed:** 0a11cc3dd515 against 7bc53f841323: Read the repository instructions, contribution rules, standards and PR template; the review checklist was absent. Read the commit log, texture classification and remake paths, copy fallback, relevant shader and test changes, switch table and portions of the memory and allocator changes. The large texture and memory files, remaining changed tests, shader sources and generated-file claims were skimmed rather than read fully; this review is therefore incomplete.; nothing run (a code review). **Checked and fine:** - All commits include AI-assistance trailers. - The new shader has a recipe entry, and generated SPIR-V headers are build outputs rather than tracked files. - The reported NVIDIA game runs use repeated interleaved comparisons and include frame pacing as well as VRAM. **Testing:** No commands from the project or tests were run, as requested. All listed CI checks are still running. **Overlaps and merge order:** Unknown; the network is closed. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.</sub>
@ -0,0 +30,4 @@
/// `bytes` of a texture's storage, whole blocks of footprint bw x bh (16 bytes each) and the zero padding between them: the kinds
/// of `want` every block is (`any` set where a block was seen). Stops once none is left. A part of a storage, read on its own
/// (vk_texture.cpp reads a large one on several threads)
inline uint32_t blocks_kinds(const uint8_t* p, size_t bytes, uint32_t bw, uint32_t bh, uint32_t want, bool& any) {
Member

L4 (blocking): The scan treats every all-zero block as padding, including blocks that occupy actual texels.

When: A texture containing opaque ASTC blocks and an all-zero error block is classified opaque because the latter is skipped. The decoder renders that error block transparent black, but BC1 encoding discards its alpha and makes the affected texels opaque; a later zero-block upload has the same issue.

Do: Use the texture layout to distinguish padding from actual blocks and classify actual zero blocks as errors; add a mixed opaque/error-block test.

**L4** (blocking): The scan treats every all-zero block as padding, including blocks that occupy actual texels. *When:* A texture containing opaque ASTC blocks and an all-zero error block is classified opaque because the latter is skipped. The decoder renders that error block transparent black, but BC1 encoding discards its alpha and makes the affected texels opaque; a later zero-block upload has the same issue. **Do:** Use the texture layout to distinguish padding from actual blocks and classify actual zero blocks as errors; add a mixed opaque/error-block test.
@ -3443,0 +3853,4 @@
// first upload)
if (tex.astc && (is_bc1(tex) || is_bc5(tex))) {
const uint32_t need = is_bc1(tex) ? astc_opaque::kAstcOpaque : astc_opaque::kAstcGray;
if (!storage_kinds(tex.gpu, total, tex.block_w, tex.block_h, need, tex.uploaded ? dirty : nullptr) && bc_remake(tex))
Member

L3 (should fix): A failed BC3 remake falls through to an upload in the format that was just found unsuitable.

When: If a BC1 texture receives non-opaque blocks or a BC5 texture receives colored blocks while BC3 allocation fails or the texture has block attachments, bc_remake returns false. upload_astc_gpu then encodes the new data as BC1 or BC5 and reports success, losing alpha or color.

Do: Do not upload or mark the update successful in the unsuitable format; provide a correct fallback or preserve the pending update and retry after making a suitable image.

**L3** (should fix): A failed BC3 remake falls through to an upload in the format that was just found unsuitable. *When:* If a BC1 texture receives non-opaque blocks or a BC5 texture receives colored blocks while BC3 allocation fails or the texture has block attachments, bc_remake returns false. upload_astc_gpu then encodes the new data as BC1 or BC5 and reports success, losing alpha or color. **Do:** Do not upload or mark the update successful in the unsuitable format; provide a correct fallback or preserve the pending update and retry after making a suitable image.
@ -316,2 +316,3 @@
const bool same_size = s.w == d.w && s.h == d.h && s.d == d.d;
if (s.tex->bc != d.tex->bc || (s.tex->bc && !same_size)) { // (big ASTC kept as BC3 on one side: vk_texture.cpp)
// (RX_VK_ASTC_BC1: kept as BC1 on one side, BC3 or BC7 on the other: no raw copy between them; texture_copy_into_bc leaves it out)
const bool unlike_bc = s.tex->bc && d.tex->bc && s.tex->format != d.tex->format;
Member

L1 (blocking): Copies between differently encoded BC textures, or into a BC1 or BC5 texture, can be silently discarded.

When: When an opaque ASTC source is kept as BC1 and the destination is BC3, unlike_bc enters this branch; texture_copy_into_bc rejects a BC source and the copy returns without writing the destination. A non-BC source copied into BC1 or BC5 is rejected by that function as well.

Do: Provide a conversion or remake path that performs these copies, and test copies among the new formats and the existing formats.

**L1** (blocking): Copies between differently encoded BC textures, or into a BC1 or BC5 texture, can be silently discarded. *When:* When an opaque ASTC source is kept as BC1 and the destination is BC3, unlike_bc enters this branch; texture_copy_into_bc rejects a BC source and the copy returns without writing the destination. A non-BC source copied into BC1 or BC5 is rejected by that function as well. **Do:** Provide a conversion or remake path that performs these copies, and test copies among the new formats and the existing formats.
@ -0,0 +4,4 @@
import tempfile
from pathlib import Path
RUN_ALL_ARGS = ["--cxx", "g++"]
Member

L5 (should fix): The new check hard-codes g++ instead of using the compiler selected by the test runner.

When: On a supported Windows or Linux development setup with clang++ available but no g++, run_all skips this check or fails it in strict mode even though a suitable compiler is installed; CXX is ignored.

Do: Pass the runner's {cxx} placeholder and use the selected compiler for direct invocation as well.

**L5** (should fix): The new check hard-codes g++ instead of using the compiler selected by the test runner. *When:* On a supported Windows or Linux development setup with clang++ available but no g++, run_all skips this check or fails it in strict mode even though a suitable compiler is installed; CXX is ignored. **Do:** Pass the runner's {cxx} placeholder and use the selected compiler for direct invocation as well.
perf(vk): keep the ASTC blocks' kinds between runs, read them no more at creation
Some checks failed
beanstalk/approval waiting for a BigBean's 👍 on the request
PR description / Title and description (pull_request_target) Has been cancelled
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
66492ca38f
Against main the VRAM lot cost 0.4% fps and 5 more frames of 50 ms
or more a run on an RTX 5080: telling a big ASTC texture's blocks
opaque or gray when it is made read 1.3 GB a run on the replay thread,
~600 ms (2400-3300 reads, 7 ms at most). The game makes the same
textures every run: what a content's blocks were found to be now goes
to cache/longshot_astc_kinds.bin by the content's whole hash, read at
the first look-up and written back every 300 frames when it has new
entries, so the next run only hashes them, as their first upload does
anyway.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Contributor

Pushed 66492ca3: what a content's ASTC blocks were found to be (opaque, gray) is now kept in cache/longshot_astc_kinds.bin between runs. The block reads at creation were the cost the first measurement showed against main (-0.4% fps, 5 more frames of 50 ms or more on the RTX 5080): from the second run on they fall from ~600 ms a run to 40-60 ms (RTX 5080) and 5 ms (RTX 3060 Laptop). Measured again against main 7bc53f84: fps, 1% low and frames of 50 ms or more the same as main on the RTX 5080, VRAM -2.7 GB; laptop +1.5% fps, 1% low +3.5%, 8 fewer frames of 50 ms or more. Tables in the description.

Pushed 66492ca3: what a content's ASTC blocks were found to be (opaque, gray) is now kept in cache/longshot_astc_kinds.bin between runs. The block reads at creation were the cost the first measurement showed against main (-0.4% fps, 5 more frames of 50 ms or more on the RTX 5080): from the second run on they fall from ~600 ms a run to 40-60 ms (RTX 5080) and 5 ms (RTX 3060 Laptop). Measured again against main 7bc53f84: fps, 1% low and frames of 50 ms or more the same as main on the RTX 5080, VRAM -2.7 GB; laptop +1.5% fps, 1% low +3.5%, 8 fewer frames of 50 ms or more. Tables in the description.
neotoxic changed title from WIP: perf(vk): 2.7 GB less VRAM on textures, render targets and buffers to perf(vk): 2.7 GB less VRAM on textures, render targets and buffers 2026-12-05 17:41:54 +00:00
Author
Contributor

@Beanstalk please run this branch against main on a Steam Deck, an AMD RX 6000-9000 on Windows, an Intel Arc and a 4 GB card: the five-area tour (Market, Kakariko, Kokiri Forest, Lost Woods, Hyrule Field), fps, 1% low, frames of 50 ms or more, VRAM by the driver. On the Deck and the 4 GB card, also RX_VK_SHADOW_SPARSE=1 and RX_VK_ASTC_BC_FUSED=1 against unset: both are off because they cost on a 6 GB RTX 3060 Laptop, and may pay on smaller GPUs. On AMD and Intel, a look at textures for wrong colours (BC1/BC5 are new formats here).

@Beanstalk please run this branch against main on a Steam Deck, an AMD RX 6000-9000 on Windows, an Intel Arc and a 4 GB card: the five-area tour (Market, Kakariko, Kokiri Forest, Lost Woods, Hyrule Field), fps, 1% low, frames of 50 ms or more, VRAM by the driver. On the Deck and the 4 GB card, also RX_VK_SHADOW_SPARSE=1 and RX_VK_ASTC_BC_FUSED=1 against unset: both are off because they cost on a 6 GB RTX 3060 Laptop, and may pay on smaller GPUs. On AMD and Intel, a look at textures for wrong colours (BC1/BC5 are new formats here).
Member

@neotoxic only members of BigBeans can start the farm.

One of them can approve this request by reacting 👍 to it or to this comment. This request was for 66492ca, and the PR has changed since (c7ebf03), so a 👍 no longer approves it. Comment @Beanstalk again to ask for the new commit.

@neotoxic only members of `BigBeans` can start the farm. ~~One of them can approve this request by reacting 👍 to it or to this comment.~~ This request was for `66492ca`, and the PR has changed since (`c7ebf03`), so a 👍 no longer approves it. Comment `@Beanstalk` again to ask for the new commit.
Owner
@review
BeanBot requested changes 2026-12-05 17:46:17 +00:00
Dismissed
BeanBot left a comment

Recommendation: Request changes. The BC texture copy and classification defects remain, so some texture copies can be lost or produce wrong colors or alpha. The measured VRAM saving is substantial on the RTX 5080, but the affected AMD systems and Steam Deck still need coverage.

The change reduces texture and render-target VRAM use and adds a persistent cache to avoid repeating ASTC block scans. It adds renderer complexity and still has correctness defects in texture copies and classification.

Blocking (3): must change before merging.

  1. L1 gpu/vk/vk_xfer.cpp:318: Copies between differently encoded BC textures, or into a BC1 or BC5 texture, can be silently discarded. When: When an opaque ASTC source is kept as BC1 and the destination is BC3, unlike_bc enters this branch; texture_copy_into_bc rejects a BC source and the copy returns without writing the destination. A non-BC source copied into BC1 or BC5 is rejected by that function as well. Do: Provide a conversion or remake path that performs these copies, and test copies among the new formats and the existing formats.
  2. L2 gpu/vk/vk_xfer.cpp:332: A blit out of a BC5-kept texture does not apply the channel mapping used by its sampled views. When: A gray ASTC texture kept as BC5 stores luminance in red and alpha in green. A copy from it to an uncompressed texture takes this raw image blit, producing red and green channels rather than the intended gray RGB and alpha. Do: Convert through a path that restores the BC5 channel mapping when copying to an uncompressed image, and cover that copy with a colored-alpha fixture.
  3. L4 gpu/vk/astc_opaque.h:33: The scan treats every all-zero block as padding, including blocks that occupy actual texels. When: A texture containing opaque ASTC blocks and an all-zero error block is classified opaque because the latter is skipped. The decoder renders that error block transparent black, but BC1 encoding discards its alpha and makes the affected texels opaque; a later zero-block upload has the same issue. Do: Use the texture layout to distinguish padding from actual blocks and classify actual zero blocks as errors; add a mixed opaque/error-block test.

Should fix (3): not blocking, but worth doing before merging.

  • L3 gpu/vk/vk_texture.cpp:3856: A failed BC3 remake falls through to an upload in the format that was just found unsuitable. When: If a BC1 texture receives non-opaque blocks or a BC5 texture receives colored blocks while BC3 allocation fails or the texture has block attachments, bc_remake returns false. upload_astc_gpu then encodes the new data as BC1 or BC5 and reports success, losing alpha or color. Do: Do not upload or mark the update successful in the unsuitable format; provide a correct fallback or preserve the pending update and retry after making a suitable image.
  • L5 tests/test_astc_opaque.py:7: The new check hard-codes g++ instead of using the compiler selected by the test runner. When: On a supported Windows or Linux development setup with clang++ available but no g++, run_all skips this check or fails it in strict mode even though a suitable compiler is installed; CXX is ignored. Do: Pass the runner's {cxx} placeholder and use the selected compiler for direct invocation as well.
  • L7 gpu/vk/vk_texture.cpp:3408: A failed cache write clears the dirty flag without scheduling a retry. (more on the line) Do: Restore the dirty flag under the mutex when saving fails, preserving any entries added during the save.

Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)

  • L6: The default rendering and memory changes have not been exercised on the affected AMD Tier 1 systems or Steam Deck. When: The new BC formats, image allocation and retention policies run on AMD drivers and the Deck, but the supplied game runs cover NVIDIA only. Do: Run the requested five-area comparison and visual checks on AMD Windows, RADV Linux and Steam Deck, including frame pacing and memory.

@fix can do L1, L2, L3, L4, L5 and L7.

Since the last review (on 0a11cc3dd5)
Still open: L1 (Copies between differently encoded BC textures, or into a BC1 or BC5 texture, can be silen…); L2 (A blit out of a BC5-kept texture does not apply the channel mapping used by its sampled vi…); L3 (A failed BC3 remake falls through to an upload in the format that was just found unsuitabl…); L4 (The scan treats every all-zero block as padding, including blocks that occupy actual texel…); L5 (The new check hard-codes g++ instead of using the compiler selected by the test runner.); L6 (The default rendering and memory changes have not been exercised on the affected AMD Tier…)
New: L7 (A failed cache write clears the dirty flag without scheduling a retry.)

Checks: Still running: 11 checks.

Also noticed (2; not asked for, not blocking)
  • The cache replacement removes the old file before renaming the temporary file, so interruption in between loses the saved cache.
  • The content memo can reach 200,001 entries while the file writer accepts at most 200,000.
More: does it help, other systems, switches, what was read

Does it help: Yes for measured VRAM use: the description reports a 2,655 MB lower driver average over three interleaved pairs on an RTX 5080, with frame metrics within the spread. The 6 GB laptop filled its budget on both versions; its reported 1.5% fps increase was within the spread.

Other systems: The changes affect Vulkan texture formats, copies, allocation and timing on Windows and Linux. The reported game runs cover NVIDIA desktop and laptop GPUs; AMD Tier 1 systems and Steam Deck remain untested, and Intel Arc and a 4 GB card are also requested.

Switches: The description lists BC1, BC5, trimmed BC, target overlap, stale alias, native BC mips, texture ahead, real size classes and untouched-page skipping on by default; sparse shadows and fused ASTC conversion default off. Stream buffer defaults to 512 KB, CPU unswizzle threshold to 64 MB, and Auto ASTC conversion and compaction thresholds change. NVIDIA measurements support the chosen defaults there; correctness and performance on other affected hardware remain unverified.

Reviewed: 66492ca38f against 7bc53f8413: Read the new ASTC kinds file and its tests, ASTC opacity helper and test runner, the relevant texture classification and copy paths, repository rules and PR template. Skimmed the remaining diff and switch table; the other changed files and their full callers were not read in full.; nothing run (a code review).

Checked and fine:

  • The cache loader rejects truncated, oversized, version-mismatched and trailing-data files before adding entries.
  • The cache frame hook runs before the texture-ahead switch can return.

Testing: No commands from the project or tests were run. The author reports six game runs on each of two NVIDIA systems; CI is still running.

Overlaps and merge order: Not checked; the network is closed.


Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.

**Recommendation: Request changes.** The BC texture copy and classification defects remain, so some texture copies can be lost or produce wrong colors or alpha. The measured VRAM saving is substantial on the RTX 5080, but the affected AMD systems and Steam Deck still need coverage. The change reduces texture and render-target VRAM use and adds a persistent cache to avoid repeating ASTC block scans. It adds renderer complexity and still has correctness defects in texture copies and classification. **Blocking (3)**: must change before merging. 1. **L1** `gpu/vk/vk_xfer.cpp:318`: Copies between differently encoded BC textures, or into a BC1 or BC5 texture, can be silently discarded. *When:* When an opaque ASTC source is kept as BC1 and the destination is BC3, unlike_bc enters this branch; texture_copy_into_bc rejects a BC source and the copy returns without writing the destination. A non-BC source copied into BC1 or BC5 is rejected by that function as well. **Do:** Provide a conversion or remake path that performs these copies, and test copies among the new formats and the existing formats. 2. **L2** `gpu/vk/vk_xfer.cpp:332`: A blit out of a BC5-kept texture does not apply the channel mapping used by its sampled views. *When:* A gray ASTC texture kept as BC5 stores luminance in red and alpha in green. A copy from it to an uncompressed texture takes this raw image blit, producing red and green channels rather than the intended gray RGB and alpha. **Do:** Convert through a path that restores the BC5 channel mapping when copying to an uncompressed image, and cover that copy with a colored-alpha fixture. 3. **L4** `gpu/vk/astc_opaque.h:33`: The scan treats every all-zero block as padding, including blocks that occupy actual texels. *When:* A texture containing opaque ASTC blocks and an all-zero error block is classified opaque because the latter is skipped. The decoder renders that error block transparent black, but BC1 encoding discards its alpha and makes the affected texels opaque; a later zero-block upload has the same issue. **Do:** Use the texture layout to distinguish padding from actual blocks and classify actual zero blocks as errors; add a mixed opaque/error-block test. **Should fix (3)**: not blocking, but worth doing before merging. - **L3** `gpu/vk/vk_texture.cpp:3856`: A failed BC3 remake falls through to an upload in the format that was just found unsuitable. *When:* If a BC1 texture receives non-opaque blocks or a BC5 texture receives colored blocks while BC3 allocation fails or the texture has block attachments, bc_remake returns false. upload_astc_gpu then encodes the new data as BC1 or BC5 and reports success, losing alpha or color. **Do:** Do not upload or mark the update successful in the unsuitable format; provide a correct fallback or preserve the pending update and retry after making a suitable image. - **L5** `tests/test_astc_opaque.py:7`: The new check hard-codes g++ instead of using the compiler selected by the test runner. *When:* On a supported Windows or Linux development setup with clang++ available but no g++, run_all skips this check or fails it in strict mode even though a suitable compiler is installed; CXX is ignored. **Do:** Pass the runner's {cxx} placeholder and use the selected compiler for direct invocation as well. - **L7** `gpu/vk/vk_texture.cpp:3408`: A failed cache write clears the dirty flag without scheduling a retry. (more on the line) **Do:** Restore the dirty flag under the mutex when saving fails, preserving any entries added during the save. **Testing before merging (1)** (runs on the systems it can change; it doesn't hold the recommendation) - **L6**: The default rendering and memory changes have not been exercised on the affected AMD Tier 1 systems or Steam Deck. *When:* The new BC formats, image allocation and retention policies run on AMD drivers and the Deck, but the supplied game runs cover NVIDIA only. **Do:** Run the requested five-area comparison and visual checks on AMD Windows, RADV Linux and Steam Deck, including frame pacing and memory. `@fix` can do L1, L2, L3, L4, L5 and L7. **Since the last review** (on 0a11cc3dd515) Still open: L1 (Copies between differently encoded BC textures, or into a BC1 or BC5 texture, can be silen…); L2 (A blit out of a BC5-kept texture does not apply the channel mapping used by its sampled vi…); L3 (A failed BC3 remake falls through to an upload in the format that was just found unsuitabl…); L4 (The scan treats every all-zero block as padding, including blocks that occupy actual texel…); L5 (The new check hard-codes g++ instead of using the compiler selected by the test runner.); L6 (The default rendering and memory changes have not been exercised on the affected AMD Tier…) New: L7 (A failed cache write clears the dirty flag without scheduling a retry.) **Checks:** Still running: 11 checks. <details> <summary>Also noticed (2; not asked for, not blocking)</summary> - The cache replacement removes the old file before renaming the temporary file, so interruption in between loses the saved cache. - The content memo can reach 200,001 entries while the file writer accepts at most 200,000. </details> <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Yes for measured VRAM use: the description reports a 2,655 MB lower driver average over three interleaved pairs on an RTX 5080, with frame metrics within the spread. The 6 GB laptop filled its budget on both versions; its reported 1.5% fps increase was within the spread. **Other systems:** The changes affect Vulkan texture formats, copies, allocation and timing on Windows and Linux. The reported game runs cover NVIDIA desktop and laptop GPUs; AMD Tier 1 systems and Steam Deck remain untested, and Intel Arc and a 4 GB card are also requested. **Switches:** The description lists BC1, BC5, trimmed BC, target overlap, stale alias, native BC mips, texture ahead, real size classes and untouched-page skipping on by default; sparse shadows and fused ASTC conversion default off. Stream buffer defaults to 512 KB, CPU unswizzle threshold to 64 MB, and Auto ASTC conversion and compaction thresholds change. NVIDIA measurements support the chosen defaults there; correctness and performance on other affected hardware remain unverified. **Reviewed:** 66492ca38fd3 against 7bc53f841323: Read the new ASTC kinds file and its tests, ASTC opacity helper and test runner, the relevant texture classification and copy paths, repository rules and PR template. Skimmed the remaining diff and switch table; the other changed files and their full callers were not read in full.; nothing run (a code review). **Checked and fine:** - The cache loader rejects truncated, oversized, version-mismatched and trailing-data files before adding entries. - The cache frame hook runs before the texture-ahead switch can return. **Testing:** No commands from the project or tests were run. The author reports six game runs on each of two NVIDIA systems; CI is still running. **Overlaps and merge order:** Not checked; the network is closed. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.</sub>
@ -3239,0 +3405,4 @@
if (++frames % 300) return;
astc_kinds_file::Map m;
{
std::lock_guard lk(kinds_memo_mu);
Member

L7 (should fix): A failed cache write clears the dirty flag without scheduling a retry.

When: If saving fails temporarily and no further new contents are scanned, later 300-frame checks see a clean cache and never retry; the next launch repeats the scans.

Do: Restore the dirty flag under the mutex when saving fails, preserving any entries added during the save.

**L7** (should fix): A failed cache write clears the dirty flag without scheduling a retry. *When:* If saving fails temporarily and no further new contents are scanned, later 300-frame checks see a clean cache and never retry; the next launch repeats the scans. **Do:** Restore the dirty flag under the mutex when saving fails, preserving any entries added during the save.
fix(vk): BC1 and BC5 textures through copies, error blocks, failed remakes and texture packs
Some checks failed
beanstalk/approval changed since the request: ask again
PR description / Title and description (pull_request_target) Has been cancelled
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
c7ebf0399f
- A copy into a BC1 or BC5 texture, or from one into another BC image, or out of a BC5 one, makes it BC3 first
  (texture_for_copy) instead of being skipped or blitting BC5's red and green.
- BC1 keeps an ASTC error block transparent black (three-colour blocks where a texel's alpha is under 128).
- A BC3 remake that cannot be made fails the upload instead of encoding into BC1 or BC5; an image made again is
  uploaded whole until an upload succeeds; with RX_VK_ASTC_BC7 it is made BC7, which the upload route encodes.
- A texture pack over a BC5 texture keeps all four channels.
- The kinds file: replaced in one step, a failed write tried again, a storage written while it was read not kept.
- test_astc_opaque takes the runner's compiler.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Assisted-by: Claude Sonnet 5.5
Owner
@review
BeanBot requested changes 2026-12-05 18:37:04 +00:00
Dismissed
BeanBot left a comment

Recommendation: Request changes. Copies into BC-kept textures can still be skipped for sources the encoder does not accept. The reported VRAM saving is substantial, but affected AMD hardware and Steam Deck coverage remains outstanding.

The change reduces texture and allocation VRAM use, with measured savings on a 16 GB NVIDIA GPU, at the cost of additional texture classification, conversion, caching and copy handling.

Blocking (2): must change before merging.

  1. L1 gpu/vk/vk_xfer.cpp:318: Copies from non-ASTC uncompressed textures into BC-kept destinations can still be discarded. When: For a same-size copy from a non-ASTC uncompressed source into a BC1 or BC5 destination, the destination is remade, but texture_copy_into_bc rejects the source because src->astc is false; copy_t2t then skips the copy. Do: Handle compatible uncompressed sources when encoding a copy into the remade BC destination, or provide another correct conversion path.
  2. L8: It conflicts with its base branch: bring it up to date (@​fix or @​rebase try first). (for the author)

Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)

  • L6: The default rendering and memory changes have not been exercised on the affected AMD Tier 1 systems or Steam Deck. When: The new BC formats, image allocation and retention policies run on AMD drivers and the Deck, but the supplied game runs cover NVIDIA only. Do: Run the requested five-area comparison and visual checks on AMD Windows, RADV Linux and Steam Deck, including frame pacing and memory.

@fix can do L1.

Since the last review (on 66492ca38f)
Resolved: L2 (A blit out of a BC5-kept texture does not apply the channel mapping used by its sampled vi…); L3 (A failed BC3 remake falls through to an upload in the format that was just found unsuitabl…); L4 (The scan treats every all-zero block as padding, including blocks that occupy actual texel…); L5 (The new check hard-codes g++ instead of using the compiler selected by the test runner.); L7 (A failed cache write clears the dirty flag without scheduling a retry.)
Still open: L1 (Copies from non-ASTC uncompressed textures into BC-kept destinations can still be discarde…); L6 (The default rendering and memory changes have not been exercised on the affected AMD Tier…)
New: L8 (It conflicts with its base branch: bring it up to date (@​fix or @​rebase try first).)

Checks: Still running: 11 checks.

More: does it help, other systems, switches, what was read

Does it help: Yes: the reported three-pair RTX 5080 comparison shows average driver VRAM falling from 9714 MB to 7059 MB, with frame rates and frame times within the reported spread. The 6 GB laptop comparison shows 4308 MB to 4248 MB and eight fewer frames of at least 50 ms; the later fix has not been measured separately.

Other systems: The renderer changes affect GPU formats, uploads, memory and timing across vendors and platforms. The reported game runs cover NVIDIA on Windows and Linux; AMD Tier 1 systems, Steam Deck, Intel Arc and a 4 GB card remain untested in the supplied results.

Switches: The PR adds or changes the switches listed in its measurements table. Defaults are measured on the two NVIDIA systems; their suitability on affected AMD systems and Steam Deck remains unverified. The fix changes the BC1 and BC5 switch descriptions, not their defaults.

Reviewed: c7ebf0399f against 7bc53f8413: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the fix diff, astc_opaque.h and test_astc_opaque.py in full; inspected the relevant copy, texture classification, cache and shader paths. The complete original PR diff and all changed files were not read in full. The review checklist and adjacent Tooling AGENTS.md were absent.; nothing run (a code review).

Checked and fine:

  • A failed cache save marks the cache dirty again under its mutex.
  • The selected compiler is forwarded to the ASTC opacity check.

Testing: No code or tests were run. The supplied CI checks are still running; the author reports game runs on NVIDIA Windows and Linux systems.

Overlaps and merge order: Not checked.


Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.

**Recommendation: Request changes.** Copies into BC-kept textures can still be skipped for sources the encoder does not accept. The reported VRAM saving is substantial, but affected AMD hardware and Steam Deck coverage remains outstanding. The change reduces texture and allocation VRAM use, with measured savings on a 16 GB NVIDIA GPU, at the cost of additional texture classification, conversion, caching and copy handling. **Blocking (2)**: must change before merging. 1. **L1** `gpu/vk/vk_xfer.cpp:318`: Copies from non-ASTC uncompressed textures into BC-kept destinations can still be discarded. *When:* For a same-size copy from a non-ASTC uncompressed source into a BC1 or BC5 destination, the destination is remade, but texture_copy_into_bc rejects the source because src->astc is false; copy_t2t then skips the copy. **Do:** Handle compatible uncompressed sources when encoding a copy into the remade BC destination, or provide another correct conversion path. 2. **L8**: It conflicts with its base branch: bring it up to date (`@​fix` or `@​rebase` try first). *(for the author)* **Testing before merging (1)** (runs on the systems it can change; it doesn't hold the recommendation) - **L6**: The default rendering and memory changes have not been exercised on the affected AMD Tier 1 systems or Steam Deck. *When:* The new BC formats, image allocation and retention policies run on AMD drivers and the Deck, but the supplied game runs cover NVIDIA only. **Do:** Run the requested five-area comparison and visual checks on AMD Windows, RADV Linux and Steam Deck, including frame pacing and memory. `@fix` can do L1. **Since the last review** (on 66492ca38fd3) Resolved: L2 (A blit out of a BC5-kept texture does not apply the channel mapping used by its sampled vi…); L3 (A failed BC3 remake falls through to an upload in the format that was just found unsuitabl…); L4 (The scan treats every all-zero block as padding, including blocks that occupy actual texel…); L5 (The new check hard-codes g++ instead of using the compiler selected by the test runner.); L7 (A failed cache write clears the dirty flag without scheduling a retry.) Still open: L1 (Copies from non-ASTC uncompressed textures into BC-kept destinations can still be discarde…); L6 (The default rendering and memory changes have not been exercised on the affected AMD Tier…) New: L8 (It conflicts with its base branch: bring it up to date (`@​fix` or `@​rebase` try first).) **Checks:** Still running: 11 checks. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Yes: the reported three-pair RTX 5080 comparison shows average driver VRAM falling from 9714 MB to 7059 MB, with frame rates and frame times within the reported spread. The 6 GB laptop comparison shows 4308 MB to 4248 MB and eight fewer frames of at least 50 ms; the later fix has not been measured separately. **Other systems:** The renderer changes affect GPU formats, uploads, memory and timing across vendors and platforms. The reported game runs cover NVIDIA on Windows and Linux; AMD Tier 1 systems, Steam Deck, Intel Arc and a 4 GB card remain untested in the supplied results. **Switches:** The PR adds or changes the switches listed in its measurements table. Defaults are measured on the two NVIDIA systems; their suitability on affected AMD systems and Steam Deck remains unverified. The fix changes the BC1 and BC5 switch descriptions, not their defaults. **Reviewed:** c7ebf0399f55 against 7bc53f841323: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the fix diff, astc_opaque.h and test_astc_opaque.py in full; inspected the relevant copy, texture classification, cache and shader paths. The complete original PR diff and all changed files were not read in full. The review checklist and adjacent Tooling AGENTS.md were absent.; nothing run (a code review). **Checked and fine:** - A failed cache save marks the cache dirty again under its mutex. - The selected compiler is forwarded to the ASTC opacity check. **Testing:** No code or tests were run. The supplied CI checks are still running; the author reports game runs on NVIDIA Windows and Linux systems. **Overlaps and merge order:** Not checked. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.</sub>
HumanBean force-pushed perf/vk-vram from c7ebf0399f
Some checks failed
beanstalk/approval changed since the request: ask again
PR description / Title and description (pull_request_target) Has been cancelled
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
to a200c870ec
Some checks are pending
CI / What the change needs (pull_request) Successful in 8s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Waiting to run
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Waiting to run
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Waiting to run
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Waiting to run
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Waiting to run
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Waiting to run
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Waiting to run
CI / Website build and checks (pull_request) Waiting to run
CI / Third-party parts and guide screenshots (pull_request) Successful in 13s
beanstalk/approval changed since the request: ask again
PR description / Title and description (pull_request_target) Successful in 8s
2026-12-05 19:02:36 +00:00
Compare
Owner

Pushed review fix-ups and rebased onto main (bb5a5682). Head is now a200c870. The branch was force-pushed: before the rebase it was c7ebf039 (a fast-forward on your 66492ca3). Your commits keep you as author. The one conflict was in tests/test_device_policy.py: main's new switch name with this PR's value.

BeanBot's findings:

  • L1 (copies): a copy into a BC1 or BC5 texture, from one into another BC image, or out of a BC5 one, now makes it BC3 first and uploads it whole, instead of being skipped or blitting BC5's red and green. Copies from other uncompressed colour textures into a BC-kept one are encoded too (tests/bc_scratch_batches_test.cpp has those cases). The remake-on-copy path has no test of its own.
  • L2: covered by L1's remake.
  • L3: if the BC3 image cannot be made, the upload fails and is retried; nothing is encoded into BC1 or BC5.
  • L4: handled in the encoder rather than the scan. A BC1 block with a transparent texel (an ASTC error block) uses the three-colour form, so it stays transparent black. tests/astc_decoder_gpu.cpp checks it on the GPU.
  • L5, L7, the non-atomic cache replace and the memo bound: fixed.
  • L8: rebased.

A second, cold review of the whole branch found these, also fixed:

  • a copy after a failed re-upload went into an empty image;
  • a texture pack over a BC5 texture sampled blue as 0 and alpha as 1;
  • with RX_VK_ASTC_BC7, a remade texture was a BC3 image given BC7 blocks;
  • the kinds file could keep a result for a storage written while it was read;
  • the stream growth log said "0 MB".

Not fixed: a BC5-kept texture later sampled through an sRGB view gets no sRGB decode (BC5 has none). I have not checked whether the game ever does that.

Checked here (CachyOS, RTX 3090): the renderer compiles for Linux and for Windows (llvm-mingw) with no warnings, and the ASTC decoder and BC encoder GPU fixture passes. run_all.py on a200c870's tree had 13 failures: 12 also fail on main alone, and the 13th (test_bc_scratch_layers) was from the copy fix and passes after updating its stand-ins.

An A/B of this head on an AMD RX 580 (RADV) is running; results will follow.

🤖 Generated with Claude Code

Pushed review fix-ups and rebased onto `main` (`bb5a5682`). Head is now `a200c870`. The branch was force-pushed: before the rebase it was `c7ebf039` (a fast-forward on your `66492ca3`). Your commits keep you as author. The one conflict was in `tests/test_device_policy.py`: `main`'s new switch name with this PR's value. BeanBot's findings: - **L1** (copies): a copy into a BC1 or BC5 texture, from one into another BC image, or out of a BC5 one, now makes it BC3 first and uploads it whole, instead of being skipped or blitting BC5's red and green. Copies from other uncompressed colour textures into a BC-kept one are encoded too (`tests/bc_scratch_batches_test.cpp` has those cases). The remake-on-copy path has no test of its own. - **L2**: covered by L1's remake. - **L3**: if the BC3 image cannot be made, the upload fails and is retried; nothing is encoded into BC1 or BC5. - **L4**: handled in the encoder rather than the scan. A BC1 block with a transparent texel (an ASTC error block) uses the three-colour form, so it stays transparent black. `tests/astc_decoder_gpu.cpp` checks it on the GPU. - **L5, L7**, the non-atomic cache replace and the memo bound: fixed. - **L8**: rebased. A second, cold review of the whole branch found these, also fixed: - a copy after a failed re-upload went into an empty image; - a texture pack over a BC5 texture sampled blue as 0 and alpha as 1; - with `RX_VK_ASTC_BC7`, a remade texture was a BC3 image given BC7 blocks; - the kinds file could keep a result for a storage written while it was read; - the stream growth log said "0 MB". Not fixed: a BC5-kept texture later sampled through an sRGB view gets no sRGB decode (BC5 has none). I have not checked whether the game ever does that. Checked here (CachyOS, RTX 3090): the renderer compiles for Linux and for Windows (llvm-mingw) with no warnings, and the ASTC decoder and BC encoder GPU fixture passes. `run_all.py` on `a200c870`'s tree had 13 failures: 12 also fail on `main` alone, and the 13th (`test_bc_scratch_layers`) was from the copy fix and passes after updating its stand-ins. An A/B of this head on an AMD RX 580 (RADV) is running; results will follow. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Owner
@review
Owner
@review
BeanBot left a comment

Recommendation: Request changes. Copies from some uncompressed color textures into BC-kept destinations can still be skipped. The renderer changes also await the affected AMD and Steam Deck runs.

The change reduces texture and render-target VRAM use, with additional upload and memory-management changes. It saves substantial VRAM in the reported NVIDIA tour, at the cost of creation-time scans and extra retained memory for texture preloading.

Blocking (1): must change before merging.

  1. L1 gpu/vk/vk_xfer.cpp:318: Some non-ASTC uncompressed color sources are still rejected when copied into a BC-kept destination. When: For a same-size copy from a one-byte color source without the linear-filter format feature into a BC-kept ASTC texture, texture_copy_into_bc returns false and copy_t2t skips the copy. Do: Provide a compatible conversion or a destination fallback for these sources, and test that the destination receives the copied content.

Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)

  • L6: The default rendering and memory changes have not been exercised on the affected AMD Tier 1 systems or Steam Deck. When: The new BC formats, image allocation and retention policies run on AMD drivers and the Deck, but the supplied game runs cover NVIDIA only. Do: Run the requested five-area comparison and visual checks on AMD Windows, RADV Linux and Steam Deck, including frame pacing and memory.

@fix can do L1.

Since the last review (on c7ebf0399f)
Resolved: L8 (It conflicts with its base branch: bring it up to date (@​fix or @​rebase try first).)
Still open: L1 (Some non-ASTC uncompressed color sources are still rejected when copied into a BC-kept des…); L6 (The default rendering and memory changes have not been exercised on the affected AMD Tier…)

Checks: Still running: 11 checks.

Also noticed (1; not asked for, not blocking)
  • A BC5-kept texture later sampled through an sRGB view may miss sRGB decoding, as the author noted; game use is unconfirmed.
More: does it help, other systems, switches, what was read

Does it help: Yes: the reported three-pair RTX 5080 tour reduced average driver VRAM from 9714 MB to 7059 MB, with frame metrics within the run spread. The 6 GB laptop remained near its budget; its reported 1% low rose from 15.4 to 15.9 fps and median frames of at least 50 ms fell from 145 to 137. These measurements predate the current head.

Other systems: The changes affect Vulkan texture formats, transfers, memory retention and upload timing across GPU vendors and operating systems. NVIDIA Windows and Linux game runs are reported; AMD Tier 1 and Steam Deck coverage remains outstanding, as do the requested Intel and 4 GB runs.

Switches: BC1, BC5, trimmed BC, native BC mip trimming, target-layer eviction, stale-alias eviction, texture preloading and real size classification default on. Fused ASTC encoding and sparse shadows default off. Zero-page skipping defaults to 1 on Windows; the unswizzle threshold is 64 MB, stream buffer 512 KB, sparse grain 1024 KB, and pack retention one 32nd of the VRAM allowance. Compaction Auto changes to one 64th, bounded at 64–128 MB; ASTC-to-BC Auto changes to 0 MB. The reported NVIDIA measurements support these choices, but affected hardware coverage is incomplete.

Reviewed: a200c870ec against bb5a5682ce: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the changed copy function and its caller, relevant switch definitions, the rebase/fix diff, and the supplied comments and measurements. The rest of the large pull request diff, changed code files, tests and project standards were not read in full; docs/review-checklist.md was absent.; nothing run (a code review).

Checked and fine:

  • The new copy path handles eligible non-four-byte color formats through a blit and batches layers through the existing encoder.
  • The supplied build report covers Linux and Windows renderer compilation and the ASTC decoder GPU fixture.

Testing: No commands from the project were run. The supplied NVIDIA game runs and GPU fixture are useful evidence; complete the requested AMD Tier 1 and Steam Deck runs, and verify the remaining copy cases with a behavior test.

Overlaps and merge order: Not checked; the network is closed.


Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.

**Recommendation: Request changes.** Copies from some uncompressed color textures into BC-kept destinations can still be skipped. The renderer changes also await the affected AMD and Steam Deck runs. The change reduces texture and render-target VRAM use, with additional upload and memory-management changes. It saves substantial VRAM in the reported NVIDIA tour, at the cost of creation-time scans and extra retained memory for texture preloading. **Blocking (1)**: must change before merging. 1. **L1** `gpu/vk/vk_xfer.cpp:318`: Some non-ASTC uncompressed color sources are still rejected when copied into a BC-kept destination. *When:* For a same-size copy from a one-byte color source without the linear-filter format feature into a BC-kept ASTC texture, texture_copy_into_bc returns false and copy_t2t skips the copy. **Do:** Provide a compatible conversion or a destination fallback for these sources, and test that the destination receives the copied content. **Testing before merging (1)** (runs on the systems it can change; it doesn't hold the recommendation) - **L6**: The default rendering and memory changes have not been exercised on the affected AMD Tier 1 systems or Steam Deck. *When:* The new BC formats, image allocation and retention policies run on AMD drivers and the Deck, but the supplied game runs cover NVIDIA only. **Do:** Run the requested five-area comparison and visual checks on AMD Windows, RADV Linux and Steam Deck, including frame pacing and memory. `@fix` can do L1. **Since the last review** (on c7ebf0399f55) Resolved: L8 (It conflicts with its base branch: bring it up to date (`@​fix` or `@​rebase` try first).) Still open: L1 (Some non-ASTC uncompressed color sources are still rejected when copied into a BC-kept des…); L6 (The default rendering and memory changes have not been exercised on the affected AMD Tier…) **Checks:** Still running: 11 checks. <details> <summary>Also noticed (1; not asked for, not blocking)</summary> - A BC5-kept texture later sampled through an sRGB view may miss sRGB decoding, as the author noted; game use is unconfirmed. </details> <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Yes: the reported three-pair RTX 5080 tour reduced average driver VRAM from 9714 MB to 7059 MB, with frame metrics within the run spread. The 6 GB laptop remained near its budget; its reported 1% low rose from 15.4 to 15.9 fps and median frames of at least 50 ms fell from 145 to 137. These measurements predate the current head. **Other systems:** The changes affect Vulkan texture formats, transfers, memory retention and upload timing across GPU vendors and operating systems. NVIDIA Windows and Linux game runs are reported; AMD Tier 1 and Steam Deck coverage remains outstanding, as do the requested Intel and 4 GB runs. **Switches:** BC1, BC5, trimmed BC, native BC mip trimming, target-layer eviction, stale-alias eviction, texture preloading and real size classification default on. Fused ASTC encoding and sparse shadows default off. Zero-page skipping defaults to 1 on Windows; the unswizzle threshold is 64 MB, stream buffer 512 KB, sparse grain 1024 KB, and pack retention one 32nd of the VRAM allowance. Compaction Auto changes to one 64th, bounded at 64–128 MB; ASTC-to-BC Auto changes to 0 MB. The reported NVIDIA measurements support these choices, but affected hardware coverage is incomplete. **Reviewed:** a200c870ec1c against bb5a5682cea3: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the changed copy function and its caller, relevant switch definitions, the rebase/fix diff, and the supplied comments and measurements. The rest of the large pull request diff, changed code files, tests and project standards were not read in full; docs/review-checklist.md was absent.; nothing run (a code review). **Checked and fine:** - The new copy path handles eligible non-four-byte color formats through a blit and batches layers through the existing encoder. - The supplied build report covers Linux and Windows renderer compilation and the ASTC decoder GPU fixture. **Testing:** No commands from the project were run. The supplied NVIDIA game runs and GPU fixture are useful evidence; complete the requested AMD Tier 1 and Steam Deck runs, and verify the remaining copy cases with a behavior test. **Overlaps and merge order:** Not checked; the network is closed. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.</sub>
Owner

On BeanBot's review of a200c870:

L1 (an integer one-byte source copied into a BC-kept texture): not changing this. main (bb5a5682) skips that copy too, so the PR loses nothing:

  • where main keeps the destination as BC3, texture_copy_into_bc takes only ASTC sources;
  • where main keeps it as RGBA8, copy_t2t finds the sizes incompatible (1 byte against 4) and then refuses the blit, because the format classes differ (integer against normalized): "texture blit the device cannot make: skipped".

Converting integer values into a colour texture has no defined result in Vulkan to reproduce. tests/bc_scratch_batches_test.cpp checks that such a source writes nothing, next to the cases that are copied.

sRGB view of a BC5-kept texture ("also noticed"): still open as I noted above; not confirmed that the game does it.

L6: the RADV run on an RX 580 is in progress. AMD on Windows and the Steam Deck need the Test Farm.

🤖 Generated with Claude Code

On BeanBot's review of `a200c870`: **L1** (an integer one-byte source copied into a BC-kept texture): not changing this. `main` (`bb5a5682`) skips that copy too, so the PR loses nothing: - where `main` keeps the destination as BC3, `texture_copy_into_bc` takes only ASTC sources; - where `main` keeps it as RGBA8, `copy_t2t` finds the sizes incompatible (1 byte against 4) and then refuses the blit, because the format classes differ (integer against normalized): "texture blit the device cannot make: skipped". Converting integer values into a colour texture has no defined result in Vulkan to reproduce. `tests/bc_scratch_batches_test.cpp` checks that such a source writes nothing, next to the cases that are copied. **sRGB view of a BC5-kept texture** ("also noticed"): still open as I noted above; not confirmed that the game does it. **L6**: the RADV run on an RX 580 is in progress. AMD on Windows and the Steam Deck need the Test Farm. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Author
Contributor

Thanks for bf3b6513 and a200c870: they cover the review's L1-L5 (my own fix for L1-L3/L5 was the same idea, dropped in favour of yours). Built a200c870 on Windows 11, RTX 5080: smoke PASS (in play from kokiri-start, BC1/BC5 textures made, no error); the kinds file starts again from empty, as its format changed.

Thanks for bf3b6513 and a200c870: they cover the review's L1-L5 (my own fix for L1-L3/L5 was the same idea, dropped in favour of yours). Built a200c870 on Windows 11, RTX 5080: smoke PASS (in play from kokiri-start, BC1/BC5 textures made, no error); the kinds file starts again from empty, as its format changed.
Owner

AMD results for a200c870 (RX 580, RADV, 3 A/B pairs against main bb5a5682) are in the description.

Good: no device loss, the screenshots of four areas match main, the ASTC/BC GPU fixture passes with validation on, and GTT use is 688 MB lower.

Not good, and worth looking at before merge:

  • frames of 100 ms or more: 8 to 11, and the worst frame 173 to 228 ms, with every PR run above every main run;
  • no VRAM saving on this 8 GB card (+155 MB);
  • major page faults 10 to 110.

An earlier run of c7ebf039 on the same card also had longer worst frames. I have not isolated which switch causes it. fps, 1% low, p99 and frames of 50 ms or more are within the spread.

🤖 Generated with Claude Code

AMD results for `a200c870` (RX 580, RADV, 3 A/B pairs against `main` `bb5a5682`) are in the description. Good: no device loss, the screenshots of four areas match `main`, the ASTC/BC GPU fixture passes with validation on, and GTT use is 688 MB lower. Not good, and worth looking at before merge: - frames of 100 ms or more: 8 to 11, and the worst frame 173 to 228 ms, with every PR run above every `main` run; - no VRAM saving on this 8 GB card (+155 MB); - major page faults 10 to 110. An earlier run of `c7ebf039` on the same card also had longer worst frames. I have not isolated which switch causes it. fps, 1% low, p99 and frames of 50 ms or more are within the spread. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Author
Contributor

Thanks for the RX 580 runs. The longer worst frames don't show on NVIDIA: on the 6 GB RTX 3060 Laptop (CachyOS, its VRAM budget full on both sides) the median worst frame went 382 → 347 ms, and on the RTX 5080 150 → 160 ms, within that PC's spread (138-206 ms on both sides). So it looks tied to RADV, or to a full 8 GB card spilling into GTT.

Suspects, most likely first. Each is one switch set against this head, same tour and 3 pairs (dev.py ab --env X=0):

  1. RX_VK_TEX_AHEAD=0: on by default in this PR, off on main. It makes the textures an earlier load drew before their first draw, and held about 250 MB more VRAM on the RTX 5080. On a full 8 GB card that could be the +155 MB, pushing other memory out to GTT at an area change.
  2. RX_VK_UNSWIZZLE_IMPORT_MB=0: big textures under 64 MB are unswizzled on the CPU instead of imported, so the CPU reads the guest pages. It is the likeliest source of the major page faults (10 → 110) and of the 688 MB less GTT.
  3. RX_VK_ASTC_BC5=0, then RX_VK_ASTC_BC1=0: BC5 had load frames +15 ms on the RTX 5080.

(RX_VK_ZERO_UNTOUCHED is Windows-only, so not in play there.)

Whichever brings the worst frame back to main's, I'll turn it off by default where it costs more than it saves, with the numbers in the description.

Thanks for the RX 580 runs. The longer worst frames don't show on NVIDIA: on the 6 GB RTX 3060 Laptop (CachyOS, its VRAM budget full on both sides) the median worst frame went 382 → 347 ms, and on the RTX 5080 150 → 160 ms, within that PC's spread (138-206 ms on both sides). So it looks tied to RADV, or to a full 8 GB card spilling into GTT. Suspects, most likely first. Each is one switch set against this head, same tour and 3 pairs (`dev.py ab --env X=0`): 1. `RX_VK_TEX_AHEAD=0`: on by default in this PR, off on `main`. It makes the textures an earlier load drew before their first draw, and held about 250 MB more VRAM on the RTX 5080. On a full 8 GB card that could be the +155 MB, pushing other memory out to GTT at an area change. 2. `RX_VK_UNSWIZZLE_IMPORT_MB=0`: big textures under 64 MB are unswizzled on the CPU instead of imported, so the CPU reads the guest pages. It is the likeliest source of the major page faults (10 → 110) and of the 688 MB less GTT. 3. `RX_VK_ASTC_BC5=0`, then `RX_VK_ASTC_BC1=0`: BC5 had load frames +15 ms on the RTX 5080. (`RX_VK_ZERO_UNTOUCHED` is Windows-only, so not in play there.) Whichever brings the worst frame back to `main`'s, I'll turn it off by default where it costs more than it saves, with the numbers in the description.
HumanBean deleted branch perf/vk-vram 2026-12-05 22:04:11 +00:00
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!3259
No description provided.