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: TextureThe texture the elements live in.
view: TextureViewThe whole texture as one view, which is what a bind group binds.
layout: TexelArrayLayoutThe array’s shape and format.
staging: StagingBufferThe 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
impl TexelArray
Sourcepub fn new(
device: &Device,
label: Option<&str>,
element_size: u64,
capacity: u64,
max_dimension: u32,
) -> Self
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.
Sourcepub fn view(&self) -> &TextureView
pub fn view(&self) -> &TextureView
The view a bind group binds.
Sourcepub fn layout(&self) -> &TexelArrayLayout
pub fn layout(&self) -> &TexelArrayLayout
The array’s shape and format.
Sourcepub fn binding_resource(&self) -> BindingResource<'_>
pub fn binding_resource(&self) -> BindingResource<'_>
The bind-group resource that binds this array.
Sourcepub fn upload(
&mut self,
device: &Device,
encoder: &mut CommandEncoder,
elements: &[u8],
)
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.
Sourcepub fn write(&mut self, queue: &Queue, elements: &[u8])
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§
impl !RefUnwindSafe for TexelArray
impl !UnwindSafe for TexelArray
impl Forget for TexelArray
impl Freeze for TexelArray
impl Send for TexelArray
impl Sync for TexelArray
impl Unpin for TexelArray
impl UnsafeUnpin for TexelArray
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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