pub struct BindGroupCache<Key: Hash + Eq + Clone> { /* private fields */ }
Expand description
Bind group cache. Corresponds to a single bind group.
If you use multiple bind groups in a single cache, you will likely have cache misses constantly.
Implementations§
Source§impl<Key: Hash + Eq + Clone> BindGroupCache<Key>
impl<Key: Hash + Eq + Clone> BindGroupCache<Key>
Sourcepub fn with_capacity(size: usize) -> Self
pub fn with_capacity(size: usize) -> Self
Create a bind group cache with given size.
Sourcepub fn create_bind_group<'a, Set, BindGroupFn>(
&mut self,
buffers: Set,
use_cache: bool,
bind_group_fn: BindGroupFn,
) -> Key
pub fn create_bind_group<'a, Set, BindGroupFn>( &mut self, buffers: Set, use_cache: bool, bind_group_fn: BindGroupFn, ) -> Key
Using the set of AutomatedBuffer
s provided
in buffers
, create or retrieve a bind group and return the key
to call get
with.
If a bind group is not found, bind_group_fn
will be called with
the resolved BeltBufferId
for the given buffers.
This result will then be cached.
use_cache
, if false, will always call the function and overwrite
the value (if any) in the cache. This is useful if bind groups
are changing every invocation.
pub fn get(&self, key: &Key) -> Option<&BindGroup>
Trait Implementations§
Auto Trait Implementations§
impl<Key> Freeze for BindGroupCache<Key>
impl<Key> !RefUnwindSafe for BindGroupCache<Key>
impl<Key> Send for BindGroupCache<Key>where
Key: Send,
impl<Key> Sync for BindGroupCache<Key>where
Key: Sync,
impl<Key> Unpin for BindGroupCache<Key>
impl<Key> !UnwindSafe for BindGroupCache<Key>
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