pub struct ResourcePool {
pub max_idle_frames: u64,
/* private fields */
}Expand description
Manages physical resources with frame-based lifetime tracking. Reuses allocations between frames when descriptors match.
Fields§
§max_idle_frames: u64Maximum number of frames a resource can be unused before being freed.
Implementations§
Source§impl ResourcePool
impl ResourcePool
pub fn new() -> Self
Sourcepub fn begin_frame(&mut self)
pub fn begin_frame(&mut self)
Advance to the next frame. Frees resources that have been idle too long.
Sourcepub fn end_frame(&self) -> PoolFrameStats
pub fn end_frame(&self) -> PoolFrameStats
End the current frame. Reports statistics.
Sourcepub fn acquire(
&mut self,
descriptor: ResourceDescriptor,
lifetime: ResourceLifetime,
bb_w: u32,
bb_h: u32,
) -> ResourceHandle
pub fn acquire( &mut self, descriptor: ResourceDescriptor, lifetime: ResourceLifetime, bb_w: u32, bb_h: u32, ) -> ResourceHandle
Acquire a resource matching the given descriptor. Reuses a free slot if possible.
Sourcepub fn release(&mut self, handle: ResourceHandle)
pub fn release(&mut self, handle: ResourceHandle)
Release a resource back to the free list.
Sourcepub fn record_write(
&mut self,
handle: ResourceHandle,
pass_idx: usize,
pass_name: &str,
)
pub fn record_write( &mut self, handle: ResourceHandle, pass_idx: usize, pass_name: &str, )
Mark a pass as writing to a resource.
Sourcepub fn record_read(
&mut self,
handle: ResourceHandle,
pass_idx: usize,
_pass_name: &str,
)
pub fn record_read( &mut self, handle: ResourceHandle, pass_idx: usize, _pass_name: &str, )
Mark a pass as reading from a resource.
Sourcepub fn descriptor(&self, handle: ResourceHandle) -> Option<&ResourceDescriptor>
pub fn descriptor(&self, handle: ResourceHandle) -> Option<&ResourceDescriptor>
Get the descriptor for a handle.
Sourcepub fn physical(&self, handle: ResourceHandle) -> Option<&PhysicalResource>
pub fn physical(&self, handle: ResourceHandle) -> Option<&PhysicalResource>
Get a physical resource by handle.
Sourcepub fn compute_aliasing(&mut self, total_passes: usize) -> &[Vec<usize>]
pub fn compute_aliasing(&mut self, total_passes: usize) -> &[Vec<usize>]
Compute aliasing groups: resources whose lifetimes don’t overlap can share memory.
Sourcepub fn detect_raw_hazards(&self) -> Vec<(String, u32)>
pub fn detect_raw_hazards(&self) -> Vec<(String, u32)>
Check all version chains for read-after-write hazards.
Sourcepub fn estimate_memory_budget(&self, bb_w: u32, bb_h: u32) -> MemoryBudget
pub fn estimate_memory_budget(&self, bb_w: u32, bb_h: u32) -> MemoryBudget
Estimate total memory budget for all active resources.
Sourcepub fn total_slots(&self) -> usize
pub fn total_slots(&self) -> usize
Total number of resources (including free slots).
Sourcepub fn active_count(&self) -> usize
pub fn active_count(&self) -> usize
Number of active (non-free) resources.
Sourcepub fn version_chain(
&self,
handle: ResourceHandle,
) -> Option<&ResourceVersionChain>
pub fn version_chain( &self, handle: ResourceHandle, ) -> Option<&ResourceVersionChain>
Get the version chain for a resource handle.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ResourcePool
impl RefUnwindSafe for ResourcePool
impl Send for ResourcePool
impl Sync for ResourcePool
impl Unpin for ResourcePool
impl UnsafeUnpin for ResourcePool
impl UnwindSafe for ResourcePool
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.