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

Speedup RGB565 rendering #7774

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ogoffart
Copy link
Member

@ogoffart ogoffart commented Mar 1, 2025

By not going through a RGB888 premultiplied color, but using a special encoded format for premultiplied color so we can operate on all color at once in a u32

Unfortunately, this is a breaking change as it changes the TargetPixel trait.

By not going throug a RGB888 premultiplied color, but using a special
encoded format for premultiplied color so we can operate on all color at
once in a u32
@ogoffart ogoffart added the breaking change Anything that probably require a semver bump label Mar 1, 2025
@ogoffart ogoffart requested a review from tronical March 1, 2025 19:35
@ogoffart
Copy link
Member Author

ogoffart commented Mar 1, 2025

Result of cargo bench -p printerdemo_mcu (with the memory mesure remoced)

Before

Timer precision: 73 ns
bench                fastest       │ slowest       │ median        │ mean          │ samples │ iters
├─ full                            │               │               │               │         │
│  ├─ Rgb565Pixel    2.281 ms      │ 4.479 ms      │ 3.244 ms      │ 3.251 ms      │ 100     │ 100
│  ╰─ Rgb<u8>        4.939 ms      │ 7.232 ms      │ 6.029 ms      │ 6.032 ms      │ 100     │ 100
╰─ render_only                     │               │               │               │         │
   ├─ Rgb565Pixel                  │               │               │               │         │
   │  ├─ FullBuffer  1.096 ms      │ 1.287 ms      │ 1.168 ms      │ 1.177 ms      │ 100     │ 100
   │  ╰─ LineByLine  1.085 ms      │ 1.297 ms      │ 1.191 ms      │ 1.189 ms      │ 100     │ 100
   ╰─ Rgb<u8>                      │               │               │               │         │
      ├─ FullBuffer  1.432 ms      │ 1.826 ms      │ 1.554 ms      │ 1.558 ms      │ 100     │ 100
      ╰─ LineByLine  1.478 ms      │ 1.818 ms      │ 1.573 ms      │ 1.594 ms      │ 100     │ 100

With this change

Timer precision: 49 ns
bench                fastest       │ slowest       │ median        │ mean          │ samples │ iters
├─ full                            │               │               │               │         │
│  ├─ Rgb565Pixel    1.989 ms      │ 4.086 ms      │ 2.932 ms      │ 2.972 ms      │ 100     │ 100
│  ╰─ Rgb<u8>        4.62 ms       │ 8.459 ms      │ 5.441 ms      │ 5.555 ms      │ 100     │ 100
╰─ render_only                     │               │               │               │         │
   ├─ Rgb565Pixel                  │               │               │               │         │
   │  ├─ FullBuffer  859.6 µs      │ 1.023 ms      │ 917.9 µs      │ 925.1 µs      │ 100     │ 100
   │  ╰─ LineByLine  828.9 µs      │ 1.048 ms      │ 941.3 µs      │ 956.4 µs      │ 100     │ 100
   ╰─ Rgb<u8>                      │               │               │               │         │
      ├─ FullBuffer  1.336 ms      │ 1.593 ms      │ 1.441 ms      │ 1.445 ms      │ 100     │ 100
      ╰─ LineByLine  1.392 ms      │ 1.618 ms      │ 1.517 ms      │ 1.496 ms      │ 100     │ 100

I don't understand why this also improve the RGB8 benchmark

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change Anything that probably require a semver bump
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant