[][src]Struct nannou::wgpu::Texture

pub struct Texture { /* fields omitted */ }

A convenient wrapper around a handle to a texture on the GPU along with its descriptor.

A texture can be thought of as an image that resides in GPU memory (as opposed to CPU memory).

This type is a thin wrapper around the wgpu crate's Texture type, but provides access to useful information like size, format, usage, etc.

Methods

impl Texture[src]

pub fn load_from_image_buffer<P, Container>(
    device: &Device,
    queue: &mut Queue,
    usage: TextureUsage,
    buffer: &ImageBuffer<P, Container>
) -> Texture where
    P: 'static + Pixel,
    Container: Deref<Target = [P::Subpixel]>, 
[src]

Load a texture directly from an image buffer using the given device queue.

No format or size conversions are performed - the given buffer is loaded directly into GPU memory.

Pixel type compatibility is ensured via the Pixel trait.

pub fn load_array_from_image_buffers<'a, I, P, Container>(
    device: &Device,
    queue: &mut Queue,
    usage: TextureUsage,
    buffers: I
) -> Option<Self> where
    I: IntoIterator<Item = &'a ImageBuffer<P, Container>>,
    I::IntoIter: ExactSizeIterator,
    P: 'static + Pixel,
    Container: 'a + Deref<Target = [P::Subpixel]>, 
[src]

Load a texture array directly from a sequence of image buffers.

No format or size conversions are performed - the given buffer is loaded directly into GPU memory.

Pixel type compatibility is ensured via the Pixel trait.

Returns None if there are no images in the given sequence.

pub fn encode_load_from_image_buffer<P, Container>(
    device: &Device,
    encoder: &mut CommandEncoder,
    usage: TextureUsage,
    buffer: &ImageBuffer<P, Container>
) -> Self where
    P: 'static + Pixel,
    Container: Deref<Target = [P::Subpixel]>, 
[src]

Encode the necessary commands to load a texture from the given image buffer.

NOTE: The returned texture will remain empty until the given encoder has its command buffer submitted to the given device's queue.

No format or size conversions are performed - the given buffer is loaded directly into GPU memory.

Pixel type compatibility is ensured via the Pixel trait.

pub fn encode_load_array_from_image_buffers<'a, I, P, Container>(
    device: &Device,
    encoder: &mut CommandEncoder,
    usage: TextureUsage,
    buffers: I
) -> Option<Self> where
    I: IntoIterator<Item = &'a ImageBuffer<P, Container>>,
    I::IntoIter: ExactSizeIterator,
    P: 'static + Pixel,
    Container: 'a + Deref<Target = [P::Subpixel]>, 
[src]

Encode the necessary commands to load a texture array directly from a sequence of image buffers.

NOTE: The returned texture will remain empty until the given encoder has its command buffer submitted to the given device's queue.

No format or size conversions are performed - the given buffer is loaded directly into GPU memory.

Pixel type compatibility is ensured via the Pixel trait.

Returns None if there are no images in the given sequence.

pub fn to_image(
    &self,
    device: &Device,
    encoder: &mut CommandEncoder
) -> Option<BufferImage>
[src]

Write the contents of the texture into a new image buffer.

Commands will be added to the given encoder to copy the entire contents of the texture into the buffer.

Returns a buffer from which the image can be read asynchronously via read.

Returns None if there is no directly compatible image::ColorType for the texture's format.

NOTE: read should not be called on the returned buffer until the encoded commands have been submitted to the device queue.

impl Texture[src]

pub fn descriptor(&self) -> &TextureDescriptor[src]

The inner descriptor from which this Texture was constructed.

pub fn descriptor_cloned(&self) -> TextureDescriptor[src]

The inner descriptor from which this Texture was constructed.

pub fn size(&self) -> [u32; 2][src]

The width and height of the texture.

See the extent method for producing the full width, height and depth of the texture.

pub fn extent(&self) -> Extent3d[src]

The width, height and depth of the texture.

pub fn array_layer_count(&self) -> u32[src]

pub fn mip_level_count(&self) -> u32[src]

pub fn sample_count(&self) -> u32[src]

pub fn dimension(&self) -> TextureDimension[src]

Describes whether the texture is of 1, 2 or 3 dimensions.

pub fn format(&self) -> TextureFormat[src]

The format of the underlying texture data.

pub fn usage(&self) -> TextureUsage[src]

The set of usage bits describing the ways in which the Texture may be used.

pub fn from_handle_and_descriptor(
    handle: TextureHandle,
    descriptor: TextureDescriptor
) -> Self
[src]

Create a Texture from the inner wgpu texture handle and the descriptor used to create it.

This constructor should only be used in the case that you already have a texture handle and a descriptor but need a Texture. The preferred construction approach is to use the TextureBuilder.

The descriptor must be the same used to create the texture.

pub fn to_buffer(
    &self,
    device: &Device,
    encoder: &mut CommandEncoder
) -> (Buffer, BufferAddress)
[src]

Write the contents of the texture into a new buffer.

Commands will be added to the given encoder to copy the entire contents of the texture into the buffer.

The buffer is returned alongside its size in bytes.

If the texture has a sample count greater than one, it will first be resolved to a non-multisampled texture before being copied to the buffer. copy_texture_to_buffer command has been performed by the GPU.

NOTE: map_read_async should not be called on the returned buffer until the encoded commands have been submitted to the device queue.

pub fn to_buffer_bytes(
    &self,
    device: &Device,
    encoder: &mut CommandEncoder
) -> BufferBytes
[src]

Encode the necessary commands to read the contents of the texture into memory.

The entire contents of the texture will be made available as a single slice of bytes.

This method uses to_buffer internally, exposing a simplified API for reading the produced buffer as a slice of bytes.

If the texture has a sample count greater than one, it will first be resolved to a non-multisampled texture before being copied to the buffer.

NOTE: read should not be called on the returned buffer until the encoded commands have been submitted to the device queue.

pub fn create_default_view_descriptor(&self) -> TextureViewDescriptor[src]

The view descriptor describing a full view of the texture.

pub fn create_default_copy_view(&self) -> TextureCopyView[src]

Creates a TextureCopyView ready for copying to or from the entire texture.

pub fn create_default_buffer_copy_view<'a>(
    &self,
    buffer: &'a Buffer
) -> BufferCopyView<'a>
[src]

Creates a BufferCopyView ready for copying to or from the given buffer where the given buffer is assumed to have the same size as the entirety of this texture.

Methods from Deref<Target = TextureHandle>

pub fn create_view(&self, desc: &TextureViewDescriptor) -> TextureView[src]

Creates a view of this texture.

pub fn create_default_view(&self) -> TextureView[src]

Creates a default view of this whole texture.

Trait Implementations

impl Debug for Texture[src]

impl Deref for Texture[src]

type Target = TextureHandle

The resulting type after dereferencing.

Auto Trait Implementations

impl !RefUnwindSafe for Texture

impl Send for Texture

impl Sync for Texture

impl Unpin for Texture

impl UnwindSafe for Texture

Blanket Implementations

impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S where
    D: AdaptFrom<S, Swp, Dwp, T>,
    Dwp: WhitePoint,
    Swp: WhitePoint,
    T: Component + Float
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T, U> ConvertInto<U> for T where
    U: ConvertFrom<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> SetParameter for T

impl<T> SetParameter for T

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,