Crate nannou_wgpu

Source
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:

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 type T 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§

ActiveAdapter
A single active adapter and its map of connected devices.
Adapter
Handle to a physical graphics and/or compute device.
AdapterInfo
Information about an adapter.
AdapterMap
A map from RequestAdapterOptions to active adapters.
AdapterMapKey
The key into the adapter map.
Backends
Represents the backends that wgpu will use.
BindGroup
Handle to a binding group.
BindGroupBuilder
Simplified creation of a bind group.
BindGroupDescriptor
Describes a group of bindings and the resources to be bound.
BindGroupEntry
An element of a BindGroupDescriptor, consisting of a bindable resource and the slot to bind it to.
BindGroupLayout
Handle to a binding group layout.
BindGroupLayoutBuilder
A type aimed at simplifying the creation of a bind group layout.
BindGroupLayoutDescriptor
Describes a BindGroupLayout.
BindGroupLayoutEntry
Describes a single binding inside a bind group.
BlendComponent
Describes a blend component of a BlendState.
BlendState
Describe the blend state of a render pipeline, within ColorTargetState.
Buffer
Handle to a GPU-accessible buffer.
BufferAsyncError
Error occurred when trying to async map a buffer.
BufferBinding
Describes the segment of a buffer to bind.
BufferInitDescriptor
Describes a Buffer when allocating.
BufferSlice
Slice into a Buffer.
BufferUsages
Different ways that you can use a buffer.
BufferView
Read only view into a mapped buffer.
BufferViewMut
Write only view into mapped buffer.
Color
RGBA double precision color.
ColorTargetState
Describes the color state of a render pipeline.
ColorWrites
Color write mask. Disabled color channels will not be written to.
CommandBuffer
Handle to a command buffer on the GPU.
CommandBufferDescriptor
Describes a CommandBuffer.
CommandEncoder
Encodes a series of GPU operations.
ComputePass
In-progress recording of a compute pass.
ComputePassDescriptor
Describes the attachments of a compute pass.
ComputePipeline
Handle to a compute pipeline.
ComputePipelineDescriptor
Describes a compute pipeline.
DepthBiasState
Describes the biasing setting for the depth target.
DepthStencilState
Describes the depth/stencil state in a render pipeline.
Device
Open connection to a graphics and/or compute device.
DeviceMap
A map of actively connected devices for an adapter.
DeviceMapKey
The key into the device map.
DeviceQueuePair
A handle to a connected logical device and its associated queue.
DownlevelCapabilities
Lists various ways the underlying platform does not conform to the WebGPU standard.
DownlevelFlags
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.
FragmentState
Describes the fragment processing in a render pipeline.
ImageCopyBufferBase
View of a buffer which can be used to copy to/from a texture.
ImageCopyTextureBase
View of a texture which can be used to copy to/from a buffer/texture.
ImageDataLayout
Layout of a texture in a buffer’s memory.
ImageHolder
Workaround for the fact that image::SubImage requires a Deref impl on the wrapped image.
ImageReadMapping
A wrapper around a slice of bytes representing an image.
ImageSubresourceRange
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.
MultisampleState
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.
PipelineLayout
Handle to a pipeline layout.
PipelineLayoutDescriptor
Describes a PipelineLayout.
PipelineStatisticsTypes
Flags for which pipeline data should be recorded.
PrimitiveState
Describes the state of primitive assembly and rasterization in a render pipeline.
PushConstantRange
A range of push constant memory to pass to a shader stage.
QuerySet
Handle to a query set.
Queue
Handle to a command queue on a device.
RenderBundle
Pre-prepared reusable bundle of GPU operations.
RenderBundleDepthStencil
Describes the depth/stencil attachment for render bundles.
RenderBundleEncoder
Encodes a series of GPU operations into a reusable “render bundle”.
RenderBundleEncoderDescriptor
Describes a RenderBundleEncoder.
RenderPass
In-progress recording of a render pass.
RenderPassBuilder
A builder type to simplify the process of creating a render pass descriptor.
RenderPassColorAttachment
Describes a color attachment to a RenderPass.
RenderPassColorAttachmentDescriptorBuilder
A builder type to simplify the process of creating a render pass descriptor.
RenderPassDepthStencilAttachment
Describes a depth/stencil attachment to a RenderPass.
RenderPassDescriptor
Describes the attachments of a render pass.
RenderPipeline
Handle to a rendering (graphics) pipeline.
RenderPipelineBuilder
A builder type to help simplify the construction of a RenderPipeline.
RenderPipelineDescriptor
Describes a render (graphics) pipeline.
RequestAdapterOptionsBase
Options for requesting adapter.
RequestDeviceError
Requesting a device failed.
RowPaddedBuffer
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.
SamplerBuilder
Simplifies the construction of a Sampler with a set of reasonable defaults.
SamplerDescriptor
Describes a Sampler.
ShaderModule
Handle to a compiled shader module.
ShaderModuleDescriptor
Descriptor for use with Device::create_shader_module.
ShaderStages
Describes the shader stages that a binding will be visible from.
StencilFaceState
Describes stencil state in a render pipeline.
StencilState
State of the stencil operation (fixed-pipeline stage).
Surface
Handle to a presentable surface.
SurfaceTexture
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.
TextureBuilder
A type aimed at simplifying the construction of a Texture.
TextureCapturer
A type dedicated to capturing a texture as a non-linear sRGBA image that can be read on the CPU.
TextureCapturerAwaitWorkerTimeout
An error indicating that the threadpool timed out while waiting for a worker to become available.
TextureFormatFeatureFlags
Feature flags for a texture format.
TextureFormatFeatures
Features supported by a given texture format
TextureHandle
Handle to a texture on the GPU.
TextureId
A unique identifier associated with a Texture.
TextureReshaper
Reshapes a texture from its original size, sample_count and format to the destination size, sample_count and format.
TextureSnapshot
A snapshot captured by a Capturer.
TextureUsages
Different ways that you can use a texture.
TextureView
A convenient wrapper around a handle to a texture view along with its descriptor.
TextureViewDescriptor
Describes a TextureView.
TextureViewHandle
Handle to a texture view.
TextureViewId
A unique identifier associated with a TextureView.
VertexAttribute
Vertex inputs (attributes) to shaders.
VertexBufferLayout
Describes how the vertex buffer is interpreted.
VertexState
Describes the vertex processing in a render pipeline.

