Trait bevy_render::batching::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.

Object Safety§

This trait is not object safe.

Implementors§