pub struct SamplerCache { /* private fields */ }Expand description
In-memory cache that de-duplicates identical sampler configurations.
When the same SamplerConfig is requested more than once the same
SamplerHandle is returned, avoiding redundant GPU object creation.
§Example
use oximedia_gpu::sampler::{SamplerCache, SamplerConfig};
let mut cache = SamplerCache::new();
let h1 = cache.get_or_insert(SamplerConfig::linear_clamp());
let h2 = cache.get_or_insert(SamplerConfig::linear_clamp());
assert_eq!(h1, h2); // same config → same handle
assert_eq!(cache.len(), 1);Implementations§
Source§impl SamplerCache
impl SamplerCache
Sourcepub fn get_or_insert(&mut self, config: SamplerConfig) -> SamplerHandle
pub fn get_or_insert(&mut self, config: SamplerConfig) -> SamplerHandle
Return an existing handle if config is already cached, or allocate a
new one and store it.
Trait Implementations§
Source§impl Debug for SamplerCache
impl Debug for SamplerCache
Source§impl Default for SamplerCache
impl Default for SamplerCache
Source§fn default() -> SamplerCache
fn default() -> SamplerCache
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for SamplerCache
impl RefUnwindSafe for SamplerCache
impl Send for SamplerCache
impl Sync for SamplerCache
impl Unpin for SamplerCache
impl UnsafeUnpin for SamplerCache
impl UnwindSafe for SamplerCache
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