mirror of
https://github.com/bevyengine/bevy
synced 2024-11-25 22:20:20 +00:00
use biggest RenderResources instead of first (#1208)
This commit is contained in:
parent
4a0837048c
commit
c434f57de1
1 changed files with 18 additions and 2 deletions
|
@ -666,8 +666,24 @@ fn asset_render_resources_node_system<T: RenderResources + Asset>(
|
|||
}
|
||||
|
||||
uniform_buffer_arrays.begin_update();
|
||||
// initialize uniform buffer arrays using the first RenderResources
|
||||
if let Some(asset) = changed_assets.values().next() {
|
||||
// initialize uniform buffer arrays using the largest RenderResources
|
||||
if let Some((asset, _)) = changed_assets
|
||||
.values()
|
||||
.map(|asset| {
|
||||
let size: usize = asset
|
||||
.iter()
|
||||
.filter_map(|render_resource| {
|
||||
if let Some(RenderResourceType::Buffer) = render_resource.resource_type() {
|
||||
render_resource.buffer_byte_len()
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.sum();
|
||||
(asset, size)
|
||||
})
|
||||
.max_by_key(|(_, size)| *size)
|
||||
{
|
||||
uniform_buffer_arrays.initialize(asset, render_resource_context);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue