Struct nannou::wgpu::RowPaddedBuffer [−][src]
pub struct RowPaddedBuffer { /* fields omitted */ }
A wrapper around a wgpu buffer suitable for copying to and from Textures. Automatically handles the padding necessary for buffer-to-texture and texture-to-buffer copies.
Note: as of wgpu
0.6, texture-to-buffer and buffer-to-texture copies require that image rows
are padded to a multiple wgpu::COPY_BYTES_PER_ROW_ALIGNMENT
bytes. Note that this is a
requirement on the buffers, not on the textures! You can have textures of whatever size you
like, but when you copy them to/from a buffer, the buffer rows need padding. This is referred
to as “pitch alignment”.
In a RowPaddedBuffer
, the image is stored in row-major order, with rows padded at the end with
uninitialized bytes to reach the necessary size.
Implementations
impl RowPaddedBuffer
[src]
pub fn new(
device: &Device,
width: u32,
height: u32,
usage: BufferUsage
) -> RowPaddedBuffer
[src]
device: &Device,
width: u32,
height: u32,
usage: BufferUsage
) -> RowPaddedBuffer
Create a row-padded buffer on the device.
Width should be given in bytes.
pub fn from_image_buffer<P, Container>(
device: &Device,
image_buffer: &ImageBuffer<P, Container>
) -> RowPaddedBuffer where
P: 'static + Pixel,
Container: Deref<Target = [P::Subpixel]>,
[src]
device: &Device,
image_buffer: &ImageBuffer<P, Container>
) -> RowPaddedBuffer where
P: 'static + Pixel,
Container: Deref<Target = [P::Subpixel]>,
Initialize from an image buffer (i.e. an image on CPU).
pub fn for_texture(
device: &Device,
texture: &Texture,
usage: BufferUsage
) -> RowPaddedBuffer
[src]
device: &Device,
texture: &Texture,
usage: BufferUsage
) -> RowPaddedBuffer
Creates a buffer compatible with a 2d slice of the given texture.
pub fn width(&self) -> u32
[src]
The width of the buffer, in bytes, NOT including padding bytes.
pub fn row_padding(&self) -> u32
[src]
The padding of each row of this buffer.
pub fn padded_width(&self) -> u32
[src]
The width of the buffer, in bytes, INCLUDING padding bytes.
pub fn height(&self) -> u32
[src]
The height of the buffer.
pub fn write(&self, buf: &[u8])
[src]
Copy data into the padded buffer.
Will copy data_width
bytes of data into each row of the buffer, leaving the remainder
of the buffer unmodified.
The buffer usage must include BufferUsage::map_read()
.
pub async fn read<'b>(
&'b self
) -> Result<ImageReadMapping<'b>, BufferAsyncError>
[src]
&'b self
) -> Result<ImageReadMapping<'b>, BufferAsyncError>
Asynchronously maps the buffer of bytes from GPU to host memory and, once mapped, calls the
given user callback with the data represented as an ImageReadMapping
.
Note: The given callback will not be called until the memory is mapped and the device is polled. You should not rely on the callback being called immediately.
pub fn encode_copy_into(
&self,
encoder: &mut CommandEncoder,
destination: &Texture
)
[src]
&self,
encoder: &mut CommandEncoder,
destination: &Texture
)
Encode a copy into a texture. Assumes the texture is 2d.
The copy will not be performed until the encoded command buffer is submitted.
pub fn encode_copy_into_at(
&self,
encoder: &mut CommandEncoder,
destination: &Texture,
depth: u32
)
[src]
&self,
encoder: &mut CommandEncoder,
destination: &Texture,
depth: u32
)
Encode a copy into a 3d texture at a given depth. Will copy this buffer (modulo padding) to a slice of the texture at the given depth.
The copy will not be performed until the encoded command buffer is submitted.
pub fn encode_copy_from(&self, encoder: &mut CommandEncoder, source: &Texture)
[src]
Encode a copy from a texture.
The copy will not be performed until the encoded command buffer is submitted.
pub fn encode_copy_from_at(
&self,
encoder: &mut CommandEncoder,
source: &Texture,
depth: u32
)
[src]
&self,
encoder: &mut CommandEncoder,
source: &Texture,
depth: u32
)
Encode a copy from a 3d texture at a given depth. Will copy a slice of the texture to fill this whole buffer (modulo padding).
The copy will not be performed until the encoded command buffer is submitted.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for RowPaddedBuffer
impl Send for RowPaddedBuffer
impl Sync for RowPaddedBuffer
impl Unpin for RowPaddedBuffer
impl !UnwindSafe for RowPaddedBuffer
Blanket Implementations
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S where
T: Component + Float,
D: AdaptFrom<S, Swp, Dwp, T>,
Swp: WhitePoint,
Dwp: WhitePoint,
[src]
T: Component + Float,
D: AdaptFrom<S, Swp, Dwp, T>,
Swp: WhitePoint,
Dwp: WhitePoint,
pub fn adapt_into_using<M>(self, method: M) -> D where
M: TransformMatrix<Swp, Dwp, T>,
[src]
M: TransformMatrix<Swp, Dwp, T>,
pub fn adapt_into(self) -> D
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> ConvertInto<U> for T where
U: ConvertFrom<T>,
[src]
U: ConvertFrom<T>,
pub fn convert_into(self) -> U
[src]
pub fn convert_unclamped_into(self) -> U
[src]
pub fn try_convert_into(self) -> Result<U, OutOfBounds<U>>
[src]
impl<T> Downcast<T> for T
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Pointable for T
pub const ALIGN: usize
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
pub unsafe fn drop(ptr: usize)
impl<T> SetParameter for T
pub fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>,
T: Parameter<Self>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Upcast<T> for T
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,