Skip to main content

TexelArray

Struct TexelArray 

Source
pub struct TexelArray {
    texture: Texture,
    view: TextureView,
    layout: TexelArrayLayout,
    staging: StagingBuffer,
    scratch: Vec<u8>,
}
Expand description

A flat array of fixed-size elements stored in a texture.

See the module docs for what it is for and how it is laid out.

Fields§

§texture: Texture

The texture the elements live in.

§view: TextureView

The whole texture as one view, which is what a bind group binds.

§layout: TexelArrayLayout

The array’s shape and format.

§staging: StagingBuffer

The staging buffer the row-padded image reaches the texture through, reused across frames like every other upload.

§scratch: Vec<u8>

The row-padded image the last upload was assembled in, kept so a steady frame reallocates nothing.

Implementations§

Source§

impl TexelArray

Source

pub fn new( device: &Device, label: Option<&str>, element_size: u64, capacity: u64, max_dimension: u32, ) -> Self

Allocate an array with room for capacity elements of element_size bytes.

max_dimension is the device’s [wgpu::Limits::max_texture_dimension_2d]; the texture never exceeds it on either axis.

§Panics

Under the conditions TexelArrayLayout::new panics.

Source

pub fn texture(&self) -> &Texture

The texture the elements live in.

Source

pub fn view(&self) -> &TextureView

The view a bind group binds.

Source

pub fn layout(&self) -> &TexelArrayLayout

The array’s shape and format.

Source

pub fn binding_resource(&self) -> BindingResource<'_>

The bind-group resource that binds this array.

Source

pub fn upload( &mut self, device: &Device, encoder: &mut CommandEncoder, elements: &[u8], )

Upload elements — whole elements, laid out as the storage buffer would have held them — into the texture, recording the copy into encoder.

The bytes go through a reused staging buffer, so a steady frame allocates nothing and the copy is batched with the rest of the frame’s work rather than costing a submission of its own.

§Panics

Under the conditions TexelArrayLayout::pack panics.

Source

pub fn write(&mut self, queue: &Queue, elements: &[u8])

Upload elements through the queue, for data written once.

The rows are re-aligned by [wgpu::Queue::write_texture], so unlike Self::upload this needs no copy alignment — but it also costs a submission of its own.

§Panics

Under the conditions TexelArrayLayout::pack panics.

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
§

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> Downcast<T> for T

§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

§

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

§

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

§

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

§

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

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

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,

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more