perf(vk): ASTC levels of 1024 or less re-encode to BC eight layers a run, through a small scratch #1843
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1843
Loading…
Reference in a new issue
No description provided.
Delete branch "GrimVisage/Longshot:feat/astc-ahead"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
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 (!repackinupload_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 andRX_VK_BC_LAYERSstay as they were.RX_VK_BC_SMALL_LAYERS=1brings back one layer a run.The first commit makes this measurable.
RX_VK_PASS_TIMINGnow times each texture's decode and re-encode as anastcspan, split by whether the upload budget can put it off.To see it on
main: enter Hyrule Field (from the Castle Town gate) withRX_VK_PASS_TIMING=1on this branch andRX_VK_BC_SMALL_LAYERS=1. Theastc decode + BC re-encode (never put off ...)row shows ~50 ms a span.Read first:
gpu/vk/vk_texture.cpp:upload_astc_gpu(thesmalllevel 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:
astcspan closes before each upload chunk's flush and opens again after, so it never counts the CPU's wait as GPU time;low_vram_texture_mips) or where it would land in system memory (logged once), and the output buffer grows only when it was made;RX_VK_ASTC_CHUNK_MPX);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.pyruntime, 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 andRX_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 amainbuild withRX_VK_BC_LAYERS=8(8 layers a run at every level, through the big scratch) showed none either.Checks:
tests/test_bc_small_scratch.pyfails onmain("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.pyandtests/test_bc_upload_retry.pypass.tests/test_parallel_init_order.py's fixture now has stubs for the small scratch; it fails to build onmain(host_read_barrier,FpsRtWait) and fails the same way here.mise run test(--strict;clang++,spirv-val, dav1d, the pinned headers and glslang present;lldwas installed after the full run, which then passedtest_thinlto_tlsalone): 800 passed, 56 failed, 17 skipped (Windows-only) in the full run; 801 and 55 withtest_thinlto_tls. None of the failures is new: the same checks run on amaincheckout (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, readsbc_scratch_layout: its fixture stops on main's errors (host_read_barrier,FpsRtWait) before reaching it, onmainand here alike, so it doesn't check this change. After those runs the branch was rebased onto main3f2c9b3c(#1838, which changes onlytests/test_nfc_scan_hint.py); the four checks named above pass again there.Still to test:
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)steamdeck): the same, expecting no grid lines and the entry no longer than onmain(@Beanstalk test the Steam Deck on Hyrule Field)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 packover the068fb8ebbase), A =RX_VK_BC_SMALL_LAYERS=1(one layer a run, asmain), 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 withRX_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 asmaindoes:mainhas noastcspan to read the decode and re-encode from (the first commit adds it). 79d83b03 is this branch before its rebase onto3f2c9b3c, which changes onlytests/test_nfc_scan_hint.py.RX_VK_BC_SMALL_LAYERS=1): this PR @ 79d83b03astc decode + BC re-encode (never put off), GPU per textureThe CPU side of the entry frame's uploads doesn't change: the replay records the same work, in fewer runs.
Risks
RX_VK_BC_IDLE_S). Not made on a small-VRAM card or out of VRAM.RX_VK_BC_SMALL_LAYERS=1doesn't make the small scratch.RX_VK_BC_SMALL_LAYERS=1turns it off.longshot_options.inior the caches.Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
gpu/vk/switches.def.tests/that reads changed source is updated, not weakened.mainand here, for a change that shows on screen. (In this comment: the same build withRX_VK_BC_SMALL_LAYERS=1, asmain, and the default; see Baseline)Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
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.
@Beanstalk
Beanstalk test farm · an earlier run: commit
3845e74(the newer results are in a comment below)Commit
3845e74· tier reviewed · approved by HumanBean · dashboardWhat 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.
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.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.
AMD Radeon RX 9060 XT, 2.0.416; 2: windows+amd+amd-proprietary+dgpuAMD Radeon RX 9070 XT, 2.0.416AMD Radeon RX 7900 XTX (RADV NAVI31), 26.2.7NVIDIA GeForce RTX 3050 Ti Laptop GPU, 621.24.0Measurements · windows+amd+dgpu
Verdict: fail on windows+amd+dgpu (2/1 report):
field-entry crashfailed.Hardware: 1: windows+amd+amd-proprietary+dgpu
AMD Radeon RX 9060 XT, 2.0.416AMD Ryzen 5 5600 6-Core Processor, 32 GB RAM; 2: windows+amd+amd-proprietary+dgpuAMD Radeon RX 9070 XT, 2.0.416AMD Ryzen 9 5900X 12-Core Processor, 32 GB RAMScene: 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 (
@Beanstalkon this PR runs it again)3f2c9b33845e74Flags and settings
None: the plan varied no setting, switch or build option.
Markdown for the PR description
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.7AMD Ryzen 7 5800X3D 8-Core Processor, 64 GB RAMScene: 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 (
@Beanstalkon 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 · 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.0AMD Ryzen 7 5800H with Radeon Graphics, 16 GB RAMScene: 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 (
@Beanstalkon 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
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, asmain):After, the default (eight layers a run at levels of 1024 or less):
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:
Beanstalk's run is still going. Its one report so far (RTX 3050 Ti laptop) came back with no metrics.
Other systems:
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.RX_VK_ASTC_CHUNK_MPXis 9 or more.RX_VK_ASTC_CPU), non-BC ASTC uploads (smallneedstex.bc), the AMD resized path (!tex.bc_resized) andtexture_copy_into_bc(still the big scratch atbc_layers()). They are untouched.RX_VK_PASS_TIMINGreports. The upload buffers'barrierrows lose the ASTC path's barriers, because the outerastcspan 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 inswitches.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:
3845e7413dagainst3f2c9b3c88(the PR's fork point; main is nowa3565ac5, #1763). Read in full:gpu/vk/vk_texture.cpp, and in the PR's versionbc_layers,bc_small_layers,bc_scratch_make,bc_encode_into,bc_encode_resized,bc_scratch_layout,bc_scratch_idle,upload_astc_gpuandupload_defer;gpu/vk/vk_gprof.hand the core ofgpu/vk/vk_gprof.cppon main;create_imageingpu/vk/vk_vma.cpp;host_shaders/bc_encoder.comp,bc7_encoder.comp);afecbaee:upload_astc_gpu,replay_flush_uploadand its test fixture's cuts;ec89f92eand #1553 (7daafa7a), with the pre-#1553upload_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.(z * blocks_y + y) * blocks_x + x. That matches the tightly packedvkCmdCopyBufferToImageof n layers, so a multi-layer run's copy is laid out right.bc_outis sizedmax(big, small)(8 MiB) and holds a small run.bc_layers().bc_scratch_idlegives it back with the samebc_last_valueas the big scratch.width - 1.upload_never_put_offis exactlyupload_defer's old rule, andupload_defernow uses it.RX_VK_PASS_TIMING, and its destructor closes it on every early return.bc_smallis read withoutbc_mu, asbc_scratch_viewalready is. Idle release is off by default and needsbc_idle_sseconds since the lastbc_scratch_layout, so no new race in practice.Blocking (to change before merge)
tests/parallel_init_order_test.cpp(#1763): drop that hunk.bc_scratch_layoutno longer hasInitRedirect, and your hunk below it should apply.chunk_texelsafter the sameconst uint64_t limit = ...;line as yourkSpans/GprofSpan, and puts its flush block between theviewline you change and the decode's dispatch. Keep both.tests/test_astc_upload_chunking.pycompilesupload_astc_gpuwith stubs. After the rebase it needsbc_small,bc_small_view,kBcSmallDim,bc_small_layers,upload_never_put_off(defined outside its cuts) and aGprofSpanstub. Ideally it should also cover a small level's 8-layer runs against the per-submission bound.astcspan runs across #1833's waits (vk_texture.cpp:1244).replay_flush_uploadends, submits, fence-waits and re-begins the command buffer several times inside one span.replay_flush_uploadand open a new one after it (anstd::optional<GprofSpan>reset around the flush would do), or have the flush close and reopen open spans invk_gprof.vk_texture.cpp:777, the test's docstring, the description).!repackremoves it. But there was no repack whenec89f92emade runs one layer. Repack came with #1553 (7daafa7a), whose description says nothing about grid lines or layers. Before it, a run read layer z atz * tail + off, and unaligned levels were skipped.level_geofor 1365 × 1365 ASTC 8×8), or get an RX 6000 run.vk_texture.cpp:858).bc_outgrows from 4 MiB to 8 MiB (small_out). That is 36 MiB more, and at the defaultRX_VK_BC_IDLE_S=0it is kept once made. No pressure path frees it.create_imagefalls 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.allocation_in_vram) or under the low-VRAM rule. Otherwise measure the entry on a 4 GB card.Suggestions (the author may take or leave)
vk_texture.cpp:1070: the "given back" log adds4 * bc_small_layers()but leaves outbc_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. Useallocation_sizeof what is actually freed.vk_texture.cpp:1270: withRX_VK_ASTC_CHUNK_MPXset below 9, a 1024² run of 8 is a single step over the bound. Capbc_runatmax(1, chunk_texels / (g.w * g.h))once #1833 is in.tests/test_bc_small_scratch.pyis mostly exact-text checks: it fails on main becausebc_small_layers()is missing, not because runs are one layer. The behaviour is better modelled intests/bc_scratch_batches_test.cpp, whoseRUNcut already runs the loop. A level of 1024 or less runs 8, a larger onebc_layers(), a repacked one 1. That would also catch the key linesmall ? bc_small_layers() : bc_layers()being undone without relying on its spelling.Questions
RX_VK_BC_LAYERS=8? That would settle Blocking 3 more cheaply than reading the history.Testing:
Overlaps and merge order:
d12ddf69); this rebases onto it as above.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.")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, besideIt's 36 MB more, not 32: the scratch is 1024² × 4 × 8 = 32 MiB, and
bc_outgrows from 4 MiB to 8 MiB (small_out). It is held for good at the defaultRX_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 forThe history doesn't show this cause. There was no repack when
ec89f92emade runs one layer; it came with #1553 (7daafa7a), which says nothing about grid lines.ec89f92eitself 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)On a full 4 GB card,
create_imageputs 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),Nit: this says 52 MB where 56 are freed (
bc_outgrew by 4), and counts the small scratch even when it wasn't made. Sumallocation_sizeof 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]);On main with #1833,
replay_flush_uploadends, 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();Once #1833 is in: with
RX_VK_ASTC_CHUNK_MPXbelow 9, one 1024² run of 8 exceeds the per-submission bound by itself. Consider cappingbc_runatmax(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)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().cxxtex = 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")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'sRUNcut: a level of 1024 or less runs 8, a larger onebc_layers(), a repacked one 1. That catches the key line being undone whatever its spelling.3845e7413ddac2d81da5Beanstalk test farm
Commit
dac2d81· tier untrusted · approved by nobody yet · dashboardA member of
BigBeanscan review this commit and comment@Beanstalkto test it.WIP: perf(vk): ASTC levels of 1024 or less re-encode to BC eight layers a run, through a small scratchto perf(vk): ASTC levels of 1024 or less re-encode to BC eight layers a run, through a small scratchRecommendation: 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.chunk_texelsand this PR's span.tests/parallel_init_order_test.cppstays deleted, as main has it. #1833's chunking fixture gets stubs forbc_small,bc_small_view,kBcSmallDim,bc_small_layers,upload_never_put_offandGprofSpan.std::optional<GprofSpan>, reset beforereplay_flush_uploadand opened again after.test_astc_pass_timingchecks that it never runs across a flush.!repackis kept.!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.Also:
chunk_texels / level_texelslayers.allocation_sizeof what is freed.Checked:
vk_texture.cppcompiles clean (-fsyntax-only) against main's headers with the build's flags.test_bc_scratch_layers,test_bc_upload_retryandtest_mem_trim.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.
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 maind12ddf69with #1833), which I had in progress when you pushed yours; on this card its ASTC code is the same asdac2d81d(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.
740742f1as a pack over the068fb8ebbase (the renderer alone, which brings ind12ddf69with #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, withRX_VK_PASS_TIMING=1, under a 20 GB cap that was never reached. The span closes and reopens around each flush.RX_VK_BC_SMALL_LAYERS=1(one layer a run, as main)RX_VK_BC_SMALL_LAYERS=4RX_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: ondac2d81d,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.pyandtests/test_texture_staging_publication.pypass 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.cppthat runs the lines choosing a level's run length. Both pass ondac2d81d. If you think it's worth it, I can open it as a smalltest(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=1andRX_VK_BC_LAYERS=8, comparing the far ground for grid lines.Still to come
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.
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 @
a7646537built 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.VK_ERRORor crash in any of the six, and each quit normally.astc decode + BC re-encode (never put off ...), per span), from the report that holds the save's load into Hyrule Field:RX_VK_BC_SMALL_LAYERS=1(one layer a run)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.