pub struct BufferRingAllocator { /* private fields */ }Expand description
A ring allocator for streaming per-frame data into a large buffer. Each frame gets a slice of the ring; after N frames the oldest slice is reused.
Implementations§
Source§impl BufferRingAllocator
impl BufferRingAllocator
Sourcepub fn create(
gl: &Context,
frame_count: usize,
frame_size: usize,
tracker: Arc<MemoryTracker>,
) -> Self
pub fn create( gl: &Context, frame_count: usize, frame_size: usize, tracker: Arc<MemoryTracker>, ) -> Self
Create a ring allocator with frame_count slots, each of frame_size bytes.
Sourcepub fn advance(&mut self) -> usize
pub fn advance(&mut self) -> usize
Advance to the next frame slot. Returns the byte offset for this frame’s data.
Sourcepub fn write_current(&self, gl: &Context, data: &[u8])
pub fn write_current(&self, gl: &Context, data: &[u8])
Write data to the current frame slot.
Sourcepub fn current_frame(&self) -> usize
pub fn current_frame(&self) -> usize
Current frame index.
Sourcepub fn frame_offset(&self, frame: usize) -> usize
pub fn frame_offset(&self, frame: usize) -> usize
Byte offset for a given frame index.
Sourcepub fn handle(&self) -> BufferHandle
pub fn handle(&self) -> BufferHandle
Handle to the underlying buffer.
Sourcepub fn frame_size(&self) -> usize
pub fn frame_size(&self) -> usize
Per-frame size in bytes.
Sourcepub fn total_size(&self) -> usize
pub fn total_size(&self) -> usize
Total size in bytes.
Auto Trait Implementations§
impl Freeze for BufferRingAllocator
impl RefUnwindSafe for BufferRingAllocator
impl Send for BufferRingAllocator
impl Sync for BufferRingAllocator
impl Unpin for BufferRingAllocator
impl UnsafeUnpin for BufferRingAllocator
impl UnwindSafe for BufferRingAllocator
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.