Expand description
flow-ngin
A lightweight, cross-platform instancing-oriented game engine focused on native and WASM compatibility. This crate exposes a small surface for constructing GPU resources, rendering pipelines and scene data. The design emphasizes reuse of pipelines, efficient instancing and a minimal runtime surface suitable for embedding in native applications or the web.
High-level modules
camera: camera types, controller and uniforms for view/projectioncontext: central GPU and window context that owns device/queue/pipelinesdata_structures: engine data models (meshes, instances, textures)flow: high level flow control (scenes / update loops)pick: object picking utilities and shaderspipelines: definitions for various render pipelines (basic, light, gui)resources: helpers to load textures/models and create GPU resourcesrender: render composition for efficient pipeline reuse
Modules§
- camera
- context
- conv
- Constrained conversion functions for assisting in situations where type inference is difficult.
- data_
structures - Engine data structures: models, textures, scene graphs, and instances.
- flow
- Flow control and application event loop.
- hal
- A cross-platform unsafe graphics abstraction.
- num_
traits - Numeric traits for generic mathematics
- pick
- Object picking and selection.
- pipelines
- prelude
- This module contains the most common traits used in
cgmath. By glob-importing this module, you can avoid the need to import each trait individually, while still being selective about what types you import. - render
- Render composition and pipeline batching.
- resources
- rwh
- Interoperability library for Rust Windowing applications.
- util
- Utility structures and functions that are built on top of the main
wgpuAPI. - wgc
- This library safely implements WebGPU on native platforms. It is designed for integration into browsers, as well as wrapping into other language-specific user-friendly libraries.
- wgt
- This library describes the API surface of WebGPU that is agnostic of the backend. This API is used for targeting both Web and Native.
Macros§
- abs_
diff_ eq - Approximate equality of using the absolute difference.
- abs_
diff_ ne - Approximate inequality of using the absolute difference.
- assert_
abs_ diff_ eq - An assertion that delegates to
abs_diff_eq!, and panics with a helpful error on failure. - assert_
abs_ diff_ ne - An assertion that delegates to
abs_diff_ne!, and panics with a helpful error on failure. - assert_
relative_ eq - An assertion that delegates to
relative_eq!, and panics with a helpful error on failure. - assert_
relative_ ne - An assertion that delegates to
relative_ne!, and panics with a helpful error on failure. - assert_
ulps_ eq - An assertion that delegates to
ulps_eq!, and panics with a helpful error on failure. - assert_
ulps_ ne - An assertion that delegates to
ulps_ne!, and panics with a helpful error on failure. - include_
spirv_ raw - Macro to load raw SPIR-V data statically, for use with
Features::EXPERIMENTAL_PASSTHROUGH_SHADERS. - include_
wgsl - Load WGSL source code from a file at compile time.
- relative_
eq - Approximate equality using both the absolute difference and relative based comparisons.
- relative_
ne - Approximate inequality using both the absolute difference and relative based comparisons.
- ulps_eq
- Approximate equality using both the absolute difference and ULPs (Units in Last Place).
- ulps_ne
- Approximate inequality using both the absolute difference and ULPs (Units in Last Place).
- vertex_
attr_ array - Macro to produce an array of [
VertexAttribute].
Structs§
- AbsDiff
- The requisite parameters for testing for approximate equality using a absolute difference based comparison.
- Adapter
- Handle to a physical graphics and/or compute device.
- Adapter
Info - Information about an adapter.
- Allocator
Report - A report that can be generated for informational purposes using
Allocator::generate_report(). - Backend
Options - Options that are passed to a given backend.
- Backends
- Represents the backends that wgpu will use.
- Basis2
- A two-dimensional rotation matrix.
- Basis3
- A three-dimensional rotation matrix.
- Bind
Group - Handle to a binding 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 Descriptor - Describes a
BindGroupLayout. - Bind
Group Layout Entry - Describes a single binding inside a bind group.
- Blas
- Bottom Level Acceleration Structure (BLAS).
- Blas
Async Error - Error occurred when trying to asynchronously prepare a blas for compaction.
- Blas
Build Entry - Builds the given sets of geometry into the given Blas.
- Blas
Triangle Geometry - Definition for a triangle geometry for a Bottom Level Acceleration Structure (BLAS).
- 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
Slice - A slice of a
Buffer, to be mapped, used for vertex or index data, or the like. - Buffer
Texture Copy Info - Information about a copy between a buffer and a texture.
- Buffer
Transition - A buffer transition for use with
CommandEncoder::transition_resources. - Buffer
Usages - Different ways that you can use a buffer.
- Buffer
Uses - Similar to
BufferUsages, but used only forCommandEncoder::transition_resources. - Buffer
View - A read-only view of a mapped buffer’s bytes.
- Buffer
View Mut - A write-only view of a mapped buffer’s bytes.
- 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.
- Compilation
Info - Compilation information for a shader module.
- Compilation
Message - A single message from the shader compilation process.
- Compute
Pass - In-progress recording of a compute pass.
- Compute
Pass Descriptor - Describes the attachments of a compute pass.
- Compute
Pass Timestamp Writes - Describes the timestamp writes of a compute pass.
- Compute
Pipeline - Handle to a compute pipeline.
- Compute
Pipeline Descriptor - Describes a compute pipeline.
- Context
Blas Build Entry - Context version see BlasBuildEntry.
- Context
Blas Triangle Geometry - Context version of BlasTriangleGeometry.
- Copy
External Image Dest Info - View of a texture which can be used to copy to a texture, including color space and alpha premultiplication information.
- Core
Counters wgpu-core’s part ofInternalCounters.- Create
Surface Error Instance::create_surface()or a related function failed.- Decomposed
- A generic transformation consisting of a rotation, displacement vector and scale amount.
- Deg
- An angle, in degrees.
- 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.
- 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.
- Downlevel
Limits - Represents the sets of additional limits on an adapter, which take place when running on downlevel backends.
- Dx12
Backend Options - Configuration for the DX12 backend.
- Error
Scope Guard - Guard for an error scope pushed with
Device::push_error_scope(). - Euler
- A set of Euler angles representing a rotation in three-dimensional space.
- Experimental
Features - Token of the user agreeing to access experimental features.
- Extent3d
- Extent of a texture related operation.
- External
Texture - Handle to an external texture on the GPU.
- External
Texture Transfer Function - Parameters describing a gamma encoding transfer function in the form tf = { k * linear | linear < b { a * pow(linear, 1/g) - (a-1) | linear >= b
- Features
- Features that are not guaranteed to be supported.
- FeaturesWGPU
- Features that are not guaranteed to be supported.
- Features
WebGPU - Features that are not guaranteed to be supported.
- Fragment
State - Describes the fragment processing in a render pipeline.
- GlBackend
Options - Configuration for the OpenGL/OpenGLES backend.
- HalCounters
wgpu-hal’s part ofInternalCounters.- Image
Subresource Range - Subresource range within an image
- Instance
- Contains the various entry points to start interacting with the system’s GPUs.
- Instance
Descriptor - Options for creating an instance.
- Instance
Flags - Instance debugging flags.
- Internal
Counters - All internal counters, exposed for debugging purposes.
- Limits
- Represents the sets of limits an adapter/device supports.
- Load
OpDont Care - Token of the user agreeing to use
LoadOp::DontCare. - Matrix2
- A 2 x 2, column major matrix
- Matrix3
- A 3 x 3, column major matrix
- Matrix4
- A 4 x 4, column major matrix
- Memory
Budget Thresholds - Memory budget thresholds used by backends to try to avoid high memory pressure situations.
- Mesh
Pipeline Descriptor - Describes a mesh shader (graphics) pipeline.
- Mesh
State - Describes the mesh shader stage in a mesh shader pipeline.
- Multisample
State - Describes the multi-sampling state of a render pipeline.
- Noop
Backend Options - Configuration for the noop backend.
- Operations
- Pair of load and store operations for an attachment aspect.
- Origin2d
- Origin of a copy from a 2D image.
- Origin3d
- Origin of a copy to/from a texture.
- Ortho
- An orthographic projection with arbitrary left/right/bottom/top distances
- Perspective
- A perspective projection with arbitrary left/right/bottom/top distances
- Perspective
Fov - A perspective projection based on a vertical field-of-view angle.
- Physical
Position - A position represented in physical pixels.
- Pipeline
Cache - Handle to a pipeline cache, which is used to accelerate
creating
RenderPipelines andComputePipelines in subsequent executions - Pipeline
Cache Descriptor - Describes a pipeline cache, which allows reusing compilation work between program runs.
- Pipeline
Compilation Options - Advanced options for use when a pipeline is compiled
- Pipeline
Layout - Handle to a pipeline layout.
- Pipeline
Layout Descriptor - Describes a
PipelineLayout. - Pipeline
Statistics Types - Flags for which pipeline data should be recorded in a query.
- Point1
- A point in 1-dimensional space.
- Point2
- A point in 2-dimensional space.
- Point3
- A point in 3-dimensional space.
- Presentation
Timestamp - Nanosecond timestamp used by the presentation engine.
- Primitive
State - Describes the state of primitive assembly and rasterization in a render pipeline.
- Quaternion
- A quaternion in scalar/vector form.
- Query
Set - Handle to a query set.
- Queue
- Handle to a command queue on a device.
- Queue
Write Buffer View - A write-only view into a staging buffer.
- Rad
- An angle, in radians.
- Relative
- The requisite parameters for testing for approximate equality using a relative based comparison.
- 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: a list of render commands in a
CommandEncoder. - Render
Pass Color Attachment - Describes a color attachment to a
RenderPass. - Render
Pass Depth Stencil Attachment - Describes a depth/stencil attachment to a
RenderPass. - Render
Pass Descriptor - Describes the attachments of a render pass.
- Render
Pass Timestamp Writes - Describes the timestamp writes of a render pass.
- Render
Pipeline - Handle to a rendering (graphics) pipeline.
- Render
Pipeline Descriptor - Describes a render (graphics) pipeline.
- Request
Adapter Options Base - Options for requesting adapter.
- Request
Device Error - Requesting a device from an
Adapterfailed. - Sampler
- Handle to a sampler.
- Shader
Module - Handle to a compiled shader module.
- Shader
Module Descriptor - Descriptor for use with
Device::create_shader_module. - Shader
Runtime Checks - Describes how shader bound checks should be performed.
- Shader
Stages - Describes the shader stages that a binding will be visible from.
- Source
Location - A human-readable representation for a span, tailored for text source.
- Stencil
Face State - Describes stencil state in a render pipeline.
- Stencil
State - State of the stencil operation (fixed-pipeline stage).
- Submission
Index - Identifier for a particular call to
Queue::submit. Can be used as part of an argument toDevice::pollto block for a particular submission to finish. - Surface
- Handle to a presentable surface.
- Surface
Capabilities - Defines the capabilities of a given surface and adapter.
- Surface
Texture - Surface texture that can be rendered to.
Result of a successful call to
Surface::get_current_texture. - Task
State - Describes the task shader stage in a mesh shader pipeline.
- Texel
Copy Buffer Info Base - View of a buffer which can be used to copy to/from a texture.
- Texel
Copy Buffer Layout - Layout of a texture in a buffer’s memory.
- Texel
Copy Texture Info Base - View of a texture which can be used to copy to/from a buffer/texture.
- Texture
- Handle to a texture on the GPU.
- Texture
Format Feature Flags - Feature flags for a texture format.
- Texture
Format Features - Features supported by a given texture format
- Texture
Transition - A texture transition for use with
CommandEncoder::transition_resources. - Texture
Usages - Different ways that you can use a texture.
- Texture
Uses - Similar to
TextureUsages, but used only forCommandEncoder::transition_resources. - Texture
View - Handle to a texture view.
- Tlas
- Top Level Acceleration Structure (TLAS).
- Tlas
Instance - Safe instance for a Tlas.
- Ulps
- The requisite parameters for testing for approximate equality using an ULPs based comparison.
- Vector1
- A 1-dimensional vector.
- Vector2
- A 2-dimensional vector.
- Vector3
- A 3-dimensional vector.
- Vector4
- A 4-dimensional vector.
- Vertex
Attribute - Vertex inputs (attributes) to shaders.
- Vertex
Buffer Layout - Specifies an interpretation of the bytes of a vertex buffer as vertex attributes.
- Vertex
State - Describes the vertex processing in a render pipeline.
- Wgsl
Language Features - WGSL language extensions.
Enums§
- Address
Mode - How edges should be handled in texture addressing.
- Astc
Block - ASTC block dimensions
- Astc
Channel - ASTC RGBA channel
- Backend
- Backends supported by wgpu.
- Binding
Resource - Resource to be bound by a
BindGroupfor use with a pipeline. - Binding
Type - Type of a binding in a bind group layout.
- Blas
Geometries - Contains the sets of geometry that go into a Blas.
- 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.
- Compilation
Message Type - The type of a compilation message.
- Composite
Alpha Mode - Specifies how the alpha channel of the textures should be handled during compositing.
- Context
Blas Geometries - Context version of BlasGeometries.
- Device
Event - Represents raw hardware events that are not associated with any particular window.
- Device
Lost Reason - Corresponds to a
GPUDeviceLostReason. - Device
Type - Supported physical device types.
- Dx12
Compiler - Selects which DX12 shader compiler to use.
- Dx12
Swapchain Kind - Selects which kind of swapchain to use on DX12.
- Dx12
UseFrame Latency Waitable Object - Whether and how to use a waitable handle obtained from
GetFrameLatencyWaitableObject. - DxcShader
Model - DXC shader model.
- Error
- Errors resulting from usage of GPU APIs.
- Error
Filter - Kinds of
Errors aDevice::push_error_scope()may be configured to catch. - External
Texture Format - Format of an
ExternalTexture. This indicates the number of underlying planes used by theExternalTextureas well as each plane’s format. - 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.
- GlFence
Behavior - Dictate the behavior of fences in OpenGL.
- Gles3
Minor Version - Selects which OpenGL ES 3 minor version to request.
- 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.
- Memory
Hints - Hints to the device about the memory allocation strategy.
- Mipmap
Filter Mode - Texel mixing mode when sampling between texels.
- Poll
Error - Error states after a device poll.
- Poll
Status - Status of device poll operation.
- Polygon
Mode - Type of drawing mode for polygons
- Power
Preference - Power Preference when choosing a physical adapter.
- Predefined
Color Space - Color spaces supported on the web.
- Present
Mode - Timing and queueing with which frames are actually displayed to the user.
- Primitive
Topology - Primitive type the input mesh is composed of.
- Query
Type - Type of query contained in a
QuerySet. - Request
Adapter Error - Error when
Instance::request_adapter()fails. - Sampler
Binding Type - Specific type of a sampler binding.
- 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.
- StoreOp
- Operation to perform to the output attachment at the end of a render pass.
- Surface
Error - Result of an unsuccessful call to
Surface::get_current_texture. - Surface
Status - Status of the received surface image.
- Surface
Target - The window/canvas/surface/swap-chain/etc. a surface is attached to, for use with safe surface creation.
- Surface
Target Unsafe - The window/canvas/surface/swap-chain/etc. a surface is attached to, for use with unsafe surface creation.
- Texture
Aspect - Selects a subset of the data a
Textureholds. - Texture
Dimension - Dimensionality of a texture.
- Texture
Format - Format in which a texture’s texels are stored in GPU memory.
- Texture
Sample Type - Specific type of a sample in a texture binding.
- Texture
View Dimension - Dimensions of a particular texture view.
- Trace
- Controls API call tracing and specifies where the trace is written.
- Vertex
Format - Vertex Format for a
VertexAttribute(input). - Vertex
Step Mode - Whether a vertex buffer is indexed by vertex or by instance.
- Window
Event - Describes an event from a [
Window].
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_rowaligned to this number. - IMMEDIATE_
DATA_ ALIGNMENT - Ranges of writes to immediate data must be at least this aligned.
- MAP_
ALIGNMENT - Minimum alignment of buffer mappings.
- MAXIMUM_
SUBGROUP_ MAX_ SIZE - The maximum allowed value for
AdapterInfo::subgroup_max_size. - MINIMUM_
SUBGROUP_ MIN_ SIZE - The minimum allowed value for
AdapterInfo::subgroup_min_size. - 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
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.
- VERTEX_
STRIDE_ ALIGNMENT Deprecated - Vertex buffer strides have to be a multiple of this number.
Traits§
- AbsDiff
Eq - Equality that is defined using the absolute difference of two numbers.
- Angle
- Angles and their associated trigonometric functions.
- Array
- An array containing elements of type
Element - Base
Float - Base floating point types
- BaseNum
- Base numeric types with partial ordering
- Bounded
- Numbers which have upper and lower bounds
- Element
Wise - Element-wise arithmetic operations. These are supplied for pragmatic reasons, but will usually fall outside of traditional algebraic properties.
- Euclidean
Space - Points in a Euclidean space with an associated space of displacement vectors.
- Inner
Space - Vectors that also have a dot (or inner) product.
- Matrix
- A column-major matrix of arbitrary dimensions.
- Metric
Space - A type with a distance function between values.
- One
- Defines a multiplicative identity element for
Self. - Relative
Eq - Equality comparisons between two numbers using both the absolute difference and relative based comparisons.
- Rotation
- A trait for a generic rotation. A rotation is a transformation that creates a circular motion, and preserves at least one point in the space.
- Rotation2
- A two-dimensional rotation.
- Rotation3
- A three-dimensional rotation.
- Square
Matrix - A column-major major matrix where the rows and column vectors are of the same dimensions.
- Transform
- A trait representing an affine transformation that can be applied to points or vectors. An affine transformation is one which
- Transform2
- Transform3
- UlpsEq
- Equality comparisons between two numbers using both the absolute difference and ULPs (Units in Last Place) based comparisons.
- Uncaptured
Error Handler - The callback of
Device::on_uncaptured_error(). - Vector
Space - Vectors that can be added together and multiplied by scalars.
- Wasm
NotSend - Wasm
NotSend Sync - Wasm
NotSync - Window
Handle - Super trait for window handles as used in
SurfaceTarget. - Zero
- Defines an additive identity element for
Self.
Functions§
- dot
- Dot product of two vectors.
- frustum
- Create a perspective matrix from a view frustum.
- ortho
- Create an orthographic projection matrix.
- perspective
- Create a perspective projection matrix.
- point1
- The short constructor.
- point2
- The short constructor.
- point3
- The short constructor.
- vec1
- The short constructor.
- vec2
- The short constructor.
- vec3
- The short constructor.
- vec4
- The short constructor.
Type Aliases§
- Acceleration
Structure Flags - Flags for an acceleration structure.
- Acceleration
Structure Geometry Flags - Flags for a geometry inside a bottom level acceleration structure.
- Acceleration
Structure Update Mode - Update mode for acceleration structure builds.
- Blas
Geometry Size Descriptors - Descriptor for the size defining attributes, for a bottom level acceleration structure.
- Blas
Triangle Geometry Size Descriptor - Descriptor for the size defining attributes of a triangle geometry, for a bottom level acceleration structure.
- Buffer
Address - Integral type used for
Bufferoffsets and sizes. - Buffer
Descriptor - Describes a
Buffer. - Buffer
Size - Integral type used for
BufferSlicesizes. - Command
Encoder Descriptor - Describes a
CommandEncoder. - Create
Blas Descriptor - Descriptor to create bottom level acceleration structures.
- Create
Tlas Descriptor - Descriptor to create top level acceleration structures.
- Device
Descriptor - Describes a
Device. - Dynamic
Offset - Integral type used for dynamic bind group offsets.
- Error
Source - Lower level source of the error.
- External
Texture Descriptor - Describes an
ExternalTexture. - Label
- Object debugging label.
- Poll
Type - Passed to
Device::pollto 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.
- Sampler
Descriptor - Describes a
Sampler. - Shader
Location - Integral type used for binding locations in shaders.
- Shader
Module Descriptor Passthrough - Descriptor for a shader module given by any of several sources.
At least one of the shader types that may be used by the backend must be
Some - Surface
Configuration - Describes a
Surface. - Texel
Copy Buffer Info - View of a buffer which can be used to copy to/from a texture.
- Texel
Copy Texture Info - View of a texture which can be used to copy to/from a buffer/texture.
- Texture
Descriptor - Describes a
Texture. - Texture
View Descriptor - Describes a
TextureView.