WIP: fix(vk): a revisited area's ASTC textures take the finalized copies' images, not a decode #1222

Draft
TrashPanda wants to merge 2 commits from TrashPanda/Longshot:fix/astc-decode-reuse into main
Contributor

Type: fix · Risk: medium · Tested on: Linux, RTX 4070 Ti · Needs: AMD (RADV), Windows, any GPU

Why

Going back to an area you just left is no smoother than the first visit, and the GPU memory it holds keeps growing.
The game puts an area's textures at new addresses each time it loads them, and the renderer's texture cache is keyed
by address, so every revisit decodes the same ASTC textures again (0.8 to 1.2 GB a load) and keeps the old decoded
copies until the budget evicts them (#1069). On cards that don't sample ASTC (every desktop NVIDIA and AMD card) that
is a decode and often a BC3 re-encode per load, and on 8 GB cards the duplicates push the budget into evicting
textures that are still in use.

How to reproduce

Seen on: Linux, RTX 4070 Ti 12 GB, NVIDIA 595.99.02 (and in #1069)
Settings and switches: defaults; RX_VK_VRAM_MB=8192 to reach the budget as an 8 GB card does
Steps: from the repository save kokiri-start, teleport Kakariko, the Market, Kakariko, the Market (scripts/memtour.py --repo-save kokiri-start --dests 2,3,2,3,2,3,2,3)
Expected: a revisit uses the textures the first visit decoded
Actual: every visit decodes them again: vk: textures: decoded ASTC climbs to 3.2 to 3.7 GB and the budget retires about 23,000 textures in a 6-minute tour

What changed

A new ASTC texture's blocks are hashed on its first upload. When the game finalizes a decoded ASTC texture, it is
listed by that hash; a later texture with the same blocks and the same shape takes its image by a GPU copy instead
of a decode, and the old one is retired at the next frame. RX_VK_ASTC_REUSE=0 turns it off.

  • gpu/vk/astc_reuse.h (new): XXH64 over the blocks (Hasher), the shape that has to match (Shape: format,
    size, levels, layers, layout, BC or not), and the list of finalized textures by hash (Freed).
  • gpu/vk/vk_texture.cpp:
    • reuse_upload(), from upload_inner()'s ASTC path, hashes a texture's first whole upload, and copies a listed
      texture's image into it when one matches.
    • reuse_released(), from texture_released(), lists a finalized texture.
    • reuse_retire_frame(), from texture_frame() after drawn_writeback_frame(), destroys the textures whose image
      was taken.
    • reuse_drop() unlists a texture used again at its own address, or going.
  • gpu/vk/vk_texture.h: Texture::blocks_hash, freed_listed, reuse_retire.
  • tests/test_astc_reuse.{py,cpp}: XXH64 against its published vectors, streaming against one call, and the shape match.
  • tests/test_drawn_page_map.py: its fixture stubs reuse_released(), which the texture_released() it compiles now calls.
  • docs/development.md: the switch. docs/tested/: the two runs below.

Measurements

Verdict: helps. Over three interleaved tours a side, the peak of decoded ASTC in VRAM is 29% lower, VRAM in use at
its peak is 506 MB lower, textures retired for the budget are 31% fewer, and the worst frame of a tour is 23% shorter.
Host memory is unchanged. One cost: hashing takes about 0.5 s of the replay thread over a tour (6 GB of blocks), which
fills the 40 ms upload budget sooner during a load, so more new ASTC textures wait a frame or more (median 537 against 85).

Hardware: Ubuntu 26.04.1 LTS (kernel 7.0.0-43), RTX 4070 Ti 12 GB, NVIDIA 595.99.02, Ryzen 7 9800X3D, 32 GB
Scene: Kakariko and the Market (child), four visits each, walking 25 s in each; 2560x1440, headless, defaults
Method: scripts/memtour.py (memory sampled every 2 s), the numbers from each run's longshot_log.txt: the peak and
median of vk: textures: decoded ASTC, the peak of vk: VRAM: N MB used, the sum of textures retired ... budget N,
the largest vk: status: 600 frames, the slowest N ms, the last new ASTC textures left for a later frame ... N so far.
Three runs a side, interleaved off, on, off, on..., each through scripts/job_queue.py timing mode (alone on the PC).
The median of the three.
How to reproduce: RX_VK_VRAM_MB=8192 python -I scripts/memtour.py <game> --repo-save kokiri-start --dests 2,3,2,3,2,3,2,3 --dwell 25 --settle 20, with and without --env RX_VK_ASTC_REUSE=0

Both columns are the same build: the renderer built alone (RX_VK_ONLY=1) from 64b1ad0c, this change on main 71b1edd8
with #1220 and #1221.

Baseline: RX_VK_ASTC_REUSE=0 instead of main, so that both sides are the same build; switched off, the change hashes
and lists nothing and every upload takes main's path.

Rebased on main 0cab3548 since. One more pair on the rebased
code (da36d129: this PR's code but for where one block sits in the file, with #1220 and #1221): decoded ASTC at its
peak 3,189 → 2,897 MB, textures retired for the budget 21,266 → 15,314, the slowest frame 684.0 → 490.5 ms; VRAM used
at its peak went the other way in that pair, 8,676 → 8,976 MB. A tour on the PR's head (51595f27) reused 4,819
textures and reached all 8 areas; its frame times aren't comparable (another program held 5 GB more during it, 1.9 GB
of RAM free).

Before: this PR @ 64b1ad0c, RX_VK_ASTC_REUSE=0 After: this PR @ 64b1ad0c Δ
decoded ASTC in VRAM, peak (MB) 3,603 (3,603 / 3,663 / 3,236) 2,562 (2,811 / 2,562 / 2,437) −29%
decoded ASTC in VRAM, median over the tour (MB) 2,552 (2,484 / 2,637 / 2,552) 2,048 (2,048 / 2,066 / 2,043) −20%
VRAM used, peak (MB) 8,958 (8,661 / 8,958 / 8,994) 8,452 (8,420 / 8,452 / 8,658) −506 MB
textures retired for the budget 23,378 (22,864 / 25,363 / 23,378) 16,109 (16,875 / 15,886 / 16,109) −31%
the slowest frame of the tour (ms) 636.6 (636.6 / 802.5 / 635.5) 487.2 (505.2 / 487.2 / 487.2) −23%
new ASTC textures left for a later frame 85 (289 / 81 / 85) 537 (537 / 516 / 837) +452
game memory, resident and swapped, peak (MB) 13,512 (13,530 / 13,512 / 13,399) 13,162 (13,161 / 13,728 / 13,162) none to speak of
textures copied, not decoded 0 5,879 (6,537 / 5,783 / 5,879), 15 GB
blocks hashed 0 5.9 GB in 493 ms (6.2 GB / 529, 5.8 GB / 485, 5.9 GB / 493)
reuse off (ab3-off2), late in the tour:
vk: textures: decoded ASTC 2511 MB, rendered 2008 MB (489 drawn in one frame, kept: 364048 KB), other 472 MB; used in the last 8 presents 2847 MB
vk: VRAM: 8220 MB used of 8822 MB allowed (1361 MB of it free in the blocks); textures 4627 MB (budget 3583 MB), 2532 textures
reuse on (ab3-on2), late in the tour:
vk: VRAM: 7932 MB used of 9024 MB allowed (1015 MB of it free in the blocks); textures 4114 MB (budget 3534 MB), 2477 textures
vk: textures: decoded ASTC 1951 MB, rendered 1381 MB (57 drawn in one frame, kept: 39661 KB), other 551 MB; used in the last 8 presents 2434 MB
vk: decoded ASTC used again: 5783 textures (14670 MB) copied from ones the game finalized, not decoded; 5783 of those retired, 65 listed; 5788 MB of blocks hashed in 485 ms

The second Kakariko visit, the same spot, reuse off and on, are in a comment: the textures are the same (only
the windmill and Navi, which move, differ).

Flags and settings

One new switch, on by default.

Flag What it is Before this PR After this PR Effect Helps / doesn't help / untested Recommendation
RX_VK_ASTC_REUSE a new decoded ASTC texture takes the image of a finalized one with the same blocks (none: always decoded) on; =0 off less VRAM and fewer evictions on revisits; ~0.08 ms of hashing a MB of new ASTC helps on an RTX 4070 Ti at an 8 GB budget; untested on AMD, Intel, Windows, the Steam Deck on for everyone

Testing

Tested: python -I -B tests/run_all.py on Linux at the head: 25 checks fail, the ones that fail on main @ 0cab3548 on
this PC (its toolchain lacks what they need; listed in a comment), but for tests/test_control.py, which timed out
in the suite (196 s) and passes alone, twice. tests/test_astc_reuse.py is new and passes. In the game: Ubuntu
26.04.1, RTX 4070 Ti, NVIDIA 595.99.02, nine tours and a screenshot run with reuse on, no device lost; the textures
checked by eye only, in the screenshots: the second visit's frame matches the decoded one.

Not tested: AMD and Intel cards (ASTC decoded and re-encoded to BC3 on the GPU there too, the same path); Windows;
the Steam Deck (its GPU samples no ASTC either, and it has the least VRAM); an adult save's areas; a long play session
instead of a 6-minute tour. The Windows build (llvm-mingw) was not made here: astc_reuse.h is standard C++ only.

Must be tested:

  • linux, radv (an AMD card): the tour above with and without RX_VK_ASTC_REUSE=0, expecting vk: decoded ASTC used again: N textures with N in the thousands, decoded ASTC lower, no texture wrong after a revisit (Test Farm: @Beanstalk linux radv, a memtour of Kakariko and the Market with RX_VK_ASTC_REUSE=0 and without)
  • steamdeck: Kakariko, the Market and back three times, expecting no wrong textures and fewer textures retired ... budget (Test Farm: @Beanstalk steamdeck, the same tour)
  • windows, any GPU: the same tour, expecting the same log line (Test Farm: @Beanstalk windows, the same tour)

Risks

What could break: a texture shown with another texture's image. That needs two textures of the same shape whose
blocks hash the same but differ (a 64-bit collision), or a texture whose blocks change between its hash and its
first draw (the hash is of the blocks as they are uploaded, the same bytes the decode reads). Textures the GPU has
written are never listed or reused. Also: textures waiting a frame more in a load (above).

Turning it off: RX_VK_ASTC_REUSE=0.

Compatibility: Nothing changes: no cache, options or ABI change.

Issues

Fixes #1069

Checklist

Everyone

  • One topic.
  • The title is a Conventional Commit (type(scope): description) of the status line's type.
  • Why gives the reason plainly and links the issues that fit (the tracker searched).
  • Measurements has a verdict, or one line saying why there is nothing to measure.
  • Testing names what was tested, what wasn't, and what must still be tested, where and how.
  • Rebased on current main.
  • python -I -B tests/run_all.py passes (any failure that also fails on main is named).
  • No game files, dumps, build output or generated files.
  • third_party/ untouched (a new folder with a PROVENANCE.md instead).
  • The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled.

When it applies

  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.
  • Numbers from the same PC, scene and settings, at least 2 interleaved runs each, the median reported.
  • Switches documented (docs/development.md; the README for a menu row) and shipped at their recommended value.
  • A file in docs/tested/ for each new measured run (format in docs/tested-configurations.md).
  • A game-free test added for the fix, failing on main and passing here.
  • A check under tests/ that reads changed source updated in this PR, not weakened.
  • Docs updated.
**Type:** fix · **Risk:** medium · **Tested on:** Linux, RTX 4070 Ti · **Needs:** AMD (RADV), Windows, any GPU ## Why Going back to an area you just left is no smoother than the first visit, and the GPU memory it holds keeps growing. The game puts an area's textures at new addresses each time it loads them, and the renderer's texture cache is keyed by address, so every revisit decodes the same ASTC textures again (0.8 to 1.2 GB a load) and keeps the old decoded copies until the budget evicts them (#1069). On cards that don't sample ASTC (every desktop NVIDIA and AMD card) that is a decode and often a BC3 re-encode per load, and on 8 GB cards the duplicates push the budget into evicting textures that are still in use. ## How to reproduce **Seen on:** Linux, RTX 4070 Ti 12 GB, NVIDIA 595.99.02 (and in #1069) **Settings and switches:** defaults; `RX_VK_VRAM_MB=8192` to reach the budget as an 8 GB card does **Steps:** from the repository save `kokiri-start`, teleport Kakariko, the Market, Kakariko, the Market (`scripts/memtour.py --repo-save kokiri-start --dests 2,3,2,3,2,3,2,3`) **Expected:** a revisit uses the textures the first visit decoded **Actual:** every visit decodes them again: `vk: textures: decoded ASTC` climbs to 3.2 to 3.7 GB and the budget retires about 23,000 textures in a 6-minute tour ## What changed A new ASTC texture's blocks are hashed on its first upload. When the game finalizes a decoded ASTC texture, it is listed by that hash; a later texture with the same blocks and the same shape takes its image by a GPU copy instead of a decode, and the old one is retired at the next frame. `RX_VK_ASTC_REUSE=0` turns it off. - `gpu/vk/astc_reuse.h` (new): XXH64 over the blocks (`Hasher`), the shape that has to match (`Shape`: format, size, levels, layers, layout, BC or not), and the list of finalized textures by hash (`Freed`). - `gpu/vk/vk_texture.cpp`: - `reuse_upload()`, from `upload_inner()`'s ASTC path, hashes a texture's first whole upload, and copies a listed texture's image into it when one matches. - `reuse_released()`, from `texture_released()`, lists a finalized texture. - `reuse_retire_frame()`, from `texture_frame()` after `drawn_writeback_frame()`, destroys the textures whose image was taken. - `reuse_drop()` unlists a texture used again at its own address, or going. - `gpu/vk/vk_texture.h`: `Texture::blocks_hash`, `freed_listed`, `reuse_retire`. - `tests/test_astc_reuse.{py,cpp}`: XXH64 against its published vectors, streaming against one call, and the shape match. - `tests/test_drawn_page_map.py`: its fixture stubs `reuse_released()`, which the `texture_released()` it compiles now calls. - `docs/development.md`: the switch. `docs/tested/`: the two runs below. ## Measurements **Verdict:** helps. Over three interleaved tours a side, the peak of decoded ASTC in VRAM is 29% lower, VRAM in use at its peak is 506 MB lower, textures retired for the budget are 31% fewer, and the worst frame of a tour is 23% shorter. Host memory is unchanged. One cost: hashing takes about 0.5 s of the replay thread over a tour (6 GB of blocks), which fills the 40 ms upload budget sooner during a load, so more new ASTC textures wait a frame or more (median 537 against 85). Hardware: Ubuntu 26.04.1 LTS (kernel 7.0.0-43), RTX 4070 Ti 12 GB, NVIDIA 595.99.02, Ryzen 7 9800X3D, 32 GB Scene: Kakariko and the Market (child), four visits each, walking 25 s in each; 2560x1440, headless, defaults Method: `scripts/memtour.py` (memory sampled every 2 s), the numbers from each run's `longshot_log.txt`: the peak and median of `vk: textures: decoded ASTC`, the peak of `vk: VRAM: N MB used`, the sum of `textures retired ... budget N`, the largest `vk: status: 600 frames, the slowest N ms`, the last `new ASTC textures left for a later frame ... N so far`. Three runs a side, interleaved off, on, off, on..., each through `scripts/job_queue.py` timing mode (alone on the PC). The median of the three. How to reproduce: `RX_VK_VRAM_MB=8192 python -I scripts/memtour.py <game> --repo-save kokiri-start --dests 2,3,2,3,2,3,2,3 --dwell 25 --settle 20`, with and without `--env RX_VK_ASTC_REUSE=0` Both columns are the same build: the renderer built alone (`RX_VK_ONLY=1`) from 64b1ad0c, this change on main 71b1edd8 with #1220 and #1221. Baseline: `RX_VK_ASTC_REUSE=0` instead of main, so that both sides are the same build; switched off, the change hashes and lists nothing and every upload takes main's path. Rebased on main 0cab3548 since. One more pair on the rebased code (da36d129: this PR's code but for where one block sits in the file, with #1220 and #1221): decoded ASTC at its peak 3,189 → 2,897 MB, textures retired for the budget 21,266 → 15,314, the slowest frame 684.0 → 490.5 ms; VRAM used at its peak went the other way in that pair, 8,676 → 8,976 MB. A tour on the PR's head (51595f27) reused 4,819 textures and reached all 8 areas; its frame times aren't comparable (another program held 5 GB more during it, 1.9 GB of RAM free). | | Before: this PR @ 64b1ad0c, `RX_VK_ASTC_REUSE=0` | After: this PR @ 64b1ad0c | Δ | |---|---|---|---| | decoded ASTC in VRAM, peak (MB) | 3,603 (3,603 / 3,663 / 3,236) | 2,562 (2,811 / 2,562 / 2,437) | −29% | | decoded ASTC in VRAM, median over the tour (MB) | 2,552 (2,484 / 2,637 / 2,552) | 2,048 (2,048 / 2,066 / 2,043) | −20% | | VRAM used, peak (MB) | 8,958 (8,661 / 8,958 / 8,994) | 8,452 (8,420 / 8,452 / 8,658) | −506 MB | | textures retired for the budget | 23,378 (22,864 / 25,363 / 23,378) | 16,109 (16,875 / 15,886 / 16,109) | −31% | | the slowest frame of the tour (ms) | 636.6 (636.6 / 802.5 / 635.5) | 487.2 (505.2 / 487.2 / 487.2) | −23% | | new ASTC textures left for a later frame | 85 (289 / 81 / 85) | 537 (537 / 516 / 837) | +452 | | game memory, resident and swapped, peak (MB) | 13,512 (13,530 / 13,512 / 13,399) | 13,162 (13,161 / 13,728 / 13,162) | none to speak of | | textures copied, not decoded | 0 | 5,879 (6,537 / 5,783 / 5,879), 15 GB | | | blocks hashed | 0 | 5.9 GB in 493 ms (6.2 GB / 529, 5.8 GB / 485, 5.9 GB / 493) | | ``` reuse off (ab3-off2), late in the tour: vk: textures: decoded ASTC 2511 MB, rendered 2008 MB (489 drawn in one frame, kept: 364048 KB), other 472 MB; used in the last 8 presents 2847 MB vk: VRAM: 8220 MB used of 8822 MB allowed (1361 MB of it free in the blocks); textures 4627 MB (budget 3583 MB), 2532 textures reuse on (ab3-on2), late in the tour: vk: VRAM: 7932 MB used of 9024 MB allowed (1015 MB of it free in the blocks); textures 4114 MB (budget 3534 MB), 2477 textures vk: textures: decoded ASTC 1951 MB, rendered 1381 MB (57 drawn in one frame, kept: 39661 KB), other 551 MB; used in the last 8 presents 2434 MB vk: decoded ASTC used again: 5783 textures (14670 MB) copied from ones the game finalized, not decoded; 5783 of those retired, 65 listed; 5788 MB of blocks hashed in 485 ms ``` The second Kakariko visit, the same spot, reuse off and on, are in a comment: the textures are the same (only the windmill and Navi, which move, differ). ### Flags and settings One new switch, on by default. | Flag | What it is | Before this PR | After this PR | Effect | Helps / doesn't help / untested | Recommendation | |---|---|---|---|---|---|---| | `RX_VK_ASTC_REUSE` | a new decoded ASTC texture takes the image of a finalized one with the same blocks | (none: always decoded) | on; `=0` off | less VRAM and fewer evictions on revisits; ~0.08 ms of hashing a MB of new ASTC | helps on an RTX 4070 Ti at an 8 GB budget; untested on AMD, Intel, Windows, the Steam Deck | on for everyone | ## Testing **Tested:** `python -I -B tests/run_all.py` on Linux at the head: 25 checks fail, the ones that fail on `main` @ 0cab3548 on this PC (its toolchain lacks what they need; listed in a comment), but for `tests/test_control.py`, which timed out in the suite (196 s) and passes alone, twice. `tests/test_astc_reuse.py` is new and passes. In the game: Ubuntu 26.04.1, RTX 4070 Ti, NVIDIA 595.99.02, nine tours and a screenshot run with reuse on, no device lost; the textures checked by eye only, in the screenshots: the second visit's frame matches the decoded one. **Not tested:** AMD and Intel cards (ASTC decoded and re-encoded to BC3 on the GPU there too, the same path); Windows; the Steam Deck (its GPU samples no ASTC either, and it has the least VRAM); an adult save's areas; a long play session instead of a 6-minute tour. The Windows build (llvm-mingw) was not made here: `astc_reuse.h` is standard C++ only. **Must be tested:** - linux, radv (an AMD card): the tour above with and without `RX_VK_ASTC_REUSE=0`, expecting `vk: decoded ASTC used again: N textures` with N in the thousands, `decoded ASTC` lower, no texture wrong after a revisit (Test Farm: @Beanstalk linux radv, a memtour of Kakariko and the Market with RX_VK_ASTC_REUSE=0 and without) - steamdeck: Kakariko, the Market and back three times, expecting no wrong textures and fewer `textures retired ... budget` (Test Farm: @Beanstalk steamdeck, the same tour) - windows, any GPU: the same tour, expecting the same log line (Test Farm: @Beanstalk windows, the same tour) ## Risks **What could break:** a texture shown with another texture's image. That needs two textures of the same shape whose blocks hash the same but differ (a 64-bit collision), or a texture whose blocks change between its hash and its first draw (the hash is of the blocks as they are uploaded, the same bytes the decode reads). Textures the GPU has written are never listed or reused. Also: textures waiting a frame more in a load (above). **Turning it off:** `RX_VK_ASTC_REUSE=0`. **Compatibility:** Nothing changes: no cache, options or ABI change. ## Issues Fixes #1069 ## Checklist ### Everyone - [x] One topic. - [x] The title is a Conventional Commit (`type(scope): description`) of the status line's type. - [x] Why gives the reason plainly and links the issues that fit (the tracker searched). - [x] Measurements has a verdict, or one line saying why there is nothing to measure. - [x] Testing names what was tested, what wasn't, and what must still be tested, where and how. - [x] Rebased on current `main`. - [x] `python -I -B tests/run_all.py` passes (any failure that also fails on `main` is named). - [x] No game files, dumps, build output or generated files. - [x] `third_party/` untouched (a new folder with a `PROVENANCE.md` instead). - [x] The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled. ### When it applies - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. - [x] Numbers from the same PC, scene and settings, at least 2 interleaved runs each, the median reported. - [x] Switches documented (docs/development.md; the README for a menu row) and shipped at their recommended value. - [x] A file in `docs/tested/` for each new measured run (format in `docs/tested-configurations.md`). - [x] A game-free test added for the fix, failing on `main` and passing here. - [x] A check under `tests/` that reads changed source updated in this PR, not weakened. - [x] Docs updated.
The game makes an area's textures again at new addresses on a revisit, and the texture cache is keyed by address: each
visit decoded the area's ASTC again (0.8-1.2 GB on a 7900 XTX, issue 1069) and kept the earlier copies until the budget
evicted them. A new decoded-ASTC texture now hashes its blocks (XXH64) at its first upload; when the game finalizes it,
it is listed by that hash. A new texture with the same blocks and image takes a listed one's image by a GPU copy, and
the old one goes at the next present unless its own address used it again. RX_VK_ASTC_REUSE=0: as before.

Refs #1069, #388, #939

Assisted-by: Claude
docs(tested): decoded ASTC used again, three tours a side on an RTX 4070 Ti
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 4s
beanstalk/approval waiting for a BigBean's 👍 on the request
065a7cc74a
Assisted-by: Claude
Author
Contributor

Tested in game: Ubuntu 26.04.1, RTX 4070 Ti, NVIDIA 595.99.02, RX_VK_VRAM_MB=8192: three interleaved tours a side of Kakariko and the Market (memtour.py), reuse off and on; with it on ~5,900 textures a tour copied instead of decoded, decoded ASTC peak 3.6 -> 2.6 GB, budget evictions -31%, worst frame 637 -> 487 ms; the revisit's textures look the same (screenshots in a comment); no device lost.

Tested in game: Ubuntu 26.04.1, RTX 4070 Ti, NVIDIA 595.99.02, RX_VK_VRAM_MB=8192: three interleaved tours a side of Kakariko and the Market (memtour.py), reuse off and on; with it on ~5,900 textures a tour copied instead of decoded, decoded ASTC peak 3.6 -> 2.6 GB, budget evictions -31%, worst frame 637 -> 487 ms; the revisit's textures look the same (screenshots in a comment); no device lost.
Author
Contributor

The second Kakariko visit (Kakariko, the Market, Kakariko; the screenshot 300 frames after arriving, no walking), the same build (51595f27's renderer over game v3.0.0-rc.5-26-g71b1edd8), RTX 4070 Ti, 2560x1440. First: RX_VK_ASTC_REUSE=0 (decoded). Second: reuse on, 343 textures (642 MB) copied, not decoded. The textures match; the windmill and Navi move.

kakariko-revisit-reuse-off.png

kakariko-revisit-reuse-on.png

The second Kakariko visit (Kakariko, the Market, Kakariko; the screenshot 300 frames after arriving, no walking), the same build (51595f27's renderer over game v3.0.0-rc.5-26-g71b1edd8), RTX 4070 Ti, 2560x1440. First: `RX_VK_ASTC_REUSE=0` (decoded). Second: reuse on, 343 textures (642 MB) copied, not decoded. The textures match; the windmill and Navi move. ![kakariko-revisit-reuse-off.png](https://git.magicbean.dev/attachments/0e01dd2c-2801-4470-9933-2cbc20199706) ![kakariko-revisit-reuse-on.png](https://git.magicbean.dev/attachments/dfd06ea5-b8b5-46b4-b7ee-44823738a3e2)
Author
Contributor

Checks that fail on main @ 0cab3548 on this PC (Ubuntu 26.04.1; its toolchain lacks what they need), python -I -B tests/run_all.py:

  • tests/test_audio_output_devices.py
  • tests/test_bug_report.py
  • tests/test_bug_report_defaults.py
  • tests/test_crash_record.py
  • tests/test_crt_options.py
  • tests/test_dlss_feature_size.py
  • tests/test_failed_compile_keeps_objects.py
  • tests/test_fsr_uniform_ownership.py
  • tests/test_guest_imported.py
  • tests/test_hardware_report.py
  • tests/test_import_reach.py
  • tests/test_lift_lookups.py
  • tests/test_linux_preflight.py
  • tests/test_linux_update.py
  • tests/test_make_game_cache.py
  • tests/test_missing_nup.py
  • tests/test_mods_size_table.py
  • tests/test_nonuniform_image_arrays.py
  • tests/test_parallel_init_order.py
  • tests/test_pending_guest_import.py
  • tests/test_replay_write_order.py
  • tests/test_run_all_changed.py
  • tests/test_vk_occlusion_queries.py
  • tests/test_walk.py
  • tests/test_walk_key.py

This PR's run fails the same ones and nothing else (tests/test_control.py timed out once in the full run on #1222's branch and passes alone).

**Checks that fail on `main` @ 0cab3548 on this PC** (Ubuntu 26.04.1; its toolchain lacks what they need), `python -I -B tests/run_all.py`: - `tests/test_audio_output_devices.py` - `tests/test_bug_report.py` - `tests/test_bug_report_defaults.py` - `tests/test_crash_record.py` - `tests/test_crt_options.py` - `tests/test_dlss_feature_size.py` - `tests/test_failed_compile_keeps_objects.py` - `tests/test_fsr_uniform_ownership.py` - `tests/test_guest_imported.py` - `tests/test_hardware_report.py` - `tests/test_import_reach.py` - `tests/test_lift_lookups.py` - `tests/test_linux_preflight.py` - `tests/test_linux_update.py` - `tests/test_make_game_cache.py` - `tests/test_missing_nup.py` - `tests/test_mods_size_table.py` - `tests/test_nonuniform_image_arrays.py` - `tests/test_parallel_init_order.py` - `tests/test_pending_guest_import.py` - `tests/test_replay_write_order.py` - `tests/test_run_all_changed.py` - `tests/test_vk_occlusion_queries.py` - `tests/test_walk.py` - `tests/test_walk_key.py` This PR's run fails the same ones and nothing else (`tests/test_control.py` timed out once in the full run on #1222's branch and passes alone).
Author
Contributor

@Beanstalk test the decoded-ASTC reuse on AMD (Linux, RADV), on a Steam Deck, and on Windows with any GPU: from the repository save kokiri-start, teleport Kakariko, the Market, Kakariko, the Market (four visits each, walking about 25 s in each), once with RX_VK_ASTC_REUSE=0 and once without it. Compare with main: the log's "vk: decoded ASTC used again: N textures" (N in the thousands with it on), the peak of "vk: textures: decoded ASTC N MB", the sum of "textures retired ... budget N", and the slowest frames after each teleport. Take a screenshot on the second Kakariko visit each way: the textures must look the same. Any wrong or swapped texture after a revisit is a failure.

@Beanstalk test the decoded-ASTC reuse on AMD (Linux, RADV), on a Steam Deck, and on Windows with any GPU: from the repository save kokiri-start, teleport Kakariko, the Market, Kakariko, the Market (four visits each, walking about 25 s in each), once with RX_VK_ASTC_REUSE=0 and once without it. Compare with main: the log's "vk: decoded ASTC used again: N textures" (N in the thousands with it on), the peak of "vk: textures: decoded ASTC N MB", the sum of "textures retired ... budget N", and the slowest frames after each teleport. Take a screenshot on the second Kakariko visit each way: the textures must look the same. Any wrong or swapped texture after a revisit is a failure.
Member

@TrashPanda only members of BigBeans can start the farm. One of them can approve this request by reacting 👍 to it.

@TrashPanda only members of `BigBeans` can start the farm. One of them can approve this request by reacting 👍 to it.
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 4s
beanstalk/approval waiting for a BigBean's 👍 on the request
This pull request is marked as a work in progress.
Some workflows are waiting to be reviewed.
This branch is out-of-date with the base branch
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'fix/astc-decode-reuse:TrashPanda-fix/astc-decode-reuse'
git switch 'TrashPanda-fix/astc-decode-reuse'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 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!1222
No description provided.