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:
- An awesome guide for wgpu-rs. Highly recommended reading if you would like to work more closely with the GPU in nannou!
- The wgpu-rs repository.
- The WebGPU specification.
- WebGPU on wikipedia.
Modules§
- blend
- A set of useful descriptors for blending colours!
- bytes
- 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 typeT
may contain padding which is considered to be uninitialised memory in Rust and may potentially lead to undefined behaviour. - util
- Utility structures and functions that are built on top of the main
wgpu
API.
Macros§
- include_
wgsl - Macro to load a WGSL module statically.
- vertex_
attr_ array - Macro to produce an array of
VertexAttribute
.
Structs§
- Active
Adapter - A single active adapter and its map of connected devices.
- Adapter
- Handle to a physical graphics and/or compute device.
- Adapter
Info - Information about an adapter.
- Adapter
Map - A map from
RequestAdapterOptions
to active adapters. - Adapter
MapKey - The key into the adapter map.
- Backends
- Represents the backends that wgpu will use.
- Bind
Group - Handle to a binding group.
- Bind
Group Builder - Simplified creation of a bind group.
- Bind
Group Descriptor - Describes a group of bindings and the resources to be bound.
- Bind
Group Entry - An element of a
BindGroupDescriptor
, consisting of a bindable resource and the slot to bind it to. - Bind
Group Layout - Handle to a binding group layout.
- Bind
Group Layout Builder - A type aimed at simplifying the creation of a bind group layout.
- Bind
Group Layout Descriptor - Describes a
BindGroupLayout
. - Bind
Group Layout Entry - Describes a single binding inside a bind group.
- Blend
Component - Describes a blend component of a
BlendState
. - Blend
State - Describe the blend state of a render pipeline,
within
ColorTargetState
. - Buffer
- Handle to a GPU-accessible buffer.
- Buffer
Async Error - Error occurred when trying to async map a buffer.
- Buffer
Binding - Describes the segment of a buffer to bind.
- Buffer
Init Descriptor - Describes a Buffer when allocating.
- Buffer
Slice - Slice into a
Buffer
. - Buffer
Usages - Different ways that you can use a buffer.
- Buffer
View - Read only view into a mapped buffer.
- Buffer
View Mut - Write only view into mapped buffer.
- Color
- RGBA double precision color.
- Color
Target State - Describes the color state of a render pipeline.
- Color
Writes - Color write mask. Disabled color channels will not be written to.
- Command
Buffer - Handle to a command buffer on the GPU.
- Command
Buffer Descriptor - Describes a
CommandBuffer
. - Command
Encoder - Encodes a series of GPU operations.
- Compute
Pass - In-progress recording of a compute pass.
- Compute
Pass Descriptor - Describes the attachments of a compute pass.
- Compute
Pipeline - Handle to a compute pipeline.
- Compute
Pipeline Descriptor - Describes a compute pipeline.
- Depth
Bias State - Describes the biasing setting for the depth target.
- Depth
Stencil State - Describes the depth/stencil state in a render pipeline.
- Device
- Open connection to a graphics and/or compute device.
- Device
Map - A map of actively connected devices for an adapter.
- Device
MapKey - The key into the device map.
- Device
Queue Pair - A handle to a connected logical device and its associated queue.
- Downlevel
Capabilities - Lists various ways the underlying platform does not conform to the WebGPU standard.
- Downlevel
Flags - Binary flags listing features that may or may not be present on downlevel adapters.
- Extent3d
- Extent of a texture related operation.
- Features
- Features that are not guaranteed to be supported.
- Fragment
State - Describes the fragment processing in a render pipeline.
- Image
Copy Buffer Base - View of a buffer which can be used to copy to/from a texture.
- Image
Copy Texture Base - View of a texture which can be used to copy to/from a buffer/texture.
- Image
Data Layout - Layout of a texture in a buffer’s memory.
- Image
Holder - Workaround for the fact that
image::SubImage
requires aDeref
impl on the wrapped image. - Image
Read Mapping - A wrapper around a slice of bytes representing an image.
- Image
Subresource Range - Subresource range within an image
- Instance
- Context for all other wgpu objects. Instance of wgpu.
- Limits
- Represents the sets of limits an adapter/device supports.
- Multisample
State - Describes the multi-sampling state of a render pipeline.
- Operations
- Pair of load and store operations for an attachment aspect.
- Origin3d
- Origin of a copy to/from a texture.
- Pipeline
Layout - Handle to a pipeline layout.
- Pipeline
Layout Descriptor - Describes a
PipelineLayout
. - Pipeline
Statistics Types - Flags for which pipeline data should be recorded.
- Primitive
State - Describes the state of primitive assembly and rasterization in a render pipeline.
- Push
Constant Range - A range of push constant memory to pass to a shader stage.
- Query
Set - Handle to a query set.
- Queue
- Handle to a command queue on a device.
- Render
Bundle - Pre-prepared reusable bundle of GPU operations.
- Render
Bundle Depth Stencil - Describes the depth/stencil attachment for render bundles.
- Render
Bundle Encoder - Encodes a series of GPU operations into a reusable “render bundle”.
- Render
Bundle Encoder Descriptor - Describes a
RenderBundleEncoder
. - Render
Pass - In-progress recording of a render pass.
- Render
Pass Builder - A builder type to simplify the process of creating a render pass descriptor.
- Render
Pass Color Attachment - Describes a color attachment to a
RenderPass
. - Render
Pass Color Attachment Descriptor Builder - A builder type to simplify the process of creating a render pass descriptor.
- Render
Pass Depth Stencil Attachment - Describes a depth/stencil attachment to a
RenderPass
. - Render
Pass Descriptor - Describes the attachments of a render pass.
- Render
Pipeline - Handle to a rendering (graphics) pipeline.
- Render
Pipeline Builder - A builder type to help simplify the construction of a RenderPipeline.
- Render
Pipeline Descriptor - Describes a render (graphics) pipeline.
- Request
Adapter Options Base - Options for requesting adapter.
- Request
Device Error - Requesting a device failed.
- RowPadded
Buffer - 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.
- Sampler
- Handle to a sampler.
- Sampler
Builder - Simplifies the construction of a
Sampler
with a set of reasonable defaults. - Sampler
Descriptor - Describes a
Sampler
. - Shader
Module - Handle to a compiled shader module.
- Shader
Module Descriptor - Descriptor for use with
Device::create_shader_module
. - Shader
Stages - Describes the shader stages that a binding will be visible from.
- Stencil
Face State - Describes stencil state in a render pipeline.
- Stencil
State - State of the stencil operation (fixed-pipeline stage).
- Surface
- Handle to a presentable surface.
- Surface
Texture - Surface texture that can be rendered to.
Result of a successful call to
Surface::get_current_texture
. - Texture
- A convenient wrapper around a handle to a texture on the GPU along with its descriptor.
- Texture
Builder - A type aimed at simplifying the construction of a Texture.
- Texture
Capturer - A type dedicated to capturing a texture as a non-linear sRGBA image that can be read on the CPU.
- Texture
Capturer Await Worker Timeout - An error indicating that the threadpool timed out while waiting for a worker to become available.
- Texture
Format Feature Flags - Feature flags for a texture format.
- Texture
Format Features - Features supported by a given texture format
- Texture
Handle - Handle to a texture on the GPU.
- Texture
Id - A unique identifier associated with a Texture.
- Texture
Reshaper - Reshapes a texture from its original size, sample_count and format to the destination size, sample_count and format.
- Texture
Snapshot - A snapshot captured by a Capturer.
- Texture
Usages - Different ways that you can use a texture.
- Texture
View - A convenient wrapper around a handle to a texture view along with its descriptor.
- Texture
View Descriptor - Describes a
TextureView
. - Texture
View Handle - Handle to a texture view.
- Texture
View Id - A unique identifier associated with a TextureView.
- Vertex
Attribute - Vertex inputs (attributes) to shaders.
- Vertex
Buffer Layout - Describes how the vertex buffer is interpreted.
- Vertex
State - Describes the vertex processing in a render pipeline.
Enums§
- Address
Mode - How edges should be handled in texture addressing.
- Backend
- Backends supported by wgpu.
- Binding
Resource - Resource that can be bound to a pipeline.
- Binding
Type - Specific type of a binding.
- Blend
Factor - Alpha blend factor.
- Blend
Operation - Alpha blend operation.
- Buffer
Binding Type - Specific type of a buffer binding.
- Compare
Function - Comparison function used for depth and stencil operations.
- Device
Type - Supported physical device types.
- Error
- Error type
- Face
- Face of a vertex.
- Filter
Mode - Texel mixing mode when sampling between texels.
- Front
Face - Vertex winding order which classifies the “front” face of a triangle.
- Index
Format - Format of indices used with pipeline.
- LoadOp
- Operation to perform to the output attachment at the start of a render pass.
- MapMode
- Type of buffer mapping.
- Polygon
Mode - Type of drawing mode for polygons
- Power
Preference - Power Preference when choosing a physical adapter.
- Present
Mode - Behavior of the presentation engine based on frame rate.
- Primitive
Topology - Primitive type the input mesh is composed of.
- Query
Type - Type of query contained in a QuerySet.
- Sampler
Border Color - Color variation to use when sampler addressing mode is
AddressMode::ClampToBorder
- Shader
Model - Collections of shader features a device supports if they support less than WebGPU normally allows.
- Shader
Source - Source of a shader module.
- Stencil
Operation - Operation to perform on the stencil value.
- Storage
Texture Access - Specific type of a sample in a texture binding.
- Surface
Error - Result of an unsuccessful call to
Surface::get_current_texture
. - Surface
Status - Status of the recieved surface image.
- Texture
Aspect - Kind of data the texture holds.
- Texture
Dimension - Dimensionality of a texture.
- Texture
Format - Underlying texture data format.
- Texture
Sample Type - Specific type of a sample in a texture binding.
- Texture
View Dimension - Dimensions of a particular texture view.
- Vertex
Format - Vertex Format for a
VertexAttribute
(input). - Vertex
Step Mode - Whether a vertex buffer is indexed by vertex or by instance.
Constants§
- COPY_
BUFFER_ ALIGNMENT - Buffer to buffer copy as well as buffer clear offsets and sizes must be aligned to this number.
- COPY_
BYTES_ PER_ ROW_ ALIGNMENT - Buffer-Texture copies must have
bytes_per_row
aligned to this number. - DEFAULT_
BACKENDS - Nannou’s default WGPU backend preferences.
- DEFAULT_
POWER_ PREFERENCE - The default power preference used for requesting the WGPU adapter.
- MAP_
ALIGNMENT - Size to align mappings.
- PUSH_
CONSTANT_ ALIGNMENT - Alignment all push constants need
- QUERY_
RESOLVE_ BUFFER_ ALIGNMENT - An offset into the query resolve buffer has to be aligned to this.
- QUERY_
SET_ MAX_ QUERIES - Maximum queries in a query set
- QUERY_
SIZE - Size of a single piece of query data.
- VERTEX_
STRIDE_ ALIGNMENT - Vertex buffer strides have to be aligned to this number.
Traits§
- ToTexture
View - Types that can produce a texture view.
- Uncaptured
Error Handler - Type for the callback of uncaptured error handler
- With
Device Queue Pair - Types that may provide access to a
wgpu::Device
and an associatedwgpu::Queue
for loading a texture from an image.
Functions§
- clear_
texture - Adds a simple render pass command to the given encoder that simply clears the given texture with the given colour.
- compute_
row_ padding - 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.
- create_
pipeline_ layout - Shorthand for creating the pipeline layout from a slice of bind group layouts.
- default_
device_ descriptor - The default device descriptor used to instantiate a logical device when creating windows.
- extent_
3d_ eq - Returns
true
if the givenwgpu::Extent3d
s are equal. - resolve_
texture - Adds a simple render pass command to the given encoder that resolves the given multisampled
src_texture
to the given non-multisampleddst_texture
. - sampler_
filtering - Whether or not the sampler descriptor describes a sampler that might perform linear filtering.
- shader_
from_ spirv_ bytes - Create a wgpu shader module from the given slice of SPIR-V bytes.
- texture_
descriptor_ eq - Returns
true
if the given texture descriptors are equal. - texture_
format_ from_ image_ color_ type - Convert the given color type from the
image
crate to the corresponding wgpu texture format. - texture_
format_ size_ bytes - Return the size of the given texture format in bytes.
Type Aliases§
- Buffer
Address - Integral type used for buffer offsets.
- Buffer
Descriptor - Describes a
Buffer
. - Buffer
Size - Integral type used for buffer slice sizes.
- Command
Encoder Descriptor - Describes a
CommandEncoder
. - Device
Descriptor - Describes a
Device
. - Dynamic
Offset - Integral type used for dynamic bind group offsets.
- Image
Copy Buffer - View of a buffer which can be used to copy to/from a texture.
- Image
Copy Texture - View of a texture which can be used to copy to/from a buffer/texture.
- Label
- Object debugging label.
- Maintain
- Passed to
Device::poll
to control how and if it should block. - Query
SetDescriptor - Describes a
QuerySet
. - Render
Bundle Descriptor - Describes a
RenderBundle
. - Request
Adapter Options - Additional information required when requesting an adapter.
- Shader
Location - Integral type used for binding locations in shaders.
- Surface
Configuration - Describes a
Surface
. - Texture
Descriptor - Describes a
Texture
.