Skip to content

Commit

Permalink
Fix 3D rendering if there's a single tile
Browse files Browse the repository at this point in the history
  • Loading branch information
mkeeter committed Mar 24, 2024
1 parent 82c75f5 commit ebc0e3d
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions fidget/src/render/render3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ pub fn render<S: Shape>(
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()));

Expand Down Expand Up @@ -455,3 +456,25 @@ pub fn render<S: Shape>(
}
(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());
}
}

0 comments on commit ebc0e3d

Please sign in to comment.