pub struct ResourceRegistry { /* private fields */ }Expand description
Shared registry of GPU textures and shaders, with generation-checked handles and reference counting.
Slots are recycled via a free list when their reference count reaches zero. The generation counter prevents stale handles from aliasing new allocations.
Implementations§
Source§impl ResourceRegistry
impl ResourceRegistry
Sourcepub fn alloc_texture(&mut self, name: String) -> TextureHandle
pub fn alloc_texture(&mut self, name: String) -> TextureHandle
Allocate a texture slot with an initial reference count of 1.
Sourcepub fn retain_texture(&mut self, h: TextureHandle) -> bool
pub fn retain_texture(&mut self, h: TextureHandle) -> bool
Increment the reference count of h.
Returns false if the handle is stale (generation mismatch or
out-of-bounds); returns true on success.
Sourcepub fn release_texture(&mut self, h: TextureHandle)
pub fn release_texture(&mut self, h: TextureHandle)
Decrement the reference count of h.
When the count reaches zero the slot’s generation is bumped and the slot is pushed onto the free list for reuse. Stale or already-freed handles are silently ignored.
Sourcepub fn get_texture(&self, h: TextureHandle) -> Option<&str>
pub fn get_texture(&self, h: TextureHandle) -> Option<&str>
Return the name associated with h, or None if stale.
Sourcepub fn alloc_shader(&mut self, name: String) -> ShaderHandle
pub fn alloc_shader(&mut self, name: String) -> ShaderHandle
Allocate a shader slot with an initial reference count of 1.
Sourcepub fn retain_shader(&mut self, h: ShaderHandle) -> bool
pub fn retain_shader(&mut self, h: ShaderHandle) -> bool
Increment the reference count of h.
Returns false if the handle is stale; returns true on success.
Sourcepub fn release_shader(&mut self, h: ShaderHandle)
pub fn release_shader(&mut self, h: ShaderHandle)
Decrement the reference count of h.
When the count reaches zero the slot is freed and the generation is bumped. Stale handles are silently ignored.
Sourcepub fn get_shader(&self, h: ShaderHandle) -> Option<&str>
pub fn get_shader(&self, h: ShaderHandle) -> Option<&str>
Return the name associated with h, or None if stale.