Skip to main content

Module specialize

Module specialize 

Source
Expand description

Variant caching for pipeline-like values.

Three types carry it:

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Β§

CompilationOptions
Owned pipeline compilation options.
FragmentStateDesc
Owned fragment stage of a RenderPipelineDesc.
RenderPipelineDesc
An owned mirror of wgpu’s render-pipeline descriptor, with every borrowed slice owned so it can outlive the descriptor it was read from.
SpecializedPipeline
A compiled pipeline together with the descriptor it came from.
SurfaceKey
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.
VertexBufferLayoutDesc
An owned vertex-buffer layout. The attributes are owned rather than borrowed, so the layout outlives the descriptor it was read from.
VertexLayout
A mesh’s vertex-buffer layout, slot by slot, shared rather than copied.
VertexStateDesc
Owned vertex stage of a RenderPipelineDesc.

TraitsΒ§

PipelineDescriptor
A blueprint that compiles into a pipeline of type P.
PipelineVariant
The complete, hashable identity of one compiled pipeline, and the recipe for its blueprint.
SurfaceTarget
A descriptor whose pipeline is only valid for one render target.

Type AliasesΒ§

VertexAttributes
The attributes of one vertex-buffer layout.