mirror of
https://github.com/bevyengine/bevy
synced 2024-11-22 20:53:53 +00:00
bevy_render: Batch insertion for prepare_uniform_components (#4179)
# Objective - Make insertion of uniform components faster ## Solution - Use batch insertion in the prepare_uniform_components system - Improves `many_cubes -- sphere` from ~42fps to ~43fps Co-authored-by: François <mockersf@gmail.com>
This commit is contained in:
parent
5af746457e
commit
0e821da704
1 changed files with 13 additions and 8 deletions
|
@ -111,14 +111,19 @@ fn prepare_uniform_components<C: Component>(
|
|||
C: AsStd140 + Clone,
|
||||
{
|
||||
component_uniforms.uniforms.clear();
|
||||
for (entity, component) in components.iter() {
|
||||
commands
|
||||
.get_or_spawn(entity)
|
||||
.insert(DynamicUniformIndex::<C> {
|
||||
index: component_uniforms.uniforms.push(component.clone()),
|
||||
marker: PhantomData,
|
||||
});
|
||||
}
|
||||
let entities = components
|
||||
.iter()
|
||||
.map(|(entity, component)| {
|
||||
(
|
||||
entity,
|
||||
(DynamicUniformIndex::<C> {
|
||||
index: component_uniforms.uniforms.push(component.clone()),
|
||||
marker: PhantomData,
|
||||
},),
|
||||
)
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
commands.insert_or_spawn_batch(entities);
|
||||
|
||||
component_uniforms
|
||||
.uniforms
|
||||
|
|
Loading…
Reference in a new issue