image:drawBlurred performances on device

Hello,
I want to gradually (and mysteriously) make an animation appear on the screen.

The animation is made from several full screen images (400x240).
For this I use image:drawBlurred, and I decrease the radius slightly with each frame.
I'm quite satisfied with the effect.

Unfortunately, I noticed on a video made by a user (I'm still not sure, because I don't have a device to test) that I might be expecting too much from the hardware: I see big fps drops.

image:drawBlurred (in one pass) doesn't seem fast enough to run on a full screen image at 30fps

I've tried doing image:blurredImage on smaller images (200x120) and then image:drawScaled(2) them, but, at least in the simulator, it still seems to take a lot of % of the sampler.

I can't pre-calculate the output because there are too many possible radiuses and images.

Am I missing something, or is there room for optimizations?
In lua, creating my own algorithm seems out of reach, because drawPixel(p) for all pixels (400 x 240) is already taking too long (at least on simulator).

I profiled the code and noticed a big hotspot where it was accessing the image data in a way that's very unfriendly to the L1 cache. I changed things around a bit and now it's running almost 4x faster. :flushed: My test was calling drawBlurred() on a full-screen image, radius=10 and passes=2. Before the fix I was getting around 3 FPS, now it's up to 11.

We won't be able to get this into the 1.12 release, but it should land in the next update after that.

2 Likes

Awesome, thank you !

Since this previous post, to get the fps slightly better, I am now displaying a half resolution image, with a reduced scale (playdate.display.setScale(2)).
While the performances are better (at the cost of a downgraded image, but this is somehow my goal, anyway), I think it is still not prefect.
With your fix, I should be able to get the 30fps.
Cool ! thanks again.

Note: For information, the silly app is : Playroll for Playdate by PacoLabs

Hi,
If the fix available yet ?
I cannot see anything related in the releases notes.
Thank you.

the MR has been merged to main, so it'll be in the next release

1 Like