perf(vk): ASTC levels of 1024 or less re-encode to BC eight layers a run, through a small scratch #1843

Merged
HumanBean merged 3 commits from GrimVisage/Longshot:feat/astc-ahead into main 2026-11-20 07:31:32 +00:00
Contributor

Summary

Entering an area with big ASTC texture arrays holds the GPU for hundreds of milliseconds on cards without ASTC. Hyrule Field's terrain material arrays (1365 x 1365 x 90) are the clearest case. Each array is decoded and re-encoded to BC3 through a scratch image, one layer at a time. A run is a decode, an encode, a copy and three full barriers, so one array makes ~990 runs, and the GPU spends most of that time between them. On an RX 9070 XT the never-put-off arrays took ~50 ms each.

One layer a run was the fix for Hyrule Field's grid lines on an RX 6600 (ec89f92e), whose cause was never found. Runs still never cross a repacked level (!repack in upload_astc_gpu, since #1553), and multi-layer runs showed no grid lines on RDNA4 RADV. So mip levels of 1024 x 1024 or less now go through a second, small scratch of 8 layers, 8 layers a run. The 2048 x 2048 scratch, the copies into BC textures and RX_VK_BC_LAYERS stay as they were. RX_VK_BC_SMALL_LAYERS=1 brings back one layer a run.

The first commit makes this measurable. RX_VK_PASS_TIMING now times each texture's decode and re-encode as an astc span, split by whether the upload budget can put it off.

To see it on main: enter Hyrule Field (from the Castle Town gate) with RX_VK_PASS_TIMING=1 on this branch and RX_VK_BC_SMALL_LAYERS=1. The astc decode + BC re-encode (never put off ...) row shows ~50 ms a span.

Read first: gpu/vk/vk_texture.cpp: upload_astc_gpu (the small level choice and its runs), bc_scratch_make, bc_scratch_layout, bc_scratch_idle.

See #1720, See #1787 (the field-entry hitch in its logs; not its drops in play). Related: #1833 changes the same loop (bounded submissions for Windows iGPUs). This leaves it less work per submission; whichever merges second needs a small rebase.

Changed in review (HumanBean): rebased onto main after #1763 (one render thread) and #1833 (bounded ASTC upload submissions), and:

  • the per-texture astc span closes before each upload chunk's flush and opens again after, so it never counts the CPU's wait as GPU time;
  • the small scratch isn't made on a small-VRAM card (low_vram_texture_mips) or where it would land in system memory (logged once), and the output buffer grows only when it was made;
  • a BC run is no longer than an upload chunk holds (RX_VK_ASTC_CHUNK_MPX);
  • the given-back log sums what is actually freed; the comments say 36 MB;
  • #1833's chunking test has stubs for the small scratch and the span, and this PR's checks follow the new lines.

