Expand description
Per-preset state bundle.
Groups everything that varies between presets — the preset itself, the
evaluator carrying its variable context, the pre-compiled per-vertex
executor, the per-wave / per-shape compiled equations, and the
RenderState their per-frame evaluation produces.
MilkEngine holds one PresetSlot for the active preset plus an
Option<PresetSlot> for the outgoing preset that keeps evaluating on
the renderer’s secondary chain during a crossfade.
Structs§
- Compiled
Shape 🔒 - Pre-compiled equations for one
shapecode_Nblock. Same rationale asCompiledWave— shapes can run their per-frame block up to 1024 times per shape per frame, so caching the compiled form is non-optional. Both phases useCompiledBlockso the bytecode VM kicks in transparently when the block fully lowers. - Compiled
Wave 🔒 - Pre-compiled equation Nodes for one
wavecode_Nblock. We compile each phase exactly once perload_preset; per-frame and per-point evaluation just runs the cachedNodes, skipping the regex-based preprocess thatMilkEvaluator::evalperforms every call. This is load-bearing for performance: a single 512-sample wave with 5 per-point statements runs the loop 2 560 times per frame. - Preset
Slot 🔒 - Everything a single preset needs to render itself: the parsed
.milkdata, an evaluator context owning its variables, the per-vertex executor pre-compiled against the preset’sper_pixel_equations, the per-wave / per-shape compiled equation lists, and the render state the per-frame loop writes into.
Functions§
- preset_
id_ 🔒for - Stable preset id used to seed
sampler_rand0Xresolution. Derived from the preset’s comp shader text (when present) — identical shaders share the same rand pick; distinct ones diverge. Falls back to a hash of the per-frame equations when the comp shader is absent. - run_
block_ 🔒with_ logger - Run a
CompiledBlockagainsteval, callingon_err(node_index, err)for each evalexpr-fallback node that fails. Centralises the “prefer bytecode (infallible) / log per-equation failures on the Nodes path” pattern shared bywave_phase,shape_phaseand the per-frame eval in [MilkEngine::update].