Skip to content

Optimize draw_pixels with consecutive pixel caching#46

Draft
stuartparmenter wants to merge 1 commit into
mainfrom
claude/optimize-dma-pixel-drawing-bjNY1
Draft

Optimize draw_pixels with consecutive pixel caching#46
stuartparmenter wants to merge 1 commit into
mainfrom
claude/optimize-dma-pixel-drawing-bjNY1

Conversation

@stuartparmenter

Copy link
Copy Markdown
Collaborator

When consecutive pixels have the same RGB values, skip redundant LUT
lookups and bit pattern computation by caching the pre-computed upper
and lower patterns. This avoids 3 LUT lookups and bit_depth×6 conditional
branches per duplicate pixel.

Particularly beneficial for images with solid color regions, UI elements
with flat backgrounds, and anti-aliased text with identical background pixels.

@stuartparmenter stuartparmenter force-pushed the claude/optimize-dma-pixel-drawing-bjNY1 branch from 50c6132 to 8113fdf Compare January 3, 2026 04:57
@stuartparmenter stuartparmenter marked this pull request as draft January 8, 2026 23:45
Add per-instance cache for raw pixel values and pre-computed bit patterns.
For consecutive identical pixels, skips:
- extract_rgb888_from_format() call
- 3 LUT lookups
- bit_depth × pattern computation iterations

Implementation:
- Pack raw source bytes into uint32_t for single-comparison cache check
- Cache pre-computed upper/lower patterns for all bit planes
- Class members persist across draw_pixels() calls (benefits single-pixel APIs)

Works on top of existing optimizations (identity fast path, branchless bit
extraction, pointer arithmetic).
@stuartparmenter stuartparmenter force-pushed the claude/optimize-dma-pixel-drawing-bjNY1 branch from 8113fdf to 364d6b3 Compare January 17, 2026 04:38
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