pub struct PipelineCache {
pub total_lookups: u64,
pub hits: u64,
pub misses: u64,
/* private fields */
}Expand description
In-memory cache mapping pipeline keys to compiled pipeline binaries.
key is a caller-defined u64 (typically a hash of the pipeline
descriptor / shader source). value is an opaque Vec<u8> that
represents the compiled pipeline object — format is backend-specific.
Fields§
§total_lookups: u64Total number of cache lookups (hits + misses).
hits: u64Total number of cache hits.
misses: u64Total number of cache misses (compilations triggered).
Implementations§
Source§impl PipelineCache
impl PipelineCache
Sourcepub fn get_or_create(
&mut self,
key: u64,
create_fn: impl Fn() -> Vec<u8>,
) -> &Vec<u8> ⓘ
pub fn get_or_create( &mut self, key: u64, create_fn: impl Fn() -> Vec<u8>, ) -> &Vec<u8> ⓘ
Return a reference to the cached binary for key, compiling and
caching it first if not already present.
create_fn is invoked at most once per unique key.
Sourcepub fn get(&self, key: u64) -> Option<&Vec<u8>>
pub fn get(&self, key: u64) -> Option<&Vec<u8>>
Return the cached binary for key, or None if not present.
Sourcepub fn invalidate(&mut self, key: u64) -> bool
pub fn invalidate(&mut self, key: u64) -> bool
Remove a cached entry (e.g. when the shader source changes).
Trait Implementations§
Source§impl Debug for PipelineCache
impl Debug for PipelineCache
Source§impl Default for PipelineCache
impl Default for PipelineCache
Source§fn default() -> PipelineCache
fn default() -> PipelineCache
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for PipelineCache
impl RefUnwindSafe for PipelineCache
impl Send for PipelineCache
impl Sync for PipelineCache
impl Unpin for PipelineCache
impl UnsafeUnpin for PipelineCache
impl UnwindSafe for PipelineCache
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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