Expand description
Variant caching for pipeline-like values.
Three types carry it:
- a PipelineVariant is the complete, hashable identity of one compiled value and builds the PipelineDescriptor it compiles from,
- Variants caches the SpecializedPipelines that result, handing the same index back the next time a variant is asked for, and
- a PipelineDescriptor is the blueprint itself: owned wgpu state that
compiles into a pipeline of type
P.
A variant is the cache key, so it must be injective: equal variants build equal descriptors, and draws whose descriptors differ resolve to different variants. Because a variant carries everything its descriptor depends on, the cache is one map β no canonical form, no second level.
There is no full-descriptor cache. A RenderPipelineDesc cannot be hashed β its compilation constants hold f64 β and memoizing on a small key is the point of the type: a family has finitely many variants, and a lookup is cheaper than comparing whole descriptors. Cached variants are never evicted, matching the bounded-variant assumption.
PipelineDescriptor is generic over the pipeline it compiles, so one cache serves a render pipeline and a compute pipeline alike: the descriptor is the only thing that knows which of the two it builds.
Re-exportsΒ§
use core::hash::Hash;πuse core::hash::Hash;πuse std::sync::Arc;πuse arrayvec::ArrayVec;πuse hashbrown::HashMap;πuse smallvec::SmallVec;πuse crate::render_attachments::RenderAttachments;πuse crate::scene::MAX_VERTEX_BUFFERS;πuse crate::util::Hashed;π
StructsΒ§
- Compilation
Options - Owned pipeline compilation options.
- Fragment
State Desc - Owned fragment stage of a RenderPipelineDesc.
- Render
Pipeline Desc - An owned mirror of wgpuβs render-pipeline descriptor, with every borrowed slice owned so it can outlive the descriptor it was read from.
- Specialized
Pipeline - A compiled pipeline together with the descriptor it came from.
- Surface
Key - The render target a pipeline is specialized for.
- Variants
- A cache of the SpecializedPipelines one family compiles. At most one pipeline is created per variant.
- Vertex
Buffer Layout Desc - An owned vertex-buffer layout. The attributes are owned rather than borrowed, so the layout outlives the descriptor it was read from.
- Vertex
Layout - A meshβs vertex-buffer layout, slot by slot, shared rather than copied.
- Vertex
State Desc - Owned vertex stage of a RenderPipelineDesc.
TraitsΒ§
- Pipeline
Descriptor - A blueprint that compiles into a pipeline of type
P. - Pipeline
Variant - The complete, hashable identity of one compiled pipeline, and the recipe for its blueprint.
- Surface
Target - A descriptor whose pipeline is only valid for one render target.
Type AliasesΒ§
- Vertex
Attributes - The attributes of one vertex-buffer layout.