Add extra buffer usages field to MeshAllocator (#19546)

Split off from https://github.com/bevyengine/bevy/pull/19058
This commit is contained in:
JMS55 2025-06-09 13:03:57 -07:00 committed by GitHub
parent 155ebf7898
commit 476e644a7d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -78,6 +78,9 @@ pub struct MeshAllocator {
/// WebGL 2. On this platform, we must give each vertex array its own
/// buffer, because we can't adjust the first vertex when we perform a draw.
general_vertex_slabs_supported: bool,
/// Additional buffer usages to add to any vertex or index buffers created.
pub extra_buffer_usages: BufferUsages,
}
/// Tunable parameters that customize the behavior of the allocator.
@ -348,6 +351,7 @@ impl FromWorld for MeshAllocator {
mesh_id_to_index_slab: HashMap::default(),
next_slab_id: default(),
general_vertex_slabs_supported,
extra_buffer_usages: BufferUsages::empty(),
}
}
}
@ -598,7 +602,7 @@ impl MeshAllocator {
buffer_usages_to_str(buffer_usages)
)),
size: len as u64,
usage: buffer_usages | BufferUsages::COPY_DST,
usage: buffer_usages | BufferUsages::COPY_DST | self.extra_buffer_usages,
mapped_at_creation: true,
});
{
@ -835,7 +839,7 @@ impl MeshAllocator {
buffer_usages_to_str(buffer_usages)
)),
size: slab.current_slot_capacity as u64 * slab.element_layout.slot_size(),
usage: buffer_usages,
usage: buffer_usages | self.extra_buffer_usages,
mapped_at_creation: false,
});