Struct nannou::wgpu::RowPaddedBuffer[][src]

pub struct RowPaddedBuffer { /* fields omitted */ }
Expand description

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

Create a row-padded buffer on the device.

Width should be given in bytes.

Initialize from an image buffer (i.e. an image on CPU).

Creates a buffer compatible with a 2d slice of the given texture.

The width of the buffer, in bytes, NOT including padding bytes.

The padding of each row of this buffer.

The width of the buffer, in bytes, INCLUDING padding bytes.

The height of the buffer.

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().

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.

Encode a copy into a texture. Assumes the texture is 2d.

The copy will not be performed until the encoded command buffer is submitted.

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.

Encode a copy from a texture.

The copy will not be performed until the encoded command buffer is submitted.

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

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Convert the source color to the destination color using the specified method Read more

Convert the source color to the destination color using the bradford method by default Read more

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Convert into T with values clamped to the color defined bounds Read more

Convert into T. The resulting color might be invalid in its color space Read more

Convert into T, returning ok if the color is inside of its defined range, otherwise an OutOfBounds error is returned which contains the unclamped color. Read more

Performs the conversion.

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.