Skip to content

Commit

Permalink
Fix staging buffer required size calculation (fixes bevyengine#1056)
Browse files Browse the repository at this point in the history
* prepare_uniform_buffers() now computes the required uniform buffer
  size over all assets, rather than just changed ones.

* set_required_staging_buffer_size_to_max() now doesn't overwrite the
  value computed by prepare_uniform_buffers() if the resulting size
  would be smaller.
  • Loading branch information
rmsc committed Feb 28, 2021
1 parent bc4fe9b commit 6272383
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,9 @@ where
}
}

self.required_staging_buffer_size = new_size;
if new_size > self.required_staging_buffer_size {
self.required_staging_buffer_size = new_size;
}
}

/// Update the staging buffer to provide enough space to copy data to target buffers.
Expand Down Expand Up @@ -687,8 +689,12 @@ fn asset_render_resources_node_system<T: RenderResources + Asset>(
uniform_buffer_arrays.initialize(asset, render_resource_context);
}

for (asset_handle, asset) in assets.iter() {
// this computes the required staging buffer size and needs to be performed over all assets,
uniform_buffer_arrays.prepare_uniform_buffers(asset_handle, asset);
}

for (asset_handle, asset) in changed_assets.iter() {
uniform_buffer_arrays.prepare_uniform_buffers(*asset_handle, asset);
let mut bindings =
asset_render_resource_bindings.get_or_insert_mut(&Handle::<T>::weak(*asset_handle));
if !setup_uniform_texture_resources::<T>(&asset, render_resource_context, &mut bindings) {
Expand Down

0 comments on commit 6272383

Please sign in to comment.