pub struct AtlasBudget {
pub atlas_size: (u32, u32),
pub max_atlases: usize,
}Expand description
The atlas geometry a tier of adapter is given.
Never vello_common’s own AtlasConfig default: that is 4096 square
across eight layers, 64 MiB of Rgba8Unorm per layer and half a gigabyte in
total, which is a desktop-only figure that a phone would pay for the first
image it drew.
Fields§
§atlas_size: (u32, u32)Extent of each atlas layer, in pixels.
max_atlases: usizeMaximum number of layers the array may grow to.
Implementations§
Source§impl AtlasBudget
impl AtlasBudget
Sourcepub const MOBILE: Self
pub const MOBILE: Self
The budget a tile-based or downlevel-clamped adapter gets: 4 MiB a layer, 16 MiB in total.
Sourcepub const DESKTOP: Self
pub const DESKTOP: Self
The budget a full-profile immediate-mode adapter gets: 16 MiB a layer, 128 MiB in total.
Sourcepub const MOBILE_LARGE_WIDE: Self
pub const MOBILE_LARGE_WIDE: Self
The large-mobile budget’s preferred shape: four 2048-square layers,
64 MiB in total — a quarter as many layers as
MOBILE_LARGE_DEEP for the same texels, so
the array grows (and copies itself) a quarter as often.
Sourcepub const MOBILE_LARGE_DEEP: Self
pub const MOBILE_LARGE_DEEP: Self
The large-mobile budget’s shape on an adapter whose texture edge stops short of 2048: sixteen 1024-square layers, the same 64 MiB.
Sourcepub fn mobile_large(caps: &TierCaps) -> Option<Self>
pub fn mobile_large(caps: &TierCaps) -> Option<Self>
The large-mobile shape caps’ adapter can create unclamped, or None
when it can create neither — the tier then falls back to
MOBILE rather than to a large budget its ceilings
would have narrowed below the plain one’s.
Sourcepub fn for_tier(tier: AtlasTier, caps: &TierCaps) -> Self
pub fn for_tier(tier: AtlasTier, caps: &TierCaps) -> Self
The unclamped budget tier stands for on caps’ adapter.
Sourcepub fn for_caps(caps: &TierCaps) -> Self
pub fn for_caps(caps: &TierCaps) -> Self
The budget for caps’ adapter, clamped to what it can actually create.
The tier choice is choose_tier over the adapter and the device’s
own memory (device_memory_bytes); the clamps that follow are the
adapter’s own texture-edge and array-layer ceilings plus the eight-bit
MAX_ATLAS_LAYERS the encoded-image record can address.
FRUST_ENGINE_ATLAS_SIZE overrides the tier’s extent, and the override
is budgeted, not unbudgeted: it passes through
within_total_bytes against the tier’s own
total_bytes before the adapter clamps. So the knob
redistributes a tier’s memory between extent and depth — one large layer
instead of eight small ones — and cannot spend more of it than the tier
itself would. Clamped to the adapter last, because an override is a
request and a request the adapter cannot honour is still narrowed to what
it can.
The resolved budget is reported once per process through
atlas_tier_line, because which tier a given phone takes is otherwise
an inference from behaviour rather than an observation: the adapter
name, the driver’s own capability answers and the memory reading are
all device-reported, and a device answering differently from the one
it resembles is exactly the case a benchmark capture has to be able to
name. That line is perf-trace-only, like every other frust-perf
line the engine emits — a build without the feature resolves the same
budget and writes nothing.
Sourcepub fn for_choice(choice: TierChoice, caps: &TierCaps) -> Self
pub fn for_choice(choice: TierChoice, caps: &TierCaps) -> Self
The budget choice resolves to on caps’ adapter — for_caps
without reading the device’s memory or writing the tier line, so the
table’s outcome is testable for any adapter and memory size.
Sourcepub fn within_total_bytes(self, total_bytes: u64) -> Self
pub fn within_total_bytes(self, total_bytes: u64) -> Self
This budget narrowed so a fully grown array costs at most total_bytes.
The extent goes first, scaled uniformly until one layer fits inside the whole allowance; the layer count then takes whatever multiple of that layer is left, never below one. Scaling the extent rather than only the depth is what makes the ceiling hold at all: a single 16384-square layer is a gigabyte on its own, so a clamp that could only reduce the layer count would have nothing left to reduce.
Both axes are floored after the uniform scale, which can only take the product below the allowance — except where an extreme aspect ratio floors one axis to nothing and it is raised back to a texel, so each axis is then held against what the other leaves.
Sourcepub fn contains(self, region: AtlasRegion, layers: u32) -> bool
pub fn contains(self, region: AtlasRegion, layers: u32) -> bool
Whether region lies inside an atlas array of layers layers at this
budget’s per-layer extent.
The pure counterpart of crate::gpu::atlas::AtlasArray::contains,
answerable with no device: a consumer that records where an image lives
before the array exists checks the rectangle here, so it can never come
to name a region the array will refuse to write and then sample it as
whatever the texture happened to hold.
Sourcepub fn clamped(self, caps: &TierCaps) -> Self
pub fn clamped(self, caps: &TierCaps) -> Self
This budget narrowed to what caps’ adapter can create.
Sourcepub fn config(self) -> AtlasConfig
pub fn config(self) -> AtlasConfig
The vello_common configuration this budget describes.
initial_atlas_count is zero so the first layer is created by the first
allocation that needs one: an application drawing no images pays for no
atlas at all, and vello_common::multi_atlas::MultiAtlasManager::new’s
own expect on eager creation can never be reached.
Sourcepub fn layer_bytes(self) -> u64
pub fn layer_bytes(self) -> u64
The bytes one fully populated layer costs at ATLAS_FORMAT_BYTES.
Sourcepub fn total_bytes(self) -> u64
pub fn total_bytes(self) -> u64
The bytes every layer of this budget costs once fully grown.
Trait Implementations§
Source§impl Clone for AtlasBudget
impl Clone for AtlasBudget
impl Copy for AtlasBudget
Source§impl Debug for AtlasBudget
impl Debug for AtlasBudget
impl Eq for AtlasBudget
Source§impl PartialEq for AtlasBudget
impl PartialEq for AtlasBudget
impl StructuralPartialEq for AtlasBudget
Auto Trait Implementations§
impl Freeze for AtlasBudget
impl RefUnwindSafe for AtlasBudget
impl Send for AtlasBudget
impl Sync for AtlasBudget
impl Unpin for AtlasBudget
impl UnsafeUnpin for AtlasBudget
impl UnwindSafe for AtlasBudget
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.