pub struct Variants<P, V: PipelineVariant<P>> {
device: Device,
keys: HashMap<V, u32>,
variants: Vec<SpecializedPipeline<P, V::Descriptor>>,
}Expand description
A cache of the SpecializedPipelines one family compiles. At most one pipeline is created per variant.
The variants are stored in creation order; Self::specialize returns their index. The cache never evicts: a family has finitely many variants, so one that specializes on the mesh’s vertex layout, say, holds one pipeline per distinct layout it has seen.
Fields§
§device: DeviceThe device variants are created on.
keys: HashMap<V, u32>The cache: variant to index into variants.
variants: Vec<SpecializedPipeline<P, V::Descriptor>>The created variants, indexed by the returned index.
Implementations§
Source§impl<P, V: PipelineVariant<P>> Variants<P, V>
impl<P, V: PipelineVariant<P>> Variants<P, V>
Sourcepub fn specialize(&mut self, variant: V) -> u32
pub fn specialize(&mut self, variant: V) -> u32
The index of the variant’s pipeline, creating it on first use.
Creates at most one pipeline per variant; the blueprint is built only on a cache miss.
Sourcepub fn get(&self, index: u32) -> &SpecializedPipeline<P, V::Descriptor>
pub fn get(&self, index: u32) -> &SpecializedPipeline<P, V::Descriptor>
Auto Trait Implementations§
impl<P, V> !RefUnwindSafe for Variants<P, V>
impl<P, V> !UnwindSafe for Variants<P, V>
impl<P, V> Forget for Variants<P, V>
impl<P, V> Freeze for Variants<P, V>where
HashMap<V, u32>: Freeze,
Vec<SpecializedPipeline<P, <V as PipelineVariant<P>>::Descriptor>>: Freeze,
impl<P, V> Send for Variants<P, V>where
HashMap<V, u32>: Send,
Vec<SpecializedPipeline<P, <V as PipelineVariant<P>>::Descriptor>>: Send,
impl<P, V> Sync for Variants<P, V>where
HashMap<V, u32>: Sync,
Vec<SpecializedPipeline<P, <V as PipelineVariant<P>>::Descriptor>>: Sync,
impl<P, V> Unpin for Variants<P, V>where
HashMap<V, u32>: Unpin,
Vec<SpecializedPipeline<P, <V as PipelineVariant<P>>::Descriptor>>: Unpin,
impl<P, V> UnsafeUnpin for Variants<P, V>where
HashMap<V, u32>: UnsafeUnpin,
Vec<SpecializedPipeline<P, <V as PipelineVariant<P>>::Descriptor>>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more