Skip to content

Commit 39cca41

Browse files
authored
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)`)
1 parent ea42d14 commit 39cca41

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

crates/bevy_render/src/render_resource/batched_uniform_buffer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ impl<T: GpuArrayBufferable> BatchedUniformBuffer<T> {
8989
}
9090

9191
pub fn flush(&mut self) {
92-
self.uniforms.push(self.temp.clone());
92+
self.uniforms.push(&self.temp);
9393

9494
self.current_offset +=
9595
align_to_next(self.temp.size().get(), self.dynamic_offset_alignment as u64) as u32;

crates/bevy_render/src/render_resource/uniform_buffer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,8 @@ impl<T: ShaderType + WriteInto> DynamicUniformBuffer<T> {
227227

228228
/// Push data into the `DynamicUniformBuffer`'s internal vector (residing on system RAM).
229229
#[inline]
230-
pub fn push(&mut self, value: T) -> u32 {
231-
self.scratch.write(&value).unwrap() as u32
230+
pub fn push(&mut self, value: &T) -> u32 {
231+
self.scratch.write(value).unwrap() as u32
232232
}
233233

234234
pub fn set_label(&mut self, label: Option<&str>) {

0 commit comments

Comments
 (0)