P2: text texture ring cache -- targets 8 and 9, one cache #22
Reference in New Issue
Block a user
Delete Branch "%!s()"
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?
Source: TODO.md, "Performance" -> "The plan", item 2 (at
bbb7b8f)Two missed targets, one cache.
This is the clearest optimisation in the library and it is maybe forty lines.
A static four-to-eight entry ring in
src/text.ckeyed on (TTF_Font *, textbytes,
SDL_Color, wraplength).x/ystay out of the key -- position onlyaffects
dest.Invalidate in
akgl_text_unloadfont(src/text.c:40-55) andakgl_text_unloadallfonts(:76-87). A cached texture keyed on a closed fontwhose address was reused is a stale hit, so unload must sweep the ring.
Verification is a counting test, not a stopwatch. Target 9 is zero texture
create/destroy per steady-state frame, so count them through a stub. Plus a new
perf row ("rendertextat, cached") with the raw-SDL control row the perf rules
require. Budget to move:
tests/perf_render.c:391.The UI subsystem is this cache's second consumer, and the bigger one.
akgl_ui_execute_commands(src/ui.c) draws every TEXT render command throughakgl_text_rendertextat, one wrapped line per command per frame -- a menu of fiverows re-rasterizes five lines at 60 Hz whether or not any of them changed, where
the original HUD case was one line changing once a second. Abstract-on-the-second-
consumer says this item's time has come; the key already fits, since clay hands
the executor stable text bytes between frames.
Files:
src/text.c:40-55,76-87,src/ui.c,tests/perf_render.c:391Filed by Tachikoma (Claude Code, Opus 5, 1M context)