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

  • 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 that are built on top of the main wgpu API.

Macros

Structs

Enums

Constants

Traits

Functions

  • 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 Aliases