Skip to content

Fast travel dissolve without its noise on Mali: BC textures the GPU compresses into decoded after the draws - #210

Merged
mamcjr merged 5 commits into
mamcjr:mainfrom
Propinbo:mali-bc-render-target-0213
Nov 4, 2026
Merged

mamcjr merged 5 commits into
mamcjr:mainfrom
Propinbo:mali-bc-render-target-0213

Conversation

@Propinbo

@Propinbo Propinbo commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

On Mali, Link doesn't dissolve during a fast travel: he turns flat dark blue and vanishes all at once instead of
breaking up into the blue lines. The dissolve samples a 32x32x32 BC4 noise volume, and on Mali that volume reads zero.

BOTW builds the volume once after a load, and on a GPU without BC that path breaks in two places:

R8 volume (nvn 0x1)    filled on the CPU, its mips drawn on the GPU from level 0
  -> never uploaded: first touched as a render target at level 1, so level 0 stayed zero
BC4 volume (nvn 0x49)  every slice and mip drawn as blocks through RGBA16_UINT views (a texel a block)
  -> on Mali the image holds decoded R8 texels (bc_vf), so the blocks were drawn in as colours
  -> the pipeline typed the target by the texture's format (BC: float) while the view is UINT

The change:

 begin_pass
+  vk_bc_shadows_resolve(targets)          # blocks drawn before, decoded unless this pass draws on
   for each colour target
+    if level > 0: vk_tex_upload_for_mips  # CPU contents uploaded before the GPU makes the mips
+    vk_bc_shadow_view                     # (Android, decoded BC + block-sized view) a shadow image in the view's
+                                          #  format at the block grid, the slice marked drawn
     else vk_view
+    view of another output type into an image of another format (ASTC/BC decoded, no shadow): not bound, logged
 draw_
-  rt_kind(texture format)
+  rt_kind(rt_format(i))                   # the view's format when the view names one (pipeline key, blend)
 dispatch_compute / copy_texture_to_buffer / copy_texture / backend_present
+  vk_bc_shadows_resolve(NULL)             # decoded before anything outside a pass reads them

The resolve copies the drawn slices to the readback buffer, waits for the GPU once and decodes the blocks with the
existing BC decoder (bc_upload_blocks, now shared with the upload path) into the texture's image. Only drawn
(level, slice) pairs are decoded. The shadow's level 0 is widened so non-power-of-two levels fit. The shadow is
released through views_forget + defer in destroy_image, so #176's dead-view check covers its views too. A reboot
in place destroys every backend, which empties the dirty list, so no RT_ON_RESET hook is needed.

Evidence

Device: Samsung SM-X730, Immortalis-G925 MC12, Vulkan driver r49p1, Android 16. Scratch saves (LARECOMP_SAVE_DIR),
30 fps, the classic touch layout. Each run was compared with an unchanged v0.2.13-beta build from the same tree.

  • Before: in the burst captures Link is already gone and only the lines are left, on the first and the second
    fast travel.
    After: the body breaks up under the lines, as it should.

    Stock 0.2.13 vs this PR, first and second fast travel
  • Log, once per load, identical in every patched run:

    [vk] 32x32x32 (nvn 0x1) first drawn into at a level past 0: its CPU contents uploaded first
    [vk] BC texture 32x32x32 (nvn 0x49) drawn into as 95: blocks decoded after the draws
    [vk] BC 32x32x32: decode 1 at frame 459: 63 slices (18541 of 18744 bytes nonzero), GPU wait 5.42 ms, decode 0.16 ms
    
  • Regression matrix, 10 runs (stock vs this PR × Native / Recompiled). Routes: Great Plateau walk, inventory and fast
    travel; Hateno walk, map, two fast travels, the Myahm Agana forest (fog) and inventory; a 15-minute session of
    12 walk / menu / fast-travel cycles.

    stock 0.2.13 this PR
    error lines (incl. DEAD VIEW) 0 0
    median FPS 30 30
    2 s windows < 29 FPS, 15-min session 156 / 563 150 / 567
    fast travel to HUD 12.2–24.2 s 12.2–23.8 s
    readback + decode — 1 per process, at the load: GPU wait 4.7–6.0 ms, decode 0.08–0.18 ms
    load-stall frame (max ms, 5 pairs) 1227 / 1307 / 1432 / 1346 / 1474 1230 / 1267 / 1427 / 1272 / 1260

    No repeat decode was seen in the 12 fast travels. Menus, the 3D LUT (4 3D target 8x8x8 lines per run) and the
    fog look the same as stock in the captures. The same matrix on 0.2.10 gave the same picture.

  • Host tests (NDK 30): timing history 8, shader cache 17, Vulkan startup 33, Vulkan compat 16 checks pass, the same
    as on 5403f00.

