pub struct TexturePool { /* private fields */ }Expand description
A pool of GPU textures backed by a fixed memory budget
Implementations§
Source§impl TexturePool
impl TexturePool
Sourcepub fn allocate(&mut self, desc: TextureDescriptor) -> Option<usize>
pub fn allocate(&mut self, desc: TextureDescriptor) -> Option<usize>
Allocate a texture in the pool
Returns Some(handle) on success, or None if the budget is
exceeded.
Sourcepub fn allocate_with_lru_eviction(
&mut self,
desc: TextureDescriptor,
) -> Option<usize>
pub fn allocate_with_lru_eviction( &mut self, desc: TextureDescriptor, ) -> Option<usize>
Allocate a texture, evicting the LRU slot if the budget is exceeded.
Returns Some(handle) on success, or None if all live textures are
too large to free enough space for the new allocation.
Sourcepub fn lru_handle(&self) -> Option<usize>
pub fn lru_handle(&self) -> Option<usize>
Return the handle of the least-recently-used allocated texture, or
None if the pool is empty.
Sourcepub fn touch(&mut self, handle: usize)
pub fn touch(&mut self, handle: usize)
Update the access timestamp of handle to mark it as recently used.
Sourcepub fn utilization(&self) -> f64
pub fn utilization(&self) -> f64
Utilisation in [0.0, 1.0]
Sourcepub fn live_count(&self) -> usize
pub fn live_count(&self) -> usize
Number of live (allocated) textures
Sourcepub fn allocated_bytes(&self) -> usize
pub fn allocated_bytes(&self) -> usize
Currently allocated bytes
Auto Trait Implementations§
impl Freeze for TexturePool
impl RefUnwindSafe for TexturePool
impl Send for TexturePool
impl Sync for TexturePool
impl Unpin for TexturePool
impl UnsafeUnpin for TexturePool
impl UnwindSafe for TexturePool
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
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more