Skip to main content

TargetPool

Struct TargetPool 

Source
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

Source

pub fn new(device: &Device) -> Self

new creates an empty pool for device.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn end_frame(&mut self)

end_frame returns this frame’s takes to the pool and drops idle entries.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,