Skip to main content

TransientPool

Struct TransientPool 

Source
pub struct TransientPool { /* private fields */ }
Expand description

Physical backing for the graph’s transients.

Owned by the renderer, not by a graph: a graph lives for one frame and a pool has to outlive it, or “pool” would mean “allocate every frame”.

Implementations§

Source§

impl TransientPool

Source

pub fn new() -> TransientPool

An empty pool.

Source

pub fn begin_frame(&mut self)

Marks every pooled resource available again.

Called by CompiledGraph::execute before it realises anything, so a caller never has to remember to.

Source

pub fn image( &mut self, device: &dyn Device, desc: TransientImageDesc, ) -> Result<(Handle<Image>, Handle<ImageView>), HalError>

An image matching desc, creating one only if every match is already in use this frame.

§Errors

HalError from image or view creation.

Source

pub fn buffer( &mut self, device: &dyn Device, desc: TransientBufferDesc, ) -> Result<Handle<Buffer>, HalError>

A buffer matching desc, creating one only if every match is already in use this frame.

§Errors

HalError from buffer creation.

Source

pub fn image_use( &self, desc: TransientImageDesc, ordinal: usize, ) -> TransientUse

What the last frame left the ordinal-th pooled image matching desc in.

ordinal counts within one description, in the order TransientPool::image hands them out — so the n-th request for a description in a frame is the n-th entry here, and a graph that has packed its transients onto physical slots can ask about a slot it has not realised yet. TransientUse::default for a description the pool has never been asked for, which is the correct answer: there is no resource, so nothing has written one.

Source

pub fn buffer_use( &self, desc: TransientBufferDesc, ordinal: usize, ) -> TransientUse

What the last frame left the ordinal-th pooled buffer matching desc in. See TransientPool::image_use.

Source

pub fn imported_image_use(&self, image: Handle<Image>) -> Option<ResourceState>

What the last graph left the imported image image in, if one has.

None means no graph has executed against this pool with image declared as InitialClaim::Tracked — so there is no claim to contradict, and an importer whose image was put into its state by an upload outside the graph is the ordinary way to arrive here. RenderGraph::compile reads it; a test asserts on it to show the ledger is not silently empty, which is the difference between this guard checking something and checking nothing.

Source

pub fn imported_buffer_use( &self, buffer: Handle<Buffer>, ) -> Option<ResourceState>

What the last graph left the imported buffer buffer in, if one has.

TransientPool::imported_image_use’s answer for a buffer, and None means the same thing: no graph has executed against this pool with buffer imported, so there is no claim to contradict. A buffer a write_buffer filled before any frame ran is the ordinary way to arrive here.

Source

pub fn retire_unused(&mut self, device: &dyn Device) -> usize

Destroys anything that has gone unused for RETIRE_AFTER_FRAMES consecutive frames, and reports how many resources went.

Call once per frame after submitting. A resize is the case that makes this necessary: it changes the key of every scene target, so without it a window dragged across the screen accumulates one image per size it passed through.

Source

pub const fn frame_count(&self) -> u64

How many frames have begun against this pool.

Source

pub fn image_count(&self) -> usize

How many physical images the pool is holding.

Source

pub fn buffer_count(&self) -> usize

How many physical buffers the pool is holding.

Source

pub fn destroy(&mut self, device: &dyn Device)

Destroys everything. Call after the device is idle, at shutdown.

Trait Implementations§

Source§

impl Debug for TransientPool

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for TransientPool

Source§

fn default() -> TransientPool

Returns the “default value” for a type. Read more

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> HalThreadSafe for T
where T: Send + Sync,

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.