The Passage
Programming Title

February 24, 2011
Michael Schoell

As reported a few days ago, I have been working on multi-threading the DirectX 9 device without the use of the MULTITHREAD flag. My work has paid off in the form of rendering cubes.

To accomplish this task quickly, I reused a lot of my old code from DarkForge. There is no need to write a lot of efficient code and at the end get 1 FPS because my multithreading is done so poorly. So I cut corners to accomplish the task quickly and get an idea of speed differences between single threading and multi-threading.

Before I could get anything tested, I had two issues to deal with. First, in early testing I found that my two threads were out of sync. For a program that syncs at the end of every frame, that was absurd. This proved to be a simple issue, one thread would do something that the other would not at the end of the sync process, causing it to not sync the next frame.

My other issue is more severe and handled in a less than decent way currently. Currently, there are not a lot of sub-systems to handle various data such as vertex buffers, vertex declarations, and shaders. Due to this, the same class that handles the device also manages my DirectX objects. Since DirectX memory must also be cleaned up on the same thread, I just clean it up when the thread is shutting down.

However, this is an issue, since my code is being designed to be able to support another graphics API such as OpenGL or DirectX 11 in the near future. My sub-systems need to be able to shut down without the thread shutting down necessarily. While I do not envision this to be particularly difficult, it is something I must keep in mind for future code.

For testing, I put together a simple scene of 100 cubes laid out in front of the camera, in the exact same way between the single threaded project and the multi-threaded project. The results were more than I could have hoped for. With one thread I got frames of 1600/sec on my computer (AMD 9950 Quad, Nvidia GTX 465, 4 GB RAM), and with two frames I got 2800/sec.

From here I move on to expanding the code base to support what DarkForge currently offers, and to testing the frames per second gains on even more advanced scenes. Another issue that must be overcome is that currently the project does not work in XP computers because of some Windows functions I am using. At the time, I did not realize that I was using Vista and later functions, and this will need fixing. The importance of DirectX 9 is lost when you cannot support Windows XP after all.

Site Development and Design by <CS>

Graphic Design by Nathan Schoell