ascending_graphics

Struct VertexBuffer

Source
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: usize

Size each Buffer Layer gets allocated to for Future buffers.

Implementations§

Source§

impl<K: BufferLayout> VertexBuffer<K>

Source

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

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

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.

Source

pub fn index_count(&self) -> usize

Returns the index count.

Source

pub fn index_max(&self) -> usize

Returns the index maximum size.

Source

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.

Source

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

pub fn set_index_count(&mut self, count: usize)

Set the Index based on how many Vertex’s Exist

Source

pub fn vertex_count(&self) -> usize

Returns the Vertex elements count.

Source

pub fn is_empty(&self) -> bool

Returns if the vertex buffer is empty

Source

pub fn is_clipped(&self) -> bool

Returns if the buffer is clipped or not to deturmine if you should use buffers or clipped_buffers.

Source

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.

Source

pub fn vertex_max(&self) -> usize

Returns vertex_buffer’s max size in bytes.

Source

pub fn vertex_stride(&self) -> usize

Returns vertex_buffer’s vertex_stride.

Source

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.

Source

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>

Source§

fn as_buffer_pass(&'a self) -> BufferPass<'a>

Creates 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> 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> Downcast for T
where T: Any,

Source§

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>

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)

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)

Convert &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
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

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

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

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

Source§

impl<T> WasmNotSendSync for T

Source§

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