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
impl TransientPool
Sourcepub fn new() -> TransientPool
pub fn new() -> TransientPool
An empty pool.
Sourcepub fn begin_frame(&mut self)
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.
Sourcepub fn image(
&mut self,
device: &dyn Device,
desc: TransientImageDesc,
) -> Result<(Handle<Image>, Handle<ImageView>), HalError>
pub fn image( &mut self, device: &dyn Device, desc: TransientImageDesc, ) -> Result<(Handle<Image>, Handle<ImageView>), HalError>
Sourcepub fn buffer(
&mut self,
device: &dyn Device,
desc: TransientBufferDesc,
) -> Result<Handle<Buffer>, HalError>
pub fn buffer( &mut self, device: &dyn Device, desc: TransientBufferDesc, ) -> Result<Handle<Buffer>, HalError>
Sourcepub fn image_use(
&self,
desc: TransientImageDesc,
ordinal: usize,
) -> TransientUse
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.
Sourcepub fn buffer_use(
&self,
desc: TransientBufferDesc,
ordinal: usize,
) -> TransientUse
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.
Sourcepub fn imported_image_use(&self, image: Handle<Image>) -> Option<ResourceState>
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.
Sourcepub fn imported_buffer_use(
&self,
buffer: Handle<Buffer>,
) -> Option<ResourceState>
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.
Sourcepub fn retire_unused(&mut self, device: &dyn Device) -> usize
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.
Sourcepub const fn frame_count(&self) -> u64
pub const fn frame_count(&self) -> u64
How many frames have begun against this pool.
Sourcepub fn image_count(&self) -> usize
pub fn image_count(&self) -> usize
How many physical images the pool is holding.
Sourcepub fn buffer_count(&self) -> usize
pub fn buffer_count(&self) -> usize
How many physical buffers the pool is holding.