Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase performance of frame buffer sprites #3516

Open
Dakkaron opened this issue Oct 19, 2024 · 0 comments
Open

Increase performance of frame buffer sprites #3516

Dakkaron opened this issue Oct 19, 2024 · 0 comments

Comments

@Dakkaron
Copy link

Currently, when using a sprite as frame buffer and pushing it to the display using .pushSprite() the performance is quite low.

I'm currently using a 320x240 24-bit color display and a 16-bit color sprite as a frame buffer and I get ~15fps when just pushing the empty frame buffer sprite to the display.

I have a proposal that should speed up this push by quite a bit while not consuming that much memory.

  • Create a frame buffer option on the sprite class that can be enabled either via constructor or via setter method.
  • If the frame buffer is enabled, a change detection buffer is added with 1 bit for every 16 pixels (or maybe 8 or 32, and probably user-configurable). So each line is split into 16-pixel-slices. For my 320x240px display, that would cost 432 bytes (compared to ~108kb for the sprite's pixel buffer).
  • Whenever anything that is written to the sprite that affects one of the pixels in a 16-pixel-slice, the bit corresponding to that slice will be set to 1.
  • Whenever .pushSprite() is called on that framebuffer sprite, only the 16-pixel-slices with changes in them will be pushed.

The best amount of pixels in a slice will probably need to be determined by actual testing, since I don't know how many cycles are used by the .setWindow() method, which will be required to be called once for each slice.

Another optimisation would be to figure out beforehand how many contiguous slices need to be pushed and only calling .setWindow() once for all contiguous slices.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant