perf(vk): 2.7 GB less VRAM on textures, render targets and buffers #3259
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
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!3259
Loading…
Reference in a new issue
No description provided.
Delete branch "neotoxic/Longshot:perf/vk-vram"
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
A run through five areas kept 2-3 GB of VRAM it never drew from: ASTC textures re-encoded as BC3 when half of them
are opaque (BC1 is half the size) or gray (BC5), dead three-layer shadow arrays and stale aliases kept alive,
oversized pools and buffers. On a 6 GB laptop GPU the same waste pushed textures out and made loads hitch. This
trims each of those, with a switch per part and its default set from A/B runs:
RX_VK_ASTC_BC1, on): the blocks are read at creation (their endpoints, on thehelper threads from 256 KB; a block whose colour modes have no alpha is opaque from its header alone); an upload
that brings non-opaque blocks makes the texture BC3 again. 1600-1800 textures, 640-740 MB on the RTX 5080.
What a content's blocks were found to be is kept in
cache/longshot_astc_kinds.binby its whole hash(
astc_kinds_file.h): from the second run on, the blocks are only hashed, as their first upload does anyway, andthe reads at creation fall from ~600 ms a run to 40-60 ms on the RTX 5080 and to 5 ms on the laptop.
RX_VK_ASTC_BC5, on): the gray in red, the alpha in green, the views swizzled back.texture_for_copy): a BC1 or BC5 texture a copy writes, or reads into another BC image (or, for BC5,into any image), is made BC3 first and uploaded whole; copies from uncompressed colour textures into a BC-kept one
go through the encoder.
RX_VK_ASTC_BC_TRIMMED, on), and ASTC textures of any size go BC (astc_bc_min_mbAutois now 0 MB, was 1).
RX_VK_TARGET_LAYERS_OVER),a texture never drawn goes once a target from the same address drew over it (
RX_VK_STALE_ALIAS): the 3072² x3shadow arrays, 216-270 MB.
RX_VK_BC_NATIVE_MIPS).(
RX_VK_TEX_AHEAD, on): the worst frames of a teleport 25 ms shorter, ~250 MB more VRAM held.images' pool takes 8 MB blocks; the first stream buffer is 512 KB (
RX_VK_STREAM_KB);bc3t_outis 4 MB; atexture goes to the small pool by the size the driver gives it (
RX_VK_SIZE_CLASS_REAL); pack images are kept upto a 32nd of the VRAM (
RX_VK_PACK_KEEP_MB).RX_VK_ZERO_UNTOUCHED): the12288² target is checked in 3.8 ms, was 31-51 ms, 288 MB less read.
imported for the GPU (
RX_VK_UNSWIZZLE_IMPORT_MB): the terrain's R16 arrays (21-38 MB) took 15-29 ms each.RX_VK_SHADOW_SPARSE,RX_VK_SHADOW_GRAIN_KB) and the one-pass ASTC-to-BC shader (RX_VK_ASTC_BC_FUSED:astc_decoder.compbuilt withASTC_TO_BC, the encoder moved tobc3_encode.glsl, whichgen-shadersnow passes-Ifor).Read first:
gpu/vk/vk_texture.cpp(storage_kinds,kinds_file_load,bc1_to_bc3,upload_unswizzle_gpu),gpu/vk/vk_memory.cpp(target retention),
gpu/vk/switches.def.Testing
Tested: Windows 11, RTX 5080, NVIDIA 617.42: 6 timed runs through Market, Kakariko, Kokiri Forest, Lost Woods and
Hyrule Field (
dev.py ab, 150 s each), no artefact; Kokiri and Kakariko screenshots with BC1 on and off identical.CachyOS Linux, RTX 3060 Laptop 6 GB, NVIDIA 620.85: the same 6 runs. The one-pass shader's output is byte for
byte the two passes' on the RTX 5080 (
tests/astc_decoder_gpu.cpp, 288 levels, BC3/BC1/BC5).mise run test: thechecks this touches pass,
tests/test_astc_kinds_file.pynew; the 19 that fail here fail onmaintoo on this PC(test_check_third_party, test_ci_source_times, test_coverage_run, test_dev_vcs, test_dlssg, test_fsr4_tune,
test_helpers_extract, test_lifter, test_longshot_builder, test_no_game_title, test_no_map_reload,
test_present_acquire_ahead, test_present_geometry_trace, test_present_held_image, test_present_image_free,
test_run_all_output, test_sync_watch_event, test_turf_budget, test_ui_renderer: tools this PC lacks, or out of date on
main), and test_dev_cargoenv fails only beside the others in a worktree (it passes alone).After the review fix-ups and the rebase onto
main@bb5a5682(HumanBean, CachyOS, RTX 3090): the renderer compilesfor Linux and Windows (llvm-mingw) with no warnings; the GPU fixture (
test_astc_decoder_gpu.py --device) passes;run_all.pyhad 13 failures, 12 of them onmainalone too (test_lifter, test_present_acquire_ahead,test_present_semaphores, test_present_held_image, test_input_background, test_dlssg, test_i18n_complete,
test_present_image_free, test_sandbox_windows, test_settings_area_keys, test_vk_draw_overhead_lean, test_walk_key),
the 13th, test_bc_scratch_layers, fixed in
a200c870and passing.AMD,
a200c870: CachyOS Linux, RX 580 8 GB (Polaris), Mesa RADV: 3 timed A/B pairs through the five areas, no deviceloss; screenshots of Kokiri Forest, Kakariko, Market and Hyrule Field look the same as
main's; the GPU fixturepasses there with validation on.
Still to test:
main; andRX_VK_ASTC_BC_FUSED=1,expecting less GPU time on ASTC uploads or not (@Beanstalk)
RX_VK_SHADOW_SPARSE=1against unset (@Beanstalk)Measurements
Verdict: 2.7 GB less VRAM (-28%) on an RTX 5080 with fps, 1% low and frames of 50 ms or more the same as
main(within the spread); on a 6 GB RTX 3060 Laptop +1.5% fps (within the spread), 1% low +3.5%, 8 fewer frames of 50 ms
or more. These NVIDIA runs are on the older
mainand the head before the fix-ups, which change copies, failedremakes, error blocks and pack views, none of them the paths those tours spend time in; not re-measured. On an 8 GB
RX 580 (current head): no VRAM saving (+155 MB), 690 MB less GTT, fps within the spread, and longer worst frames
(table below).
Setup: Windows 11, RTX 5080 16 GB, NVIDIA 617.42; Hyrule Field, child, then a teleport every 12 s through Market,
Kakariko, Kokiri Forest, Lost Woods and Hyrule Field; preset Custom, resolution 67%, 1280x720, uncapped; the frame trace,
150 s each after a warm-up until no frame waited for a pipeline, 3 interleaved pairs, the median;
dev.py ab7bc53f8466492ca3Setup: CachyOS Linux, RTX 3060 Laptop 6 GB, NVIDIA 620.85; the same tour, resolution 67%, 1440x900
3a0f7d8f72c08218is this branch's tree on the laptop's older base,3a0f7d8f(the one commit ofmainsince,7bc53f84,changes mods, no file in common).
Before the file of kinds (
1356eaf1againstmain@3a0f7d8f, the same PC and tour): VRAM -2709 MB, but -0.4% fps(every B run below every A run) and 5 more frames of 50 ms or more, the block reads at creation (~600 ms a run on the
replay thread): what
astc_kinds_file.hnow saves from the second run on.Setup: CachyOS Linux, RX 580 8 GB, Mesa RADV, i7-9700K; 1280x720, resolution 67%, uncapped, headless; a teleport every
few seconds through the five areas for 90 s after one untimed lap; 3 interleaved pairs, the median (each run in
brackets)
bb5a5682a200c870The cause of the longer worst frames is not isolated (no per-switch A/B there yet).
The switches one by one (each its own A/B on the RTX 5080 or the laptop, the default it ships at):
RX_VK_ASTC_BC1RX_VK_ASTC_BC5RX_VK_ASTC_BC_TRIMMEDastc_bc_min_mbAuto 0RX_VK_TARGET_LAYERS_OVER,RX_VK_STALE_ALIASRX_VK_BC_NATIVE_MIPSRX_VK_TEX_AHEADRX_VK_COMPACT_MBAuto)RX_VK_SIZE_CLASS_REALRX_VK_COMPACTis onRX_VK_STREAM_KBRX_VK_ZERO_UNTOUCHEDRX_VK_UNSWIZZLE_IMPORT_MBRX_VK_SHADOW_SPARSERX_VK_ASTC_BC_FUSEDRisks
main's (above), with no VRAM saving there.game does that.
slower upload, logged (
its blocks are not all opaque now). Wrong colours on BC1/BC5 textures would be thevisible sign:
RX_VK_ASTC_BC1=0/RX_VK_ASTC_BC5=0.memory it doesn't need; on 4-8 GB cards and the Deck the saving is what keeps textures resident.
cache/longshot_astc_kinds.binis new, up to ~3 MB, written every 300 frames when it has new entries. A file ofanother version, cut short or too big is read as none; a content's hash is 64 bits whole, so a wrong "opaque" from it
would take a hash collision.
settings.toml; theASTC to BC fromandCompaction free spacemenu rows keep their keys, only their Auto values changed.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.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: Windows 11, RTX 5080, NVIDIA 617.42, and CachyOS Linux, RTX 3060 Laptop 6 GB, NVIDIA 620.85: 6 timed runs each through Market, Kakariko, Kokiri Forest, Lost Woods and Hyrule Field with every default of this branch, no artefact, no crash; BC1 textures in Kokiri and Kakariko look the same as BC3.
@Beanstalk please run this branch against main on a Steam Deck, an AMD RX 6000-9000 on Windows, an Intel Arc and a 4 GB card: the five-area tour (Market, Kakariko, Kokiri Forest, Lost Woods, Hyrule Field), fps, 1% low, frames of 50 ms or more, VRAM by the driver. On the Deck and the 4 GB card, also RX_VK_SHADOW_SPARSE=1 and RX_VK_ASTC_BC_FUSED=1 against unset: both are off because they cost on a 6 GB RTX 3060 Laptop, and may pay on smaller GPUs. On AMD and Intel, a look at textures for wrong colours (BC1/BC5 are new formats here).
@neotoxic only members of
BigBeanscan start the farm.One of them can approve this request by reacting 👍 to it or to this comment.This request was for0a11cc3, and the PR has changed since (66492ca), so a 👍 no longer approves it. Comment@Beanstalkagain to ask for the new commit.Possibly related, for context:
@review
Recommendation: Request changes. The change saves substantial VRAM in the reported RTX 5080 runs, but some texture copies are skipped or produce incorrect channels, and failed format conversion can silently upload incorrect texture data. The default rendering changes also need the outstanding hardware runs.
The PR reduces texture and allocation sizes, changes target retention, and prepares some textures ahead of use. It adds several format-conversion and memory-management paths, with correctness costs in cases outside the reported tour.
Blocking (3): must change before merging.
gpu/vk/vk_xfer.cpp:318: Copies between differently encoded BC textures, or into a BC1 or BC5 texture, can be silently discarded. (more on the line) Do: Provide a conversion or remake path that performs these copies, and test copies among the new formats and the existing formats.gpu/vk/vk_xfer.cpp:332: A blit out of a BC5-kept texture does not apply the channel mapping used by its sampled views. When: A gray ASTC texture kept as BC5 stores luminance in red and alpha in green. A copy from it to an uncompressed texture takes this raw image blit, producing red and green channels rather than the intended gray RGB and alpha. Do: Convert through a path that restores the BC5 channel mapping when copying to an uncompressed image, and cover that copy with a colored-alpha fixture.gpu/vk/astc_opaque.h:33: The scan treats every all-zero block as padding, including blocks that occupy actual texels. (more on the line) Do: Use the texture layout to distinguish padding from actual blocks and classify actual zero blocks as errors; add a mixed opaque/error-block test.Should fix (2): not blocking, but worth doing before merging.
gpu/vk/vk_texture.cpp:3856: A failed BC3 remake falls through to an upload in the format that was just found unsuitable. (more on the line) Do: Do not upload or mark the update successful in the unsuitable format; provide a correct fallback or preserve the pending update and retry after making a suitable image.tests/test_astc_opaque.py:7: The new check hard-codes g++ instead of using the compiler selected by the test runner. (more on the line) Do: Pass the runner's {cxx} placeholder and use the selected compiler for direct invocation as well.Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
@fixcan do L1, L2, L3, L4 and L5.Questions (1) (not confirmed from the code; they don't hold the recommendation)
Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes for VRAM on the reported RTX 5080: three interleaved pairs report a median reduction from 9,631 MB to 6,922 MB. On the 6 GB RTX 3060 Laptop, driver VRAM rose from 4,216 MB to 4,263 MB and FPS was within the run spread; the reported improvement in frame pacing needs confirmation on the affected hardware and at player settings.
Other systems: Both Windows and Linux use the changed texture conversion, copies, retention and allocation paths. The reported game runs cover NVIDIA on each OS; AMD Windows and RADV, Steam Deck, Intel Arc, smaller cards, texture packs and other game areas remain insufficiently covered. Windows also uses the new untouched-page optimization.
Switches: ASTC_BC1, ASTC_BC5, ASTC_BC_TRIMMED, TARGET_LAYERS_OVER, STALE_ALIAS, BC_NATIVE_MIPS, SIZE_CLASS_REAL and TEX_AHEAD default on; TEX_AHEAD changed from off. ASTC_BC_FUSED and SHADOW_SPARSE default off. SHADOW_GRAIN_KB defaults to 1024, STREAM_KB to 512, ZERO_UNTOUCHED to 1, UNSWIZZLE_IMPORT_MB to 64, and PACK_KEEP_MB to one thirty-second of the allowance clamped to 64–512 MB. STREAM_MB remains supported. The ASTC-to-BC Auto threshold changed from 1 MB to 0 and compaction Auto from one sixteenth clamped to 64–512 MB to one sixty-fourth clamped to 64–128 MB. Rows exist; the on defaults are not yet validated across affected hardware, and the copy defects make the format defaults unsafe as implemented.
Reviewed:
0a11cc3dd5against7bc53f8413: Read the repository instructions, contribution rules, standards and PR template; the review checklist was absent. Read the commit log, texture classification and remake paths, copy fallback, relevant shader and test changes, switch table and portions of the memory and allocator changes. The large texture and memory files, remaining changed tests, shader sources and generated-file claims were skimmed rather than read fully; this review is therefore incomplete.; nothing run (a code review).Checked and fine:
Testing: No commands from the project or tests were run, as requested. All listed CI checks are still running.
Overlaps and merge order: Unknown; the network is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@ -0,0 +30,4 @@/// `bytes` of a texture's storage, whole blocks of footprint bw x bh (16 bytes each) and the zero padding between them: the kinds/// of `want` every block is (`any` set where a block was seen). Stops once none is left. A part of a storage, read on its own/// (vk_texture.cpp reads a large one on several threads)inline uint32_t blocks_kinds(const uint8_t* p, size_t bytes, uint32_t bw, uint32_t bh, uint32_t want, bool& any) {L4 (blocking): The scan treats every all-zero block as padding, including blocks that occupy actual texels.
When: A texture containing opaque ASTC blocks and an all-zero error block is classified opaque because the latter is skipped. The decoder renders that error block transparent black, but BC1 encoding discards its alpha and makes the affected texels opaque; a later zero-block upload has the same issue.
Do: Use the texture layout to distinguish padding from actual blocks and classify actual zero blocks as errors; add a mixed opaque/error-block test.
@ -3443,0 +3853,4 @@// first upload)if (tex.astc && (is_bc1(tex) || is_bc5(tex))) {const uint32_t need = is_bc1(tex) ? astc_opaque::kAstcOpaque : astc_opaque::kAstcGray;if (!storage_kinds(tex.gpu, total, tex.block_w, tex.block_h, need, tex.uploaded ? dirty : nullptr) && bc_remake(tex))L3 (should fix): A failed BC3 remake falls through to an upload in the format that was just found unsuitable.
When: If a BC1 texture receives non-opaque blocks or a BC5 texture receives colored blocks while BC3 allocation fails or the texture has block attachments, bc_remake returns false. upload_astc_gpu then encodes the new data as BC1 or BC5 and reports success, losing alpha or color.
Do: Do not upload or mark the update successful in the unsuitable format; provide a correct fallback or preserve the pending update and retry after making a suitable image.
@ -316,2 +316,3 @@const bool same_size = s.w == d.w && s.h == d.h && s.d == d.d;if (s.tex->bc != d.tex->bc || (s.tex->bc && !same_size)) { // (big ASTC kept as BC3 on one side: vk_texture.cpp)// (RX_VK_ASTC_BC1: kept as BC1 on one side, BC3 or BC7 on the other: no raw copy between them; texture_copy_into_bc leaves it out)const bool unlike_bc = s.tex->bc && d.tex->bc && s.tex->format != d.tex->format;L1 (blocking): Copies between differently encoded BC textures, or into a BC1 or BC5 texture, can be silently discarded.
When: When an opaque ASTC source is kept as BC1 and the destination is BC3, unlike_bc enters this branch; texture_copy_into_bc rejects a BC source and the copy returns without writing the destination. A non-BC source copied into BC1 or BC5 is rejected by that function as well.
Do: Provide a conversion or remake path that performs these copies, and test copies among the new formats and the existing formats.
@ -0,0 +4,4 @@import tempfilefrom pathlib import PathRUN_ALL_ARGS = ["--cxx", "g++"]L5 (should fix): The new check hard-codes g++ instead of using the compiler selected by the test runner.
When: On a supported Windows or Linux development setup with clang++ available but no g++, run_all skips this check or fails it in strict mode even though a suitable compiler is installed; CXX is ignored.
Do: Pass the runner's {cxx} placeholder and use the selected compiler for direct invocation as well.
Pushed
66492ca3: what a content's ASTC blocks were found to be (opaque, gray) is now kept in cache/longshot_astc_kinds.bin between runs. The block reads at creation were the cost the first measurement showed against main (-0.4% fps, 5 more frames of 50 ms or more on the RTX 5080): from the second run on they fall from ~600 ms a run to 40-60 ms (RTX 5080) and 5 ms (RTX 3060 Laptop). Measured again against main7bc53f84: fps, 1% low and frames of 50 ms or more the same as main on the RTX 5080, VRAM -2.7 GB; laptop +1.5% fps, 1% low +3.5%, 8 fewer frames of 50 ms or more. Tables in the description.WIP: perf(vk): 2.7 GB less VRAM on textures, render targets and buffersto perf(vk): 2.7 GB less VRAM on textures, render targets and buffers@Beanstalk please run this branch against main on a Steam Deck, an AMD RX 6000-9000 on Windows, an Intel Arc and a 4 GB card: the five-area tour (Market, Kakariko, Kokiri Forest, Lost Woods, Hyrule Field), fps, 1% low, frames of 50 ms or more, VRAM by the driver. On the Deck and the 4 GB card, also RX_VK_SHADOW_SPARSE=1 and RX_VK_ASTC_BC_FUSED=1 against unset: both are off because they cost on a 6 GB RTX 3060 Laptop, and may pay on smaller GPUs. On AMD and Intel, a look at textures for wrong colours (BC1/BC5 are new formats here).
@neotoxic only members of
BigBeanscan start the farm.One of them can approve this request by reacting 👍 to it or to this comment.This request was for66492ca, and the PR has changed since (c7ebf03), so a 👍 no longer approves it. Comment@Beanstalkagain to ask for the new commit.@review
Recommendation: Request changes. The BC texture copy and classification defects remain, so some texture copies can be lost or produce wrong colors or alpha. The measured VRAM saving is substantial on the RTX 5080, but the affected AMD systems and Steam Deck still need coverage.
The change reduces texture and render-target VRAM use and adds a persistent cache to avoid repeating ASTC block scans. It adds renderer complexity and still has correctness defects in texture copies and classification.
Blocking (3): must change before merging.
gpu/vk/vk_xfer.cpp:318: Copies between differently encoded BC textures, or into a BC1 or BC5 texture, can be silently discarded. When: When an opaque ASTC source is kept as BC1 and the destination is BC3, unlike_bc enters this branch; texture_copy_into_bc rejects a BC source and the copy returns without writing the destination. A non-BC source copied into BC1 or BC5 is rejected by that function as well. Do: Provide a conversion or remake path that performs these copies, and test copies among the new formats and the existing formats.gpu/vk/vk_xfer.cpp:332: A blit out of a BC5-kept texture does not apply the channel mapping used by its sampled views. When: A gray ASTC texture kept as BC5 stores luminance in red and alpha in green. A copy from it to an uncompressed texture takes this raw image blit, producing red and green channels rather than the intended gray RGB and alpha. Do: Convert through a path that restores the BC5 channel mapping when copying to an uncompressed image, and cover that copy with a colored-alpha fixture.gpu/vk/astc_opaque.h:33: The scan treats every all-zero block as padding, including blocks that occupy actual texels. When: A texture containing opaque ASTC blocks and an all-zero error block is classified opaque because the latter is skipped. The decoder renders that error block transparent black, but BC1 encoding discards its alpha and makes the affected texels opaque; a later zero-block upload has the same issue. Do: Use the texture layout to distinguish padding from actual blocks and classify actual zero blocks as errors; add a mixed opaque/error-block test.Should fix (3): not blocking, but worth doing before merging.
gpu/vk/vk_texture.cpp:3856: A failed BC3 remake falls through to an upload in the format that was just found unsuitable. When: If a BC1 texture receives non-opaque blocks or a BC5 texture receives colored blocks while BC3 allocation fails or the texture has block attachments, bc_remake returns false. upload_astc_gpu then encodes the new data as BC1 or BC5 and reports success, losing alpha or color. Do: Do not upload or mark the update successful in the unsuitable format; provide a correct fallback or preserve the pending update and retry after making a suitable image.tests/test_astc_opaque.py:7: The new check hard-codes g++ instead of using the compiler selected by the test runner. When: On a supported Windows or Linux development setup with clang++ available but no g++, run_all skips this check or fails it in strict mode even though a suitable compiler is installed; CXX is ignored. Do: Pass the runner's {cxx} placeholder and use the selected compiler for direct invocation as well.gpu/vk/vk_texture.cpp:3408: A failed cache write clears the dirty flag without scheduling a retry. (more on the line) Do: Restore the dirty flag under the mutex when saving fails, preserving any entries added during the save.Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
@fixcan do L1, L2, L3, L4, L5 and L7.Since the last review (on
0a11cc3dd5)Still open: L1 (Copies between differently encoded BC textures, or into a BC1 or BC5 texture, can be silen…); L2 (A blit out of a BC5-kept texture does not apply the channel mapping used by its sampled vi…); L3 (A failed BC3 remake falls through to an upload in the format that was just found unsuitabl…); L4 (The scan treats every all-zero block as padding, including blocks that occupy actual texel…); L5 (The new check hard-codes g++ instead of using the compiler selected by the test runner.); L6 (The default rendering and memory changes have not been exercised on the affected AMD Tier…)
New: L7 (A failed cache write clears the dirty flag without scheduling a retry.)
Checks: Still running: 11 checks.
Also noticed (2; not asked for, not blocking)
More: does it help, other systems, switches, what was read
Does it help: Yes for measured VRAM use: the description reports a 2,655 MB lower driver average over three interleaved pairs on an RTX 5080, with frame metrics within the spread. The 6 GB laptop filled its budget on both versions; its reported 1.5% fps increase was within the spread.
Other systems: The changes affect Vulkan texture formats, copies, allocation and timing on Windows and Linux. The reported game runs cover NVIDIA desktop and laptop GPUs; AMD Tier 1 systems and Steam Deck remain untested, and Intel Arc and a 4 GB card are also requested.
Switches: The description lists BC1, BC5, trimmed BC, target overlap, stale alias, native BC mips, texture ahead, real size classes and untouched-page skipping on by default; sparse shadows and fused ASTC conversion default off. Stream buffer defaults to 512 KB, CPU unswizzle threshold to 64 MB, and Auto ASTC conversion and compaction thresholds change. NVIDIA measurements support the chosen defaults there; correctness and performance on other affected hardware remain unverified.
Reviewed:
66492ca38fagainst7bc53f8413: Read the new ASTC kinds file and its tests, ASTC opacity helper and test runner, the relevant texture classification and copy paths, repository rules and PR template. Skimmed the remaining diff and switch table; the other changed files and their full callers were not read in full.; nothing run (a code review).Checked and fine:
Testing: No commands from the project or tests were run. The author reports six game runs on each of two NVIDIA systems; CI is still running.
Overlaps and merge order: Not checked; the network is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@ -3239,0 +3405,4 @@if (++frames % 300) return;astc_kinds_file::Map m;{std::lock_guard lk(kinds_memo_mu);L7 (should fix): A failed cache write clears the dirty flag without scheduling a retry.
When: If saving fails temporarily and no further new contents are scanned, later 300-frame checks see a clean cache and never retry; the next launch repeats the scans.
Do: Restore the dirty flag under the mutex when saving fails, preserving any entries added during the save.
@review
Recommendation: Request changes. Copies into BC-kept textures can still be skipped for sources the encoder does not accept. The reported VRAM saving is substantial, but affected AMD hardware and Steam Deck coverage remains outstanding.
The change reduces texture and allocation VRAM use, with measured savings on a 16 GB NVIDIA GPU, at the cost of additional texture classification, conversion, caching and copy handling.
Blocking (2): must change before merging.
gpu/vk/vk_xfer.cpp:318: Copies from non-ASTC uncompressed textures into BC-kept destinations can still be discarded. When: For a same-size copy from a non-ASTC uncompressed source into a BC1 or BC5 destination, the destination is remade, but texture_copy_into_bc rejects the source because src->astc is false; copy_t2t then skips the copy. Do: Handle compatible uncompressed sources when encoding a copy into the remade BC destination, or provide another correct conversion path.@fixor@rebasetry first). (for the author)Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
@fixcan do L1.Since the last review (on
66492ca38f)Resolved: L2 (A blit out of a BC5-kept texture does not apply the channel mapping used by its sampled vi…); L3 (A failed BC3 remake falls through to an upload in the format that was just found unsuitabl…); L4 (The scan treats every all-zero block as padding, including blocks that occupy actual texel…); L5 (The new check hard-codes g++ instead of using the compiler selected by the test runner.); L7 (A failed cache write clears the dirty flag without scheduling a retry.)
Still open: L1 (Copies from non-ASTC uncompressed textures into BC-kept destinations can still be discarde…); L6 (The default rendering and memory changes have not been exercised on the affected AMD Tier…)
New: L8 (It conflicts with its base branch: bring it up to date (
@fixor@rebasetry first).)Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes: the reported three-pair RTX 5080 comparison shows average driver VRAM falling from 9714 MB to 7059 MB, with frame rates and frame times within the reported spread. The 6 GB laptop comparison shows 4308 MB to 4248 MB and eight fewer frames of at least 50 ms; the later fix has not been measured separately.
Other systems: The renderer changes affect GPU formats, uploads, memory and timing across vendors and platforms. The reported game runs cover NVIDIA on Windows and Linux; AMD Tier 1 systems, Steam Deck, Intel Arc and a 4 GB card remain untested in the supplied results.
Switches: The PR adds or changes the switches listed in its measurements table. Defaults are measured on the two NVIDIA systems; their suitability on affected AMD systems and Steam Deck remains unverified. The fix changes the BC1 and BC5 switch descriptions, not their defaults.
Reviewed:
c7ebf0399fagainst7bc53f8413: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the fix diff, astc_opaque.h and test_astc_opaque.py in full; inspected the relevant copy, texture classification, cache and shader paths. The complete original PR diff and all changed files were not read in full. The review checklist and adjacent Tooling AGENTS.md were absent.; nothing run (a code review).Checked and fine:
Testing: No code or tests were run. The supplied CI checks are still running; the author reports game runs on NVIDIA Windows and Linux systems.
Overlaps and merge order: Not checked.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
c7ebf0399fa200c870ecPushed review fix-ups and rebased onto
main(bb5a5682). Head is nowa200c870. The branch was force-pushed: before the rebase it wasc7ebf039(a fast-forward on your66492ca3). Your commits keep you as author. The one conflict was intests/test_device_policy.py:main's new switch name with this PR's value.BeanBot's findings:
tests/bc_scratch_batches_test.cpphas those cases). The remake-on-copy path has no test of its own.tests/astc_decoder_gpu.cppchecks it on the GPU.A second, cold review of the whole branch found these, also fixed:
RX_VK_ASTC_BC7, a remade texture was a BC3 image given BC7 blocks;Not fixed: a BC5-kept texture later sampled through an sRGB view gets no sRGB decode (BC5 has none). I have not checked whether the game ever does that.
Checked here (CachyOS, RTX 3090): the renderer compiles for Linux and for Windows (llvm-mingw) with no warnings, and the ASTC decoder and BC encoder GPU fixture passes.
run_all.pyona200c870's tree had 13 failures: 12 also fail onmainalone, and the 13th (test_bc_scratch_layers) was from the copy fix and passes after updating its stand-ins.An A/B of this head on an AMD RX 580 (RADV) is running; results will follow.
🤖 Generated with Claude Code
@review
@review
Recommendation: Request changes. Copies from some uncompressed color textures into BC-kept destinations can still be skipped. The renderer changes also await the affected AMD and Steam Deck runs.
The change reduces texture and render-target VRAM use, with additional upload and memory-management changes. It saves substantial VRAM in the reported NVIDIA tour, at the cost of creation-time scans and extra retained memory for texture preloading.
Blocking (1): must change before merging.
gpu/vk/vk_xfer.cpp:318: Some non-ASTC uncompressed color sources are still rejected when copied into a BC-kept destination. When: For a same-size copy from a one-byte color source without the linear-filter format feature into a BC-kept ASTC texture, texture_copy_into_bc returns false and copy_t2t skips the copy. Do: Provide a compatible conversion or a destination fallback for these sources, and test that the destination receives the copied content.Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
@fixcan do L1.Since the last review (on
c7ebf0399f)Resolved: L8 (It conflicts with its base branch: bring it up to date (
@fixor@rebasetry first).)Still open: L1 (Some non-ASTC uncompressed color sources are still rejected when copied into a BC-kept des…); L6 (The default rendering and memory changes have not been exercised on the affected AMD Tier…)
Checks: Still running: 11 checks.
Also noticed (1; not asked for, not blocking)
More: does it help, other systems, switches, what was read
Does it help: Yes: the reported three-pair RTX 5080 tour reduced average driver VRAM from 9714 MB to 7059 MB, with frame metrics within the run spread. The 6 GB laptop remained near its budget; its reported 1% low rose from 15.4 to 15.9 fps and median frames of at least 50 ms fell from 145 to 137. These measurements predate the current head.
Other systems: The changes affect Vulkan texture formats, transfers, memory retention and upload timing across GPU vendors and operating systems. NVIDIA Windows and Linux game runs are reported; AMD Tier 1 and Steam Deck coverage remains outstanding, as do the requested Intel and 4 GB runs.
Switches: BC1, BC5, trimmed BC, native BC mip trimming, target-layer eviction, stale-alias eviction, texture preloading and real size classification default on. Fused ASTC encoding and sparse shadows default off. Zero-page skipping defaults to 1 on Windows; the unswizzle threshold is 64 MB, stream buffer 512 KB, sparse grain 1024 KB, and pack retention one 32nd of the VRAM allowance. Compaction Auto changes to one 64th, bounded at 64–128 MB; ASTC-to-BC Auto changes to 0 MB. The reported NVIDIA measurements support these choices, but affected hardware coverage is incomplete.
Reviewed:
a200c870ecagainstbb5a5682ce: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the changed copy function and its caller, relevant switch definitions, the rebase/fix diff, and the supplied comments and measurements. The rest of the large pull request diff, changed code files, tests and project standards were not read in full; docs/review-checklist.md was absent.; nothing run (a code review).Checked and fine:
Testing: No commands from the project were run. The supplied NVIDIA game runs and GPU fixture are useful evidence; complete the requested AMD Tier 1 and Steam Deck runs, and verify the remaining copy cases with a behavior test.
Overlaps and merge order: Not checked; the network is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
On BeanBot's review of
a200c870:L1 (an integer one-byte source copied into a BC-kept texture): not changing this.
main(bb5a5682) skips that copy too, so the PR loses nothing:mainkeeps the destination as BC3,texture_copy_into_bctakes only ASTC sources;mainkeeps it as RGBA8,copy_t2tfinds the sizes incompatible (1 byte against 4) and then refuses the blit, because the format classes differ (integer against normalized): "texture blit the device cannot make: skipped".Converting integer values into a colour texture has no defined result in Vulkan to reproduce.
tests/bc_scratch_batches_test.cppchecks that such a source writes nothing, next to the cases that are copied.sRGB view of a BC5-kept texture ("also noticed"): still open as I noted above; not confirmed that the game does it.
L6: the RADV run on an RX 580 is in progress. AMD on Windows and the Steam Deck need the Test Farm.
🤖 Generated with Claude Code
Thanks for
bf3b6513anda200c870: they cover the review's L1-L5 (my own fix for L1-L3/L5 was the same idea, dropped in favour of yours). Builta200c870on Windows 11, RTX 5080: smoke PASS (in play from kokiri-start, BC1/BC5 textures made, no error); the kinds file starts again from empty, as its format changed.AMD results for
a200c870(RX 580, RADV, 3 A/B pairs againstmainbb5a5682) are in the description.Good: no device loss, the screenshots of four areas match
main, the ASTC/BC GPU fixture passes with validation on, and GTT use is 688 MB lower.Not good, and worth looking at before merge:
mainrun;An earlier run of
c7ebf039on the same card also had longer worst frames. I have not isolated which switch causes it. fps, 1% low, p99 and frames of 50 ms or more are within the spread.🤖 Generated with Claude Code
Thanks for the RX 580 runs. The longer worst frames don't show on NVIDIA: on the 6 GB RTX 3060 Laptop (CachyOS, its VRAM budget full on both sides) the median worst frame went 382 → 347 ms, and on the RTX 5080 150 → 160 ms, within that PC's spread (138-206 ms on both sides). So it looks tied to RADV, or to a full 8 GB card spilling into GTT.
Suspects, most likely first. Each is one switch set against this head, same tour and 3 pairs (
dev.py ab --env X=0):RX_VK_TEX_AHEAD=0: on by default in this PR, off onmain. It makes the textures an earlier load drew before their first draw, and held about 250 MB more VRAM on the RTX 5080. On a full 8 GB card that could be the +155 MB, pushing other memory out to GTT at an area change.RX_VK_UNSWIZZLE_IMPORT_MB=0: big textures under 64 MB are unswizzled on the CPU instead of imported, so the CPU reads the guest pages. It is the likeliest source of the major page faults (10 → 110) and of the 688 MB less GTT.RX_VK_ASTC_BC5=0, thenRX_VK_ASTC_BC1=0: BC5 had load frames +15 ms on the RTX 5080.(
RX_VK_ZERO_UNTOUCHEDis Windows-only, so not in play there.)Whichever brings the worst frame back to
main's, I'll turn it off by default where it costs more than it saves, with the numbers in the description.