pub struct IntermediateTargets<T = Texture, V = TextureView> { /* private fields */ }Expand description
The engine’s pool of off-screen intermediates, with its own frame clock.
The clock is what the substrate pool ages entries against; it advances once
per Self::end_frame, including frames that acquired nothing — those are
the frames a parked entry ages on.
Implementations§
Source§impl<T, V> IntermediateTargets<T, V>
impl<T, V> IntermediateTargets<T, V>
Sourcepub fn max_texture_size(&self) -> u32
pub fn max_texture_size(&self) -> u32
The largest intermediate this pool will allocate, per axis.
Sourcepub fn descriptor(width: u32, height: u32, label: &str) -> TextureDesc
pub fn descriptor(width: u32, height: u32, label: &str) -> TextureDesc
The descriptor an intermediate of width x height is requested with,
before the pool quantizes it.
Sourcepub fn acquire<A>(
&mut self,
allocator: &A,
width: u32,
height: u32,
label: &str,
) -> IntermediateTexture<T, V>where
A: TextureAllocator<Texture = T, View = V>,
pub fn acquire<A>(
&mut self,
allocator: &A,
width: u32,
height: u32,
label: &str,
) -> IntermediateTexture<T, V>where
A: TextureAllocator<Texture = T, View = V>,
Hands out an intermediate of at least width x height, or refuses it
for exceeding Self::max_texture_size.
The check is on the requested extent rather than the quantized one: the substrate pool clamps its quantization to the adapter ceiling already, so a request inside the engine’s ceiling can never quantize past the adapter’s.
Sourcepub fn release(&mut self, texture: PooledTexture<T, V>)
pub fn release(&mut self, texture: PooledTexture<T, V>)
Parks an intermediate for reuse.
Sourcepub fn end_frame(&mut self)
pub fn end_frame(&mut self)
Advances the frame clock and ages parked entries out of the pool.
Call once per frame, whether or not the frame acquired anything.
Sourcepub fn drop_parked(&mut self)
pub fn drop_parked(&mut self)
Drops the parked entries the last RESIZE_KEEP_ALIVE_FRAMES frames
did not use, keeping the pool itself and its counters.
This is what a surface resize calls. A page keyed on the old surface extent is dead weight the moment the surface changes size, and holding it for the pool’s full keep-alive window is waste — so a resize collapses that window to the frames immediately behind it instead of waiting a second for the ordinary aging to reach them.
It collapses the window rather than emptying the pool, and the
difference is the whole point. Not every page is keyed on the surface:
a fading card, a dismissing sheet, a menu at its own size all ask for
the same page extent whatever the window does, and a window edge being
dragged produces a resize per frame. Dropping everything on each of
them would evict that page between every pair of frames that wants it
and turn the pool back into a plain allocator for the whole drag —
exactly the failure the substrate pool’s aging slack exists to prevent
(see frust_gpu::pool’s module header). Keeping what the frames right
behind this resize actually used is bounded by what one frame can hold
live at once and is precisely the set the next frame asks for again.
Implemented by aging against a clock far enough ahead to expire
everything older, without moving this pool’s own clock: the frame
counter still advances once per Self::end_frame, so a resize does
not age unrelated entries by a second every time a window edge moves.
Entries still checked out are untouched — the pool does not hold those.