Enums§

AddressMode
How edges should be handled in texture addressing.
Backend
Backends supported by wgpu.
BindingResource
Resource that can be bound to a pipeline.
BindingType
Specific type of a binding.
BlendFactor
Alpha blend factor.
BlendOperation
Alpha blend operation.
BufferBindingType
Specific type of a buffer binding.
CompareFunction
Comparison function used for depth and stencil operations.
DeviceType
Supported physical device types.
Error
Error type
Face
Face of a vertex.
FilterMode
Texel mixing mode when sampling between texels.
FrontFace
Vertex winding order which classifies the “front” face of a triangle.
IndexFormat
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.
PolygonMode
Type of drawing mode for polygons
PowerPreference
Power Preference when choosing a physical adapter.
PresentMode
Behavior of the presentation engine based on frame rate.
PrimitiveTopology
Primitive type the input mesh is composed of.
QueryType
Type of query contained in a QuerySet.
SamplerBorderColor
Color variation to use when sampler addressing mode is AddressMode::ClampToBorder
ShaderModel
Collections of shader features a device supports if they support less than WebGPU normally allows.
ShaderSource
Source of a shader module.
StencilOperation
Operation to perform on the stencil value.
StorageTextureAccess
Specific type of a sample in a texture binding.
SurfaceError
Result of an unsuccessful call to Surface::get_current_texture.
SurfaceStatus
Status of the recieved surface image.
TextureAspect
Kind of data the texture holds.
TextureDimension
Dimensionality of a texture.
TextureFormat
Underlying texture data format.
TextureSampleType
Specific type of a sample in a texture binding.
TextureViewDimension
Dimensions of a particular texture view.
VertexFormat
Vertex Format for a VertexAttribute (input).
VertexStepMode
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§

ToTextureView
Types that can produce a texture view.
UncapturedErrorHandler
Type for the callback of uncaptured error handler
WithDeviceQueuePair
Types that may provide access to a wgpu::Device and an associated wgpu::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 given wgpu::Extent3ds 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-multisampled dst_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§

BufferAddress
Integral type used for buffer offsets.
BufferDescriptor
Describes a Buffer.
BufferSize
Integral type used for buffer slice sizes.
CommandEncoderDescriptor
Describes a CommandEncoder.
DeviceDescriptor
Describes a Device.
DynamicOffset
Integral type used for dynamic bind group offsets.
ImageCopyBuffer
View of a buffer which can be used to copy to/from a texture.
ImageCopyTexture
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.
QuerySetDescriptor
Describes a QuerySet.
RenderBundleDescriptor
Describes a RenderBundle.
RequestAdapterOptions
Additional information required when requesting an adapter.
ShaderLocation
Integral type used for binding locations in shaders.
SurfaceConfiguration
Describes a Surface.
TextureDescriptor
Describes a Texture.