Skip to content

Add extra buffer usages field to MeshAllocator #19546

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 9, 2025
Merged
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
8 changes: 6 additions & 2 deletions crates/bevy_render/src/mesh/allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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(),
}
}
}
Expand Down Expand Up @@ -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,
});
{
Expand Down Expand Up @@ -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,
});

Expand Down