pub struct VertexBuffer<K: BufferLayout> {
pub unprocessed: Vec<Vec<OrderedIndex>>,
pub buffers: Vec<Vec<ClippedIndexDetails>>,
pub vertex_buffer: Buffer<K>,
pub index_buffer: Buffer<K>,
pub layer_size: usize,
/* private fields */
}Expand description
VertexBuffer holds all the Details to render with Verticies and indicies. This stores and handles the orders of all rendered objects to try and reduce the amount of GPU uploads we make.
Fields§
§unprocessed: Vec<Vec<OrderedIndex>>Unprocessed Buffer Data.
buffers: Vec<Vec<ClippedIndexDetails>>Buffers ready to Render
vertex_buffer: Buffer<K>The main Vertex Buffer within GPU memory.
index_buffer: Buffer<K>The main Index Buffer within GPU memory.
layer_size: usizeSize each Buffer Layer gets allocated to for Future buffers.
Implementations§
Source§impl<K: BufferLayout> VertexBuffer<K>
impl<K: BufferLayout> VertexBuffer<K>
Sourcepub fn create_buffer(
gpu_device: &GpuDevice,
buffers: &BufferData,
layer_size: usize,
) -> Self
pub fn create_buffer( gpu_device: &GpuDevice, buffers: &BufferData, layer_size: usize, ) -> Self
Used to create a VertexBuffer.
Only use this for creating a reusable buffer.
§Arguments
- buffers: The (Vertex:Vec
, Indices:Vec ) to Create the Buffer with. - layer_size: The capacity allocated for any future elements per new Buffer Layer.
Sourcepub fn add_buffer_store(
&mut self,
renderer: &GpuRenderer,
index: OrderedIndex,
buffer_layer: usize,
)
pub fn add_buffer_store( &mut self, renderer: &GpuRenderer, index: OrderedIndex, buffer_layer: usize, )
Adds the Buffer to the unprocessed list so it can be processed in VertexBuffer::finalize
This must be called in order to Render the Object.
§Arguments
- index: The Order Index of the Object we want to render.
- buffer_layer: The Buffer Layer we want to add this Object too.
Sourcepub fn finalize(&mut self, renderer: &mut GpuRenderer)
pub fn finalize(&mut self, renderer: &mut GpuRenderer)
Processes all unprocessed listed buffers and uploads any changes to the gpu
This must be called after VertexBuffer::add_buffer_store in order to Render the Objects.
Sourcepub fn index_count(&self) -> usize
pub fn index_count(&self) -> usize
Returns the index count.
Sourcepub fn indices(&self, bounds: Option<Range<u64>>) -> BufferSlice<'_>
pub fn indices(&self, bounds: Option<Range<u64>>) -> BufferSlice<'_>
Returns wgpu::BufferSlice of indices.
bounds is used to set a specific Range if needed.
If bounds is None then range is 0..index_count.
Sourcepub fn new(device: &GpuDevice, layer_size: usize) -> Self
pub fn new(device: &GpuDevice, layer_size: usize) -> Self
Creates an VertexBuffer with a default buffer size.
Buffer size is based on the initial crate::BufferLayout::default_buffer length.
§Arguments
- layer_size: The capacity allocated for any future elements per new Buffer Layer.
Sourcepub fn set_index_count(&mut self, count: usize)
pub fn set_index_count(&mut self, count: usize)
Set the Index based on how many Vertex’s Exist
Sourcepub fn vertex_count(&self) -> usize
pub fn vertex_count(&self) -> usize
Returns the Vertex elements count.
Sourcepub fn is_clipped(&self) -> bool
pub fn is_clipped(&self) -> bool
Returns if the buffer is clipped or not to deturmine if you should use buffers or clipped_buffers.
Sourcepub fn set_as_clipped(&mut self)
pub fn set_as_clipped(&mut self)
Sets the Buffer into Clipping mode. This will Produce a clipped_buffers instead of the buffers which will still be layered but a Vector of individual objects will Exist rather than a grouped object per layer. Will make it less Efficient but allows Bounds Clipping.
Sourcepub fn vertex_max(&self) -> usize
pub fn vertex_max(&self) -> usize
Returns vertex_buffer’s max size in bytes.
Sourcepub fn vertex_stride(&self) -> usize
pub fn vertex_stride(&self) -> usize
Returns vertex_buffer’s vertex_stride.
Sourcepub fn vertices(&self, bounds: Option<Range<u64>>) -> BufferSlice<'_>
pub fn vertices(&self, bounds: Option<Range<u64>>) -> BufferSlice<'_>
Returns wgpu::BufferSlice of vertices.
bounds is used to set a specific Range if needed.
If bounds is None then range is 0..vertex_count.
Sourcepub fn with_capacity(
gpu_device: &GpuDevice,
capacity: usize,
layer_size: usize,
) -> Self
pub fn with_capacity( gpu_device: &GpuDevice, capacity: usize, layer_size: usize, ) -> Self
Creates an VertexBuffer with a buffer capacity.
Buffer size is based on the initial crate::BufferLayout::default_buffer length.
§Arguments
- capacity: The capacity of the Buffers instances for future allocation * 2.
- layer_size: The capacity allocated for any future elements per new Buffer Layer.
Trait Implementations§
Source§impl<'a, K: BufferLayout> AsBufferPass<'a> for VertexBuffer<K>
impl<'a, K: BufferLayout> AsBufferPass<'a> for VertexBuffer<K>
Source§fn as_buffer_pass(&'a self) -> BufferPass<'a>
fn as_buffer_pass(&'a self) -> BufferPass<'a>
BufferPass from the Holding Object.Auto Trait Implementations§
impl<K> !Freeze for VertexBuffer<K>
impl<K> !RefUnwindSafe for VertexBuffer<K>
impl<K> Send for VertexBuffer<K>where
K: Send,
impl<K> Sync for VertexBuffer<K>where
K: Sync,
impl<K> Unpin for VertexBuffer<K>where
K: Unpin,
impl<K> !UnwindSafe for VertexBuffer<K>
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
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>
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>
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)
&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)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more