Merge Danger

Door: two-way. Runtime-only and stateless across runs; reverting the commit restores the old behaviour.

Blast Radius: render targets.

  • The shadow, readback and decode are #ifdef __ANDROID__ and are reached only for a BC texture the GPU lacks (Mali)
    drawn into through a view of the block's size. On BOTW that is the noise volume, once per load.
  • Two parts apply to every GPU and platform:
    • rt_format: a target's output type (pipeline key and blend) now follows the view's format when the view names
      one. This changes pipelines only where a draw goes through a view whose format kind differs from its
      texture's.
    • A view of another output type into an image created in another format (ASTC/BC decoded) is no longer bound; it
      was undefined behaviour before.
  • Only tested on Mali-G925. Adreno (where LARECOMP_3D_RT keeps 3D targets off and BC is native), other Mali
    drivers and multi-hour sessions are untested. The paths for non-power-of-two BC targets, 2D BC targets and a
    format change of the drawing view are code-reviewed only; the game does not exercise them.
  • Cost: one GPU wait (~5–7 ms) during the load stall after a load.

🤖 Generated with Claude Code

…ompresses into decoded after the draws

BOTW makes its 32x32x32 BC4 noise volume once after a load: an R8 volume filled on the CPU, its mips drawn on the
GPU from it, then every slice and mip compressed by drawing blocks into the BC4 texture through RGBA16_UINT views.
On a GPU without BC (Mali) the BC texture holds decoded R8 texels, so the blocks went in as colours and the volume
read zero - and the source volume was never uploaded either (first drawn into at level 1). The fast-travel dissolve
lost its noise: Link turned flat dark blue and vanished at once instead of breaking up into the blue lines.

- A texture first drawn into at a level past 0 gets its CPU contents uploaded first (vk_tex_upload_for_mips).
- Draws through a block-sized view into a BC texture with decoded texels go to a shadow image in the view's format
  at the block grid; before the texture is next read (another pass, a dispatch, a copy, the present) the drawn
  slices come back to the CPU and are decoded into the image (one GPU wait, ~5-7 ms, once per load on BOTW).
- A target drawn through a view of another output type into an image of another format is no longer bound.

Mali-G925, stock 0.2.10 vs this, Native and Recompiled, first and second fast travel, menu, 3D LUT, fog and a
15-minute session of 14 fast travels: the dissolve is back, no errors, FPS and frame times as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Propinbo added a commit to Propinbo/BOTWRecompAndroid that referenced this pull request Nov 3, 2026
Documentation only (MALI_PROGRESS.md).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Propinbo and others added 4 commits November 3, 2026 17:54
… replaces it

begin_pass skipped decoding the dirty shadow of a texture the new pass draws into, and vk_bc_shadow_view then
destroyed that shadow when the new view had another format: what the earlier pass drew (another level, slice or
layer) was lost. vk_bc_shadows_resolve now keeps a shadow only for a target drawn through a view in the shadow's
format; any other use of it decodes the shadow first. A texture drawn in two formats within one pass keeps its
shadow and the other view draws without one. tools/test_bc_shadow.c (textures.c with Vulkan stubbed) checks it;
on 050fbc2 the format change decoded nothing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A new shadow image was only put in its layout (contents undefined), its first pass could clear it, and the whole
slice drawn into is decoded afterwards: blocks a draw did not cover (a scissored draw, a zero write mask) replaced
the texture's decoded contents with undefined or cleared data. bc_shadow_fill now gives a new shadow the guest's
blocks (tegra layout, as upload_texture reads them), or, for a shadow replacing one in another format, that one's
blocks (an image copy between same-size formats); shadow attachments always load. tools/test_bc_shadow.c checks the
fills; 050fbc2 made none.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ailures checked

