Trait GetFullBatchData

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

    // Required methods
    fn get_binned_batch_data(
        param: &SystemParamItem<'_, '_, Self::Param>,
        query_item: MainEntity,
    ) -> Option<Self::BufferData>;
    fn get_index_and_compare_data(
        param: &SystemParamItem<'_, '_, Self::Param>,
        query_item: MainEntity,
    ) -> Option<(NonMaxU32, Option<Self::CompareData>)>;
    fn get_binned_index(
        param: &SystemParamItem<'_, '_, Self::Param>,
        query_item: MainEntity,
    ) -> Option<NonMaxU32>;
    fn write_batch_indirect_parameters_metadata(
        indexed: bool,
        base_output_index: u32,
        batch_set_index: Option<NonMaxU32>,
        indirect_parameters_buffers: &mut UntypedPhaseIndirectParametersBuffers,
        indirect_parameters_offset: u32,
    );
}
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§

Source

type BufferInputData: Pod + Default + Sync + Send

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

Required Methods§

Source

fn get_binned_batch_data( param: &SystemParamItem<'_, '_, Self::Param>, query_item: MainEntity, ) -> 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.

Source

fn get_index_and_compare_data( param: &SystemParamItem<'_, '_, Self::Param>, query_item: MainEntity, ) -> 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.

Source

fn get_binned_index( param: &SystemParamItem<'_, '_, Self::Param>, query_item: MainEntity, ) -> Option<NonMaxU32>

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.

This function is currently only called for unbatchable entities when GPU instance buffer building is in use. For batchable entities, the uniform index is written during queuing (e.g. in queue_material_meshes). In the case of CPU instance buffer building, the CPU writes the uniforms, so there’s no index to return.

Source

fn write_batch_indirect_parameters_metadata( indexed: bool, base_output_index: u32, batch_set_index: Option<NonMaxU32>, indirect_parameters_buffers: &mut UntypedPhaseIndirectParametersBuffers, indirect_parameters_offset: u32, )

Writes the gpu_preprocessing::IndirectParametersGpuMetadata necessary to draw this batch into the given metadata buffer at the given index.

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

  • indexed is true if the mesh is indexed or false if it’s non-indexed.

  • base_output_index is the index of the first mesh instance in this batch in the MeshUniform output buffer.

  • batch_set_index is the index of the batch set in the gpu_preprocessing::IndirectBatchSet buffer, if this batch belongs to a batch set.

  • indirect_parameters_buffers is the buffer in which to write the metadata.

  • indirect_parameters_offset is the index in that buffer at which to write the metadata.

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§