bevy_render::batching

Trait GetBatchData

Source
pub trait GetBatchData {
    type Param: SystemParam + 'static;
    type CompareData: PartialEq;
    type BufferData: GpuArrayBufferable + Sync + Send + 'static;

    // Required method
    fn get_batch_data(
        param: &SystemParamItem<'_, '_, Self::Param>,
        query_item: Entity,
    ) -> Option<(Self::BufferData, Option<Self::CompareData>)>;
}
Expand description

A trait to support getting data used for batching draw commands via phase items.

This is a simple version that only allows for sorting, not binning, as well as only CPU processing, not GPU preprocessing. For these fancier features, see GetFullBatchData.

Required Associated Types§

Source

type Param: SystemParam + 'static

The system parameters GetBatchData::get_batch_data needs in order to compute the batch data.

Source

type CompareData: PartialEq

Data used for comparison between phase items. If the pipeline id, draw function id, per-instance data buffer dynamic offset and this data matches, the draws can be batched.

Source

type BufferData: GpuArrayBufferable + Sync + Send + 'static

The per-instance data to be inserted into the crate::render_resource::GpuArrayBuffer containing these data for all instances.

Required Methods§

Source

fn get_batch_data( param: &SystemParamItem<'_, '_, Self::Param>, query_item: Entity, ) -> Option<(Self::BufferData, Option<Self::CompareData>)>

Get the per-instance data to be inserted into the crate::render_resource::GpuArrayBuffer. If the instance can be batched, also return the data used for comparison when deciding whether draws can be batched, else return None for the CompareData.

This is only called when building instance data on CPU. In the GPU instance data building path, we use GetFullBatchData::get_index_and_compare_data instead.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§