Skip to content

Bad performance when animating #42

@elpiel

Description

@elpiel
  • Version of embedded-graphics-simulator in use (if applicable): 0.3
  • Version of embedded-graphics in use (if applicable): 0.7

Description of the problem/feature request/other

It seems that the simulator has a very bad performance when it comes to doing animation with SDL2.
When I was testing I got ~15 FPS with BinaryColor & 8-9 FPS when using Rgb888 (or Rgb858, I forgot which one).

One way I saw performance gets crippled even more is by using scale > 1.

Another performance bottleneck could be the creation of texture on each Sdl2Window::update call:

simulator/src/window.rs

Lines 249 to 263 in 96e8a36

pub fn update(&mut self, framebuffer: &OutputImage<Rgb888>) {
let Size { width, height } = framebuffer.size();
let texture_creator = self.canvas.texture_creator();
let mut texture = texture_creator
.create_texture_streaming(sdl2::pixels::PixelFormatEnum::RGB24, width, height)
.unwrap();
texture
.update(None, framebuffer.data.as_ref(), width as usize * 3)
.unwrap();
self.canvas.copy(&texture, None, None).unwrap();
self.canvas.present();
}

  • Is there a valid case where the size of the framebuffer might change?
  • Are there any other places which might cause bottlenecks or is it the constant update of the full-display image that's the bottleneck?

Here's an example that can be run to see the performance in FPS with a simple text (for the FPS) and a very small 360p display & BinaryColor:

https://github.com/LechevSpace/embedded-fps/blob/main/examples/embedded_graphics.rs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions