pub struct ModelBufferAllocator { /* private fields */ }Expand description
Model Buffer allocator.
Each frame the sequence is:
- [
reset()] — clear the staging vector - [
allocate()] — push uniforms and return byte offsets - Caller uploads via
ResourceManager::upload_model_buffer()
Implementations§
Source§impl ModelBufferAllocator
impl ModelBufferAllocator
pub fn new() -> Self
pub fn buffer_handle(&self) -> &BufferRef
pub fn uniform_stride() -> NonZero<u64>
Sourcepub fn allocate(&mut self, data: DynamicModelUniforms) -> u32
pub fn allocate(&mut self, data: DynamicModelUniforms) -> u32
Allocate a model uniform slot, returning the byte offset.
Sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
Shrink the capacity to fit the current number of uniforms. Only intended to be called during scene transitions when we expect a significant drop in the number of active models, to free up GPU memory. Not called every frame to avoid fragmentation and performance overhead.
pub fn flush_to_buffer( &self, device: &Device, queue: &Queue, gpu_buffers: &mut SlotMap<GpuBufferHandle, GpuBuffer>, buffer_index: &mut FxHashMap<u64, GpuBufferHandle>, frame_index: u64, ) -> bool
pub fn host_data(&self) -> &[DynamicModelUniforms]
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ModelBufferAllocator
impl RefUnwindSafe for ModelBufferAllocator
impl Send for ModelBufferAllocator
impl Sync for ModelBufferAllocator
impl Unpin for ModelBufferAllocator
impl UnsafeUnpin for ModelBufferAllocator
impl UnwindSafe for ModelBufferAllocator
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<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().