Conversation
This introduces rendering optimizations that reduce backend overhead for partial-redraw and text-heavy UI scenes: 1. iui_emit_box: universal draw interception point replacing all direct ctx->renderer.draw_box() calls. Route through ink-bounds tracking and optional batch system. 2. Ink-bounds tracking: per-frame union bounding box of all draw calls (boxes, text, lines, circles, arcs). Backend can query iui_ink_bounds_get() to blit only the dirty region instead of full framebuffer. Uses FLT_MAX/-FLT_MAX initialization to eliminate first-extend branch on Arm Cortex-M pipeline. Negative width/height inputs are normalized before accumulation. 3. Draw call batching — 256-command buffer with clip-rect grouping on flush. All primitive types (rect, text, line, circle, arc) are routed through the batch when enabled, preserving draw order. Vector font text correctly bypasses the text batch (renders through iui_emit_box which is already batch-aware). 4. Text width cache — 64-entry hash table with linear probing and LFU eviction. Eliminates 99% of backend text_width callbacks. Cache key includes font_height to prevent cross-size poisoning when typography helpers temporarily mutate font metrics. Amortized O(k) decay per frame avoids O(N) scan. IUI_TEXT_CACHE_SIZE enforced as power-of-two via _Static_assert. Benchmark (noop backend, 480x800, 5000 frames, median-of-3): - Settings scene: 58 draws/frame, 1.9 us baseline - Dashboard scene: 98 draws/frame, 2.4 us baseline - Form scene: 66 draws/frame, 0.8 us baseline - Text cache: 99% text_width elimination across all scenes - Ink-bounds coverage: 100-119% of screen area (tight) The ink-bounds overhead (47-72%) measured with noop backend is expected: zero-cost draw calls make tracking arithmetic dominate. With a real GPU/framebuffer backend, the dirty-rect savings from partial redraws offset this cost significantly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This introduces rendering optimizations that reduce backend overhead for partial-redraw and text-heavy UI scenes:
Benchmark (noop backend, 480x800, 5000 frames, median-of-3):
The ink-bounds overhead (47-72%) measured with noop backend is expected: zero-cost draw calls make tracking arithmetic dominate. With a real GPU/framebuffer backend, the dirty-rect savings from partial redraws offset this cost significantly.
Summary by cubic
Adds ink-bounds tracking, draw batching, and a text-width cache to cut redraw work and reduce backend text measurement calls. Routes all box draws through
iui_emit_boxand adds a rendering benchmark.New Features
iui_emit_boxintercepts box draws and flows through ink-bounds and optional batching.iui_ink_bounds_get; reset iniui_begin_frame._Static_assert.tests/bench-render.cto profile Settings, Dashboard, and Form scenes.Migration
iui_batch_enable,iui_dirty_enable,iui_ink_bounds_enable, andiui_text_cache_enable.iui_ink_bounds_geteach frame to blit only the returned rect; fall back to full-frame if invalid.iui_emit_boxinstead ofctx->renderer.draw_box.IUI_TEXT_CACHE_SIZEmust be a power of two.Written for commit 01c9607. Summary will update on new commits.