Skip to main content

Crate nannou_wgpu

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§

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
Load WGSL source code from a file at compile time.
vertex_attr_array
Macro to produce an array of [VertexAttribute].

Structs§

Adapter
Handle to a physical graphics and/or compute device.
AdapterInfo
Information about an adapter.
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
A slice of a Buffer, to be mapped, used for vertex or index data, or the like.
BufferUsages
Different ways that you can use a buffer.
BufferView
A read-only view of a mapped buffer’s bytes.
BufferViewMut
A write-only view of a mapped buffer’s bytes.
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.
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.
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
Contains the various entry points to start interacting with the system’s GPUs.
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 in a query.
PrimitiveState
Describes the state of primitive assembly and rasterization in a render pipeline.
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: a list of render commands in a CommandEncoder.
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 from an Adapter 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.
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.
TexelCopyBufferLayout
Layout of a texture in a buffer’s memory.
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.
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.
TextureUsages
Different ways that you can use a texture.
TextureView
A convenient wrapper around a handle to a texture view along with its descriptor.
TextureViewHandle
Handle to a texture view.
TextureViewId
A unique identifier associated with a TextureView.
VertexAttribute
Vertex inputs (attributes) to shaders.
VertexBufferLayout
Specifies an interpretation of the bytes of a vertex buffer as vertex attributes.
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 to be bound by a BindGroup for use with a pipeline.
BindingType
Type of a binding in a bind group layout.
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
Errors resulting from usage of GPU APIs.
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.
MipmapFilterMode
Texel mixing mode when sampling between texels.
PolygonMode
Type of drawing mode for polygons
PowerPreference
Power Preference when choosing a physical adapter.
PresentMode
Timing and queueing with which frames are actually displayed to the user.
PrimitiveTopology
Primitive type the input mesh is composed of.
QueryType
Type of queries 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.
SurfaceStatus
Status of the received surface image.
TextureAspect
Selects a subset of the data a Texture holds.
TextureDimension
Dimensionality of a texture.
TextureFormat
Format in which a texture’s texels are stored in GPU memory.
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
Minimum alignment of buffer mappings.
QUERY_RESOLVE_BUFFER_ALIGNMENT
An offset into the query resolve buffer has to be aligned to this.
QUERY_SET_MAX_QUERIES
Maximum number of query result slots that can be requested in a QuerySetDescriptor.
QUERY_SIZE
Size in bytes of a single piece of query data.
VERTEX_ALIGNMENT
Vertex buffer offsets and strides have to be a multiple of this number.

Traits§

ToTextureView
Types that can produce a texture view.
UncapturedErrorHandler
The callback of Device::on_uncaptured_error().
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 and sizes.
BufferDescriptor
Describes a Buffer.
BufferSize
Integral type used for BufferSlice sizes.
CommandEncoderDescriptor
Describes a CommandEncoder.
DeviceDescriptor
Describes a Device.
DynamicOffset
Integral type used for dynamic bind group offsets.
Label
Object debugging label.
PollType
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.
SamplerDescriptor
Describes a Sampler.
ShaderLocation
Integral type used for binding locations in shaders.
SurfaceConfiguration
Describes a Surface.
TexelCopyBufferInfo
View of a buffer which can be used to copy to/from a texture.
TexelCopyTextureInfo
View of a texture which can be used to copy to/from a buffer/texture.
TextureDescriptor
Describes a Texture.
TextureViewDescriptor
Describes a TextureView.