Starling 2.0 Final
Daniel Sperl on April 19, 2016
It‘s been several weeks already since I offered you a first look at the brand new version of Starling (if you haven‘t read my previous post yet, make sure to do so before continuing: Starling 2.0 Beta). Many developers were brave enough to take it for a test ride or even port their existing games over to the new version. That feedback was extremely valuable for me — thanks a lot to everyone who participated!
从上次发布最新的Starling版本到现在已经有几周时间了。很多勇敢的开发人员已经在测试甚至直接将他们的游戏基于新版本就行构建。那些反馈对我来说真的很有价值,感谢那些身先士卒的勇士们。
So you kept me quite busy, but it was well worth the effort: not only was I able to move lots of potential issues out of the way, but I could also spend some more time on polishing the new version.
由于这些反馈,我就一直很忙,但是这些努力都非常的又价值:这不仅仅是因为我可以处理掉一些潜在的问题,也可以让给我花更多的时间去打磨新版本。
Thus, finally, it‘s time to make the next step and publish the official version! Read on to find out all about the additional changes that made it into the "Starling 2.0" release.
这样,最后,是时候去做开始下一步了,发布官方版本!继续阅读,去发现Starling的一些变化,这些变化使它变成了Starling 2.0 release .
Bringing CPU usage down to ZERO
使CPU下降到0
Sometimes, it‘s the simple things that have the biggest impact. Remember the new "render cache" I introduced in the new version, which optimizes CPU workload for static parts of the display tree? It turned out I could even take this one step further. (A huge thanks to maximgavrilov for coming up with this idea!)
很多时候,重新构建会使原有程序和Starling有较大的不兼容性,但也只有这样才能保持它的单纯,以及后续的持续成长。(理解了一下更改是这个意思)。是否记得我之前提到过的渲染缓存,它可以降低CPU负载,当有很多静态对象的情况下。我又对这个重新做了进一步的调整。
It happens surprisingly often in an app or game that a scene stays completely static for several frames. Just look at the Starling Demo or the Feathers Component Explorer: as long as you‘re not directly interacting with the app, they are mostly static. So why redraw the stage at all?
这种情况在APP或游戏中非常常见,场景会完全静止很多帧。可以看一下Starling Demo和Feathers Component Explorer,只要你不直接和APP交互,那么他们其实都是静止的,那为什么不直接渲染整个Stage呢?
That‘s exactly the point of the new skipUnchangedFrames-property. If enabled, static scenes are recognized as such and the back buffer is simply left as it is. On a mobile device, the impact of this feature can‘t be overestimated! There‘s simply no better way to enhance battery life.
那就是新的 skipUnchangedFrames 属性。如果启用这个属性,静态场景会被这样识别,直接简单的使用一个后台缓存就搞定。在一个移动设备中,也不是所有的情况都符合这种场景,所以还是要保留你的期望值。这是一个简单的方法提升电池寿命。
You might ask why I didn‘t activate this feature by default. The reason: RenderTexture and cclasses need special treatment when it‘s enabled (requiring a call to setRequiresRedraw whenever their content changes), so I decided to better not cause any unpleasant surprises. Still, it‘s highly recommended to always activate this feature; especially since it doesn‘t cost anything, performance-wise.
你可能会问为什么不默认就打开这个特性。那是因为RenderTexture和RenderTexture类需要特殊的处理。所以我决定最好不要有一个不愉快的惊喜。但是任然建议激活这个特性。因为他没有任何消耗,性能提升上是一个比明智的选择。
One more thing: to make it easy to recognize if you are utilizing this optimization in a given moment, I modified the statistics display slightly: it will now turn dark green whenever a significant amount of frames is being skipped. Keep an eye on that!
另外,为了能够简单地识别处是否正在使用这个优化方法,我稍微修改了一下statistics display,当那些帧被跳过时它会变成墨绿色。
Optimizing Filters
滤镜优化
As described in my previous blog post, the filter API of Starling 2 is a massive improvement over the previous version. It‘s easier to write custom filters, you can use them more flexibly, and they make automatic use of the render cache.
正如我之前博文中提到的,滤镜API和之前的版本比有了较大的改进。它将更容易地编写自定义滤镜,你可以更灵活的使用他们,它们直接被渲染缓存支持。
However, in cases where the render cache did not kick in, they were also a little bit slower than before. Well, not any longer! I spent a lot of additional effort on that API and brought it up to speed. The final render pass now draws directly into the back buffer, without detour over a texture.
尽管如此,在某些渲染缓存没有涉及的地方,滤镜的效率还是会比之前的版本略慢一些。但是这段时间并不长,我另外花了时间在这些API上,使他们有更快的速度。最终的渲染器直接写入Back Buffer,不需要在文理的基础上绕弯了。
You need even more speed? Performance junkies now have all the options they need: cache the filter output, use a lower resolution, or even change the textureFormat to a lower bit depth — all without compromising any of the original API enhancements.
你想要更好的性能不?性能控们会有更加全面的选择了,缓存滤镜输出,使用较低的分辨率,或者使文理类型使用较低的位深,而这些不会影响到原始API的性能提升。
All modesty aside, you won‘t find a filter API anywhere else that‘s as easy to use, as fast, or as flexible as this! ??
不谦虚的说,你不可能在别的地方找到一个比这个更好用,更灵活、更快的滤镜API了
Optimizing the Rest
其他优化
A huge part of my time was also spent on performance optimizations throughout the complete rendering pipeline. I found a number of shortcuts to exploit as well as bottlenecks to avoid, bringing up performance to a fantastic level.
我的大部分时间都花在通过渲染通道的优化来提升性能。我找到一些捷径去避免那些性能瓶颈,把性能提升到一个更高的层次。
All in all, my tests indicate that the CPU consumption of Starling 2 is typically a little higher than 1.8, which is simply a side effect of the additional flexibility (it seems the old saying about the "free lunch" has some truth in it, after all). On the other hand, GPU usage was reduced significantly, meaning you can move around more pixels than before and you‘ve got more options to speed things up manually.
总的来说,我的测试指出,CPU消耗,Starling 2要比1.8略高一些。这些主要是用于提高灵活度,(毕竟世界上没有免费的午餐)。另外GPU消耗情况下降的比较多。这就是说,你可以比以前移动更多的像素,也可以手动设置一些额外的选项来提升速度。
As for bug reports, I was actually surprised how few problems popped up, despite the big number of testers! I think that‘s a testament to the robustness of the new architecture; cleaner code makes for less bugs, that‘s the simple truth.
Wrapping it all up
I‘m extremely happy that I can finally scrap that "beta" sign and make Starling 2.0 "final". Personally, it marks the conclusion of a long and exciting development phase that confronted me with way more challenges than I ever anticipated — and I‘m very proud of the result.
Now, what comes out of this is all in your hands! I can‘t wait to see the ways in which you push the new architecture to its limits. (Deferred Shading, anyone? A new filter collection? Or Cross-Texture Batching?)
You can download Starling 2.0 at the usual place, of course! Don‘t forget to drop a comment below to tell me how it works for you. I‘m looking forward to your feedback!
But wait, before you go, there‘s one more thing. It‘s ...
Give-Away-Time!
一下是MyFlashLabs提供免费的ANE,大家可以去看看
To celebrate the release of Starling 2, the guys from MyFlashLabs approached me with a special offer exclusively for Starling developers: they are giving away some of their most popular native extensions for free!
All you have to do is put those ANEs into the shopping cart and use the coupon-code "free-ane-for-starling-users" at checkout.
Pro developers who need more ANEs and want guaranteed support can save even more money: MyFlashLabs agreed on a 60% discount on their club membership (coupon: "club-for-starling-users"). As with the individual ANEs, this offer may be used only by Starling developers.
Knowing that many Starling developers are struggling to find great ANEs, I simply couldn‘t say "no" to this offer. ?? My thanks to the complete MyFlashLabs-team!