pub struct MeshAllocator { /* private fields */ }
Expand description
Manages the assignment of mesh data to GPU buffers.
The Bevy renderer tries to pack vertex and index data for multiple meshes together so that multiple meshes can be drawn back-to-back without any rebinding. This resource manages these buffers.
Within each slab, or hardware buffer, the underlying allocation algorithm is
[offset-allocator
], a Rust port of Sebastian Aaltonen’s hard-real-time C++
OffsetAllocator
. Slabs start small and then grow as their contents fill
up, up to a maximum size limit. To reduce fragmentation, vertex and index
buffers that are too large bypass this system and receive their own buffers.
The MeshAllocatorSettings
allows you to tune the behavior of the
allocator for better performance with your application. Most applications
won’t need to change the settings from their default values.
Implementations§
source§impl MeshAllocator
impl MeshAllocator
sourcepub fn mesh_vertex_slice(
&self,
mesh_id: &AssetId<Mesh>,
) -> Option<MeshBufferSlice<'_>>
pub fn mesh_vertex_slice( &self, mesh_id: &AssetId<Mesh>, ) -> Option<MeshBufferSlice<'_>>
Returns the buffer and range within that buffer of the vertex data for the mesh with the given ID.
If the mesh wasn’t allocated, returns None.
sourcepub fn mesh_index_slice(
&self,
mesh_id: &AssetId<Mesh>,
) -> Option<MeshBufferSlice<'_>>
pub fn mesh_index_slice( &self, mesh_id: &AssetId<Mesh>, ) -> Option<MeshBufferSlice<'_>>
Returns the buffer and range within that buffer of the index data for the mesh with the given ID.
If the mesh has no index data or wasn’t allocated, returns None.
Trait Implementations§
source§impl FromWorld for MeshAllocator
impl FromWorld for MeshAllocator
source§fn from_world(world: &mut World) -> Self
fn from_world(world: &mut World) -> Self
Self
using data from the given World
.impl Resource for MeshAllocator
Auto Trait Implementations§
impl Freeze for MeshAllocator
impl !RefUnwindSafe for MeshAllocator
impl Send for MeshAllocator
impl Sync for MeshAllocator
impl Unpin for MeshAllocator
impl !UnwindSafe for MeshAllocator
Blanket Implementations§
source§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
source§fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
T
ShaderType
for self
. When used in AsBindGroup
derives, it is safe to assume that all images in self
exist.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