Level 0 of a shadow was sized so that blocks << level fit at every level, one-block levels included: a 32x32x32
volume got 32x32 blocks for its 8x8, a 2048x16 texture with 12 levels 2048x2048 for 512x4. Levels of one block fit
any extent (at least 1), so only larger levels count; one side still reaches 2^(levels - 1) for the image's level
count (2048x4 there). The shadow's calloc and the decode's region array are checked before use (the decode, out of
memory, drops what was drawn and leaves the shadow usable). tools/test_bc_shadow.c checks the extents.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
vk_bc_shadows_resolve compared only the view's format with the shadow's, but vk_bc_shadow_view also refuses views
(levels past the texture's or 16, 3D levels LARECOMP_3D_RT leaves out, multisampled): such a pass drew into the
decoded image while the shadow stayed dirty, and its later decode overwrote that draw. Both now ask
bc_shadow_format. tools/test_bc_shadow.c checks a same-format view past the levels; the runner skips tests that
need android/deps/out when the app was never built.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Propinbo

Propinbo commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Follow-ups pushed to this branch, found while auditing the shadow path on Mali G925 (SM-X730):

  • P1 (5f91d4f, review fix 0c6908d): a dirty BC shadow is now decoded before a pass in another format replaces it. Before, what the earlier pass drew into another level, slice or layer was lost. A shadow is kept only for a view that actually draws into it.
  • P2 (c5d6297): a new shadow now starts with the texture's blocks (from guest memory, or from the old shadow on a format change), and shadow attachments always load. Before, blocks a scissored or zero-mask draw did not cover were decoded from undefined or cleared data.
  • P3 (1095022): shadows are only as large as their levels need (32x32x32 volume: 8x8x32 blocks instead of 32x32x32; 2048x16 with 12 levels: 2048x4 instead of 2048x2048). Allocation failures are checked.

How it was checked

Game runs used this code plus a local env-gated counter commit that is not pushed. Baseline: this PR before the follow-ups (050fbc2). Routes: Hateno and Great Plateau.

  • Device tests: the new tools/test_bc_shadow.c passes on the device, 10 cases, no SKIP. On 050fbc2 the P1, P2 and P3 logic checks fail.
  • Validation (VVL 1.4.363.0): no new VUIDs against the baseline, Native and Recompiled. The same 10 IDs appear on both and on stock 5403f00. One VkBufferCopy-size-01988 (zero-size copy) appeared in one follow-ups run, and also once on stock; it does not come from the shadow code.
  • Dissolve: identical frame by frame against the baseline in screen recordings, with no noise.
  • Performance: within the spread of repeats. Mean FPS per round, follow-ups vs baseline: Hateno 29.16 / 29.21 vs 29.24 / 29.21; Great Plateau 28.77 / 28.83 vs 29.17 / 28.85. One 15-minute session each: 29.31 vs 29.39.

In these runs the shadow path ran once per world load (1 shadow made, 1 resolved), with no format change. So in the game this shows no regression; the P1 format-change fix and the P2 uncovered-block case are covered only by the device test.

Known limits

  • P2: a new shadow takes its blocks from guest memory, so blocks a GPU copy wrote into the BC texture before the shadow existed would be missed. The tested routes made no buffer-to-BC or texture-to-BC copies.
  • Validation gap: validation was not captured during the fast-travel dissolve itself on the follow-ups build, because the scripted map input missed the shrine under the layer's slowdown. Without validation, the dissolve ran normally.
  • test_android_runtime.ps1 still exits non-zero: test_nvn_lifetime does not link (rt_fatal_message, plat_now_ns). The same happens on 050fbc2 and on stock 5403f00, and these commits don't touch it. With local link stubs it segfaults on both 050fbc2 and the last follow-up commit, so that test needs its own fix.

@mamcjr
mamcjr merged commit bdbe389 into mamcjr:main Nov 4, 2026
mamcjr added a commit that referenced this pull request Nov 4, 2026
@mamcjr

mamcjr commented Nov 4, 2026

Copy link
Copy Markdown
Owner

Merged, thank you! This was a great write-up, and the evidence made it easy to review.

It fixes more than Mali: on my POCO F7 Ultra (Adreno 830, Turnip) Link also turned flat blue and vanished at once on a fast travel, which is what #220 reports on a Snapdragon 8 Elite. With this PR he breaks up into the lines and forms back on arrival. On Adreno the part doing it is the noise volume's CPU contents uploaded before its mips are drawn (first drawn into at a level past 0 shows once per load); the BC shadow path isn't reached there, as expected.

I've added you to the README's contributors. It'll be in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants