pub struct GpuShaderCache { /* private fields */ }Expand description
In-process GPU shader cache.
Implementations§
Source§impl GpuShaderCache
impl GpuShaderCache
Sourcepub fn new(max_bytes: usize, max_entries: usize, policy: EvictionPolicy) -> Self
pub fn new(max_bytes: usize, max_entries: usize, policy: EvictionPolicy) -> Self
Create a new shader cache.
max_bytes– evict when total payload exceeds this many bytes.max_entries– evict when the number of entries exceeds this.policy– which eviction strategy to use.
Sourcepub fn insert(&mut self, shader: CompiledShader)
pub fn insert(&mut self, shader: CompiledShader)
Insert a compiled shader into the cache.
If the cache is full, one entry is evicted according to the current policy before the new entry is stored.
Sourcepub fn get(&mut self, version: &ShaderVersion) -> Option<&CompiledShader>
pub fn get(&mut self, version: &ShaderVersion) -> Option<&CompiledShader>
Retrieve a compiled shader by its version key.
Returns None if the shader is not cached.
Sourcepub fn contains(&self, version: &ShaderVersion) -> bool
pub fn contains(&self, version: &ShaderVersion) -> bool
Check whether a shader is present in the cache.
Sourcepub fn remove(&mut self, version: &ShaderVersion) -> Option<CompiledShader>
pub fn remove(&mut self, version: &ShaderVersion) -> Option<CompiledShader>
Remove a specific shader from the cache.
Sourcepub fn invalidate_backend(&mut self, backend: &str)
pub fn invalidate_backend(&mut self, backend: &str)
Remove all shaders for a given backend.
Sourcepub fn stats(&self) -> &ShaderCacheStats
pub fn stats(&self) -> &ShaderCacheStats
Current statistics.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for GpuShaderCache
impl RefUnwindSafe for GpuShaderCache
impl Send for GpuShaderCache
impl Sync for GpuShaderCache
impl Unpin for GpuShaderCache
impl UnsafeUnpin for GpuShaderCache
impl UnwindSafe for GpuShaderCache
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
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