Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions crates/bevy_render/src/render_resource/uniform_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ impl<T: ShaderType> Default for DynamicUniformBuffer<T> {
}
}

impl<T: ShaderType + WriteInto> DynamicUniformBuffer<T> {
impl<T: ShaderType> DynamicUniformBuffer<T> {
pub fn new_with_alignment(alignment: u64) -> Self {
Self {
scratch: DynamicUniformBufferWrapper::new_with_alignment(Vec::new(), alignment),
Expand Down Expand Up @@ -226,12 +226,6 @@ impl<T: ShaderType + WriteInto> DynamicUniformBuffer<T> {
self.scratch.as_ref().is_empty()
}

/// 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 set_label(&mut self, label: Option<&str>) {
let label = label.map(str::to_string);

Expand Down Expand Up @@ -353,6 +347,14 @@ impl<T: ShaderType + WriteInto> DynamicUniformBuffer<T> {
}
}

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
}
}

/// A writer that can be used to directly write elements into the target buffer.
///
/// For more information, see [`DynamicUniformBuffer::get_writer`].
Expand Down
9 changes: 6 additions & 3 deletions crates/bevy_render/src/uniform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,12 @@ impl<C: Component + ShaderType> ComponentUniforms<C> {

impl<C: Component + ShaderType> Default for ComponentUniforms<C> {
fn default() -> Self {
Self {
uniforms: Default::default(),
}
let mut uniforms = DynamicUniformBuffer::default();
uniforms.set_label(Some(&format!(
"{} ComponentUniforms buffer",
core::any::type_name::<C>()
)));
Self { uniforms }
}
}

Expand Down