pub struct GpuResourceManager { /* private fields */ }Expand description
Simple GPU resource manager that tracks allocations and their sizes.
Implementations§
Source§impl GpuResourceManager
impl GpuResourceManager
Sourcepub fn allocate(
&mut self,
resource_type: ResourceType,
size_bytes: usize,
label: impl Into<String>,
) -> Result<ResourceHandle, String>
pub fn allocate( &mut self, resource_type: ResourceType, size_bytes: usize, label: impl Into<String>, ) -> Result<ResourceHandle, String>
Allocate a new resource.
Returns a valid ResourceHandle on success, or an error string if
size_bytes is zero.
Sourcepub fn free(&mut self, handle: ResourceHandle) -> bool
pub fn free(&mut self, handle: ResourceHandle) -> bool
Free a previously allocated resource.
Returns true if the resource existed and was freed, false otherwise.
Sourcepub fn total_gpu_bytes(&self) -> usize
pub fn total_gpu_bytes(&self) -> usize
Total bytes currently allocated in GPU memory (device-local resources).
Sourcepub fn total_bytes(&self) -> usize
pub fn total_bytes(&self) -> usize
Total bytes across all resource types.
Sourcepub fn allocation_count(&self) -> usize
pub fn allocation_count(&self) -> usize
Number of live allocations.
Sourcepub fn resource_type(&self, handle: ResourceHandle) -> Option<ResourceType>
pub fn resource_type(&self, handle: ResourceHandle) -> Option<ResourceType>
Query the type of a resource by handle.
Sourcepub fn resource_size(&self, handle: ResourceHandle) -> Option<usize>
pub fn resource_size(&self, handle: ResourceHandle) -> Option<usize>
Query the size of a resource in bytes.
Sourcepub fn resource_label(&self, handle: ResourceHandle) -> Option<&str>
pub fn resource_label(&self, handle: ResourceHandle) -> Option<&str>
Query the label of a resource.
Sourcepub fn is_alive(&self, handle: ResourceHandle) -> bool
pub fn is_alive(&self, handle: ResourceHandle) -> bool
Returns true if the handle refers to a live allocation.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for GpuResourceManager
impl RefUnwindSafe for GpuResourceManager
impl Send for GpuResourceManager
impl Sync for GpuResourceManager
impl Unpin for GpuResourceManager
impl UnsafeUnpin for GpuResourceManager
impl UnwindSafe for GpuResourceManager
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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