Skip to content

Launcher: the backdrop in 64 px tiles, smaller LVGL draw buffers (redraws 57 -> 41 ms, +184 KB in games) - #30

Merged
finger563 merged 1 commit into
mainfrom
perf/launcher-backdrop-tiles
Nov 21, 2026
Merged

finger563 merged 1 commit into
mainfrom
perf/launcher-backdrop-tiles

Conversation

@finger563

Copy link
Copy Markdown
Contributor

Summary

Launcher redraws are about 30% faster, and every game gets 184 KB of PSRAM back.

  • The backdrop in 64 px tiles (Backdrop: the pattern tile repeated to Metrics::pattern_px (64 px on the Tab5) emu-ui#1, perf/pattern-tile-size): the launcher's background pattern was drawn one 6-22 px tile at a time, about 25,600 draws per full redraw. That was the largest single cost of a redraw, and the larger tiles take a few hundred draws.
  • The LVGL draw buffers are a twentieth of the screen instead of a tenth.
    • They stay allocated while a game runs, for the pause menu, so every game gets 184 KB back.
    • With the tiles, the launcher is still faster than before.
    • It also more than offsets the tiles' cache (about 9 KB per console style shown).
  • overlay_image.py: words inside merged strings (.str1.N) no longer count as references into the core overlay.
    • Four characters of a string can spell the address of an overlay function: " 60H" is 0x48303620, a function start in four cores. That failed the build.
    • It happened as soon as the strings moved, so main could hit it with any change.

Measurements (Tab5, 20 s of scrolling, LVGL REFR_START to REFR_READY)

Build Average redraw Slowest GBA in game: free / largest
main 57.1 ms 164 ms 5,425 / 5,375 KB
tiles, draw buffers 1/10 37.2 ms 96 ms 5,364 / 5,247 KB
tiles, draw buffers 1/20 (this PR) 40.6 ms 111 ms 5,548 / 5,503 KB

Measured and left out: a full-frame LVGL draw buffer for the launcher

The buffer was allocated while the launcher shows and freed when a game starts.

Average redraw Slowest Memory and heap
main 57 ms 164 ms —
One full-frame buffer (1.76 MB) 66 ms 158 ms GBA's largest free block 512 KB smaller
Tiles + two full-frame buffers (3.5 MB) 40 ms 80 ms Launcher's heap fragmented
  • One buffer is slower: LVGL can't draw the next area until the PPA has rotated the last one onto the panel. wait_for_flushing took 18% of the GUI task. The two 1/10 buffers overlap these.
  • Two buffers only trim the slowest redraws, at 3.5 MB while the launcher is up.

Testing

  • On the Tab5:
    • scrolled the launcher and switched consoles;
    • played GBA, opened and closed the pause menu, quit.
    • No panic, and the PSRAM numbers are in the table above.
  • The overlay check passes, with 2069 references allowed, as on main.

Merge esp-cpp/emu-ui#1 first; this PR's emu-ui submodule points at its branch.

🤖 Generated with Claude Code

https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY

- emu-ui perf/pattern-tile-size: the backdrop's pattern tile is repeated
  to 64 px instead of one period (6-22 px): a few hundred draws per full
  redraw instead of ~25,600. Scrolling the launcher, the average redraw
  goes from 57 to 41 ms and the slowest from 164 to 111 ms.
- The LVGL draw buffers are a twentieth of the screen instead of a tenth:
  they stay allocated during games (for the pause menu), so every game
  gets 184 KB back (GBA: 5425 -> 5548 KB free with the tiles' cache).
  With tenths the launcher measured 37 ms (slowest 96 ms).
- overlay_image.py: words inside merged strings (.str1.N) are not
  references into the overlay. Any change to the strings can align four
  characters that spell an overlay function's address (" 60H" =
  0x48303620, a function start in four cores) and fail the build.

A full-frame LVGL draw buffer for the launcher was measured and left out:
one buffer serializes drawing with the PPA rotation (57 -> 66 ms
average), two (3.5 MB) only trim the slowest redraws (96 -> 80 ms) and
fragment the launcher's heap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
@finger563
finger563 merged commit 30b94af into main Nov 21, 2026
1 check passed
@finger563
finger563 deleted the perf/launcher-backdrop-tiles branch November 21, 2026 04:26
finger563 added a commit that referenced this pull request Nov 21, 2026
tools/overlay_image.py: both sides added the merged-strings exception (#30
and this branch); main's version is kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
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.

1 participant