Hey, friends!
I’d like to show you some fast results of benchmarking briefly three most popular Stage3D frameworks for the 2D rendering:
Starling, ND2D, Genome2D.
I got latest available builds (and sources) of those frameworks and written a simple AIR app with some amount of images moving, rotating, scaling, and changing alpha on every frame.
Images were placed across whole stage within several iterations (adding fixed images amount on every frame until we reach fixed maximum).
All images had the same texture – small 25 by 25 box with a bit of alpha channel.
I tested that app on my PC and on two mobile devices – iPad1 with iOS 5.0.1 and GalaxyTab 10.1 with Android 3.1.
So, this is a results I got:
Starling from GitHub Commit:9aa93a8195c47252253fd4d2b671115e19d16b6f, 24.03.2012:
iPad 1:
1350 images at 30 FPS
RAM: 6.4 MB
GalaxyTab 10.1 (OC 1.4GHz):
1350 images at 30 FPS
RAM: 6.2 MB
PC (i7 4.8 GHz, Radeon 6790):
10000 images at 30 FPS
RAM: 19.7 MB
RAM with 1000 images: 9.1 MB
Starling is a really nice open source framework. It mimics classic DisplayList, have a huge community (thanks to Adobe) and very detailed API reference. Thus it’s really easy to learn and contribute.
ND2D from GitHub Commit:453531f7aee46b00a112c6f0d5d8b46d62075287, 05.03.2012:
This framework has two different “modes” for the effective massive sprites rendering – using Sprite2DCloud or Sprite2DBatch as Sprites container. I tested both.
Sprite2DCloud:
iPad 1:
~1150 images at 30 FPS
RAM: 6.4 MB
GalaxyTab 10.1 (OC 1.4GHz):
~1150 images at 30 FPS
RAM: 6.2 MB
PC (i7 4.8 GHz, Radeon 6790):
16000 images at 30 FPS with drop to 16 FPS while adding images (100 images per frame), you’ll be fine adding all images from the start
RAM: 37 MB
RAM with 1000 images: 9.5 MB
Sprite2DBatch:
iPad 1:
~1150 images at 30 FPS
RAM: 6.6 MB
GalaxyTab 10.1 (OC 1.4GHz):
~1150 images at 30 FPS
RAM: 6.1 MB
PC (i7 4.8 GHz, Radeon 6790):
10800 images at 30 FPS
RAM: 23.2 MB
RAM with 1000 images: 9.1 MB
ND2D is another nice open source framework we have to render 2D using Stage3D. It has big community (smaller than Starling though), pretty raw API reference (with most of all methods and properties without any description) and it comparable in terms of performance to Starling.
It also easy to understand and use because it is similar to the native DisplayList we have in Flash and there are many examples and information on forums about different use scenarios.
Genome2D Nightly 0.9.0.1093:
This is a surprising framework. Just look at the benchmark results below!
iPad 1:
1900 images at 30 FPS
RAM: 6.5 MB
GalaxyTab 10.1 (OC 1.4GHz):
3800 images at 30 FPS
RAM: 10 MB
PC (i7 4.8 GHz, Radeon 6790):
~40000 images at 30 FPS
RAM: 68.7 MB
RAM with 1000 images: 9.1 MB
It’s a really hardcore framework! It has awesome performance, but no API reference, small community, and no examples for the latest nightly builds (at this moment, latest nightly build is far away from the latest stable build).
It’s could be pretty tricky to use it for the beginner.
So, what we have now for creating 2D content using Stage3D:
Starling – the sweetest one. In some tests slower than ND2D though.
ND2D – compromise – could be faster than Starling in some cases but looks not so sweet at least because of weak API reference (so far) =)
Genome2D – for the maximum performance in some cases (like mine) and mostly for the hardcore devs with ninjaneering skills) I hope it will became more friendly in future.
I think all three frameworks are comparable on features – all have the particle systems, blending, and other advanced features. And all three are under active development so new features are come continuously.
Also I should mention iPad and GalaxyTab 10.1 overclocked to 1.4 were head-to-head in Starling and ND2D in this benchmark. I guess it could happen because of the different screen resolutions and probably compensating each other HW and SW differences.
So for now if you wish to port some of your not hardcore (in resources consumption) game to the Stage3D with comfort, feel free to choice Starling. If you wish to have as much performance as possible (and if you’re ready to have a great adventure) – try Genome2D. Choose ND2D in the middle case.
Feel free to grab all Android benchmarks (and AIR 3.2 p6 Runtimes for Android) as bonus here:
http://codestage.ru/files/flood/android/benchmark.zip
If you think I could make a mistake in my tests – please, write me – I’ll be glad to know about and fix it!
*Update 1*
Recently I updated starling-imagebatch Starling extension by Philippe to keep it synced with latest Starling changes and perfomed this benchmark using it!
So, results are:
iPad 1:
2000 images at 30 FPS
RAM: 6.4 MB
GalaxyTab 10.1 (OC 1.4GHz):
2000 images at 30 FPS
RAM: 5.1 MB
PC (i7 4.8 GHz, Radeon 6790):
>16000 images at rapid 60 FPS (can’t set more images because of full buffer capacity)
RAM: 14.9 MB
RAM with 1000 images: 8.4 MB
Memory exploding bug
While I worked with the ImageBatch I found one memory exploding bug occasionally.
It’s very weird and I’m not sure where its roots are growing at this moment.
Please, look at this really often called piece of code:
var k:Number = (premultipliedAlpha ? item.alpha : 1) / 255;
and at this 2 lines of code:
var k:Number = premultipliedAlpha ? item.alpha : 1; k /= 255;
There is not so much difference, yeah?
But first line explodes RAM with speed about 5 MB per second!
And second code block not explode RAM at all and work just fine!
Found a typo? Please, highlight it and press Shift + Enter or click here to inform me!
http://game-develop.net/swfs/laytest.html
http://code.google.com/p/animation-render-engine/
try the are2d with 10000 image
Starling initially didn’t have any batching built-in (thus the reason why I did the ImageBatch extension on github), but performance definitely improved over time and it does batching, etc. quite decently now (see, it does a better job than ND2D now).
It got a popularity boost because it has some documentation and friendly support and because it was highlighted by Adobe to communicate about an easy to use 2D framework.
(it was meant as an answer to Sasmaster)
Thanks for this nice article, and for the constructive comments. I used Starling till now, since it is well documented and very well supported (Daniel is really a nice guy :)). But I want to make an iOS interface reimplementation, and I need some 2.5D features badly (like RotateY). I just saw that ND2D had it, so I may give it a go.
Thanks guys for your hard work and talent!
Thanks for that interesting comparison, Dmitriy! It’s great to see Starling’s performance relative to the other frameworks; and I’m happy about the results! That Genome comes out as the clear winner is no surprise — congrat’s, sHTiF, you’re really doing an amazing job. Kudos to you!
The highest priority of Starling has always been to make it easy to use and easy to read and understand its internals. Performance is important, too — especially on mobile — but I try my best not to let it violate that priority. That’s simply what you get with Starling. =)
BTW, blend modes are available in the head revision, even custom blend modes (via
BlendMode.register()
).It’s also very simple to write custom shaders — I don’t know why people think it’s not; you can easily write custom render functions. I will write a tutorial on that topic soon. (In the meantime, the particle system is a good example of custom rendering.)
Many thanks for your attention and comment, Daniel! And nice to see Starling is moving ahead, gets more features and people love, it’s great.
In fact when the first versions of Starling came out I started digging into it as I needed an example for native stage3d module in Flint.It was horrible! They were doing no batches, uploading data into gpu on each call and more nasty practices. Not sure how much have changed since then but I really don’t understand all te buzz Adobe make around this lib.Good to see strong competitors next to it. Ah btw,soon some 2d surprises will come from Flare3d and it is going to be smth entirely different from what these 2d APIs suggest.
Sasmaster, glad to see you here too! Thanks for you comment, I had some deep look into the Starling at the beginning too and was surprised how bad was it’s internal event propagation. It was intend to do so much before simple Event.ENTER_FRAME reaching user defined listener, it scared me) But now much of that stuff works faster end have almost no footprint. I’m sure Starling was improved hardly since that time. interesting to know more about 2D surprise from the Flare3D team. I hope it will be free?
Is there a difference when using a power of 2 sized image?
Philippe, glad to see you here too!) It’s an interesting to figure it out, good question! I’ll make some tests later and post results here.
There is no difference as on the GPU everything is power of 2, so even if you don’t use power of 2 image the frameworks will convert it to power of 2 and crop it using UV. There could be a difference if you really wanted to but it would mean to do a specific shader that knows its working with power of 2 image and doesn’t need UV as it will be 0,1. Which means it can batch more data into a single pass and therefore render more triangles.
I did a very fast shader that always assumed this and I was able to render over 9000 32×32 sprites at 60fps on IPad2. It was actually available in one of the G2D builds as blitFast method. Its no longer there because its useless in general where you use atlases to avoid texture rebinding and therefore always need to work with UV. The blit shader that works with UV is not that much slower I mean around 7500 sprites at 60FPS which is plenty enough for any game 😉
Sure I am aware of Genome2D’s shortcomings when it comes to presentation and documentation. As you put it by the hacker reference I enjoy coding as much as I hate doing documentation. Hopefully some people may lend a hand with it.
But I always try to help people that ask and believe me there are a lot of people working on games using Genome2D that talk to me through forum, mail and even skype. Once they get familiar with the component model they all like it 🙂 Even the guys from Adobe said that component model is the way to go, but they can’t just break it easily to all the flash programmers that are too familiar with inheritance model. 😉
Hey sHTiF, very glad to see you here! Thanks for your comment, I believe Genome2D is a really way to go, just not for the beginners – they are all about DisplayList and not really ready to move from it to another model. I’m sure many advanced devs already use Genome as it much faster than others in many cases! Thanks for making our choice wider!
focus nice to hear that my work is appretiated. I am really trying to push the 0.9.x version out there as possible which will be last before 1.0 with major refactoring in packages/classes as some of you using nighly already know. Also the only renderer left is Stage3D as others became obsolete with AIR3.2 and Adobe pushing the drivers barier further down. With this step I can start looking forward into more game related stuff like lighting, tilemaps, vectors etc. that people are requesting.
I am already looking at porting my old 2D lighting model from my Flash9 G2D version here http://www.flash-core.com/examples/g2d/270609/
Wow, that’s a great news! I’m very glad you’re developing it hard and moving further! Lighting and vectors are really appreciated and wanted features. Thanks for letting us know more about your plans.
For me Starling feels like the entry-level of API’s: it’s very smooth in API and Docs, but also very limited. For example it has no advanced blendmodes and you don’t have access to the shaders. ND2D’s API is almost as friendly but without the docs (NEED!) but it’s very easy to edit the shaders and so to ‘break out’ of the feature set. Genome is just too much of some hackers hobby project.
Thanks for your comment! About blend modes in Starling – basic are arrived recently and custom will be soon as I understood.