Thursday, March 25, 2010

XNA 4.0, the WP7 emulator and the GPU

After giving a first go at writing a brainless Silverlight application for the Windows Phone 7 emulator, I turned towards XNA 4.0. My curiosity about this platform was itching me so I decided to have a go and scratch. XNA is a platform that enables (hopefully) quicker and easier development of managed code games for XBOX, PC, the Zune and now the Windows Phone 7.

Although this is a managed environment with lots of abstracted features such as the device GPU and bitmap rendering (you really don't care how the bits are painted, nor how the frame buffer is laid out), it still has all sorts of interesting "low-level" stuff that managed to draw my attention. One of issues that drew my attention is the requirement of taming the GC in order to get a smooth experience.

A few years back I had the very interesting experience of running a .NET CF 1.1 game on a Pocket PC 2003 device. This game (1945) is still available with full source code from CodeProject and struck me for being fast (I have this speed bias against managed code, so it was enlightening). Naturally I decided that my first experiment with XNA 4.0 would be to write a port of this game.

Unfortunately my three-year-old laptop worked against me. The NVidia Ge Force Go 7700 with 1 GB of dedicated RAM still seems quite appropriate for Windows 7 (after all, I get a 4.7 performance index for games and 4.8 for Aero) but fails miserably when it comes to driving the WP7 emulator. If you read the CTP release notes, you get the impression that the major requirement is DirectX 10 support. It's not. I have DirectX11 installed and still it does not work. Apparently your graphics driver must support the Windows Device Driver Model (WDDM) 1.1 and DDI (whatever that is) version 10. Unfortunately my driver supports only DDI 9Ex and WDDM 1.0. Apparently there is no updated NVidia driver that supports the required features (and that does not BSOD).

Dead in the water? No, I turned to my Zune 120 and XNA Studio 3.0 and started to write the Zune version of 1945. After all, this is also a sandboxed mobile device, so it's fair game.

I will post the code and my experiences writing in the forthcoming posts.