There have been some concerns brought up in the XNA community about whether XNA hurts performance of games. Although I haven’t heard any questions directed specifically at the FlatRedBall Engine, since I’ve been working on the rendering portion of the engine, I thought I’d bring this topic up.
So, first, is XNA slower than Managed DirectX. Yes. But let me explain. Figures vary, but I’ve heard that XNA calls are 3 – 10% slower than similar MDX calls. Ok, so it’s not that bad, and further evaluation reveals more. First, consider that just the XNA calls are slower, not your entire game. Therefore all game logic will run the exact same. That means all sorting, movement, custom functions, attachments, and all the other wonderful stuff that FRB provides will run the exact same.
Next, consider that the hardware does a lot of work during the rendering which doesn’t really depend on the call. That is, sure it might take longer to feed a vertex buffer to the GFX card, but once it has it and its doing the transformations and writing to video memory, that’s all dependent on the card.
This means that even if you isolate the rendering itself, it WON’T go 3-10% slower when compared to MDX.
Finally, the XNA translation has given me the opportunity to do a lot of the things that I’ve wanted to do to the engine, but couldn’t because of fear of breaking existing code. I’ve been working on the C#/MDX version of FRB for nearly 3 years and during that time I’ve learned quite a bit.
One of the major changes that is going to happen to FRB is that there will no longer be DynamicSprites. All Sprites (including unordered Sprites) will give the user control over vertices. Furthermore, the ability to limit automatic every-frame updating is no longer limited to Unordered Sprites. Sprites can be easily moved between being automatically and manually updated at any time.
Since all Sprites will be just as DynamicSprites are in the MDX version of FRB, that means that alpha (fade) and color (tint) information will be stored on the vertices rather than in a separate value. This enables the engine to perform rendering with fewer breaks in the rendering. That is, the engine will be able to batch Sprites more effectively, greatly reducing the number of XNA calls being made.
With the use of sprite sheets, the number of calls can be reduced even further. I anticipate that in regular usage (without using sprite sheets to reduce texture switches), the new Sprites will more than compensate for the slower XNA calls. That means that even though FRB is moving to a “slower” framework, the engine will actually be more efficient than before.
Effectively placing Sprites in the manual update group (which is simply one call) can improve performance even more.
And of course, let’s not forget one thing – the ability to run on the incredibly powerful Xbox 360. With all of these combined, the new FRB will be easier to use and much faster. The translation continues…
–Vic–
