74static_assert(
sizeof(
ra8_tile_key_t) ==
sizeof(uint32_t) +
sizeof(uint16_t) +
sizeof(uint16_t) +
75 sizeof(uint16_t) +
sizeof(uint16_t),
76 "ra8_tile_key_t must be padding-free for byte-wise key comparison");
180typedef enum : uint8_t {
453 uint16_t* out_warmed);
479 uint32_t* out_misses,
480 uint32_t* out_evictions);
Error Code Definitions for ra8-firmware.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
The one reusable hash + pin + evict cache engine (#147, #345).
ra8_err_t ra8_tile_cache_get(ra8_tile_cache_t *tc, const ra8_tile_key_t *key, ra8_tile_t *out_tile)
Get (and pin) the decoded tile for key.
ra8_err_t ra8_tile_cache_prefetch_pan(ra8_tile_cache_t *tc, const ra8_tile_prefetch_req_t *req, uint16_t *out_warmed)
Predictively warm the tiles one step ahead of a panning viewport.
ra8_err_t ra8_tile_cache_stats(const ra8_tile_cache_t *tc, uint32_t *out_hits, uint32_t *out_misses, uint32_t *out_evictions)
Report the cache hit / miss / eviction counters.
ra8_err_t ra8_tile_cache_put(ra8_tile_cache_t *tc, const uint8_t *pixels)
Release one pin on a tile previously returned by ra8_tile_cache_get.
ra8_err_t ra8_tile_cache_init(ra8_tile_cache_t *tc, const ra8_tile_cache_cfg_t *cfg)
Initialise a tile cache over caller-supplied storage.
uint32_t ra8_tile_cache_capacity(const ra8_tile_cache_t *tc)
Report the number of cells the cache can hold.
ra8_tile_pan_dir_t
Direction of viewport travel, for predictive pan prefetch.
@ k_ra8_tile_pan_none
No travel: prefetch is a no-op.
@ k_ra8_tile_pan_up
Warm the row above the viewport.
@ k_ra8_tile_pan_down
Warm the row below the viewport.
@ k_ra8_tile_pan_left
Warm the column left of the viewport.
@ k_ra8_tile_pan_right
Warm the column right of the viewport.
ra8_err_t ra8_tile_cache_prefetch(ra8_tile_cache_t *tc, const ra8_tile_key_t *key)
Warm one tile into the cache without holding a pin (read-ahead).
ra8_err_t ra8_tile_rect_of_pixels(uint32_t px, uint32_t py, uint32_t pw, uint32_t ph, uint16_t tile_w, uint16_t tile_h, uint16_t tile_cols, uint16_t tile_rows, ra8_tile_rect_t *out)
Convert a pixel rectangle into the inclusive tile rectangle covering it.
ra8_err_t(* ra8_tile_decode_fn)(void *ctx, const ra8_tile_key_t *key, uint8_t *cell, uint32_t cell_bytes, uint16_t *out_w, uint16_t *out_h)
Decode an image tile into a cache cell (decode-on-miss DIP seam).
Per-cell link metadata (one caller-owned array entry per cell).
Cache engine state (caller-owned; treat as private).
Caller-supplied storage + decoder for ra8_tile_cache_init.
ra8_tile_dims_t * dims
cell_count dimension descriptors.
uint32_t cell_bytes
Bytes per cell (max decoded tile).
ra8_tile_decode_fn decode
Decode-on-miss callback.
uint8_t * cell_mem
cell_count * cell_bytes of tile storage.
uint32_t cell_count
Number of cells.
ra8_keycache_cell_t * meta
cell_count link-metadata entries.
uint32_t bucket_count
Number of hash buckets (>= 1).
ra8_tile_key_t * keys
cell_count key-storage entries.
void * decode_ctx
Opaque context passed to decode.
int32_t * buckets
bucket_count hash-bucket heads.
Tile-cache state (caller-owned; treat as private).
ra8_keycache_t kc
Underlying keyed-LRU cache.
void * decode_ctx
Caller's decoder context.
ra8_tile_decode_fn decode
Caller's tile decoder.
Per-cell user descriptor: the decoded tile dimensions.
uint16_t h
Decoded tile height in pixels.
uint16_t w
Decoded tile width in pixels.
Identifies one decoded image tile.
uint16_t tile_y
Tile row index (in tile units).
uint16_t tile_x
Tile column index (in tile units).
uint16_t zoom
Zoom / mip level (0 = native).
uint32_t image_id
Source image identifier.
uint16_t reserved
Reserved; keep zero (padding-free byte-wise key).
A predictive pan-prefetch request: what is visible + where it heads.
uint16_t max_tiles
Residency budget: warm at most this many.
ra8_tile_rect_t view
The tiles the viewport currently straddles.
uint16_t tile_rows
Image tile rows (lead-edge clamp bound).
uint16_t zoom
Zoom / mip level for the key (0 = native).
ra8_tile_pan_dir_t dir
Direction of viewport travel.
uint32_t image_id
Tile-cache key image id (the image panned).
uint16_t tile_cols
Image tile columns (lead-edge clamp bound).
An inclusive rectangle of tile grid coordinates (the visible tiles).
uint16_t ty0
Topmost visible tile row (inclusive).
uint16_t tx1
Rightmost visible tile column (inclusive).
uint16_t ty1
Bottommost visible tile row (inclusive).
uint16_t tx0
Leftmost visible tile column (inclusive).
A pinned view of a cached tile returned by ra8_tile_cache_get.
const uint8_t * pixels
Decoded tile pixels (cell payload).
uint16_t height
Decoded tile height in pixels.
uint16_t width
Decoded tile width in pixels.