You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my application, I need to generate a new texture each time in egui update. I found that update_egui_textures_system sometimes takes more than 0.5 seconds to run. Then I located the code that was causing the performance:
pub(crate)fn color_image_as_bevy_image(egui_image:&egui::ColorImage,sampler_descriptor:ImageSampler,) -> Image{let pixels = egui_image
.pixels.iter()// We unmultiply Egui textures to premultiply them later in the fragment shader.// As user textures loaded as Bevy assets are not premultiplied (and there seems to be no// convenient way to convert them to premultiplied ones), we do the this with Egui ones..flat_map(|color| color.to_srgba_unmultiplied()).collect();
...
My guess is to_srgba_unmultiplied is causing the slowdown. Then I replaced it with the crate fast-srgb8, which is x10 times faster!
pub(crate)fn color_image_as_bevy_image(egui_image:&egui::ColorImage,sampler_descriptor:ImageSampler,) -> Image{let pixels = egui_image
.pixels.iter()// We unmultiply Egui textures to premultiply them later in the fragment shader.// As user textures loaded as Bevy assets are not premultiplied (and there seems to be no// convenient way to convert them to premultiplied ones), we do the this with Egui ones..flat_map(|color| fast_srgb8::f32x4_to_srgb8(color.to_normalized_gamma_f32())).collect();
...
I hope it helps if you are having this same problem.
The text was updated successfully, but these errors were encountered:
Hi! Thank you for sharing. I haven't got a chance to test it myself yet. Btw, have you tried running your app in the release mode, or at least compiling dependencies with optimisations?
Hi! Thank you for sharing. I haven't got a chance to test it myself yet. Btw, have you tried running your app in the release mode, or at least compiling dependencies with optimisations?
Will the slowdown still be this significant?
Sorry for not paying attention to this message and replying a bit late.
In my application, I need to generate a new texture each time in egui update. I found that
update_egui_textures_system
sometimes takes more than 0.5 seconds to run. Then I located the code that was causing the performance:My guess is
to_srgba_unmultiplied
is causing the slowdown. Then I replaced it with the cratefast-srgb8
, which is x10 times faster!I hope it helps if you are having this same problem.
The text was updated successfully, but these errors were encountered: