AEFeinstein / Super-2024-Swadge-FW

Firmware for the Super Magfest 2024 Swadge
https://adam.feinste.in/Super-2024-Swadge-FW/
MIT License
11 stars 9 forks source link

Unify framebuffer location #126

Closed cnlohr closed 2 months ago

cnlohr commented 10 months ago

This is a long-term concern. Nothing needed immediately.

It is a not-insignificant perf hit to call getPxTftFramebuffer or to reach into and get a global pixel register value. However, using file-static variables are fast.

It would be really good if we could avoid the function call, or global read.

I was seeing ~10% perf boosts on the flight sim by making these changes.

AEFeinstein commented 10 months ago

The framebuffer is malloc'd rather than being file static. I think if you want to static it, we'll also need to steal some memory from the heap in the linker.

if (NULL == pixels)
{
    pixels = (paletteColor_t*)malloc(sizeof(paletteColor_t) * TFT_HEIGHT * TFT_WIDTH);
}
cnlohr commented 10 months ago

No need to static it or not - its getting access to the pointer that's the hard/slow part. Making a project-global variable takes an inordinate amount of time to load at the beginning of the function.

AEFeinstein commented 10 months ago

OK. If it's really that easy and impacts flightsim, do it in that branch?

cnlohr commented 10 months ago

Good to have a discussion on - I am doing it where it counts most for flightsim, but could improve wsg timing as well.

AEFeinstein commented 10 months ago

Is there any downside?

AEFeinstein commented 2 months ago

Closing until we need the perf boost.