mirror of
https://github.com/bevyengine/bevy
synced 2024-11-22 04:33:37 +00:00
Make DynamicUniformBuffer::push
accept an &T
instead of T
(#11373)
# Objective - `DynamicUniformBuffer::push` takes an owned `T` but only uses a shared reference to it - This in turn requires users of `DynamicUniformBuffer::push` to potentially unecessarily clone data ## Solution - Have `DynamicUniformBuffer::push` take a shared reference to `T` --- ## Changelog - `DynamicUniformBuffer::push` now takes a `&T` instead of `T` ## Migration Guide - Users of `DynamicUniformBuffer::push` now need to pass references to `DynamicUniformBuffer::push` (e.g. existing `uniforms.push(value)` will now become `uniforms.push(&value)`)
This commit is contained in:
parent
ea42d14344
commit
39cca41f3f
2 changed files with 3 additions and 3 deletions
|
@ -89,7 +89,7 @@ impl<T: GpuArrayBufferable> BatchedUniformBuffer<T> {
|
|||
}
|
||||
|
||||
pub fn flush(&mut self) {
|
||||
self.uniforms.push(self.temp.clone());
|
||||
self.uniforms.push(&self.temp);
|
||||
|
||||
self.current_offset +=
|
||||
align_to_next(self.temp.size().get(), self.dynamic_offset_alignment as u64) as u32;
|
||||
|
|
|
@ -227,8 +227,8 @@ impl<T: ShaderType + WriteInto> DynamicUniformBuffer<T> {
|
|||
|
||||
/// Push data into the `DynamicUniformBuffer`'s internal vector (residing on system RAM).
|
||||
#[inline]
|
||||
pub fn push(&mut self, value: T) -> u32 {
|
||||
self.scratch.write(&value).unwrap() as u32
|
||||
pub fn push(&mut self, value: &T) -> u32 {
|
||||
self.scratch.write(value).unwrap() as u32
|
||||
}
|
||||
|
||||
pub fn set_label(&mut self, label: Option<&str>) {
|
||||
|
|
Loading…
Reference in a new issue