Sunday, November 9, 2008

Situation update

There has been little visible activity on the tutorials recently. That's because I have been busy implementing a small 3d object viewer. I have the somewhat unfortunate tendency to choose complexity over simplicity, which means that this viewer should be cross-platform. It is based on a generic scene-graph library and will support both DirectX (using SlimDX) and OpenGL (using the TAO framework).
It can display 3d objects stored in .X files, currently using the DirectX API. I have started a mini-project to write my own parser for it, as DirectX is limited to windows platforms.
I am starting to see the end of the tunnel, and the following tutorials should come soon:

- A generic scene graph library. It will demonstrate the use of some of F# objected-oriented constructs. It will also show how to use SlimDX with F#, which you can already see in snk_kid's examples.

- A parser for .X files. Writing this code proved more challenging than expected: .X files start by defining the data structures that are used later in the file to describe the data. See e.g. Direct-X File Format. This is a flexible but unusual approach: Data structures are normally fixed from file to file, and parsers can be written with this knowledge at hand. I found an elegant solution using a functional approach: The data structure declarations are parsed, generating new data parsers, which are used later when parsing the data itself.

I am staying clear of XNA for the time being. It would seem that my dream of getting my racing game to run on the XBox360 is not realizable, as the CLR on the XBox360 is notably slow when it comes to computations on floats, which are hardly avoidable in physics simulations.

Mono and games
Regarding performance and games, it seems Mono is overtaking Microsoft's CLR. Miguel de Icaza has announced that Mono now has experimental support for SIMD instructions. My racing game is currently implemented in C++, but does not take advantage of SIMD instructions. I am hopeful that a new clean implementation of my physics engine in F# may actually be faster than the current C++ one.


m said...


Thanks for posting these samples.

Once we had prototyped our SIMD implementation we had some significant performance gains on benchmarks that we cooked in-house.

Your sample programs were a good way of checking if the SIMD optimizations would actually be useful in a real time scenario as opposed to the micro-benchmarks that we were writing.

The results were very encouraging. The more complicated the math, the better the SIMD support looked.


Flying Frog Consultancy Ltd. said...

Mono is generally around 3× slower than Microsoft's CLR so I'd be very surprised if their new support for SIMD did much to close the gap.