The measurements below are from before this rebase (79d83b03, without #1833); they weren't taken again.

Testing

Tested: Linux (Fedora 45, kernel 7.3), RX 9070 XT, Mesa RADV. The branch's dev.py runtime, from a test save through the Castle Town gate into Hyrule Field and 120 s of running with the camera turning. 4 runs, interleaved between the default and RX_VK_BC_SMALL_LAYERS=1. No device lost, no errors. The far ground in each run's arrival screenshot (a pair is in the comments) shows no grid lines, and none were visible watching the runs. An earlier series on a main build with RX_VK_BC_LAYERS=8 (8 layers a run at every level, through the big scratch) showed none either.

Checks: tests/test_bc_small_scratch.py fails on main ("no small scratch: every ASTC-to-BC run is one layer, whatever its level's size") and passes here. tests/test_astc_pass_timing.py, tests/test_bc_scratch_layers.py, tests/test_switch_table.py, tests/test_mem_trim.py and tests/test_bc_upload_retry.py pass. tests/test_parallel_init_order.py's fixture now has stubs for the small scratch; it fails to build on main (host_read_barrier, FpsRtWait) and fails the same way here. mise run test (--strict; clang++, spirv-val, dav1d, the pinned headers and glslang present; lld was installed after the full run, which then passed test_thinlto_tls alone): 800 passed, 56 failed, 17 skipped (Windows-only) in the full run; 801 and 55 with test_thinlto_tls. None of the failures is new: the same checks run on a main checkout (08994a9e) fail there too (54 distinct checks now, none passes on main). I haven't looked into why they fail; the ones I sampled fail on main's own stale expectations (e.g. vk_texture.cpp's arenas are no longer 64 MB: update this test, a fixture that doesn't compile). Failing on main too: appimage_player_build bug_report_defaults capture_readback_visibility capture_read_once crash_dialog crt_options damage_debug_menu dev_ab dev_packs display_startup_failure dlss_feature_size draw_stream_visibility failed_compile_keeps_objects frame_overlap fsr3fi_hud_layer fsr_image_retirement fsr_uniform_ownership guest_imported high_fps_fixes host_guest_writes hud_layout_row libc_hooks lift_cache linux_preflight linux_pressure linux_tools linux_update log_open_failure make_game_ngx mise_build missing_nup mods_list mods_size_table ngx_sdk nonuniform_image_arrays parallel_init_order pending_guest_import pipeline_play_cache prepare_cache_save present_queue_default present_source_crop present_thread profiling_mode psychov35_fsr3_fg readback_timeout_source replay_write_order slow_frames song_note_cue staging_burst texel_buffer_ownership upscaler_rows vcore_escape vk_occlusion_queries walk_key (tests/ unless nx2/). One of them, test_parallel_init_order, reads bc_scratch_layout: its fixture stops on main's errors (host_read_barrier, FpsRtWait) before reaching it, on main and here alike, so it doesn't check this change. After those runs the branch was rebased onto main 3f2c9b3c (#1838, which changes only tests/test_nfc_scan_hint.py); the four checks named above pass again there.

Still to test:

  • Windows and Linux AMD, Windows NVIDIA (windows+amd+dgpu, linux+radv, windows+nvidia): enter Hyrule Field from the Castle Town gate and look across the field, expecting no grid lines on the far ground (@Beanstalk test Windows AMD dGPU, Linux RADV and Windows NVIDIA on Hyrule Field)
  • Steam Deck (steamdeck): the same, expecting no grid lines and the entry no longer than on main (@Beanstalk test the Steam Deck on Hyrule Field)
  • RX 6000 on Linux (#1787's RX 6700 XT, or the RX 6600 that showed the grid lines): the same, by hand

Measurements

Verdict: The never-put-off arrays' decode and BC re-encode at Hyrule Field's entry take 16.1-17.5 ms of GPU time a texture, against 49.7-49.9 ms with one layer a run: about 3x less, ~260 ms of GPU work fewer at the entry. GPU time in play afterwards is the same within the spread.

Setup: Linux (Fedora 45), RX 9070 XT, Mesa RADV; 2560 x 1440 fullscreen, the same options file every run (Debug tools and the FPS counter off). The branch's runtime (dev.py pack over the 068fb8eb base), A = RX_VK_BC_SMALL_LAYERS=1 (one layer a run, as main), B = default. Runs interleaved B, A, B, A, each a job of the PC's queue in timing mode under a 20 GB cap (never reached): test save, teleport to the Market, out of the gate into Hyrule Field, 120 s of running. Every run with RX_VK_PASS_TIMING=1 RX_VK_FRAME_GATE=0 RX_VK_CAPTURE_NT=1.

Baseline: the same build with RX_VK_BC_SMALL_LAYERS=1, which runs one layer a run as main does: main has no astc span to read the decode and re-encode from (the first commit adds it). 79d83b03 is this branch before its rebase onto 3f2c9b3c, which changes only tests/test_nfc_scan_hint.py.

Before, A, one layer a run (RX_VK_BC_SMALL_LAYERS=1): this PR @ 79d83b03 After, B, the default: this PR @ 79d83b03
astc decode + BC re-encode (never put off), GPU per texture 49.9 ms, 49.7 ms 16.1 ms, 17.5 ms
the same, a frame over the report's 600 presents 0.665, 0.662 ms 0.215, 0.233 ms
the entry frame's uploads (replay thread) 106, 97 ms 96, 100 ms
GPU time a frame in play (last 6 reports) 10.7, 10.4 ms 11.1, 10.0 ms

The CPU side of the entry frame's uploads doesn't change: the replay records the same work, in fewer runs.

# A (vc-sml1a)
vk:   u   0.665 ms     0.0 x  49859.2 us       0.0 items    0.20 MB  astc decode + BC re-encode (never put off: a layer array, or over 1024x1024)
# B (vc-sml8a)
vk:   u   0.215 ms     0.0 x  16127.3 us       0.0 items    0.20 MB  astc decode + BC re-encode (never put off: a layer array, or over 1024x1024)

Risks

  • 36 MB more VRAM (32 MB scratch, 4 MB more output buffer), held once the first BC texture is made (as the first scratch is: RX_VK_BC_IDLE_S). Not made on a small-VRAM card or out of VRAM. RX_VK_BC_SMALL_LAYERS=1 doesn't make the small scratch.
  • Grid lines on the far ground if a multi-layer run went wrong on some driver. The cause found is fixed and none showed on RADV; Still to test covers the rest. RX_VK_BC_SMALL_LAYERS=1 turns it off.
  • After updating: nothing changes in saves, longshot_options.ini or the caches.

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.
  • Screenshots of the same spot on main and here, for a change that shows on screen. (In this comment: the same build with RX_VK_BC_SMALL_LAYERS=1, as main, and the default; see Baseline)
  • Docs updated.
  • 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 Entering an area with big ASTC texture arrays holds the GPU for hundreds of milliseconds on cards without ASTC. Hyrule Field's terrain material arrays (1365 x 1365 x 90) are the clearest case. Each array is decoded and re-encoded to BC3 through a scratch image, one layer at a time. A run is a decode, an encode, a copy and three full barriers, so one array makes ~990 runs, and the GPU spends most of that time between them. On an RX 9070 XT the never-put-off arrays took ~50 ms each. One layer a run was the fix for Hyrule Field's grid lines on an RX 6600 (ec89f92e), whose cause was never found. Runs still never cross a repacked level (`!repack` in `upload_astc_gpu`, since #1553), and multi-layer runs showed no grid lines on RDNA4 RADV. So mip levels of 1024 x 1024 or less now go through a second, small scratch of 8 layers, 8 layers a run. The 2048 x 2048 scratch, the copies into BC textures and `RX_VK_BC_LAYERS` stay as they were. `RX_VK_BC_SMALL_LAYERS=1` brings back one layer a run. The first commit makes this measurable. `RX_VK_PASS_TIMING` now times each texture's decode and re-encode as an `astc` span, split by whether the upload budget can put it off. To see it on `main`: enter Hyrule Field (from the Castle Town gate) with `RX_VK_PASS_TIMING=1` on this branch and `RX_VK_BC_SMALL_LAYERS=1`. The `astc decode + BC re-encode (never put off ...)` row shows ~50 ms a span. Read first: `gpu/vk/vk_texture.cpp`: `upload_astc_gpu` (the `small` level choice and its runs), `bc_scratch_make`, `bc_scratch_layout`, `bc_scratch_idle`. See #1720, See #1787 (the field-entry hitch in its logs; not its drops in play). Related: #1833 changes the same loop (bounded submissions for Windows iGPUs). This leaves it less work per submission; whichever merges second needs a small rebase. **Changed in review (HumanBean):** rebased onto main after #1763 (one render thread) and #1833 (bounded ASTC upload submissions), and: - the per-texture `astc` span closes before each upload chunk's flush and opens again after, so it never counts the CPU's wait as GPU time; - the small scratch isn't made on a small-VRAM card (`low_vram_texture_mips`) or where it would land in system memory (logged once), and the output buffer grows only when it was made; - a BC run is no longer than an upload chunk holds (`RX_VK_ASTC_CHUNK_MPX`); - the given-back log sums what is actually freed; the comments say 36 MB; - #1833's chunking test has stubs for the small scratch and the span, and this PR's checks follow the new lines. The measurements below are from before this rebase (79d83b03, without #1833); they weren't taken again. ## Testing **Tested:** Linux (Fedora 45, kernel 7.3), RX 9070 XT, Mesa RADV. The branch's `dev.py` runtime, from a test save through the Castle Town gate into Hyrule Field and 120 s of running with the camera turning. 4 runs, interleaved between the default and `RX_VK_BC_SMALL_LAYERS=1`. No device lost, no errors. The far ground in each run's arrival screenshot (a pair is in the comments) shows no grid lines, and none were visible watching the runs. An earlier series on a `main` build with `RX_VK_BC_LAYERS=8` (8 layers a run at every level, through the big scratch) showed none either. Checks: `tests/test_bc_small_scratch.py` fails on `main` ("no small scratch: every ASTC-to-BC run is one layer, whatever its level's size") and passes here. `tests/test_astc_pass_timing.py`, `tests/test_bc_scratch_layers.py`, `tests/test_switch_table.py`, `tests/test_mem_trim.py` and `tests/test_bc_upload_retry.py` pass. `tests/test_parallel_init_order.py`'s fixture now has stubs for the small scratch; it fails to build on `main` (`host_read_barrier`, `FpsRtWait`) and fails the same way here. `mise run test` (--strict; `clang++`, `spirv-val`, dav1d, the pinned headers and glslang present; `lld` was installed after the full run, which then passed `test_thinlto_tls` alone): 800 passed, 56 failed, 17 skipped (Windows-only) in the full run; 801 and 55 with `test_thinlto_tls`. None of the failures is new: the same checks run on a `main` checkout (08994a9e) fail there too (54 distinct checks now, none passes on main). I haven't looked into why they fail; the ones I sampled fail on main's own stale expectations (e.g. `vk_texture.cpp's arenas are no longer 64 MB: update this test`, a fixture that doesn't compile). Failing on main too: appimage_player_build bug_report_defaults capture_readback_visibility capture_read_once crash_dialog crt_options damage_debug_menu dev_ab dev_packs display_startup_failure dlss_feature_size draw_stream_visibility failed_compile_keeps_objects frame_overlap fsr3fi_hud_layer fsr_image_retirement fsr_uniform_ownership guest_imported high_fps_fixes host_guest_writes hud_layout_row libc_hooks lift_cache linux_preflight linux_pressure linux_tools linux_update log_open_failure make_game_ngx mise_build missing_nup mods_list mods_size_table ngx_sdk nonuniform_image_arrays parallel_init_order pending_guest_import pipeline_play_cache prepare_cache_save present_queue_default present_source_crop present_thread profiling_mode psychov35_fsr3_fg readback_timeout_source replay_write_order slow_frames song_note_cue staging_burst texel_buffer_ownership upscaler_rows vcore_escape vk_occlusion_queries walk_key (tests/ unless nx2/). One of them, `test_parallel_init_order`, reads `bc_scratch_layout`: its fixture stops on main's errors (`host_read_barrier`, `FpsRtWait`) before reaching it, on `main` and here alike, so it doesn't check this change. After those runs the branch was rebased onto main `3f2c9b3c` (#1838, which changes only `tests/test_nfc_scan_hint.py`); the four checks named above pass again there. **Still to test:** - Windows and Linux AMD, Windows NVIDIA (`windows+amd+dgpu`, `linux+radv`, `windows+nvidia`): enter Hyrule Field from the Castle Town gate and look across the field, expecting no grid lines on the far ground (@Beanstalk test Windows AMD dGPU, Linux RADV and Windows NVIDIA on Hyrule Field) - Steam Deck (`steamdeck`): the same, expecting no grid lines and the entry no longer than on `main` (@Beanstalk test the Steam Deck on Hyrule Field) - RX 6000 on Linux (#1787's RX 6700 XT, or the RX 6600 that showed the grid lines): the same, by hand ## Measurements **Verdict:** The never-put-off arrays' decode and BC re-encode at Hyrule Field's entry take 16.1-17.5 ms of GPU time a texture, against 49.7-49.9 ms with one layer a run: about 3x less, ~260 ms of GPU work fewer at the entry. GPU time in play afterwards is the same within the spread. Setup: Linux (Fedora 45), RX 9070 XT, Mesa RADV; 2560 x 1440 fullscreen, the same options file every run (Debug tools and the FPS counter off). The branch's runtime (`dev.py pack` over the `068fb8eb` base), A = `RX_VK_BC_SMALL_LAYERS=1` (one layer a run, as `main`), B = default. Runs interleaved B, A, B, A, each a job of the PC's queue in timing mode under a 20 GB cap (never reached): test save, teleport to the Market, out of the gate into Hyrule Field, 120 s of running. Every run with `RX_VK_PASS_TIMING=1 RX_VK_FRAME_GATE=0 RX_VK_CAPTURE_NT=1`. Baseline: the same build with `RX_VK_BC_SMALL_LAYERS=1`, which runs one layer a run as `main` does: `main` has no `astc` span to read the decode and re-encode from (the first commit adds it). 79d83b03 is this branch before its rebase onto `3f2c9b3c`, which changes only `tests/test_nfc_scan_hint.py`. | | Before, A, one layer a run (`RX_VK_BC_SMALL_LAYERS=1`): this PR @ 79d83b03 | After, B, the default: this PR @ 79d83b03 | |---|---|---| | `astc decode + BC re-encode (never put off)`, GPU per texture | 49.9 ms, 49.7 ms | 16.1 ms, 17.5 ms | | the same, a frame over the report's 600 presents | 0.665, 0.662 ms | 0.215, 0.233 ms | | the entry frame's uploads (replay thread) | 106, 97 ms | 96, 100 ms | | GPU time a frame in play (last 6 reports) | 10.7, 10.4 ms | 11.1, 10.0 ms | The CPU side of the entry frame's uploads doesn't change: the replay records the same work, in fewer runs. ```text # A (vc-sml1a) vk: u 0.665 ms 0.0 x 49859.2 us 0.0 items 0.20 MB astc decode + BC re-encode (never put off: a layer array, or over 1024x1024) # B (vc-sml8a) vk: u 0.215 ms 0.0 x 16127.3 us 0.0 items 0.20 MB astc decode + BC re-encode (never put off: a layer array, or over 1024x1024) ``` ## Risks - **36 MB more VRAM** (32 MB scratch, 4 MB more output buffer), held once the first BC texture is made (as the first scratch is: `RX_VK_BC_IDLE_S`). Not made on a small-VRAM card or out of VRAM. `RX_VK_BC_SMALL_LAYERS=1` doesn't make the small scratch. - **Grid lines on the far ground** if a multi-layer run went wrong on some driver. The cause found is fixed and none showed on RADV; Still to test covers the rest. `RX_VK_BC_SMALL_LAYERS=1` turns it off. - After updating: nothing changes in saves, `longshot_options.ini` or the caches. ## 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] Screenshots of the same spot on `main` and here, for a change that shows on screen. (In [this comment](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1843#issuecomment-57411): the same build with `RX_VK_BC_SMALL_LAYERS=1`, as `main`, and the default; see Baseline) - [x] Docs updated. - [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)
At Hyrule Field's entry the GPU sat at 100% for ~450 ms while the log's GPU time line showed
a 20 ms submission at most (#1720): the ASTC decode and BC3 re-encode in the upload command
buffers were in no span. Each texture's decode is now one, kind "astc", in four rows: decoded
only or re-encoded too, and whether upload_defer can put the texture off or never does (a layer
array, or over 1024x1024). upload_defer and the labels share that rule (upload_never_put_off).

Assisted-by: Claude Opus 5.5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
perf(vk): ASTC levels of 1024 or less re-encode to BC eight layers a run, through a small scratch (#1720)
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 5s
beanstalk/approval approved by HumanBean (reviewed)
beanstalk/windows+amd+dgpu 1/1 fail
beanstalk/linux+radv 0/1 pass, 1 running, 0 queued
beanstalk/windows+nvidia 0/1 pass, 1 running, 0 queued
beanstalk/steamdeck 0/1 pass, 1 running, 1 queued
beanstalk/linux+amd+gpu-rx-6* 0/1 pass, 0 running, 2 queued
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
Website / Website on Cloudflare (pull_request) Has been cancelled
3845e7413d
An ASTC array kept as BC3 is decoded into a scratch and encoded from it a run at a time; a run is a decode, an encode,
a copy and three full barriers. With one layer a run (RX_VK_BC_LAYERS, the answer to Hyrule Field's grid lines), the
terrain's material arrays (1365 x 1365 x 90, 11 levels) made ~990 runs, and at Hyrule Field's entry on an RX 9070 XT
the GPU took 51 ms an array, most of it between runs. The grid lines came from a run of several layers over a level
repacked into one layer's staging; runs no longer cross a repacked level (`!repack`), so levels no larger than 1024 x
1024 now go through a second scratch of 8 layers (RX_VK_BC_SMALL_LAYERS; 1: none, as before): 32 MB more VRAM, and
the 2048 x 2048 scratch, its copies and RX_VK_BC_LAYERS stay as they were.

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

Tested in game: Linux (Fedora 45, kernel 7.3), RX 9070 XT, Mesa RADV, this branch's dev.py runtime: from a test save through the Castle Town gate into Hyrule Field and 120 s of running with the camera turning, 4 runs interleaved between the default and RX_VK_BC_SMALL_LAYERS=1. No device lost, no errors, no grid lines on the far ground in the arrival screenshots or while watching. The never-put-off terrain arrays' decode and BC re-encode went from ~50 ms to 16-17.5 ms of GPU time each.

Tested in game: Linux (Fedora 45, kernel 7.3), RX 9070 XT, Mesa RADV, this branch's dev.py runtime: from a test save through the Castle Town gate into Hyrule Field and 120 s of running with the camera turning, 4 runs interleaved between the default and RX_VK_BC_SMALL_LAYERS=1. No device lost, no errors, no grid lines on the far ground in the arrival screenshots or while watching. The never-put-off terrain arrays' decode and BC re-encode went from ~50 ms to 16-17.5 ms of GPU time each.
Owner

@Beanstalk

@Beanstalk
Member
Beanstalk test farm · an earlier run: commit 3845e74 (the newer results are in a comment below)

Commit 3845e74 · tier reviewed · approved by HumanBean · dashboard

What will be tested · AI plan (gpt-6.1-terra)

The plan compares Hyrule Field entry and terrain rendering on Windows AMD dGPU, Linux RADV, Windows NVIDIA, Steam Deck and Linux RX 6000 hardware. It measures load time, entry hitches, gameplay frame time and VRAM, and compares field screenshots for corruption such as grid lines. Crashes, material visual differences or performance regressions beyond the limits fail the plan; each tester takes about 11 minutes. The Linux RX 6000 target has no matching tester listed online and will wait for one. No tester online now matches linux+amd+gpu-rx-6*: that target waits for one.

  • Where: windows+amd+dgpu (1-2 reports), linux+radv (1-2 reports), windows+nvidia (1-2 reports), steamdeck (1-2 reports), linux+amd+gpu-rx-6* (GPU "rx 6*", 1-2 reports).
  • field-entry: from the repository's save kokiri-start, then teleport to Market, teleport to Hyrule Field, take the picture field-arrival to compare with main, move the stick, take the picture field-turned to compare with main, measure field for 20 s (after 5 s warm-up); 1 run on each side.
  • Measured: crashes, frame times, stutters and hitches, load times, VRAM use, the game's log.
  • The PR fails if: it crashes; or a picture differs from main by more than 5%; or peak VRAM is more than 10% above main; or longest load is more than 15% above main; or frame time (p99) is more than 15% above main; or forbidden log lines is above 0; or worst frame time in the whole run is more than 20% above main.
  • Time: about 11 min of game runs per tester (2 game starts), plus the two builds.

Started at 05:34 UTC.

Estimate: done in about 15 min, from the queue and the testers online now; some jobs can't start yet.

Target Reports Crash Frame p99 (ms) vs main VRAM peak (MB) vs main Result
windows+amd+dgpu · 1: windows+amd+amd-proprietary+dgpu AMD Radeon RX 9060 XT, 2.0.416; 2: windows+amd+amd-proprietary+dgpu AMD Radeon RX 9070 XT, 2.0.416 2/1 1 2 1 PR run — — fail ⚠ outlier
linux+radv · 1: linux+amd+radv+dgpu AMD Radeon RX 7900 XTX (RADV NAVI31), 26.2.7 1/1 1 none — — running
windows+nvidia · 1: windows+nvidia+nvidia-proprietary+dgpu NVIDIA GeForce RTX 3050 Ti Laptop GPU, 621.24.0 1/1 1 none — — running
steamdeck 0/1 — — — running
linux+amd+gpu-rx-6* 0/1 — — — queued

Measurements · windows+amd+dgpu

Verdict: fail on windows+amd+dgpu (2/1 report): field-entry crash failed.

Hardware: 1: windows+amd+amd-proprietary+dgpu AMD Radeon RX 9060 XT, 2.0.416 AMD Ryzen 5 5600 6-Core Processor, 32 GB RAM; 2: windows+amd+amd-proprietary+dgpu AMD Radeon RX 9070 XT, 2.0.416 AMD Ryzen 9 5900X 12-Core Processor, 32 GB RAM
Scene: field-entry, from the repository's save kokiri-start; each cell's settings and switches as the table names them
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); field-entry: 1 game start a side, field 20 s after 5 s warm-up; each number the median of the runs, then of 2 reports
How to reproduce: the farm's plan above (@Beanstalk on this PR runs it again)

Before: main @ 3f2c9b3 After: this PR @ 3845e74
field-entry · field · peak VRAM (MB) — 6,559
field-entry · longest load (s) 10.3 6.1 (−40%)
field-entry · field · frame time (p99) (ms) — 20.1
field-entry · forbidden log lines 0.0 0.0
field-entry · worst frame time in the whole run (ms) 303.6 259.6 (−15%)

Flags and settings

None: the plan varied no setting, switch or build option.

Markdown for the PR description
## Measurements

**Verdict:** fail on windows+amd+dgpu (2/1 report): `field-entry crash` failed.

Hardware: 1: windows+amd+amd-proprietary+dgpu `AMD Radeon RX 9060 XT, 2.0.416` `AMD Ryzen 5 5600 6-Core Processor, 32 GB RAM`; 2: windows+amd+amd-proprietary+dgpu `AMD Radeon RX 9070 XT, 2.0.416` `AMD Ryzen 9 5900X 12-Core Processor, 32 GB RAM`  
Scene: field-entry, from the repository's save kokiri-start; each cell's settings and switches as the table names them  
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); field-entry: 1 game start a side, field 20 s after 5 s warm-up; each number the median of the runs, then of 2 reports  
How to reproduce: the farm's plan above (`@Beanstalk` on this PR runs it again)

| | Before: main @ 3f2c9b3 | After: this PR @ 3845e74 |
|---|---|---|
| field-entry · field · peak VRAM (MB) | — | 6,559 |
| field-entry · longest load (s) | 10.3 | 6.1 (−40%) |
| field-entry · field · frame time (p99) (ms) | — | 20.1 |
| field-entry · forbidden log lines | 0.0 | 0.0 |
| field-entry · worst frame time in the whole run (ms) | 303.6 | 259.6 (−15%) |

### Flags and settings

None: the plan varied no setting, switch or build option.

Measurements · linux+radv

Verdict: running on linux+radv (1/1 report).

Hardware: 1: linux+amd+radv+dgpu AMD Radeon RX 7900 XTX (RADV NAVI31), 26.2.7 AMD Ryzen 7 5800X3D 8-Core Processor, 64 GB RAM
Scene: field-entry, from the repository's save kokiri-start; each cell's settings and switches as the table names them
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); field-entry: 1 game start a side, field 20 s after 5 s warm-up; each number the median of the runs, then of 1 report
How to reproduce: the farm's plan above (@Beanstalk on this PR runs it again)

Nothing was measured: no metric came back.

Flags and settings

None: the plan varied no setting, switch or build option.

Markdown for the PR description
## Measurements

**Verdict:** running on linux+radv (1/1 report).

Hardware: 1: linux+amd+radv+dgpu `AMD Radeon RX 7900 XTX (RADV NAVI31), 26.2.7` `AMD Ryzen 7 5800X3D 8-Core Processor, 64 GB RAM`  
Scene: field-entry, from the repository's save kokiri-start; each cell's settings and switches as the table names them  
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); field-entry: 1 game start a side, field 20 s after 5 s warm-up; each number the median of the runs, then of 1 report  
How to reproduce: the farm's plan above (`@Beanstalk` on this PR runs it again)

Nothing was measured: no metric came back.

### Flags and settings

None: the plan varied no setting, switch or build option.

Measurements · windows+nvidia

Verdict: running on windows+nvidia (1/1 report).

Hardware: 1: windows+nvidia+nvidia-proprietary+dgpu NVIDIA GeForce RTX 3050 Ti Laptop GPU, 621.24.0 AMD Ryzen 7 5800H with Radeon Graphics, 16 GB RAM
Scene: field-entry, from the repository's save kokiri-start; each cell's settings and switches as the table names them
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); field-entry: 1 game start a side, field 20 s after 5 s warm-up; each number the median of the runs, then of 1 report
How to reproduce: the farm's plan above (@Beanstalk on this PR runs it again)

Nothing was measured: no metric came back.

Flags and settings

None: the plan varied no setting, switch or build option.

Markdown for the PR description
## Measurements

**Verdict:** running on windows+nvidia (1/1 report).

Hardware: 1: windows+nvidia+nvidia-proprietary+dgpu `NVIDIA GeForce RTX 3050 Ti Laptop GPU, 621.24.0` `AMD Ryzen 7 5800H with Radeon Graphics, 16 GB RAM`  
Scene: field-entry, from the repository's save kokiri-start; each cell's settings and switches as the table names them  
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); field-entry: 1 game start a side, field 20 s after 5 s warm-up; each number the median of the runs, then of 1 report  
How to reproduce: the farm's plan above (`@Beanstalk` on this PR runs it again)

