Ch 14 Deferred Rendering code very slow on iOS

Hi, first of all: excellent book, I’m enjoying every bit of it.

I’ve made it to the Multipass & Deferred Rendering chapter, followed the tutorial and managed to get the final code up and running without issues on a Mac. But when I tried to run it on an iOS device, the performance is awful (10 fps on an iPhone X and 5 fps on an iPad Air 2), when the same code runs smooth at 60fps on a MacBook Pro.

I’ve also tried Apple’s Deferred Lighting sample code and it works fine both on macOS and iOS (60 fps on both). So I think maybe there’s a bug somewhere in the book’s sample code that it’s causing this low fps on iOS devices. Any ideas?

Thanks!

@orle we’re really happy that you like the book :blush:

Did you try lowering the number of lights on iOS? I cannot remember with certainty but I think their sample code used less lights than we did.

Hi Marius,

Yes, I’ve tried with only 10 lights, and I’m getting 13 fps on an iPad Air 2.

After messing around with the debugger, I’ve found that the Composition Pass seems to be the culprit, since it’s taking 78 ms to process.

In the composition_frag shader function, the compositeLighting function is taking 50%, in particular the

Light light = lights[i];

inside the loop is taking up 43%

Imgur

Imgur

Imgur

Also, the texture sampling seems to be taking too long (32ms):

Imgur

This happens only on iOS. On the mac it works fine.

@orle I am not seeing any performance issue on my iPhone or iPad. do you have a newer device to try on? iPad Air 2 is 5 years old and has been discontinued a couple of years ago.

Ok, I’ve tried on my iPhone X and it can reach 60fps stable with 15 lights. The iPad Air 2 is clearly very old hardware…

I didn’t expect so much difference in performance between the iPhone X and the Macbook Pro (I can get 60fps with 60 lights on the mac). I expected the iPhone X GPU to be almost as powerful as the discrete one on the mac, but obviously it’s not :grinning:

Thanks a lot for your help!

I believe the mobile GPU will get more and more powerful but it’ll take another few years :slight_smile: