pub trait BatchedPhaseItem: PhaseItem {
    // Required methods
    fn batch_range(&self) -> &Option<Range<u32>>;
    fn batch_range_mut(&mut self) -> &mut Option<Range<u32>>;

    // Provided method
    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§

fn batch_range(&self) -> &Option<Range<u32>>

Range in the vertex buffer of this item.

fn batch_range_mut(&mut self) -> &mut Option<Range<u32>>

Range in the vertex buffer of this item.

Provided Methods§

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.

Implementors§