bevyengine/bevy · error
Allocation didn't exist or was already prepared
Error message
Allocation didn't exist or was already prepared
What it means
Panic in MaterialBindGroupAllocator::prepare_bind_groups: an unprepared bind group listed in to_prepare had no pending allocation entry (already prepared or never allocated). Indicates allocator state bookkeeping corruption; normally unreachable.
Source
Thrown at crates/bevy_render/src/material_bind_groups.rs:2487
/// [`Self::allocate_unprepared`]. Such bind groups will defer being
/// prepared until the next time this method is called.
fn prepare_bind_groups(
&mut self,
render_device: &RenderDevice,
pipeline_cache: &PipelineCache,
fallback_buffer: &FallbackBuffer,
shader_buffer_assets: &RenderAssets<GpuShaderBuffer>,
changed_shader_buffers: &RenderChangedShaderBuffers,
) {
self.invalidate_bind_group_for_changed_shader_buffers_if_needed(changed_shader_buffers);
for bind_group_index in mem::take(&mut self.to_prepare) {
let Some(MaterialNonBindlessAllocatedBindGroup::Unprepared {
bind_group: unprepared_bind_group,
layout: bind_group_layout,
}) = mem::take(&mut self.bind_groups[*bind_group_index as usize])
else {
panic!("Allocation didn't exist or was already prepared");
};
// Pack any `Data` into uniform buffers.
let mut uniform_buffers = vec![];
for (index, binding) in unprepared_bind_group.binding_resources.iter() {
let UnpreparedBindingResource::Data(ref data_range) = *binding else {
continue;
};
let label = format!("material uniform data {}", *index);
let uniform_buffer = render_device.create_buffer_with_data(&BufferInitDescriptor {
label: Some(&label),
contents: &unprepared_bind_group.data_buffer
[(data_range.start as usize)..(data_range.end as usize)],
usage: BufferUsages::COPY_DST | BufferUsages::UNIFORM,
});
uniform_buffers.push(uniform_buffer);
}
View on GitHub (pinned to 396ca72708)
Solutions
- Report as a Bevy engine bug with a reproducing project
- Avoid custom sequences that prepare the same material bind group twice
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at crates/bevy_render/src/material_bind_groups.rs:2487 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of bevyengine/bevy@396ca72708 (2026-08-20).
Data as JSON: /api/errors/904b557c9cb5a3bb.
Report an issue: GitHub.