Module text_pipeline

Module text_pipeline 

Source
Expand description

Text overlay (§6) GPU pipeline.

Renders MILK_MSG.INI message strings as 2D glyph quads atop the comp output. Glyphs are rasterised on-demand by ab_glyph into a shared Rgba8Unorm atlas (alpha stored in .r), and the pipeline emits one draw per frame from a dynamic vertex buffer holding every glyph of every active message.

Two bundled fonts come from epaint_default_fonts:

  • 0 (default): Ubuntu-Light — clean sans the MD2 default message font (Arial) maps to.
  • 1 (mono): Hack-Regular — covers presets that ask for a monospace face. Mapping ignores bold/italic; MD2 only exposes those as font=...; bold=1 toggles and most preset packs author for the default sans anyway.

The atlas grows append-only inside a fixed 1024×1024 texture; if a glyph doesn’t fit, the renderer falls back to the existing slot pool (logged once). 1024² is enough for a few thousand glyphs at 32 px body size — well above what MILK_MSG.INI files use in the wild (≤ 8 messages).

Structs§

GlyphKey 🔒
Cache key for one rasterised glyph.
GlyphSlot 🔒
One rasterised glyph’s slot in the atlas.
TextAtlas
GPU + CPU text atlas. Owned by TextPipeline.
TextFrame
One message the engine asks the renderer to draw this frame. POD — the text/layout/font lookup all happens host-side in TextPipeline::record.
TextPipeline
Text GPU pipeline. One render pipeline + a growable vertex buffer.
TextQuadVertex
Per-glyph vertex pushed to the GPU vertex buffer.

Constants§

TEXT_ATLAS_SIZE
Atlas texture side (square). 1024² fits ~3K glyphs at 32px body — well above typical MILK_MSG.INI usage. The atlas grows append-only inside this footprint; once full, new glyph requests fall back to existing nearest-size slots.

Functions§

bundled_fonts 🔒
Load the two bundled fonts: Ubuntu-Light (index 0) + Hack-Regular (index 1). Failures collapse to a one-font vec so the pipeline always has something to lay out against; the dropped font logs once.