DynamicBuffer

Struct DynamicBuffer 

Source
pub struct DynamicBuffer<D: Device, T: Sized> { /* private fields */ }
Expand description

A GPU buffer type which can resize and stretch like a vector

Implementations§

Source§

impl<D, T> DynamicBuffer<D, T>
where D: Device, T: Sized,

Source

pub fn new(usage: BufferUsage, num_buffers: usize) -> Self

creates a new empty buffer, you need to reserve space afterwards

Source

pub fn swap(&mut self)

Swap buffers once a frame for safe CPU writes an GPU in flight reads

Source

pub fn mut_buf(&mut self) -> &mut D::Buffer

Access the internal buffer to write to this frame, for safe CPU writes an GPU in flight reads

Source

pub fn buf(&mut self) -> &D::Buffer

Access immutable buffer to us in the current frame

Source

pub fn reserve(&mut self, device: &mut D, heap: &mut D::Heap, capacity: usize)

creates a new buffer if more cpaacity is required

Source

pub fn clear(&mut self)

Resets length to zero

Source

pub fn len(&self) -> usize

Returns the length of the data written to the buffer in elements

Source

pub fn is_empty(&self) -> bool

Returns true if the len is 0

Source

pub fn capacity(&self) -> usize

Returns the capacity of the buffer

Source

pub fn write<T2: Sized>(&mut self, offset: usize, data: &[T2])

Write arbitrary data data to the buffer and update len, it should be either a u8 slice, a single &T or a slice of T

Source

pub fn push(&mut self, item: &T)

Push an item of type T to the dynamic buffer and update the len

Source

pub fn get_lookup(&self) -> GpuBufferLookup

Auto Trait Implementations§

§

impl<D, T> Freeze for DynamicBuffer<D, T>

§

impl<D, T> RefUnwindSafe for DynamicBuffer<D, T>

§

impl<D, T> Send for DynamicBuffer<D, T>
where T: Send,

§

impl<D, T> Sync for DynamicBuffer<D, T>
where T: Sync,

§

impl<D, T> Unpin for DynamicBuffer<D, T>
where T: Unpin, <D as Device>::Buffer: Unpin,

§

impl<D, T> UnwindSafe for DynamicBuffer<D, T>
where T: UnwindSafe, <D as Device>::Buffer: UnwindSafe,

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> 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<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.