From ebc0e3deed409ffc14eb06b5760e0e32722d7084 Mon Sep 17 00:00:00 2001 From: Matt Keeter Date: Sun, 24 Mar 2024 18:31:23 -0400 Subject: [PATCH] Fix 3D rendering if there's a single tile --- fidget/src/render/render3d.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/fidget/src/render/render3d.rs b/fidget/src/render/render3d.rs index 409ae19e..0a118c48 100644 --- a/fidget/src/render/render3d.rs +++ b/fidget/src/render/render3d.rs @@ -404,6 +404,7 @@ pub fn render( for ts in tiles.chunks(tiles_per_thread) { tile_queues.push(Queue::new(ts.to_vec())); } + tile_queues.resize_with(config.threads, || Queue::new(vec![])); let i_tape = Arc::new(shape.interval_tape(Default::default())); @@ -455,3 +456,25 @@ pub fn render( } (image_depth, image_color) } + +#[cfg(test)] +mod test { + use super::*; + use crate::{eval::MathShape, vm::VmShape, Context}; + + /// Make sure we don't crash if there's only a single tile + #[test] + fn test_tile_queues() { + let mut ctx = Context::new(); + let x = ctx.x(); + let shape = VmShape::new(&ctx, x).unwrap(); + + let cfg = RenderConfig::<3> { + image_size: 128, // very small! + threads: 8, + ..RenderConfig::default() + }; + let out = cfg.run(shape); + assert!(out.is_ok()); + } +}