slightly more cleanup
diff --git a/sparse_strips/vello_bench/src/tile.rs b/sparse_strips/vello_bench/src/tile.rs index cf7cbe6..280fcd3 100644 --- a/sparse_strips/vello_bench/src/tile.rs +++ b/sparse_strips/vello_bench/src/tile.rs
@@ -2,28 +2,38 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT use crate::data::get_data_items; -use criterion::Criterion; +use criterion::{BenchmarkId, Criterion}; +use vello_common::flatten::Line; use vello_common::tile::Tiles; use vello_cpu::Level; -pub fn tile(c: &mut Criterion) { - let mut g = c.benchmark_group("tile"); +fn run_tile_benchmark<F>(c: &mut Criterion, group_name: &str, op: F) +where + F: Fn(&mut Tiles, &[Line], u16, u16) + Copy, +{ + let mut g = c.benchmark_group(group_name); g.sample_size(50); - macro_rules! tile_single { - ($item:expr) => { - let lines = $item.lines(); - - g.bench_function($item.name.clone(), |b| { - b.iter(|| { - let mut tiler = Tiles::new(Level::new()); - tiler.make_tiles_analytic_aa(&lines, $item.width, $item.height); - }) - }); - }; - } - for item in get_data_items() { - tile_single!(item); + let lines = item.lines(); + g.bench_with_input(BenchmarkId::from_parameter(&item.name), &item, |b, item| { + b.iter(|| { + let mut tiler = Tiles::new(Level::new()); + op(&mut tiler, &lines, item.width, item.height); + }); + }); + } + g.finish(); +} + +pub fn tile(c: &mut Criterion) { + #[expect(clippy::type_complexity, reason = "tiler variants")] + let methods: &[(&str, fn(&mut Tiles, &[Line], u16, u16))] = &[ + ("tile_aaa", |t, l, w, h| t.make_tiles_analytic_aa(l, w, h)), + ("tile_msaa", |t, l, w, h| t.make_tiles_msaa(l, w, h)), + ]; + + for (name, op) in methods { + run_tile_benchmark(c, name, *op); } }
diff --git a/sparse_strips/vello_common/src/tile.rs b/sparse_strips/vello_common/src/tile.rs index b35745b..b93a45b 100644 --- a/sparse_strips/vello_common/src/tile.rs +++ b/sparse_strips/vello_common/src/tile.rs
@@ -11,15 +11,15 @@ use peniko::kurbo::common::FloatFuncs as _; /// T-op bit -const T: u32 = 1 << 0; +const T: u32 = 0b00001; /// B-ottom bit -const B: u32 = 1 << 1; +const B: u32 = 0b00010; /// L-eft bit -const L: u32 = 1 << 2; +const L: u32 = 0b00100; /// R-ight bit -const R: u32 = 1 << 3; +const R: u32 = 0b01000; /// W-inding bit -const W: u32 = 1 << 4; +const W: u32 = 0b10000; /// Shift amount corresponding to the bottom bit. const BOT_SHIFT: u32 = B.trailing_zeros();