Crate nannou_wgpu[][src]

Expand description

Items related to wgpu and its integration in nannou!

WebGPU is the portable graphics specification that nannou targets allowing us to write code that is both fast and allows us to target a wide range of platforms. wgpu is the name of the crate we use that implements this specification.

This crate re-exports the entire wgpu crate along with all of its documentation while also adding some additional items that makes wgpu easier to use alongside nannou.

The image feature enables easier interoperation with the image crate, including functions for uploading textures from image files.

The capturer feature provides the wgpu::TextureCapturer API that aims to simplify the process of downloading textures from the GPU and easily save them as image files. As an example, this is particularly useful for recording the contents of a window or sketch.

Note that when using nannou_wgpu via nannou::wgpu, both features are enabled by default.

Useful links:


A set of useful descriptors for blending colours!

The functions within this module use unsafe in order to retrieve their input as a slice of bytes. This is necessary in order to upload data to the GPU via the wgpu DeviceExt::create_buffer_init buffer constructor. This method is unsafe as the type T may contain padding which is considered to be uninitialised memory in Rust and may potentially lead to undefined behaviour.

Utility structures and functions.


Macro to load a WGSL module statically.

Macro to produce an array of VertexAttribute.


A single active adapter and its map of connected devices.

Handle to a physical graphics and/or compute device.

Information about an adapter.

A map from RequestAdapterOptions to active adapters.

The key into the adapter map.

Represents the backends that wgpu will use.

Handle to a binding group.

Simplified creation of a bind group.

Describes a group of bindings and the resources to be bound.

Bindable resource and the slot to bind it to.

Handle to a binding group layout.

A type aimed at simplifying the creation of a bind group layout.

Describes a single binding inside a bind group.

Describes the blend component of a pipeline.

Describe the blend state of a render pipeline.

Handle to a GPU-accessible buffer.

Error occurred when trying to async map a buffer.

Describes the segment of a buffer to bind.

Describes a Buffer when allocating.

Slice into a Buffer.

Different ways that you can use a buffer.

Read only view into a mapped buffer.

Write only view into mapped buffer.

RGBA double precision color.

Describes the color state of a render pipeline.

Color write mask. Disabled color channels will not be written to.

Handle to a command buffer on the GPU.

Describes a [CommandBuffer].

Encodes a series of GPU operations.

In-progress recording of a compute pass.

Describes the attachments of a compute pass.

Handle to a compute pipeline.

Describes a compute pipeline.

Describes the biasing setting for the depth target.

Describes the depth/stencil state in a render pipeline.

Open connection to a graphics and/or compute device.

A map of actively connected devices for an adapter.

The key into the device map.

A handle to a connected logical device and its associated queue.

Lists various ways the underlying platform does not conform to the WebGPU standard.

Binary flags listing features that may or may not be present on downlevel adapters.

Extent of a texture related operation.

Features that are not guaranteed to be supported.

Describes the fragment process in a render pipeline.

View of a buffer which can be used to copy to/from a texture.

View of a texture which can be used to copy to/from a buffer/texture.

Layout of a texture in a buffer’s memory.

Workaround for the fact that image::SubImage requires a Deref impl on the wrapped image.

A wrapper around a slice of bytes representing an image.

Subresource range within an image

Context for all other wgpu objects. Instance of wgpu.

Represents the sets of limits an adapter/device supports.

Describes the multi-sampling state of a render pipeline.

Pair of load and store operations for an attachment aspect.

Origin of a copy to/from a texture.

Handle to a pipeline layout.

Describes a pipeline layout.

Flags for which pipeline data should be recorded.

Describes the state of primitive assembly and rasterization in a render pipeline.

A range of push constant memory to pass to a shader stage.

Handle to a query set.

Handle to a command queue on a device.

Pre-prepared reusable bundle of GPU operations.

Describes the depth/stencil attachment for render bundles.

Encodes a series of GPU operations into a reusable “render bundle”.

In-progress recording of a render pass.

A builder type to simplify the process of creating a render pass descriptor.

Describes a color attachment to a RenderPass.

A builder type to simplify the process of creating a render pass descriptor.

Describes a depth/stencil attachment to a RenderPass.

Describes the attachments of a render pass.

Handle to a rendering (graphics) pipeline.

A builder type to help simplify the construction of a RenderPipeline.

Describes a render (graphics) pipeline.

Options for requesting adapter.

