minedmap: add support for parallel processing

For now, only RegionProcessor and TileMipmapper are run in parallel.
This commit is contained in:
Matthias Schiffer 2023-08-14 15:48:05 +02:00
parent c1260a63b5
commit 78fe1ec50e
Signed by: neocturne
GPG key ID: 16EF3F64CB201D9C
6 changed files with 191 additions and 11 deletions

View file

@ -1,4 +1,5 @@
use anyhow::{Context, Result};
use rayon::prelude::*;
use minedmap::{io::fs, types::*};
@ -151,8 +152,8 @@ impl<'a> TileMipmapper<'a> {
let next = Self::map_coords(prev);
for (&z, xs) in &next.0 {
for &x in xs {
next.0.par_iter().try_for_each(|(&z, xs)| {
xs.par_iter().try_for_each(|&x| {
let coords = TileCoords { x, z };
self.render_mipmap::<image::Rgba<u8>>(TileKind::Map, level, coords, prev)?;
self.render_mipmap::<image::LumaA<u8>>(
@ -161,8 +162,9 @@ impl<'a> TileMipmapper<'a> {
coords,
prev,
)?;
}
}
anyhow::Ok(())
})
})?;
tile_stack.push(next);
}