pub struct TargetPool { /* private fields */ }Expand description
TargetPool reuses offscreen textures across frames.
Layer, snapshot, filter, and raster-attachment targets are taken during
planning, stay alive through GPU submission, and return at Self::end_frame.
Entries unused for several frames are dropped. Main-target MSAA color and
depth scratch is keyed by size and kept.
Views returned by take_* are cloned wgpu handles. Do not keep them past
Self::end_frame: the pool may reuse or drop the underlying textures.
Implementations§
Source§impl TargetPool
impl TargetPool
Sourcepub fn take_layer(
&mut self,
size: [u32; 2],
format: TextureFormat,
transient: bool,
) -> LayerTarget
pub fn take_layer( &mut self, size: [u32; 2], format: TextureFormat, transient: bool, ) -> LayerTarget
take_layer returns a pooled offscreen layer of size and format.
transient is true when every segment of the target discards at pass
end. The returned views must not be used after Self::end_frame.
Sourcepub fn take_raster_attachments(
&mut self,
size: [u32; 2],
format: TextureFormat,
) -> RasterAttachments
pub fn take_raster_attachments( &mut self, size: [u32; 2], format: TextureFormat, ) -> RasterAttachments
take_raster_attachments returns pooled MSAA color and depth for a
raster-cache fill of size and format.
The resolve target is the cache’s own persistent texture, so only the
transient attachments pool here. Exact-size match. The returned views
must not be used after Self::end_frame.
Sourcepub fn take_snapshot(
&mut self,
size: [u32; 2],
format: TextureFormat,
) -> Snapshot
pub fn take_snapshot( &mut self, size: [u32; 2], format: TextureFormat, ) -> Snapshot
take_snapshot returns a pooled destination copy of size and format.
The returned views must not be used after Self::end_frame.
Sourcepub fn take_filter(
&mut self,
size: [u32; 2],
format: TextureFormat,
) -> FilterTarget
pub fn take_filter( &mut self, size: [u32; 2], format: TextureFormat, ) -> FilterTarget
take_filter returns a pooled single-sample filter target of size and format.
size should already be snapped to FILTER_SIZE_BUCKET. The returned
view must not be used after Self::end_frame.
Sourcepub fn main_scratch(
&mut self,
size: [u32; 2],
format: TextureFormat,
transient: bool,
) -> MainScratch
pub fn main_scratch( &mut self, size: [u32; 2], format: TextureFormat, transient: bool, ) -> MainScratch
main_scratch returns MSAA color and depth for the frame’s main target.
transient is true when every segment discards at pass end (a
single-segment frame). The swap to a persistent pair on the first
resume also comes through here. Scratch is keyed by size and kept.