diff --git a/src/common/render_batch.rs b/src/common/render_batch.rs index 94c8989..199145b 100644 --- a/src/common/render_batch.rs +++ b/src/common/render_batch.rs @@ -24,6 +24,11 @@ impl RenderBatch { .filter_map(|(id, mesh)| { let instances = instance_registry.get_instances_for(id); + if instances.is_empty() { + // A buffer with zero size breaks the rendering pipeline, plus there's no point + return None; + } + let gpu_instances = instances.iter() .cloned() .map(|instance| { @@ -31,10 +36,6 @@ impl RenderBatch { }) .collect::>(); - if gpu_instances.is_empty() { - return None; - } - // Build instances into a RenderBatch let instance_buffer = Buffer::from_iter( allocator.clone(),