Astrabit-ST / Luminol

An RPG Maker XP-VX Ace rewrite, written in Rust with love 💕
https://luminol.dev/
GNU General Public License v3.0
95 stars 11 forks source link

Rayon tesselation #136

Closed Speak2Erase closed 2 days ago

Speak2Erase commented 4 days ago

What's the issue? Please describe. egui supports multi-threaded tesselation via Rayon. (Rayon also supports being run via web workers.) We should look into seeing if this would improve performance!

Describe the solution you'd like We enable egui's rayon feature and use wasm_bindgen_rayon on wasm32 to enable it there too. Obviously we'd need to see if this would have a performance uplift before enabling it.

Tests Turning the tile id preview would be a pretty decent test as that involves drawing a significant amount of text.

white-axe commented 4 days ago

Maybe it would improve performance in the case of drawing tile IDs on a very large, zoomed out map, but we don't use tessellation for our custom shaders and egui skips tessellation by default for most things that are not visible onscreen. I'll make a branch for testing this though.

white-axe commented 2 days ago

After looking at the tessellation code more closely, it seems parallel tessellation is disabled for performance reasons except for when drawing egui::Shape::Path with more than 32 points, Bézier curves, ellipses and egui::Shape::Vec. The egui documentation doesn't recommend using that last one.

https://github.com/emilk/egui/blob/0.27.2/crates/epaint/src/tessellator.rs#L1862-L1881

I don't think we use any of these so enabling parallel tessellation is completely useless.

I still have a branch where I enabled rayon tessellation anyways just for testing purposes, or in case we need rayon for some other reason.