pub trait RenderDataBundleStorageTrait {
// Required methods
fn push_triangles(
&mut self,
layout: &[VertexAttributeDescriptor],
material: &MaterialResource,
render_path: RenderPath,
sort_index: u64,
node_handle: Handle<Node>,
func: &mut dyn FnMut(VertexBufferRefMut<'_>, TriangleBufferRefMut<'_>),
);
fn push(
&mut self,
data: &SurfaceResource,
material: &MaterialResource,
render_path: RenderPath,
sort_index: u64,
instance_data: SurfaceInstanceData,
);
}
Expand description
A trait for an entity that can collect render data.
Required Methods§
Sourcefn push_triangles(
&mut self,
layout: &[VertexAttributeDescriptor],
material: &MaterialResource,
render_path: RenderPath,
sort_index: u64,
node_handle: Handle<Node>,
func: &mut dyn FnMut(VertexBufferRefMut<'_>, TriangleBufferRefMut<'_>),
)
fn push_triangles( &mut self, layout: &[VertexAttributeDescriptor], material: &MaterialResource, render_path: RenderPath, sort_index: u64, node_handle: Handle<Node>, func: &mut dyn FnMut(VertexBufferRefMut<'_>, TriangleBufferRefMut<'_>), )
Adds a new mesh to the bundle storage using the given set of vertices and triangles. This method automatically creates a render bundle according to a hash of the following parameters:
- Material
- Vertex Type
- Render Path
If one of these parameters is different, then a new bundle will be created and used to store the given vertices and indices. If an appropriate bundle exists, the method will store the given vertices and the triangles in it.
§When to use
This method is used to reduce amount of draw calls of underlying GAPI, by merging small portions of data into one big block that shares drawing parameters and can be rendered in a single draw call. The vertices in this case should be pre-processed by applying world transform to them. This is so-called dynamic batching.
Do not use this method if you have a mesh with lots of vertices and triangles, because pre-processing them on CPU could take more time than rendering them directly on GPU one-by-one.
Sourcefn push(
&mut self,
data: &SurfaceResource,
material: &MaterialResource,
render_path: RenderPath,
sort_index: u64,
instance_data: SurfaceInstanceData,
)
fn push( &mut self, data: &SurfaceResource, material: &MaterialResource, render_path: RenderPath, sort_index: u64, instance_data: SurfaceInstanceData, )
Adds a new surface instance to the storage. The method will automatically put the instance in the appropriate bundle. Bundle selection is done using the material, surface data, render path. If only one of these parameters is different, then the surface instance will be put in a separate bundle.