Requesting a device failed.

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.

Handle to a sampler.

Simplifies the construction of a Sampler with a set of reasonable defaults.

Handle to a compiled shader module.

Descriptor for a shader module.

Describes the shader stages that a binding will be visible from.

Describes stencil state in a render pipeline.

State of the stencil operation (fixed-pipeline stage).

Handle to a presentable surface.

Configures a [Surface] for presentation.

Surface texture that can be rendered to. Result of a successful call to Surface::get_current_texture.

A snapshot captured by a Capturer.

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

A type aimed at simplifying the construction of a Texture.

A type dedicated to capturing a texture as a non-linear sRGBA image that can be read on the CPU.

An error indicating that the threadpool timed out while waiting for a worker to become available.

Feature flags for a texture format.

Features supported by a given texture format

Handle to a texture on the GPU.

A unique identifier associated with a Texture.

Reshapes a texture from its original size, sample_count and format to the destination size, sample_count and format.

Different ways that you can use a texture.

A convenient wrapper around a handle to a texture view along with its descriptor.

Handle to a texture view.

A unique identifier associated with a TextureView.

Vertex inputs (attributes) to shaders.

Describes how the vertex buffer is interpreted.

Describes the vertex process in a render pipeline.


How edges should be handled in texture addressing.

Backends supported by wgpu.

Resource that can be bound to a pipeline.

Specific type of a binding.

Alpha blend factor.

Alpha blend operation.

Specific type of a buffer binding.

Comparison function used for depth and stencil operations.

Supported physical device types.

Error type

Face of a vertex.

Texel mixing mode when sampling between texels.

Winding order which classifies the “front” face.

Format of indices used with pipeline.

Operation to perform to the output attachment at the start of a renderpass.

Passed to Device::poll to control if it should block or not. This has no effect on the web.

Type of buffer mapping.

Type of drawing mode for polygons

Power Preference when choosing a physical adapter.

Behavior of the presentation engine based on frame rate.

Primitive type the input mesh is composed of.

Type of query contained in a QuerySet.

Color variation to use when sampler addressing mode is AddressMode::ClampToBorder

Collections of shader features a device supports if they support less than WebGPU normally allows.

Source of a shader module.

Operation to perform on the stencil value.

Specific type of a sample in a texture binding.

Result of an unsuccessful call to Surface::get_current_texture.

Status of the recieved surface image.

Kind of data the texture holds.

Dimensionality of a texture.

Underlying texture data format.

Specific type of a sample in a texture binding.

Dimensions of a particular texture view.

Vertex Format for a Vertex Attribute (input).

Rate that determines when vertex data is advanced.


Buffer to buffer copy as well as buffer clear offsets and sizes must be aligned to this number.

Buffer-Texture copies must have bytes_per_row aligned to this number.

Nannou’s default WGPU backend preferences.

The default power preference used for requesting the WGPU adapter.

Size to align mappings.

Alignment all push constants need

An offset into the query resolve buffer has to be aligned to this.

Maximum queries in a query set

Size of a single piece of query data.

Vertex buffer strides have to be aligned to this number.


Types that can produce a texture view.

Type for the callback of uncaptured error handler

Types that may provide access to a wgpu::Device and an associated wgpu::Queue for loading a texture from an image.


Adds a simple render pass command to the given encoder that simply clears the given texture with the given colour.

Given the initial number of bytes per row within an image, compute the number of bytes that must be added per row to produce a valid bytes per row alignment.

Shorthand for creating the pipeline layout from a slice of bind group layouts.

The default device descriptor used to instantiate a logical device when creating windows.

Returns true if the given wgpu::Extent3ds are equal.

Adds a simple render pass command to the given encoder that resolves the given multisampled src_texture to the given non-multisampled dst_texture.

Whether or not the sampler descriptor describes a sampler that might perform linear filtering.

Create a wgpu shader module from the given slice of SPIR-V bytes.

Returns true if the given texture descriptors are equal.

Convert the given color type from the image crate to the corresponding wgpu texture format.

Return the size of the given texture format in bytes.

Type Definitions

Integral type used for buffer offsets.

Integral type used for buffer slice sizes.

Integral type used for dynamic bind group offsets.

View of a buffer which can be used to copy to/from a texture.

View of a texture which can be used to copy to/from a buffer/texture.

Object label.

Additional information required when requesting an adapter.

Integral type used for binding locations in shaders.