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
* when doing a full asset copy (resize), prepare_uniform_buffers() is
  now called on all assets rather than just changed ones. This makes
  sure the staging buffer is large enough.

* 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.

Co-authored-by: François <[email protected]>
  • Loading branch information
rmsc and mockersf committed Mar 3, 2021
1 parent e61d792 commit 69c1bb1
Showing 1 changed file with 9 additions and 1 deletion.
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 @@ -698,6 +700,12 @@ fn asset_render_resources_node_system<T: RenderResources + Asset>(

let resized = uniform_buffer_arrays.resize_buffer_arrays(render_resource_context);
if resized {
// full asset copy needed, make sure there is also space for unchanged assets
for (asset_handle, asset) in assets.iter() {
if !changed_assets.contains_key(&asset_handle) {
uniform_buffer_arrays.prepare_uniform_buffers(asset_handle, asset);
}
}
uniform_buffer_arrays.set_required_staging_buffer_size_to_max()
}
uniform_buffer_arrays.resize_staging_buffer(render_resource_context);
Expand Down

0 comments on commit 69c1bb1

Please sign in to comment.