One of the reasons I’m pleased with the Silverlight version of Legend of the Greasepole is that it represents a reasonably-scaled multimedia application, and therefore a good way to learn about the Silverlight 2 runtime’s performance.
The Silverlight 2 Beta game engine runs rings around the game engine I tried to create using the Silverlight 2 Alpha. Yes, samples existed during the Alpha days that let you build a simple Silverlight game engine, but I didn’t see any applications that were successfully pushing push over 100 bitmap-animated sprites around the screen. I certainly was unsuccessful.
Although, as evidenced by the current build of Greasepole, the Silverlight 2 Beta situation is dramatically imrpoved, the lack of hardware acceleration is still very noticable when running at higher resolutions. This performance impact is relevant to an Image-oriented application like Legend of the Greasepole.
Can the game’s framerate be improved at high resolutions?
Late last year, I tried to make a version of the game run on the Silverlight 2 Alpha.
While the perf in the game’s menus was passable, the actual gameplay caused the Silverlight plugin to grind to a halt and crash (as 150+ sprites, rendered as Images with opacity blending, were presented simultaneously).
When updating my Silverlight game engine to the Silverlight 2 Beta, changes included:
- using ZOrder instead of manually re-ordering Images in the Canvas’s Children collection between frames
- moving bitmaps and sounds from loose, pre-downloaded files to Resources in Assemblies
- an overall reduction in the number of RenderTransforms in the scene
- avoiding setting of Width and Height as per Silverlight Performance Tips (in the MSDN docs)
At game time, performance is superb when running in a window of around the game’s native resolution of 640×480. But when the player toggles fullscreen mode (achieved in code by scaling the Canvas on which the 150+ Images are being drawn), it kinda sorta almost looks good. It definitely achieves less than the game’s desired 24 frames per second.
So… Is the Engine Fill-Rate Limited?
Since the game performs so well at reduced resolutions, I’m currently theorizing that the engine is fill-rate limited in Silverlight at high resolutions. That makes sense, because the Silverlight 2 Beta plug-ins for IE7 and Firefox2 aren’t hardware accelerated.
Still, the changes that took place in the plug-in and the engine that were enabled by the switch between Silverlight 2 Alpha and Beta have made dramatic improvements to the game’s performance. They were enough to bring the game to life.
Written Mar 25th, 2008 |