Skip to content

Commit 4163b84

Browse files
teoxoyjames7132
authored andcommitted
Use uniform buffer usage for SkinnedMeshUniform instead of all usages (bevyengine#4816)
# Objective fixes bevyengine#4811 (caused by bevyengine#4339 [[exact change](https://github.com/bevyengine/bevy/pull/4339/files#diff-4bf3ed03d4129aad9f5678ba19f9b14ee8e3e61d6f6365e82197b01c74468b10R712-R721)] - where the buffer type has been changed from `UniformVec` to `BufferVec`) ## Solution Use uniform buffer usage for `SkinnedMeshUniform` instead of all usages due to the `Default` derive.
1 parent b2ce4d8 commit 4163b84

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

crates/bevy_pbr/src/render/mesh.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -715,11 +715,18 @@ pub fn queue_mesh_bind_group(
715715
// ignoring the rest, whether they're valid for other dynamic offsets or not. This trick may
716716
// be supported later in encase, and then we should make use of it.
717717

718-
#[derive(Default)]
719718
pub struct SkinnedMeshUniform {
720719
pub buffer: BufferVec<Mat4>,
721720
}
722721

722+
impl Default for SkinnedMeshUniform {
723+
fn default() -> Self {
724+
Self {
725+
buffer: BufferVec::new(BufferUsages::UNIFORM),
726+
}
727+
}
728+
}
729+
723730
pub fn prepare_skinned_meshes(
724731
render_device: Res<RenderDevice>,
725732
render_queue: Res<RenderQueue>,

crates/bevy_render/src/render_resource/buffer_vec.rs

+2-11
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,14 @@ pub struct BufferVec<T: Pod> {
1414
buffer_usage: BufferUsages,
1515
}
1616

17-
impl<T: Pod> Default for BufferVec<T> {
18-
fn default() -> Self {
17+
impl<T: Pod> BufferVec<T> {
18+
pub const fn new(buffer_usage: BufferUsages) -> Self {
1919
Self {
2020
values: Vec::new(),
2121
buffer: None,
2222
capacity: 0,
23-
buffer_usage: BufferUsages::all(),
2423
item_size: std::mem::size_of::<T>(),
25-
}
26-
}
27-
}
28-
29-
impl<T: Pod> BufferVec<T> {
30-
pub fn new(buffer_usage: BufferUsages) -> Self {
31-
Self {
3224
buffer_usage,
33-
..Default::default()
3425
}
3526
}
3627

0 commit comments

Comments
 (0)