Skip to main content

ModelBufferAllocator

Struct ModelBufferAllocator 

Source
pub struct ModelBufferAllocator { /* private fields */ }
Expand description

Model Buffer allocator.

Each frame the sequence is:

  1. [reset()] — clear the staging vector
  2. [allocate()] — push uniforms and return byte offsets
  3. Caller uploads via ResourceManager::upload_model_buffer()

Implementations§

Source§

impl ModelBufferAllocator

Source

pub fn new() -> Self

Source

pub fn reset(&mut self)

Reset at the beginning of each frame.

Source

pub fn buffer_handle(&self) -> &BufferRef

Source

pub fn uniform_stride() -> NonZero<u64>

Source

pub fn allocate(&mut self, data: DynamicModelUniforms) -> u32

Allocate a model uniform slot, returning the byte offset.

Source

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.

Source

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

Source

pub fn host_data(&self) -> &[DynamicModelUniforms]

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Trait Implementations§

Source§

impl Default for ModelBufferAllocator

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

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().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,