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: u32The most iterations any one loop() or while() may run.
instructions: u32The 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
impl Budget
Sourcepub const INIT: Self
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.
Sourcepub const FRAME: Self
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.
Sourcepub const VERTEX: Self
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§
impl Copy for Budget
impl Eq for Budget
impl StructuralPartialEq for Budget
Auto Trait Implementations§
impl Freeze for Budget
impl RefUnwindSafe for Budget
impl Send for Budget
impl Sync for Budget
impl Unpin for Budget
impl UnsafeUnpin for Budget
impl UnwindSafe for Budget
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.