From 2d8b895841ab0fdb2408b6cfa3781f294c894897 Mon Sep 17 00:00:00 2001 From: alphafetus Date: Sat, 8 Aug 2026 13:47:23 -0400 Subject: [PATCH] chore: check number of instances before mapping to new type --- src/common/render_batch.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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(),