Performance #73
Performance #73
Comments
After playing a little bit around with NME and various targets, I found out that we should definitely implement different rendering systems for the various platforms. Here is a diagram of a benchmark I ran with the different drawing techniques on the targets Flash and Windows: Finally I came up with 3 major rendering systems to allow maximum performance on all platforms:
After those systems are implemented, we can test further platforms and see what's running best on them. Now I'd like to go a little bit more in detail about the rendering systems: copyPixelsThis is the current rendering system. It uses "blitting" to display objects on screen, which means Rygal creates one bitmap that has the size of the game and every texture/sprite gets drawn on that bitmap. This method is a little bit faster on Flash than the traditional display lists, it however has the disadvantage that it can't handle rotation. Display listThis is the default rendering system of NME (And Flash). It basically consists of display objects that can be added to the stage, thus being drawn there. To implement this system in Rygal, one would have to rebuild the DisplayObject-hierarchy inside the GameObject-tree (Which is quite similar to the default display list model), so for instance a Sprite contains a hidden nme.display.Bitmap that will be added to the stage as soon as it gets added to the game. This is the fastest possible way of drawing in HTML 5 and has the advantage of being able to transform (Rotation, scale, etc.). It's however not able to use correct zooming (When tranforming), as rotations may result in "subpixels", so for instance in a game with 4x zoom (So one game's pixel consists of 4x4 visual pixels) where there is a sprite that is rotated, the pixels of the sprite may not always fill one whole "game-pixel", which looks quite bad in Pixelart-games. drawTilesNME introduces the class Tilesheet that may be used for drawing a spritesheet. However, it has one particular method that revolutionized performance in NME: drawTiles. This is a single method that is able to draw an arbitrary number of tiles from the spritesheet. It takes an array as a parameter where are all target positions, accompanied by optional transformation data. It is able to draw ridiculously fast on C++ targets like Windows, thus being the most useful performance enhancement.
|
Even more performance increase would be gained when using Stage3D on the flash target, let's see if we could implement that as well. |
It might help to look at Stage3DDrawingContext and BitmapDrawingContext in Flambe. DrawingContext is an interface that appears to be equivalent to Rygal's Canvas. |
Gonna implement the drawTiles method soon as it will hopefully reintroduce HTML5 support as well: |
There seems to be some sporadic framerate issues with Rygal, especially noticable at the beginning when starting a flash target. I'm not sure if and how much Rygal is responsible for those issues, but they should definitely be checked out.
The text was updated successfully, but these errors were encountered: