Skip to main content

Budget

Struct Budget 

Source
pub struct Budget {
    pub loops: u32,
    pub instructions: u32,
}
Expand description

What one run may spend: how many iterations any single loop may take, and how many instructions the whole run may execute.

Per program rather than one constant, because the three programs of a bundle cost wildly different amounts. per_frame_init runs once at load; per_frame runs once a frame; per_vertex runs once per vertex, thousands of times a frame. A single bound tight enough for the third would break the first — the corpus’s commonest per_frame_init idiom is loop(10000, megabuf(index) = .1; index = index + 1), seeding a scratch array, and 84 presets in the largest pack do exactly that.

Both numbers are bounds, not budgets: nothing is reserved and an honest program never approaches either. What they buy is that untrusted program text cannot hang a frame, which is ADR-0113’s stated residual risk on the shader side and is closed on this side.

Fields§

§loops: u32

The most iterations any one loop() or while() may run.

§instructions: u32

The most instructions the whole run may execute — the backstop under the loop bound, so a program whose bare jumps form a cycle still terminates.

Implementations§

Source§

impl Budget

Source

pub const INIT: Self

per_frame_init: runs once, at preset load, off the hot path. The loop bound is MilkDrop’s own (1 << 20), and the instruction bound is generous enough that seeding a whole megabuf fits.

Source

pub const FRAME: Self

per_frame: once a frame. A million instructions is a few milliseconds on the CPUs this ships to — far past any real preset, and far under a stall.

Source

pub const VERTEX: Self

per_vertex: once per vertex, so its bound is multiplied by the mesh. At the rich tier’s 5 963 vertices this ceiling is still 49 M instructions a frame in the worst case, which is why it is three orders under the others — real per-vertex programs are a few hundred instructions, and the measured tier ladder (TierConfig::mesh_grid) is priced against that.

Trait Implementations§

Source§

impl Clone for Budget

Source§

fn clone(&self) -> Budget

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Budget

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Budget

Source§

fn eq(&self, other: &Budget) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Budget

Source§

impl Eq for Budget

Source§

impl StructuralPartialEq for Budget

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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,