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.