Trait bevy_render::render_phase::BatchedPhaseItem
source · pub trait BatchedPhaseItem: EntityPhaseItem {
fn batch_range(&self) -> &Option<Range<u32>>;
fn batch_range_mut(&mut self) -> &mut Option<Range<u32>>;
fn add_to_batch(&mut self, other: &Self) -> BatchResult { ... }
}
Expand description
A PhaseItem
that can be batched dynamically.
Batching is an optimization that regroups multiple items in the same vertex buffer to render them in a single draw call.
If this is implemented on a type, the implementation of PhaseItem::sort
should
be changed to implement a stable sort, or incorrect/suboptimal batching may result.
Required Methods
sourcefn batch_range(&self) -> &Option<Range<u32>>
fn batch_range(&self) -> &Option<Range<u32>>
Range in the vertex buffer of this item
sourcefn batch_range_mut(&mut self) -> &mut Option<Range<u32>>
fn batch_range_mut(&mut self) -> &mut Option<Range<u32>>
Range in the vertex buffer of this item
Provided Methods
sourcefn add_to_batch(&mut self, other: &Self) -> BatchResult
fn add_to_batch(&mut self, other: &Self) -> BatchResult
Batches another item within this item if they are compatible.
Items can be batched together if they have the same entity, and consecutive ranges.
If batching is successful, the other
item should be discarded from the render pass.