pub struct VmState { /* private fields */ }Expand description
Everything a run needs beyond the program: the register file, the scratch arenas, the operand stack and the RNG.
Allocated once at preset load. A frame borrows it mutably and returns it unchanged in shape — nothing here resizes while a preset renders, which is the whole of the real-time claim.
Implementations§
Source§impl VmState
impl VmState
Sourcepub fn new(registers: usize, stack_depth: usize, salt: u32) -> Self
pub fn new(registers: usize, stack_depth: usize, salt: u32) -> Self
Allocate for a program of registers registers and stack_depth operand
slots, with the RNG seeded from salt.
Sized for the largest of a bundle’s programs by the caller, so the three of them share one state and the values a per-frame program leaves in its registers are what the per-vertex program starts from — which is MilkDrop’s own execution model.
Sourcepub fn accommodate(&mut self, program: &EelProgram)
pub fn accommodate(&mut self, program: &EelProgram)
Grow the register file and operand stack to hold program, if they do not
already. Load-time only — called when a bundle’s programs are attached,
never per frame.
Sourcepub fn set(&mut self, index: u16, value: f32)
pub fn set(&mut self, index: u16, value: f32)
Write register index, ignoring one that does not exist.
Sourcepub fn clear_registers(&mut self)
pub fn clear_registers(&mut self)
Zero every register — what a preset switch does before the first
per_frame_init run.
Sourcepub fn clear_memory(&mut self)
pub fn clear_memory(&mut self)
Zero both scratch arenas. Load-time: a preset must not inherit the
previous one’s megabuf.