Skip to main content

VmState

Struct VmState 

Source
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

Source

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.

Source

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.

Source

pub fn get(&self, index: u16) -> f32

Read register index, or 0 for one that does not exist.

Source

pub fn set(&mut self, index: u16, value: f32)

Write register index, ignoring one that does not exist.

Source

pub fn clear_registers(&mut self)

Zero every register — what a preset switch does before the first per_frame_init run.

Source

pub fn clear_memory(&mut self)

Zero both scratch arenas. Load-time: a preset must not inherit the previous one’s megabuf.

Source

pub fn reset_rng(&mut self)

Restore the RNG to its seed, so a re-run of a preset from frame zero draws the same sequence (ADR-0051 / NFR §6).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

impl<T> WasmNotSync for T
where T: Sync,