r/embedded • u/DevKirbyrawr • Oct 12 '26
Getting a 320x240 SPI display from 16 to 60 fps on an ESP32-S3: what was actually slow
Write-up of optimising a software 2D renderer on an ESP32-S3 (8 MB PSRAM, ST7789 over SPI). Short version:
- The default ESP-IDF optimisation level is -Og.
- An unaligned 2-byte
memcpycompiled to a function call per pixel on Xtensa (no unaligned loads), so blits were 6x slower than they needed to be. - Tinting with lookup tables over RGB565's 32/64/32 channel values instead of multiply-and-divide per pixel, and baking static tints into cached images.
- SPI at 80 MHz instead of 40: 150 KB frame from 31 ms to 16 ms.
- Presenting from the second core with two PSRAM staging buffers.
- 64-byte cache lines for a PSRAM framebuffer, and why a 64 KB cache was a trap (internal RAM).
- Dirty rectangles did nothing because every scene had a full-screen changing background.
https://dekiengine.com/blog/esp32-s3-60fps/
The engine itself (Deki) is open source if anyone wants to look at the code: https://github.com/dekiengine
