Skip to main content

BumpBudget

Struct BumpBudget 

Source
pub struct BumpBudget {
    pub lines: u32,
    pub binning: u32,
    pub tiles: u32,
    pub seg_counts: u32,
    pub segments: u32,
    pub blend_spill: u32,
    pub ptcl: u32,
    pub max_binding_bytes: u32,
}
Expand description

How much bump-allocated scratch a renderer reserves, in elements.

Every field here is a count the GPU also reports back through BumpAllocators, which is what makes the reservation measurable rather than guessed: BumpBudget::observe takes what a frame asked for and grows the budget to cover it.

Growth is one-way within a process. A window that once drew a map keeps room to draw a map, on the grounds that it probably will again, and that handing the memory back costs a reallocation of every buffer at the moment the user is busiest. A renderer that opts in (Renderer::set_shrink_scratch in vello) hands it back once its scene has stayed much lighter for a while.

Fields§

§lines: u32

Flattened line segments (LineSoup).

§binning: u32

Words of per-bin draw-object lists, not counting the draw-info region they share a buffer with.

§tiles: u32

Per-path tile allocations (Tile).

§seg_counts: u32

Line/tile crossings counted by path_count (SegmentCount).

§segments: u32

Per-tile path segments (PathSegment).

§blend_spill: u32

Words of spilled blend scratch.

§ptcl: u32

Words of per-tile command list beyond the structural n_tiles * PTCL_INITIAL_ALLOC floor.

§max_binding_bytes: u32

Bytes of the largest buffer the device can bind. No bump-allocated buffer, floors included, is sized past it. WebGPU’s default is 128 MiB, below Self::CEILING for lines and segments.

Implementations§

Source§

impl BumpBudget

Source

pub const UPSTREAM: Self

Upstream vello’s constants, kept for reference and as the scale the ceiling below is expressed in.

Source

pub const INITIAL: Self

What a renderer starts from, before it has seen a frame: zero, with BufferSizes applying the viewport floor underneath. A renderer that never draws anything reserves what the floor says and no more.

Source

pub const CEILING: Self

Nothing grows past this – four times upstream’s reservation. No user interface reaches it; a scene that did would have rendered wrong on upstream too, and this way the renderer can say so instead of reserving without limit.

Source

pub fn floor_for_viewport(n_tiles: u32) -> Self

The least a viewport of n_tiles can be rendered with, per the measurements at the constants above.

Source

pub fn floor_for_scene(n_tiles: u32, n_path_tags: u32) -> Self

The viewport floor, extended by the encoded path stream’s known first-frame complexity.

Most buffers scale with screen area. Flattened lines also scale with the amount of path data, especially for dashed strokes, and there is no previous frame from which to learn on the first render.

Source

pub fn with_max_binding_bytes(self, bytes: u32) -> Self

This budget with every buffer limited to bytes per binding.

Source

pub fn binding_capacity<T>(&self) -> u32

Elements of T that fit in one binding.

Source

pub fn observe(&mut self, used: &BumpAllocators) -> bool

Grow to cover what a frame reported using, with headroom.

Returns true if anything changed, which is the caller’s cue to drop pooled buffers of the sizes that are no longer asked for.

The headroom matters because feedback arrives after the render that produced it: reserving exactly the previous usage would repeatedly under-provision a growing scene. A failure may prevent later stages from reporting their final demand, so convergence is not guaranteed in a single subsequent render.

A counter that has wrapped (see [CORRUPT_COUNT]) is ignored rather than believed: growing from it would pin a binding’s worth of memory per buffer for the rest of the process on one bad readback.

Source

pub fn observe_within(&mut self, used: &BumpAllocators, ceiling: &Self) -> bool

BumpBudget::observe, growing no field past ceiling.

Source

pub fn fit_total_bytes(&mut self, max_bytes: u64)

Shrink every reservation by the same factor until the whole budget fits in max_bytes. A browser’s GPU process has a hard memory limit (Safari’s is 600 MB); seven buffers each allowed a full binding reach most of a gigabyte, and a GPU process killed there mid-frame took the macOS window server down with it.

Source

pub fn ceiling_for_viewport(n_tiles: u32) -> Self

The most a viewport of n_tiles may grow to.

BumpBudget::CEILING is flat, and upstream’s constants it is scaled from were picked at 1080p. The floors beneath it scale with the viewport, so on a large enough target a flat ceiling sits below what the viewport structurally needs: blend spill, in particular, is TILE_WIDTH * TILE_HEIGHT words per tile per nesting level past the on-chip stack, and a 5120x2880 desktop with one spilled level everywhere asks for 14.7M words against a flat ceiling of 4.2M. A frame like that overflows, observes, is refused growth, and overflows again, forever – a black screen that looks like progress. The device’s binding limit still applies on top.

Source

pub fn size_in_bytes(&self) -> u64

Bytes this budget reserves, not counting the viewport floors.

Trait Implementations§

Source§

impl Clone for BumpBudget

Source§

fn clone(&self) -> Self

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 Copy for BumpBudget

Source§

impl Debug for BumpBudget

Source§

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

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

impl Default for BumpBudget

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for BumpBudget

Source§

impl PartialEq for BumpBudget

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for BumpBudget

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
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.