Skip to content

Commit 476e644

Browse files
authored
Add extra buffer usages field to MeshAllocator (#19546)
Split off from #19058
1 parent 155ebf7 commit 476e644

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

crates/bevy_render/src/mesh/allocator.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ pub struct MeshAllocator {
7878
/// WebGL 2. On this platform, we must give each vertex array its own
7979
/// buffer, because we can't adjust the first vertex when we perform a draw.
8080
general_vertex_slabs_supported: bool,
81+
82+
/// Additional buffer usages to add to any vertex or index buffers created.
83+
pub extra_buffer_usages: BufferUsages,
8184
}
8285

8386
/// Tunable parameters that customize the behavior of the allocator.
@@ -348,6 +351,7 @@ impl FromWorld for MeshAllocator {
348351
mesh_id_to_index_slab: HashMap::default(),
349352
next_slab_id: default(),
350353
general_vertex_slabs_supported,
354+
extra_buffer_usages: BufferUsages::empty(),
351355
}
352356
}
353357
}
@@ -598,7 +602,7 @@ impl MeshAllocator {
598602
buffer_usages_to_str(buffer_usages)
599603
)),
600604
size: len as u64,
601-
usage: buffer_usages | BufferUsages::COPY_DST,
605+
usage: buffer_usages | BufferUsages::COPY_DST | self.extra_buffer_usages,
602606
mapped_at_creation: true,
603607
});
604608
{
@@ -835,7 +839,7 @@ impl MeshAllocator {
835839
buffer_usages_to_str(buffer_usages)
836840
)),
837841
size: slab.current_slot_capacity as u64 * slab.element_layout.slot_size(),
838-
usage: buffer_usages,
842+
usage: buffer_usages | self.extra_buffer_usages,
839843
mapped_at_creation: false,
840844
});
841845

0 commit comments

Comments
 (0)