Trait bevy::render::batching::GetFullBatchData

pub trait GetFullBatchData: GetBatchData {
    type BufferInputData: Pod + Sync + Send;

    // Required methods
    fn get_binned_batch_data(
        param: &<Self::Param as SystemParam>::Item<'_, '_>,
        query_item: Entity
    ) -> Option<Self::BufferData>;
    fn get_index_and_compare_data(
        param: &<Self::Param as SystemParam>::Item<'_, '_>,
        query_item: Entity
    ) -> Option<(NonMaxU32, Option<Self::CompareData>)>;
    fn get_binned_index(
        param: &<Self::Param as SystemParam>::Item<'_, '_>,
        query_item: Entity
    ) -> Option<NonMaxU32>;
    fn get_batch_indirect_parameters_index(
        param: &<Self::Param as SystemParam>::Item<'_, '_>,
        indirect_parameters_buffer: &mut IndirectParametersBuffer,
        entity: Entity,
        instance_index: u32
    ) -> Option<NonMaxU32>;
}
Expand description

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

This version allows for binning and GPU preprocessing.

Required Associated Types§

type BufferInputData: Pod + Sync + Send

The per-instance data that was inserted into the crate::render_resource::BufferVec during extraction.

Required Methods§

fn get_binned_batch_data( param: &<Self::Param as SystemParam>::Item<'_, '_>, query_item: Entity ) -> Option<Self::BufferData>

Get the per-instance data to be inserted into the crate::render_resource::GpuArrayBuffer.

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

fn get_index_and_compare_data( param: &<Self::Param as SystemParam>::Item<'_, '_>, query_item: Entity ) -> Option<(NonMaxU32, Option<Self::CompareData>)>

Returns the index of the GetFullBatchData::BufferInputData that the GPU preprocessing phase will use.

We already inserted the GetFullBatchData::BufferInputData during the extraction phase before we got here, so this function shouldn’t need to look up any render data. If CPU instance buffer building is in use, this function will never be called.

fn get_binned_index( param: &<Self::Param as SystemParam>::Item<'_, '_>, query_item: Entity ) -> Option<NonMaxU32>

Returns the index of the GetFullBatchData::BufferInputData that the GPU preprocessing phase will use, for the binning path.

We already inserted the GetFullBatchData::BufferInputData during the extraction phase before we got here, so this function shouldn’t need to look up any render data. If CPU instance buffer building is in use, this function will never be called.

fn get_batch_indirect_parameters_index( param: &<Self::Param as SystemParam>::Item<'_, '_>, indirect_parameters_buffer: &mut IndirectParametersBuffer, entity: Entity, instance_index: u32 ) -> Option<NonMaxU32>

Pushes gpu_preprocessing::IndirectParameters necessary to draw this batch onto the given IndirectParametersBuffer, and returns its index.

This is only used if GPU culling is enabled (which requires GPU preprocessing).

Object Safety§

This trait is not object safe.

Implementors§