pub struct SourceGroupCache<G = BindGroup> { /* private fields */ }Expand description
Bind groups that name a pooled or retained page, kept across frames.
A page-round resources group, a composite or backdrop segment’s group and a
filter pass’s source group each name one texture view; rebuilding them for
the same view every frame is pure cost. Entries are keyed by what they
sample (SourceGroupKey) and swept every frame: Self::sweep drops
every entry the frame did not use, so a group never keeps a texture alive
past the frame after the last one that drew with it — well inside the page
pool’s own keep-alive window, which has no eviction hook to invalidate
against. The owner clears the cache outright when an input every entry
shares (the coverage view) is recreated.
Generic over the group type so the keying and sweep rules test without a device.
Implementations§
Source§impl<G: Clone> SourceGroupCache<G>
impl<G: Clone> SourceGroupCache<G>
Sourcepub fn get_or_build(
&mut self,
key: SourceGroupKey,
build: impl FnOnce() -> G,
) -> G
pub fn get_or_build( &mut self, key: SourceGroupKey, build: impl FnOnce() -> G, ) -> G
The group under key, built by build on a miss. Marks it used.