pub struct BufferVec<T: Pod> { /* private fields */ }
Expand description

A structure for storing raw bytes that have already been properly formatted for use by the GPU.

“Properly formatted” means that item data already meets the alignment and padding requirements for how it will be used on the GPU. The item type must implement [Pod] for its data representation to be directly copyable.

Index, vertex, and instance-rate vertex buffers have no alignment nor padding requirements and so this helper type is a good choice for them.

The contained data is stored in system RAM. Calling reserve allocates VRAM from the RenderDevice. write_buffer queues copying of the data from system RAM to VRAM.

Other options for storing GPU-accessible data are:

Implementations

Creates a Buffer on the RenderDevice with size at least std::mem::size_of::<T>() * capacity, unless a such a buffer already exists.

If a Buffer exists, but is too small, references to it will be discarded, and a new Buffer will be created. Any previously created Buffers that are no longer referenced will be deleted by the RenderDevice once it is done using them (typically 1-2 frames).

In addition to any BufferUsages provided when the BufferVec was created, the buffer on the RenderDevice is marked as BufferUsages::COPY_DST.

Queues writing of data from system RAM to VRAM using the RenderDevice and the provided RenderQueue.

Before queuing the write, a reserve operation is executed.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
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. Read more
Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more
Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s. Read more
Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s. Read more
Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more