pub struct TexturePool { /* private fields */ }Expand description
Free-list pool of offscreen textures. One per consumer render loop; lease at frame start, release at frame end.
Implementations§
Source§impl TexturePool
impl TexturePool
pub fn new() -> Self
Sourcepub fn lease(&mut self, device: &Device, key: TextureKey) -> TextureLease
pub fn lease(&mut self, device: &Device, key: TextureKey) -> TextureLease
Lease a texture matching key — reuses a free pooled
texture when one exists, otherwise allocates.
Sourcepub fn release(&mut self, lease: TextureLease)
pub fn release(&mut self, lease: TextureLease)
Return a leased texture to the free list for reuse.
Sourcepub fn free_count(&self) -> usize
pub fn free_count(&self) -> usize
Total free (releasable) textures across all keys.
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Drop every pooled texture (e.g. after a resize storm left stale-size entries behind).
Sourcepub fn retain(&mut self, keep: impl FnMut(&TextureKey) -> bool)
pub fn retain(&mut self, keep: impl FnMut(&TextureKey) -> bool)
Keep only free-list buckets whose key satisfies keep;
everything else is dropped (wgpu frees the textures).
The targeted eviction seam for the live-resize hazard the
module doc names: a consumer that renders at one resolution
per frame calls retain(|k| k.width == w && k.height == h)
when its surface size changes, so a macOS live-resize drag
(a distinct size nearly every frame) cannot strand full-window
texture sets for every intermediate size (M3 review
2026-06-12 — mado leaked ~24 MB x 9 textures per visited
size with the 6-effect chain enabled). Covers DPI and format
churn too: the predicate sees the whole key.