pub struct BindGroupCache { /* private fields */ }Expand description
Bounded LRU cache for wgpu bind groups, keyed by layout identity and the ordered set of buffer handles bound to that layout.
wgpu bind-group creation is non-trivial; this cache eliminates the redundant cost on repeated dispatches that share the same buffer handles. Capped at 256 entries with LRU eviction to prevent descriptor-heap exhaustion on long-running servers.
Implementations§
Source§impl BindGroupCache
impl BindGroupCache
Sourcepub fn with_cap(cap: usize) -> Self
pub fn with_cap(cap: usize) -> Self
Create with an explicit cap (used by tests and consumers that want to size the LRU against known working-set bounds).
Sourcepub fn get_or_create(
&self,
layout_id: usize,
handles: &[GpuBufferHandle],
factory: impl FnOnce() -> BindGroup,
) -> Arc<BindGroup>
pub fn get_or_create( &self, layout_id: usize, handles: &[GpuBufferHandle], factory: impl FnOnce() -> BindGroup, ) -> Arc<BindGroup>
Return a cached bind group or create one with factory.
layout_id must uniquely identify the wgpu::BindGroupLayout
(e.g. Arc::as_ptr(layout).addr()).
handles must be in the same order as the wgpu::BindGroupEntry
slice that the caller will pass to create_bind_group so that
identical handle sets map to the same cache key.
Sourcepub fn stats(&self) -> BindGroupCacheStats
pub fn stats(&self) -> BindGroupCacheStats
Return cache statistics for diagnostics and tests.
Trait Implementations§
Source§impl Clone for BindGroupCache
impl Clone for BindGroupCache
Source§fn clone(&self) -> BindGroupCache
fn clone(&self) -> BindGroupCache
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more