Skip to main content

AtlasArray

Struct AtlasArray 

Source
pub struct AtlasArray { /* private fields */ }
Expand description

The atlas array texture, its view, and the layer count both were created at.

Created lazily by the first frame that makes an image resident, then grown only. The view is kept beside the texture because a bind group is built against it and has to be rebuilt whenever growth replaces the texture — generation is what tells a caller that happened.

Implementations§

Source§

impl AtlasArray

Source

pub fn new(device: &Device, width: u32, height: u32) -> Self

An atlas array of width x height texels with at least two layers due to the floor raised by wgpu-hal 30.0.1’s GLES backend heuristic — one resident layer is still the logical minimum, but a second layer is allocated to work around a target-selection bug in get_info_from_desc (see atlas_texture_descriptor).

Source

pub fn with_layers( device: &Device, width: u32, height: u32, layers: u32, ) -> Self

An atlas array of width x height texels over layers layers.

Source

pub fn texture(&self) -> &Texture

The array texture the shader samples.

Source

pub fn view(&self) -> &TextureView

The D2Array view a bind group binds.

Source

pub fn size(&self) -> (u32, u32)

Extent of each layer, in texels.

Source

pub fn layers(&self) -> u32

How many array layers currently exist.

Source

pub fn layer_view(&self, layer: u32) -> Option<TextureView>

A render-attachment view over one array layer, or None when the array has no such layer.

Minted per use rather than cached alongside view: a layer target is wanted only on a frame that has glyph pixels to rasterize, while the sampling view is bound by every frame, and holding one view per layer for the array’s lifetime would keep a handle alive per layer for a path most frames never take.

Source

pub fn generation(&self) -> u64

How many times growth has replaced the underlying texture.

A bind group built against view stays valid for as long as this value does not change.

Source

pub fn ensure_layers( &mut self, device: &Device, queue: &Queue, layers: u32, ) -> bool

Grow the array to hold at least layers layers, preserving every existing layer’s texels.

Returns whether the texture was replaced — the signal a caller needs to rebuild its bind group. A request at or below the current depth, or one past MAX_ATLAS_INDEX, is a no-op: the encoded-image record cannot name a layer the shader could not address, so refusing here is what keeps an unaddressable layer from being created at all.

The old-to-new copy is recorded into a command encoder of this method’s own and submitted before returning, rather than into the frame’s. That is an ordering requirement rather than a convenience — see the module doc’s Why growth submits a command buffer of its own. Call it before the frame’s atlas writes are issued; anything already queued is flushed by this submit and so lands in the old texture.

Source

pub fn write_region( &self, queue: &Queue, region: AtlasRegion, pixels: &[u8], ) -> bool

Write pixels into region.

pixels must be region’s own extent in premultiplied Rgba8Unorm, row-major and unpadded — exactly what crate::cache::images::ImageUpload carries. A slice that does not match, or a region outside the array, is refused rather than handed to the queue, which would validate it into a device error mid-frame.

Source

pub fn clear_region(&self, queue: &Queue, region: AtlasRegion) -> bool

Clear region to transparent texels.

This is what makes an eviction observable as absence rather than as a stale image: the rectangle a reaped entry gave back is zeroed before a later allocation can hand part of it to something smaller, so a sample that strays into the unwritten remainder reads transparent black rather than the previous tenant’s pixels.

Source

pub fn contains(&self, region: AtlasRegion) -> bool

Whether region lies wholly inside this array.

Trait Implementations§

Source§

impl Debug for AtlasArray

Source§

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

Formats the value using the given formatter. Read more

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

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

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

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.
Source§

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

Source§

impl<T> WasmNotSendSync for T

Source§

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