Nothing was measured: no metric came back.

### Flags and settings

None: the plan varied no setting, switch or build option.
<!-- beanstalk:previous --> <details><summary>Beanstalk test farm · an earlier run: commit <code>3845e74</code> (the newer results are in a comment below)</summary> Commit `3845e74` · tier **reviewed** · approved by HumanBean · [dashboard](https://beanstalk.magicbean.dev/prs/1843) **What will be tested** · AI plan (`gpt-6.1-terra`) The plan compares Hyrule Field entry and terrain rendering on Windows AMD dGPU, Linux RADV, Windows NVIDIA, Steam Deck and Linux RX 6000 hardware. It measures load time, entry hitches, gameplay frame time and VRAM, and compares field screenshots for corruption such as grid lines. Crashes, material visual differences or performance regressions beyond the limits fail the plan; each tester takes about 11 minutes. The Linux RX 6000 target has no matching tester listed online and will wait for one. No tester online now matches linux+amd+gpu-rx-6*: that target waits for one. - **Where:** windows+amd+dgpu (1-2 reports), linux+radv (1-2 reports), windows+nvidia (1-2 reports), steamdeck (1-2 reports), linux+amd+gpu-rx-6* (GPU "rx 6*", 1-2 reports). - **field-entry:** from the repository's save `kokiri-start`, then teleport to Market, teleport to Hyrule Field, take the picture field-arrival to compare with main, move the stick, take the picture field-turned to compare with main, measure field for 20 s (after 5 s warm-up); 1 run on each side. - **Measured:** crashes, frame times, stutters and hitches, load times, VRAM use, the game's log. - **The PR fails if:** it crashes; or a picture differs from main by more than 5%; or peak VRAM is more than 10% above main; or longest load is more than 15% above main; or frame time (p99) is more than 15% above main; or forbidden log lines is above 0; or worst frame time in the whole run is more than 20% above main. - **Time:** about 11 min of game runs per tester (2 game starts), plus the two builds. Started at 05:34 UTC. **Estimate:** done in about 15 min, from the queue and the testers online now; some jobs can't start yet. | Target | Reports | Crash | Frame p99 (ms) vs main | VRAM peak (MB) vs main | Result | | --- | --- | --- | --- | --- | --- | | windows+amd+dgpu · 1: windows+amd+amd-proprietary+dgpu `AMD Radeon RX 9060 XT, 2.0.416`; 2: windows+amd+amd-proprietary+dgpu `AMD Radeon RX 9070 XT, 2.0.416` | 2/1 [1](https://beanstalk.magicbean.dev/reports/rp_1a2b9d3dfdcea94c) [2](https://beanstalk.magicbean.dev/reports/rp_d1a04e6782eff8a6) | 1 PR run | — | — | fail ⚠ outlier | | linux+radv · 1: linux+amd+radv+dgpu `AMD Radeon RX 7900 XTX (RADV NAVI31), 26.2.7` | 1/1 [1](https://beanstalk.magicbean.dev/reports/rp_70ce13a7a13f4b6d) | none | — | — | running | | windows+nvidia · 1: windows+nvidia+nvidia-proprietary+dgpu `NVIDIA GeForce RTX 3050 Ti Laptop GPU, 621.24.0` | 1/1 [1](https://beanstalk.magicbean.dev/reports/rp_d83ece64d24dffd3) | none | — | — | running | | steamdeck | 0/1 | — | — | — | running | | linux+amd+gpu-rx-6* | 0/1 | — | — | — | queued | #### Measurements · windows+amd+dgpu **Verdict:** fail on windows+amd+dgpu (2/1 report): `field-entry crash` failed. Hardware: 1: windows+amd+amd-proprietary+dgpu `AMD Radeon RX 9060 XT, 2.0.416` `AMD Ryzen 5 5600 6-Core Processor, 32 GB RAM`; 2: windows+amd+amd-proprietary+dgpu `AMD Radeon RX 9070 XT, 2.0.416` `AMD Ryzen 9 5900X 12-Core Processor, 32 GB RAM` Scene: field-entry, from the repository's save kokiri-start; each cell's settings and switches as the table names them Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); field-entry: 1 game start a side, field 20 s after 5 s warm-up; each number the median of the runs, then of 2 reports How to reproduce: the farm's plan above (`@Beanstalk` on this PR runs it again) | | Before: main @ 3f2c9b3 | After: this PR @ 3845e74 | |---|---|---| | field-entry · field · peak VRAM (MB) | — | 6,559 | | field-entry · longest load (s) | 10.3 | 6.1 (−40%) | | field-entry · field · frame time (p99) (ms) | — | 20.1 | | field-entry · forbidden log lines | 0.0 | 0.0 | | field-entry · worst frame time in the whole run (ms) | 303.6 | 259.6 (−15%) | ### Flags and settings None: the plan varied no setting, switch or build option. <details><summary>Markdown for the PR description</summary> ```markdown ## Measurements **Verdict:** fail on windows+amd+dgpu (2/1 report): `field-entry crash` failed. Hardware: 1: windows+amd+amd-proprietary+dgpu `AMD Radeon RX 9060 XT, 2.0.416` `AMD Ryzen 5 5600 6-Core Processor, 32 GB RAM`; 2: windows+amd+amd-proprietary+dgpu `AMD Radeon RX 9070 XT, 2.0.416` `AMD Ryzen 9 5900X 12-Core Processor, 32 GB RAM` Scene: field-entry, from the repository's save kokiri-start; each cell's settings and switches as the table names them Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); field-entry: 1 game start a side, field 20 s after 5 s warm-up; each number the median of the runs, then of 2 reports How to reproduce: the farm's plan above (`@Beanstalk` on this PR runs it again) | | Before: main @ 3f2c9b3 | After: this PR @ 3845e74 | |---|---|---| | field-entry · field · peak VRAM (MB) | — | 6,559 | | field-entry · longest load (s) | 10.3 | 6.1 (−40%) | | field-entry · field · frame time (p99) (ms) | — | 20.1 | | field-entry · forbidden log lines | 0.0 | 0.0 | | field-entry · worst frame time in the whole run (ms) | 303.6 | 259.6 (−15%) | ### Flags and settings None: the plan varied no setting, switch or build option. ``` </details> #### Measurements · linux+radv **Verdict:** running on linux+radv (1/1 report). Hardware: 1: linux+amd+radv+dgpu `AMD Radeon RX 7900 XTX (RADV NAVI31), 26.2.7` `AMD Ryzen 7 5800X3D 8-Core Processor, 64 GB RAM` Scene: field-entry, from the repository's save kokiri-start; each cell's settings and switches as the table names them Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); field-entry: 1 game start a side, field 20 s after 5 s warm-up; each number the median of the runs, then of 1 report How to reproduce: the farm's plan above (`@Beanstalk` on this PR runs it again) Nothing was measured: no metric came back. ### Flags and settings None: the plan varied no setting, switch or build option. <details><summary>Markdown for the PR description</summary> ```markdown ## Measurements **Verdict:** running on linux+radv (1/1 report). Hardware: 1: linux+amd+radv+dgpu `AMD Radeon RX 7900 XTX (RADV NAVI31), 26.2.7` `AMD Ryzen 7 5800X3D 8-Core Processor, 64 GB RAM` Scene: field-entry, from the repository's save kokiri-start; each cell's settings and switches as the table names them Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); field-entry: 1 game start a side, field 20 s after 5 s warm-up; each number the median of the runs, then of 1 report How to reproduce: the farm's plan above (`@Beanstalk` on this PR runs it again) Nothing was measured: no metric came back. ### Flags and settings None: the plan varied no setting, switch or build option. ``` </details> #### Measurements · windows+nvidia **Verdict:** running on windows+nvidia (1/1 report). Hardware: 1: windows+nvidia+nvidia-proprietary+dgpu `NVIDIA GeForce RTX 3050 Ti Laptop GPU, 621.24.0` `AMD Ryzen 7 5800H with Radeon Graphics, 16 GB RAM` Scene: field-entry, from the repository's save kokiri-start; each cell's settings and switches as the table names them Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); field-entry: 1 game start a side, field 20 s after 5 s warm-up; each number the median of the runs, then of 1 report How to reproduce: the farm's plan above (`@Beanstalk` on this PR runs it again) Nothing was measured: no metric came back. ### Flags and settings None: the plan varied no setting, switch or build option. <details><summary>Markdown for the PR description</summary> ```markdown ## Measurements **Verdict:** running on windows+nvidia (1/1 report). Hardware: 1: windows+nvidia+nvidia-proprietary+dgpu `NVIDIA GeForce RTX 3050 Ti Laptop GPU, 621.24.0` `AMD Ryzen 7 5800H with Radeon Graphics, 16 GB RAM` Scene: field-entry, from the repository's save kokiri-start; each cell's settings and switches as the table names them Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); field-entry: 1 game start a side, field 20 s after 5 s warm-up; each number the median of the runs, then of 1 report How to reproduce: the farm's plan above (`@Beanstalk` on this PR runs it again) Nothing was measured: no metric came back. ### Flags and settings None: the plan varied no setting, switch or build option. ``` </details> </details>
Author
Contributor

Arrival in Hyrule Field from the Castle Town gate, the same spot in two runs of the same build (79d83b03, 1280 x 720 capture of a 2560 x 1440 run). No grid lines on the far ground in either.

Before, RX_VK_BC_SMALL_LAYERS=1 (one layer a run, as main): before

After, the default (eight layers a run at levels of 1024 or less): after

Arrival in Hyrule Field from the Castle Town gate, the same spot in two runs of the same build (79d83b03, 1280 x 720 capture of a 2560 x 1440 run). No grid lines on the far ground in either. Before, `RX_VK_BC_SMALL_LAYERS=1` (one layer a run, as `main`): ![before](https://git.magicbean.dev/attachments/7113583d-d3ae-47ba-97d6-8a767951916f) After, the default (eight layers a run at levels of 1024 or less): ![after](https://git.magicbean.dev/attachments/6c84acbc-5547-4721-a38f-ecdc142fd038)
HumanBean requested changes 2026-11-20 06:17:25 +00:00
Dismissed
HumanBean left a comment

Recommendation: Request changes. The gain is real and large on the one card measured, but three things block it. It has to be rebased onto main (#1763) and #1833, and on that base its new timing span runs across #1833's CPU waits. The grid-line safety argument rests on a cause the history doesn't show. And 36 MB of VRAM is held for good on every card, never measured on a small one.

For players without ASTC on the GPU (every PC; the coarse-block terrain arrays go to BC everywhere), entering Hyrule Field should hitch less: the terrain arrays' decode and BC re-encode take about a third of the GPU time. The code change is small and readable: a second scratch and a per-level choice of run length. Its cost is VRAM, and a return to multi-layer runs, which were turned off once because of on-screen corruption.

Does it help: Yes, for the GPU time it measures, on one card. Never-put-off arrays: 49.9 and 49.7 ms of GPU time a texture at one layer a run, against 16.1 and 17.5 ms at eight. That is RX 9070 XT, Mesa RADV, Linux, 2 interleaved runs a side, far outside the spread: about 260 ms less GPU work at the field's entry. GPU time in play is unchanged within the spread (10.7/10.4 against 11.1/10.0 ms). What it doesn't show:

  • the entry hitch a player feels: the longest frame or frame time at arrival. Only GPU span time and the replay thread's CPU time (unchanged) were reported;
  • any other GPU;
  • the current base: the numbers are from 79d83b03 on a pre-#1763 base without #1833, and #1833 changes how this loop is submitted.

Beanstalk's run is still going. Its one report so far (RTX 3050 Ti laptop) came back with no metrics.

Other systems:

  • Other vendors and the Steam Deck. NVIDIA, Intel, Windows AMD, the Steam Deck and other iGPUs all take this path for coarse-block ASTC (RX_VK_ASTC_BC_MB), and iGPUs for every large ASTC texture. None is measured, and the GPU that showed the grid lines (RX 6600, RDNA2) is the one that matters most. See Blocking 3.
  • iGPUs and #1833. A small run is 8× the texels of today's run, inside #1833's per-submission bound (16 Mpx default; a 1024² × 8 run is 8.4 Mpx). That holds only while RX_VK_ASTC_CHUNK_MPX is 9 or more.
  • Low-VRAM cards and shared-memory iGPUs. 36 MB more is held for good. See Blocking 4.
  • Paths it can't reach: the CPU decode (RX_VK_ASTC_CPU), non-BC ASTC uploads (small needs tex.bc), the AMD resized path (!tex.bc_resized) and texture_copy_into_bc (still the big scratch at bc_layers()). They are untouched.
  • RX_VK_PASS_TIMING reports. The upload buffers' barrier rows lose the ASTC path's barriers, because the outer astc span now holds them (one span per command buffer). Old and new logs aren't comparable row for row.

Switches:

  • RX_VK_BC_SMALL_LAYERS (new, tune, default 8, clamped 1-8; 1 means no small scratch). Its row is in switches.def, sorted. Default 8 is right on RDNA4 RADV by the measurements, but not yet shown on other vendors or on RDNA2, where multi-layer runs were seen to corrupt. It should stay as the way back until those runs pass. After that, a range of 1-8 is more than anyone needs: an on/off way back (=1) is enough, and so is a reason to keep it at all.
  • RX_VK_BC_LAYERS: only its description changes (it now covers levels over 1024). Fine.

Reviewed: 3845e7413d against 3f2c9b3c88 (the PR's fork point; main is now a3565ac5, #1763). Read in full:

  • the diff of gpu/vk/vk_texture.cpp, and in the PR's version bc_layers, bc_small_layers, bc_scratch_make, bc_encode_into, bc_encode_resized, bc_scratch_layout, bc_scratch_idle, upload_astc_gpu and upload_defer;
  • gpu/vk/vk_gprof.h and the core of gpu/vk/vk_gprof.cpp on main; create_image in gpu/vk/vk_vma.cpp;
  • the encoders' output indexing (host_shaders/bc_encoder.comp, bc7_encoder.comp);
  • the switch rows; the two new tests and the two fixture edits;
  • #1833's head afecbaee: upload_astc_gpu, replay_flush_upload and its test fixture's cuts;
  • the history: ec89f92e and #1553 (7daafa7a), with the pre-#1553 upload_astc_gpu.

Nothing was run (a code review).

Fixed in this review: nothing.

Checked and fine:

  • while (!repack && ...) keeps a repacked level to one layer a run, and the small path doesn't change that.
  • The encoders write layer z's blocks at (z * blocks_y + y) * blocks_x + x. That matches the tightly packed vkCmdCopyBufferToImage of n layers, so a multi-layer run's copy is laid out right. bc_out is sized max(big, small) (8 MiB) and holds a small run.
  • The small scratch's first layout goes in the same barrier as the big one's, only when it was made. If it can't be made, every level falls back to the big scratch at bc_layers().
  • bc_scratch_idle gives it back with the same bc_last_value as the big scratch.
  • With #1833, the flush falls between runs, after the previous run's encode, copy and full barrier, and is followed by a full barrier. So neither scratch's contents ever have to survive a flush, and GENERAL layout persists across the re-begin. The small scratch's contents and layout are safe there.
  • At a level 1023 wide with ASTC 12×12 blocks, the decoder writes past 1024. Those are out-of-bounds image stores, which are discarded, and the encoder clamps its reads to width - 1.
  • upload_never_put_off is exactly upload_defer's old rule, and upload_defer now uses it.
  • The span is only live under RX_VK_PASS_TIMING, and its destructor closes it on every early return.
  • bc_small is read without bc_mu, as bc_scratch_view already is. Idle release is off by default and needs bc_idle_s seconds since the last bc_scratch_layout, so no new race in practice.

Blocking (to change before merge)

  1. Rebase onto main and #1833.
    • Main deleted tests/parallel_init_order_test.cpp (#1763): drop that hunk. bc_scratch_layout no longer has InitRedirect, and your hunk below it should apply.
    • #1833 inserts chunk_texels after the same const uint64_t limit = ...; line as your kSpans/GprofSpan, and puts its flush block between the view line you change and the decode's dispatch. Keep both.
    • #1833's tests/test_astc_upload_chunking.py compiles upload_astc_gpu with stubs. After the rebase it needs bc_small, bc_small_view, kBcSmallDim, bc_small_layers, upload_never_put_off (defined outside its cuts) and a GprofSpan stub. Ideally it should also cover a small level's 8-layer runs against the per-submission bound.
  2. The per-texture astc span runs across #1833's waits (vk_texture.cpp:1244).
    • A never-put-off array (1365² × 90) crosses many 16 Mpx chunks, so replay_flush_upload ends, submits, fence-waits and re-begins the command buffer several times inside one span.
    • The begin timestamp lands in one submission and the end in a later one. The span then counts the GPU idle while the CPU waits and records, and reports that as "GPU per texture". That is the number this PR uses to show its gain.
    • Fix: close the span before replay_flush_upload and open a new one after it (an std::optional<GprofSpan> reset around the flush would do), or have the flush close and reopen open spans in vk_gprof.
    • Then measure again on main with #1833. The submission structure is different there, and the 3× may not hold as it is.
  3. The grid-line safety argument isn't shown (vk_texture.cpp:777, the test's docstring, the description).
    • The comment says the grid lines' cause was a run over a repacked level, and that !repack removes it. But there was no repack when ec89f92e made runs one layer. Repack came with #1553 (7daafa7a), whose description says nothing about grid lines or layers. Before it, a run read layer z at z * tail + off, and unaligned levels were skipped.
    • ec89f92e's own message says only that layers after a run's first came out wrong at the smaller levels on an RX 6600. It names no cause: one layer a run was a workaround.
    • So 8-layer runs are back on for everyone, with RDNA4 RADV as the only evidence. RDNA4 may never have shown the lines: the RX 6600 is the card that did, and Beanstalk has no RX 6000 tester.
    • Either show the mechanism (for example, that the wrong layers on pre-#1553 code were exactly the levels #1553 now repacks, which can be worked out from level_geo for 1365 × 1365 ASTC 8×8), or get an RX 6000 run.
    • Until then, the comment and the test should say "not seen on RDNA4 RADV", not name a cause.
  4. The VRAM is 36 MB, not 32, held for good, and unmeasured on a small card (vk_texture.cpp:858).
    • The scratch is 1024² × 4 × 8 = 32 MiB, and bc_out grows from 4 MiB to 8 MiB (small_out). That is 36 MiB more, and at the default RX_VK_BC_IDLE_S=0 it is kept once made. No pressure path frees it.
    • On a full 4 GB card, create_image falls back to system memory. Every small level's decode and encode would then read and write over PCIe, quite possibly slower than main's one-layer runs through the VRAM scratch.
    • Fix: don't make the small scratch, or drop it, when it doesn't land in VRAM (allocation_in_vram) or under the low-VRAM rule. Otherwise measure the entry on a 4 GB card.
    • Correct "32 MB" in the comment and in Risks.

Suggestions (the author may take or leave)

  • vk_texture.cpp:1070: the "given back" log adds 4 * bc_small_layers() but leaves out bc_out's growth. It says 52 MB where 56 are freed, 68 where 72 are freed with the second scratch, and it counts the small scratch even when it wasn't made. Use allocation_size of what is actually freed.
  • Log once when the small scratch couldn't be made. Today the fall-back to one layer a run is silent.
  • vk_texture.cpp:1270: with RX_VK_ASTC_CHUNK_MPX set below 9, a 1024² run of 8 is a single step over the bound. Cap bc_run at max(1, chunk_texels / (g.w * g.h)) once #1833 is in.
  • Measure the arrival frame's time (or the longest frame within a second of arrival) beside the span, as the number a player feels.
  • tests/test_bc_small_scratch.py is mostly exact-text checks: it fails on main because bc_small_layers() is missing, not because runs are one layer. The behaviour is better modelled in tests/bc_scratch_batches_test.cpp, whose RUN cut already runs the loop. A level of 1024 or less runs 8, a larger one bc_layers(), a repacked one 1. That would also catch the key line small ? bc_small_layers() : bc_layers() being undone without relying on its spelling.
  • If measurements show 4 layers (16 MB) keep most of the gain, that is a cheaper default.

Questions

  • Was the RX 6600's corruption ever reproduced on a build after #1553 with RX_VK_BC_LAYERS=8? That would settle Blocking 3 more cheaply than reading the history.

Testing:

  • The author ran 4 interleaved runs on RX 9070 XT RADV Linux (no corruption seen in the arrival screenshots or while watching).
  • Beanstalk is running for Windows AMD dGPU, Linux RADV, Windows NVIDIA and the Steam Deck. One NVIDIA report came back with no metrics. The RX 6000 target has no tester.
  • Missing: RX 6000 (by hand), a 4 GB card, and a re-measure on main with #1833. All hold the merge.

Overlaps and merge order:

  • #1833 is merged (d12ddf69); this rebases onto it as above.
  • #521 (WIP BC1) touches the same BC encode and scratch code.
  • #1847 (WIP RX_VK_TEX_PREP) touches the same function. If it records uploads off the render thread, the scratches (now two) are shared state that needs the same guard.
**Recommendation: Request changes.** The gain is real and large on the one card measured, but three things block it. It has to be rebased onto main (#1763) and [#1833](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1833), and on that base its new timing span runs across #1833's CPU waits. The grid-line safety argument rests on a cause the history doesn't show. And 36 MB of VRAM is held for good on every card, never measured on a small one. For players without ASTC on the GPU (every PC; the coarse-block terrain arrays go to BC everywhere), entering Hyrule Field should hitch less: the terrain arrays' decode and BC re-encode take about a third of the GPU time. The code change is small and readable: a second scratch and a per-level choice of run length. Its cost is VRAM, and a return to multi-layer runs, which were turned off once because of on-screen corruption. **Does it help:** Yes, for the GPU time it measures, on one card. Never-put-off arrays: 49.9 and 49.7 ms of GPU time a texture at one layer a run, against 16.1 and 17.5 ms at eight. That is RX 9070 XT, Mesa RADV, Linux, 2 interleaved runs a side, far outside the spread: about 260 ms less GPU work at the field's entry. GPU time in play is unchanged within the spread (10.7/10.4 against 11.1/10.0 ms). What it doesn't show: - the entry hitch a player feels: the longest frame or frame time at arrival. Only GPU span time and the replay thread's CPU time (unchanged) were reported; - any other GPU; - the current base: the numbers are from 79d83b03 on a pre-#1763 base without #1833, and #1833 changes how this loop is submitted. Beanstalk's run is still going. Its one report so far (RTX 3050 Ti laptop) came back with no metrics. **Other systems:** - **Other vendors and the Steam Deck.** NVIDIA, Intel, Windows AMD, the Steam Deck and other iGPUs all take this path for coarse-block ASTC (`RX_VK_ASTC_BC_MB`), and iGPUs for every large ASTC texture. None is measured, and the GPU that showed the grid lines (RX 6600, RDNA2) is the one that matters most. See Blocking 3. - **iGPUs and #1833.** A small run is 8× the texels of today's run, inside #1833's per-submission bound (16 Mpx default; a 1024² × 8 run is 8.4 Mpx). That holds only while `RX_VK_ASTC_CHUNK_MPX` is 9 or more. - **Low-VRAM cards and shared-memory iGPUs.** 36 MB more is held for good. See Blocking 4. - **Paths it can't reach:** the CPU decode (`RX_VK_ASTC_CPU`), non-BC ASTC uploads (`small` needs `tex.bc`), the AMD resized path (`!tex.bc_resized`) and `texture_copy_into_bc` (still the big scratch at `bc_layers()`). They are untouched. - **`RX_VK_PASS_TIMING` reports.** The upload buffers' `barrier` rows lose the ASTC path's barriers, because the outer `astc` span now holds them (one span per command buffer). Old and new logs aren't comparable row for row. **Switches:** - `RX_VK_BC_SMALL_LAYERS` (new, `tune`, default 8, clamped 1-8; 1 means no small scratch). Its row is in `switches.def`, sorted. Default 8 is right on RDNA4 RADV by the measurements, but not yet shown on other vendors or on RDNA2, where multi-layer runs were seen to corrupt. It should stay as the way back until those runs pass. After that, a range of 1-8 is more than anyone needs: an on/off way back (`=1`) is enough, and so is a reason to keep it at all. - `RX_VK_BC_LAYERS`: only its description changes (it now covers levels over 1024). Fine. **Reviewed:** 3845e7413d68 against 3f2c9b3c886a (the PR's fork point; main is now a3565ac5, #1763). Read in full: - the diff of `gpu/vk/vk_texture.cpp`, and in the PR's version `bc_layers`, `bc_small_layers`, `bc_scratch_make`, `bc_encode_into`, `bc_encode_resized`, `bc_scratch_layout`, `bc_scratch_idle`, `upload_astc_gpu` and `upload_defer`; - `gpu/vk/vk_gprof.h` and the core of `gpu/vk/vk_gprof.cpp` on main; `create_image` in `gpu/vk/vk_vma.cpp`; - the encoders' output indexing (`host_shaders/bc_encoder.comp`, `bc7_encoder.comp`); - the switch rows; the two new tests and the two fixture edits; - #1833's head afecbaee: `upload_astc_gpu`, `replay_flush_upload` and its test fixture's cuts; - the history: ec89f92e and #1553 (7daafa7a), with the pre-#1553 `upload_astc_gpu`. Nothing was run (a code review). **Fixed in this review:** nothing. **Checked and fine:** - `while (!repack && ...)` keeps a repacked level to one layer a run, and the small path doesn't change that. - The encoders write layer z's blocks at `(z * blocks_y + y) * blocks_x + x`. That matches the tightly packed `vkCmdCopyBufferToImage` of n layers, so a multi-layer run's copy is laid out right. `bc_out` is sized `max(big, small)` (8 MiB) and holds a small run. - The small scratch's first layout goes in the same barrier as the big one's, only when it was made. If it can't be made, every level falls back to the big scratch at `bc_layers()`. - `bc_scratch_idle` gives it back with the same `bc_last_value` as the big scratch. - With #1833, the flush falls between runs, after the previous run's encode, copy and full barrier, and is followed by a full barrier. So neither scratch's contents ever have to survive a flush, and GENERAL layout persists across the re-begin. The small scratch's contents and layout are safe there. - At a level 1023 wide with ASTC 12×12 blocks, the decoder writes past 1024. Those are out-of-bounds image stores, which are discarded, and the encoder clamps its reads to `width - 1`. - `upload_never_put_off` is exactly `upload_defer`'s old rule, and `upload_defer` now uses it. - The span is only live under `RX_VK_PASS_TIMING`, and its destructor closes it on every early return. - `bc_small` is read without `bc_mu`, as `bc_scratch_view` already is. Idle release is off by default and needs `bc_idle_s` seconds since the last `bc_scratch_layout`, so no new race in practice. **Blocking** (to change before merge) 1. **Rebase onto main and #1833.** - Main deleted `tests/parallel_init_order_test.cpp` (#1763): drop that hunk. `bc_scratch_layout` no longer has `InitRedirect`, and your hunk below it should apply. - #1833 inserts `chunk_texels` after the same `const uint64_t limit = ...;` line as your `kSpans`/`GprofSpan`, and puts its flush block between the `view` line you change and the decode's dispatch. Keep both. - #1833's `tests/test_astc_upload_chunking.py` compiles `upload_astc_gpu` with stubs. After the rebase it needs `bc_small`, `bc_small_view`, `kBcSmallDim`, `bc_small_layers`, `upload_never_put_off` (defined outside its cuts) and a `GprofSpan` stub. Ideally it should also cover a small level's 8-layer runs against the per-submission bound. 2. **The per-texture `astc` span runs across #1833's waits** (`vk_texture.cpp:1244`). - A never-put-off array (1365² × 90) crosses many 16 Mpx chunks, so `replay_flush_upload` ends, submits, fence-waits and re-begins the command buffer several times inside one span. - The begin timestamp lands in one submission and the end in a later one. The span then counts the GPU idle while the CPU waits and records, and reports that as "GPU per texture". That is the number this PR uses to show its gain. - Fix: close the span before `replay_flush_upload` and open a new one after it (an `std::optional<GprofSpan>` reset around the flush would do), or have the flush close and reopen open spans in `vk_gprof`. - Then measure again on main with #1833. The submission structure is different there, and the 3× may not hold as it is. 3. **The grid-line safety argument isn't shown** (`vk_texture.cpp:777`, the test's docstring, the description). - The comment says the grid lines' cause was a run over a repacked level, and that `!repack` removes it. But there was no repack when ec89f92e made runs one layer. Repack came with #1553 (7daafa7a), whose description says nothing about grid lines or layers. Before it, a run read layer z at `z * tail + off`, and unaligned levels were skipped. - ec89f92e's own message says only that layers after a run's first came out wrong at the smaller levels on an RX 6600. It names no cause: one layer a run was a workaround. - So 8-layer runs are back on for everyone, with RDNA4 RADV as the only evidence. RDNA4 may never have shown the lines: the RX 6600 is the card that did, and Beanstalk has no RX 6000 tester. - Either show the mechanism (for example, that the wrong layers on pre-#1553 code were exactly the levels #1553 now repacks, which can be worked out from `level_geo` for 1365 × 1365 ASTC 8×8), or get an RX 6000 run. - Until then, the comment and the test should say "not seen on RDNA4 RADV", not name a cause. 4. **The VRAM is 36 MB, not 32, held for good, and unmeasured on a small card** (`vk_texture.cpp:858`). - The scratch is 1024² × 4 × 8 = 32 MiB, and `bc_out` grows from 4 MiB to 8 MiB (`small_out`). That is 36 MiB more, and at the default `RX_VK_BC_IDLE_S=0` it is kept once made. No pressure path frees it. - On a full 4 GB card, `create_image` falls back to system memory. Every small level's decode and encode would then read and write over PCIe, quite possibly slower than main's one-layer runs through the VRAM scratch. - Fix: don't make the small scratch, or drop it, when it doesn't land in VRAM (`allocation_in_vram`) or under the low-VRAM rule. Otherwise measure the entry on a 4 GB card. - Correct "32 MB" in the comment and in Risks. **Suggestions** (the author may take or leave) - `vk_texture.cpp:1070`: the "given back" log adds `4 * bc_small_layers()` but leaves out `bc_out`'s growth. It says 52 MB where 56 are freed, 68 where 72 are freed with the second scratch, and it counts the small scratch even when it wasn't made. Use `allocation_size` of what is actually freed. - Log once when the small scratch couldn't be made. Today the fall-back to one layer a run is silent. - `vk_texture.cpp:1270`: with `RX_VK_ASTC_CHUNK_MPX` set below 9, a 1024² run of 8 is a single step over the bound. Cap `bc_run` at `max(1, chunk_texels / (g.w * g.h))` once #1833 is in. - Measure the arrival frame's time (or the longest frame within a second of arrival) beside the span, as the number a player feels. - `tests/test_bc_small_scratch.py` is mostly exact-text checks: it fails on main because `bc_small_layers()` is missing, not because runs are one layer. The behaviour is better modelled in `tests/bc_scratch_batches_test.cpp`, whose `RUN` cut already runs the loop. A level of 1024 or less runs 8, a larger one `bc_layers()`, a repacked one 1. That would also catch the key line `small ? bc_small_layers() : bc_layers()` being undone without relying on its spelling. - If measurements show 4 layers (16 MB) keep most of the gain, that is a cheaper default. **Questions** - Was the RX 6600's corruption ever reproduced on a build after #1553 with `RX_VK_BC_LAYERS=8`? That would settle Blocking 3 more cheaply than reading the history. **Testing:** - The author ran 4 interleaved runs on RX 9070 XT RADV Linux (no corruption seen in the arrival screenshots or while watching). - Beanstalk is running for Windows AMD dGPU, Linux RADV, Windows NVIDIA and the Steam Deck. One NVIDIA report came back with no metrics. The RX 6000 target has no tester. - Missing: RX 6000 (by hand), a 4 GB card, and a re-measure on main with #1833. All hold the merge. **Overlaps and merge order:** - [#1833](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1833) is merged (d12ddf69); this rebases onto it as above. - [#521](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/521) (WIP BC1) touches the same BC encode and scratch code. - [#1847](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1847) (WIP `RX_VK_TEX_PREP`) touches the same function. If it records uploads off the render thread, the scratches (now two) are shared state that needs the same guard.
@ -268,2 +268,3 @@
SW(RX_VK_BC_LAYERS, tune, int, "1 (clamped 1-8)", "How many layers the ASTC-to-BC scratch images have, which is how many one run decodes and encodes.")
SW(RX_VK_BC_LAYERS, tune, int, "1 (clamped 1-8)", "How many layers the 2048 x 2048 ASTC-to-BC scratch images have, which is how many one run decodes and encodes at a level over 1024.")
SW(RX_VK_BC_POOL, attempt, bool, "off: the BC scratch images each get a dedicated allocation", "=1 takes the two ASTC-to-BC scratch images from the shared image pool instead of dedicated allocations.")
SW(RX_VK_BC_SMALL_LAYERS, tune, int, "8 (clamped 1-8; 1: no small scratch)", "How many layers the 1024 x 1024 ASTC-to-BC scratch has, which is how many one run decodes and encodes at a level of 1024 or less.")
Owner

Default 8 is shown right only on RDNA4 RADV; the card that corrupted with multi-layer runs (RX 6600) is unrun. Keep it as the way back until that run and the farm's pass. After that, an on/off way back is enough, not a 1-8 tune.

Default 8 is shown right only on RDNA4 RADV; the card that corrupted with multi-layer runs (RX 6600) is unrun. Keep it as the way back until that run and the farm's pass. After that, an on/off way back is enough, not a 1-8 tune.
@ -772,0 +772,4 @@
/// (longshot) The small scratch: levels no larger than kBcSmallDim (the terrain's material arrays from their second level
/// down) decode and encode bc_small_layers() layers a run through it, not one. A run is a decode, an encode, a copy and
/// three full barriers: an array of 90 layers and 11 levels made ~990 of them, and the GPU spent most of the time between
/// them (Hyrule Field's entry on an RX 9070 XT: 51 ms an array at one layer a run, 15 ms at 8; #1720). 32 MB, beside
Owner

It's 36 MB more, not 32: the scratch is 1024² × 4 × 8 = 32 MiB, and bc_out grows from 4 MiB to 8 MiB (small_out). It is held for good at the default RX_VK_BC_IDLE_S=0.

It's 36 MB more, not 32: the scratch is 1024² × 4 × 8 = 32 MiB, and `bc_out` grows from 4 MiB to 8 MiB (`small_out`). It is held for good at the default `RX_VK_BC_IDLE_S=0`.
@ -772,0 +774,4 @@
/// three full barriers: an array of 90 layers and 11 levels made ~990 of them, and the GPU spent most of the time between
/// them (Hyrule Field's entry on an RX 9070 XT: 51 ms an array at one layer a run, 15 ms at 8; #1720). 32 MB, beside
/// the 2048 x 2048 scratch's 20. RX_VK_BC_SMALL_LAYERS=<n>: its layers (8; 1: no small scratch, every run one layer).
/// Their runs can't hold a repacked level (upload_astc_gpu), the cause of the grid lines one layer a run was for
Owner

The history doesn't show this cause. There was no repack when ec89f92e made runs one layer; it came with #1553 (7daafa7a), which says nothing about grid lines. ec89f92e itself names no cause. Either show the mechanism (that the wrong layers were exactly the levels #1553 now repacks), or say "not seen on RDNA4 RADV" until an RX 6000 run.

The history doesn't show this cause. There was no repack when ec89f92e made runs one layer; it came with #1553 (7daafa7a), which says nothing about grid lines. ec89f92e itself names no cause. Either show the mechanism (that the wrong layers were exactly the levels #1553 now repacks), or say "not seen on RDNA4 RADV" until an RX 6000 run.
@ -839,6 +855,18 @@ bool bc_scratch_make() { // (bc_mu held)
bc_scratch = VK_NULL_HANDLE, bc_scratch_view = VK_NULL_HANDLE;
return false;
}
if (bc_small_layers() > 1) { // (not made: its levels go through the first scratch, one layer a run)
Owner

On a full 4 GB card, create_image puts this in system memory, so every small level's decode and encode would go over PCIe, likely slower than main's one-layer runs through the VRAM scratch. Don't make it, or drop it, when !allocation_in_vram(bc_small_alloc) or under the low-VRAM rule. Also log once when it can't be made: the fall-back is silent.

On a full 4 GB card, `create_image` puts this in system memory, so every small level's decode and encode would go over PCIe, likely slower than main's one-layer runs through the VRAM scratch. Don't make it, or drop it, when `!allocation_in_vram(bc_small_alloc)` or under the low-VRAM rule. Also log once when it can't be made: the fall-back is silent.
@ -1033,3 +1069,2 @@
}
logf("vk: the BC3 scratch (%u MB%s) unused for %u s: given back", (second ? 36 : 20) * bc_layers(), second ? ", both" : "",
bc_idle_s());
logf("vk: the BC3 scratch (%u MB%s) unused for %u s: given back", (second ? 36 : 20) * bc_layers() + (bc_small_layers() > 1 ? 4 * bc_small_layers() : 0),
Owner

Nit: this says 52 MB where 56 are freed (bc_out grew by 4), and counts the small scratch even when it wasn't made. Sum allocation_size of what is actually freed.

Nit: this says 52 MB where 56 are freed (`bc_out` grew by 4), and counts the small scratch even when it wasn't made. Sum `allocation_size` of what is actually freed.
@ -1197,0 +1241,4 @@
{"astc decode (the upload budget can put it off)", "astc decode (never put off: a layer array, or over 1024x1024)"},
{"astc decode + BC re-encode (the upload budget can put it off)",
"astc decode + BC re-encode (never put off: a layer array, or over 1024x1024)"}};
GprofSpan span(cmd, kSpans[tex.bc ? 1 : 0][upload_never_put_off(tex) ? 1 : 0]);
Owner

On main with #1833, replay_flush_upload ends, submits, fence-waits and re-begins this command buffer inside the loop, several times for a 1365² × 90 array. This span's begin and end timestamps then fall in different submissions, so it counts the GPU idle during the CPU's waits as "GPU per texture". Close it before the flush and reopen it after (e.g. std::optional<GprofSpan>), then measure again on that base.

On main with #1833, `replay_flush_upload` ends, submits, fence-waits and re-begins this command buffer inside the loop, several times for a 1365² × 90 array. This span's begin and end timestamps then fall in different submissions, so it counts the GPU idle during the CPU's waits as "GPU per texture". Close it before the flush and reopen it after (e.g. `std::optional<GprofSpan>`), then measure again on that base.
@ -1218,1 +1267,4 @@
const bool repack = off % dev.props.limits.minStorageBufferOffsetAlignment != 0 || bytes < g.swizzled;
// (a level the small scratch holds: bc_small_layers() layers a run through it; a resized one has its own scratch)
const bool small = tex.bc && bc_small && !tex.bc_resized && g.w <= kBcSmallDim && g.h <= kBcSmallDim;
const uint32_t bc_run = small ? bc_small_layers() : bc_layers();
Owner

Once #1833 is in: with RX_VK_ASTC_CHUNK_MPX below 9, one 1024² run of 8 exceeds the per-submission bound by itself. Consider capping bc_run at max(1, chunk_texels / (g.w * g.h)).

Once #1833 is in: with `RX_VK_ASTC_CHUNK_MPX` below 9, one 1024² run of 8 exceeds the per-submission bound by itself. Consider capping `bc_run` at `max(1, chunk_texels / (g.w * g.h))`.
@ -212,6 +212,8 @@ std::chrono::steady_clock::time_point bc_used_at;
uint64_t bc_last_value = 0;
std::atomic<bool> bc_have{false};
uint32_t bc_layers() { return 1; }
uint32_t bc_small_layers() { return 1; } // (no small scratch here: its first layout goes in the first one's barrier)
Owner

Main deleted this file in #1763: drop this hunk on the rebase.

Main deleted this file in #1763: drop this hunk on the rebase.
@ -0,0 +55,4 @@
p.add_argument("--cxx", default="g++")
cxx = p.parse_args().cxx
tex = TEX.read_text(encoding="utf-8")
need("uint32_t bc_small_layers() {" in tex, "no small scratch: every ASTC-to-BC run is one layer, whatever its level's size")
Owner

This fails on main because a name is missing, not because runs are one layer. The behaviour is better modelled in bc_scratch_batches_test.cpp's RUN cut: a level of 1024 or less runs 8, a larger one bc_layers(), a repacked one 1. That catches the key line being undone whatever its spelling.

This fails on main because a name is missing, not because runs are one layer. The behaviour is better modelled in `bc_scratch_batches_test.cpp`'s `RUN` cut: a level of 1024 or less runs 8, a larger one `bc_layers()`, a repacked one 1. That catches the key line being undone whatever its spelling.
HumanBean force-pushed feat/astc-ahead from 3845e7413d
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 5s
beanstalk/approval approved by HumanBean (reviewed)
beanstalk/windows+amd+dgpu 1/1 fail
beanstalk/linux+radv 0/1 pass, 1 running, 0 queued
beanstalk/windows+nvidia 0/1 pass, 1 running, 0 queued
beanstalk/steamdeck 0/1 pass, 1 running, 1 queued
beanstalk/linux+amd+gpu-rx-6* 0/1 pass, 0 running, 2 queued
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
Website / Website on Cloudflare (pull_request) Has been cancelled
to dac2d81da5
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 7s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 11s
CI / Workflow lint (actionlint) (pull_request) Successful in 11s
Third-party parts / As their notes say (pull_request) Successful in 13s
PR description / Description follows the template (pull_request_target) Successful in 4s
beanstalk/approval not approved yet
CI / Website build and checks (pull_request) Failing after 4m21s
2026-11-20 06:59:53 +00:00
Compare
Member

Beanstalk test farm

Commit dac2d81 · tier untrusted · approved by nobody yet · dashboard

A member of BigBeans can review this commit and comment @Beanstalk to test it.

<!-- beanstalk:sticky --> ### Beanstalk test farm Commit `dac2d81` · tier **untrusted** · approved by nobody yet · [dashboard](https://beanstalk.magicbean.dev/prs/1843) A member of `BigBeans` can review this commit and comment `@Beanstalk` to test it.
HumanBean changed title from WIP: perf(vk): ASTC levels of 1024 or less re-encode to BC eight layers a run, through a small scratch to perf(vk): ASTC levels of 1024 or less re-encode to BC eight layers a run, through a small scratch 2026-11-20 07:00:18 +00:00
HumanBean approved these changes 2026-11-20 07:00:33 +00:00
HumanBean left a comment

Recommendation: Approve, on dac2d81d. The review's blocking points are fixed in this branch. The run-length gain stands as measured on an RX 9070 XT. Merged at the maintainer's call, ahead of runs on other GPUs and a re-measure on the new base.

Fixed in this review: dac2d81d, on top of the author's two commits, rebased onto main after #1763 and #1833.

  1. Rebase: the conflicts are resolved, keeping both #1833's chunk_texels and this PR's span. tests/parallel_init_order_test.cpp stays deleted, as main has it. #1833's chunking fixture gets stubs for bc_small, bc_small_view, kBcSmallDim, bc_small_layers, upload_never_put_off and GprofSpan.
  2. The span: it is now an std::optional<GprofSpan>, reset before replay_flush_upload and opened again after. test_astc_pass_timing checks that it never runs across a flush.
  3. The grid lines: the comment, the test and the description say the cause wasn't found, and that RDNA4 RADV showed none. !repack is kept.
  4. VRAM:
    • The small scratch is made only when !low_vram_texture_mips() and when it lands in VRAM (allocation_in_vram). Otherwise it's logged once and every level goes one layer a run.
    • The output buffer grows only for a scratch that was made.
    • The text says 36 MB.

Also:

  • A BC run is capped at chunk_texels / level_texels layers.
  • The given-back log sums allocation_size of what is freed.

Checked:

  • vk_texture.cpp compiles clean (-fsyntax-only) against main's headers with the build's flags.
  • The other checks that cut these functions still find their lines: test_bc_scratch_layers, test_bc_upload_retry and test_mem_trim.
  • The tests were not run.

Still wanted: RX 6000 (the card that showed the grid lines), a 4 GB card, and the Beanstalk runs. Also a re-measure of the span on the new base: the numbers are from 79d83b03, before #1833.

**Recommendation: Approve,** on dac2d81d. The review's blocking points are fixed in this branch. The run-length gain stands as measured on an RX 9070 XT. Merged at the maintainer's call, ahead of runs on other GPUs and a re-measure on the new base. **Fixed in this review:** dac2d81d, on top of the author's two commits, rebased onto main after #1763 and #1833. 1. **Rebase:** the conflicts are resolved, keeping both #1833's `chunk_texels` and this PR's span. `tests/parallel_init_order_test.cpp` stays deleted, as main has it. #1833's chunking fixture gets stubs for `bc_small`, `bc_small_view`, `kBcSmallDim`, `bc_small_layers`, `upload_never_put_off` and `GprofSpan`. 2. **The span:** it is now an `std::optional<GprofSpan>`, reset before `replay_flush_upload` and opened again after. `test_astc_pass_timing` checks that it never runs across a flush. 3. **The grid lines:** the comment, the test and the description say the cause wasn't found, and that RDNA4 RADV showed none. `!repack` is kept. 4. **VRAM:** - The small scratch is made only when `!low_vram_texture_mips()` and when it lands in VRAM (`allocation_in_vram`). Otherwise it's logged once and every level goes one layer a run. - The output buffer grows only for a scratch that was made. - The text says 36 MB. Also: - A BC run is capped at `chunk_texels / level_texels` layers. - The given-back log sums `allocation_size` of what is freed. **Checked:** - `vk_texture.cpp` compiles clean (`-fsyntax-only`) against main's headers with the build's flags. - The other checks that cut these functions still find their lines: `test_bc_scratch_layers`, `test_bc_upload_retry` and `test_mem_trim`. - The tests were not run. **Still wanted:** RX 6000 (the card that showed the grid lines), a 4 GB card, and the Beanstalk runs. Also a re-measure of the span on the new base: the numbers are from 79d83b03, before #1833.
Author
Contributor

Thanks for the fixes and the merge. Here's the re-measure on the new base you asked for. It ran on my own build of the same fixes (740742f1, never pushed, on main d12ddf69 with #1833), which I had in progress when you pushed yours; on this card its ASTC code is the same as dac2d81d (the low-VRAM rules don't apply at 16 GB).

Re-measure on the new base

Linux (Fedora 45), RX 9070 XT, Mesa 26.2.7 RADV, 2560 x 1440 fullscreen. 740742f1 as a pack over the 068fb8eb base (the renderer alone, which brings in d12ddf69 with #1833). Each run starts from a test save, teleports to the Market, goes out of the Castle Town gate into Hyrule Field, then 180 s of running with the camera turning. Interleaved 8, 1, 4, 8, 1, 4 layers after a warm-up run, with RX_VK_PASS_TIMING=1, under a 20 GB cap that was never reached. The span closes and reopens around each flush.

Before, RX_VK_BC_SMALL_LAYERS=1 (one layer a run, as main) RX_VK_BC_SMALL_LAYERS=4 After, the default (8)
never-put-off decode + BC re-encode, ms a frame over the entry's 600-present report 0.697, 0.782 0.324, 0.300 0.248, 0.255
the same, GPU ms in all at the entry 418, 469 194, 180 149, 153
longest frame at the arrival 117, 124 ms 150, 127 ms 122, 144 ms
frames of 50 ms or more at the arrival 3, 5 5, 5 4, 7
GPU time a frame in play (last 6 reports) 9.60, 9.85 ms 9.80, 9.55 ms 9.55, 9.60 ms
  • The 3x holds on the new base: 8 layers take 2.7-3.1x less GPU time than one, about 290 ms less GPU work at the field's entry.
  • 4 layers keep about 88% of that for half the scratch (16 MB instead of 32), if you'd rather have the cheaper default you mentioned.
  • The arrival frame doesn't change on this card: it's CPU-bound (in the slow-frame lines, the replay's submit takes most of each long arrival frame, 114.5 of 117.6 ms in one, mostly draw, descriptors and texture lookups), and the RX 9070 XT absorbs the GPU work. The saving should show as a shorter hitch on a weaker GPU, but this run doesn't show that.
  • A decode-only pair (RX_VK_ASTC_RGBA8=1) isn't comparable: without BC a different set of textures takes that path, more than twice the bytes. So I haven't split decode from encode.

These numbers are from my build, not the merged commit. Would you like the series run again on main 65488813, or are these acceptable? You noted the tests weren't run: on dac2d81d, tests/test_astc_upload_chunking.py, tests/test_bc_scratch_layers.py, tests/test_bc_small_scratch.py, tests/test_astc_pass_timing.py, tests/test_switch_table.py, tests/test_bc_upload_retry.py and tests/test_texture_staging_publication.py pass here (run_all.py --strict).

A possible follow-up

The chunking test stubs the small scratch as not made, so it doesn't check a small level's 8-layer runs against the per-submission bound. My version of the test makes the scratch: the 1365 x 1365 x 90 array then takes 420 dispatches, and every submission stays under 16 Mpx. It also adds a run-length check in bc_scratch_batches_test.cpp that runs the lines choosing a level's run length. Both pass on dac2d81d. If you think it's worth it, I can open it as a small test(vk) PR.

Your RX 6600 question

Not that I can find. ec89f92e's message is the only report: on an RX 6600, at the smaller levels, every layer after a run's first came out wrong, with no cause named. #384 measured memory only (Steam Decks, RTX 3090, RX 580), and no issue or PR mentions grid lines after #1553. For the RX 6000 run, I'll test an RX 6800 XT on Windows: Hyrule Field from the Castle Town gate with the default, RX_VK_BC_SMALL_LAYERS=1 and RX_VK_BC_LAYERS=8, comparing the far ground for grid lines.

Still to come

  • RX 6000: the RX 6800 XT run above.
  • The Windows crash in the first farm run: the RX 9070 XT's PR run ended 0xC00000FD (stack overflow) after reaching the field, but the report's log stops before it. Is the full log available?

Not something I can do: a 4 GB card (I don't have one) and the Beanstalk runs on other GPUs. Those need the farm or someone with the hardware.

Thanks for the fixes and the merge. Here's the re-measure on the new base you asked for. It ran on my own build of the same fixes (`740742f1`, never pushed, on main `d12ddf69` with #1833), which I had in progress when you pushed yours; on this card its ASTC code is the same as `dac2d81d` (the low-VRAM rules don't apply at 16 GB). ## Re-measure on the new base Linux (Fedora 45), RX 9070 XT, Mesa 26.2.7 RADV, 2560 x 1440 fullscreen. `740742f1` as a pack over the `068fb8eb` base (the renderer alone, which brings in `d12ddf69` with #1833). Each run starts from a test save, teleports to the Market, goes out of the Castle Town gate into Hyrule Field, then 180 s of running with the camera turning. Interleaved 8, 1, 4, 8, 1, 4 layers after a warm-up run, with `RX_VK_PASS_TIMING=1`, under a 20 GB cap that was never reached. The span closes and reopens around each flush. | | Before, `RX_VK_BC_SMALL_LAYERS=1` (one layer a run, as main) | `RX_VK_BC_SMALL_LAYERS=4` | After, the default (8) | |---|---|---|---| | never-put-off decode + BC re-encode, ms a frame over the entry's 600-present report | 0.697, 0.782 | 0.324, 0.300 | 0.248, 0.255 | | the same, GPU ms in all at the entry | 418, 469 | 194, 180 | 149, 153 | | longest frame at the arrival | 117, 124 ms | 150, 127 ms | 122, 144 ms | | frames of 50 ms or more at the arrival | 3, 5 | 5, 5 | 4, 7 | | GPU time a frame in play (last 6 reports) | 9.60, 9.85 ms | 9.80, 9.55 ms | 9.55, 9.60 ms | - The 3x holds on the new base: 8 layers take 2.7-3.1x less GPU time than one, about 290 ms less GPU work at the field's entry. - 4 layers keep about 88% of that for half the scratch (16 MB instead of 32), if you'd rather have the cheaper default you mentioned. - The arrival frame doesn't change on this card: it's CPU-bound (in the slow-frame lines, the replay's submit takes most of each long arrival frame, 114.5 of 117.6 ms in one, mostly draw, descriptors and texture lookups), and the RX 9070 XT absorbs the GPU work. The saving should show as a shorter hitch on a weaker GPU, but this run doesn't show that. - A decode-only pair (`RX_VK_ASTC_RGBA8=1`) isn't comparable: without BC a different set of textures takes that path, more than twice the bytes. So I haven't split decode from encode. These numbers are from my build, not the merged commit. Would you like the series run again on main `65488813`, or are these acceptable? You noted the tests weren't run: on `dac2d81d`, `tests/test_astc_upload_chunking.py`, `tests/test_bc_scratch_layers.py`, `tests/test_bc_small_scratch.py`, `tests/test_astc_pass_timing.py`, `tests/test_switch_table.py`, `tests/test_bc_upload_retry.py` and `tests/test_texture_staging_publication.py` pass here (`run_all.py --strict`). ## A possible follow-up The chunking test stubs the small scratch as not made, so it doesn't check a small level's 8-layer runs against the per-submission bound. My version of the test makes the scratch: the 1365 x 1365 x 90 array then takes 420 dispatches, and every submission stays under 16 Mpx. It also adds a run-length check in `bc_scratch_batches_test.cpp` that runs the lines choosing a level's run length. Both pass on `dac2d81d`. If you think it's worth it, I can open it as a small `test(vk)` PR. ## Your RX 6600 question Not that I can find. ec89f92e's message is the only report: on an RX 6600, at the smaller levels, every layer after a run's first came out wrong, with no cause named. #384 measured memory only (Steam Decks, RTX 3090, RX 580), and no issue or PR mentions grid lines after #1553. For the RX 6000 run, I'll test an RX 6800 XT on Windows: Hyrule Field from the Castle Town gate with the default, `RX_VK_BC_SMALL_LAYERS=1` and `RX_VK_BC_LAYERS=8`, comparing the far ground for grid lines. ## Still to come - **RX 6000:** the RX 6800 XT run above. - **The Windows crash in the first farm run:** the RX 9070 XT's PR run ended `0xC00000FD` (stack overflow) after reaching the field, but the report's log stops before it. Is the full log available? Not something I can do: a 4 GB card (I don't have one) and the Beanstalk runs on other GPUs. Those need the farm or someone with the hardware.
Contributor

Windows NVIDIA, after the merge: Windows 11 Pro 26300, RTX 3080 10 GB (NVIDIA 621.14; it has no ASTC, so it takes this path), main @ a7646537 built here. The Test Farm's NVIDIA report had no numbers, so this is that Still to test row.

Six starts, interleaved: default, RX_VK_BC_SMALL_LAYERS=1, =1, default, default, =1. Each start: RX_VK_PASS_TIMING=1, an adult save in Hyrule Field, a teleport to the Market and 80 s there, out of the gate on foot into Hyrule Field, 80 s standing, then a 45 s run around the field. The same pinned options file every run, uncapped.

  • No grid lines on the ground in either arm, in the field shots at the gate (looking out across the field) or in the 8 shots of each run around. One caveat: the game's clock had it at night in every run, so the ground was dim. A daytime look would be a stronger check.
  • No device lost, VK_ERROR or crash in any of the six, and each quit normally.
  • GPU time of the never-put-off decode and BC re-encode (astc decode + BC re-encode (never put off ...), per span), from the report that holds the save's load into Hyrule Field:
Before: RX_VK_BC_SMALL_LAYERS=1 (one layer a run) After: the default (8)
per span 5.56, 5.55, 5.46 ms 4.06, 3.63, 3.65 ms
a frame, over that report's 600 presents 0.398, 0.398, 0.400 ms 0.230, 0.236, 0.237 ms
Hyrule Field standing, median fps 85.2, 85.7, 84.4 85.5, 83.8, 85.9

So on the RTX 3080 it's about 1.4x less GPU time a span (the RX 9070 XT showed 3x, from a much slower start: ~50 ms against ~5.5 ms here). Frame rate in the field is within the spread. RX_VK_PASS_TIMING's smaller spans (the budget-deferred ones) are the same in both arms.

Posted by an AI agent (Claude Code) for d4nkn3ss.

Windows NVIDIA, after the merge: Windows 11 Pro 26300, RTX 3080 10 GB (NVIDIA 621.14; it has no ASTC, so it takes this path), main @ a7646537 built here. The Test Farm's NVIDIA report had no numbers, so this is that Still to test row. Six starts, interleaved: default, `RX_VK_BC_SMALL_LAYERS=1`, `=1`, default, default, `=1`. Each start: `RX_VK_PASS_TIMING=1`, an adult save in Hyrule Field, a teleport to the Market and 80 s there, out of the gate on foot into Hyrule Field, 80 s standing, then a 45 s run around the field. The same pinned options file every run, uncapped. - **No grid lines** on the ground in either arm, in the field shots at the gate (looking out across the field) or in the 8 shots of each run around. One caveat: the game's clock had it at night in every run, so the ground was dim. A daytime look would be a stronger check. - **No device lost, `VK_ERROR` or crash** in any of the six, and each quit normally. - **GPU time of the never-put-off decode and BC re-encode** (`astc decode + BC re-encode (never put off ...)`, per span), from the report that holds the save's load into Hyrule Field: | | Before: `RX_VK_BC_SMALL_LAYERS=1` (one layer a run) | After: the default (8) | |---|---|---| | per span | 5.56, 5.55, 5.46 ms | 4.06, 3.63, 3.65 ms | | a frame, over that report's 600 presents | 0.398, 0.398, 0.400 ms | 0.230, 0.236, 0.237 ms | | Hyrule Field standing, median fps | 85.2, 85.7, 84.4 | 85.5, 83.8, 85.9 | So on the RTX 3080 it's about 1.4x less GPU time a span (the RX 9070 XT showed 3x, from a much slower start: ~50 ms against ~5.5 ms here). Frame rate in the field is within the spread. `RX_VK_PASS_TIMING`'s smaller spans (the budget-deferred ones) are the same in both arms. *Posted by an AI agent (Claude Code) for d4nkn3ss.*
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!1843
No description provided.