Home
Portfolio
Home
Home
The Passage
Mandelbrot
DarkForge
Stranded
Programming Title
Michael

April 11, 2011
Michael Schoell

Things have been slow for the past couple of weeks due to graduating from Full Sail University and moving back home. I began playing Dragon Age 2 and Anno 1404, which kept me well distracted for many hours.

However, I have greatly sped up my DirectX project. With 10,000 cubes being rendered without texturing, I had some 60 FPS. With texturing and bilinear filtering, 40 FPS. This idea I was okay with, after all, there is a lot of cubes being textured so it stands to reason that it may take time. However, the FPS did not change when I turned around (thus making the fragment shader unused as pixels fail to be on screen).

So I examined the issue and found DirectX to be making around 13 SetSamplerState warnings per object. If that is true for 10,000 objects, that is 130,000 SetSamplerState warnings. To me, that meant there was probably 130,000 if-statements happening per frame behind the scenes. I needed to fix that.

My first task was to research the problem, to see if there was anything I was doing wrong. As it turns out, the ID3DXEffect uses ID3DXEffectStateManager to stop redundant commands from making it to the video card, something I was assured was more expensive than if a check was made CPU side. However, my system uses a hierarchy to sort objects by their states, making such if-statements mostly redundant. Where the default system will check per BeginPass for a shader, my system would at least only check per change in state (usually a change in texture). In the case of my 10,000 cubes, being rendered with 3 different textures, that happens almost never.

So I threw out the ID3DXEffect structure, and made direct calls to the device to change shader states. In no time I had my project back up and running, free of DirectX bulk, and to my amazement I had not only gotten the 20 FPS I had lost from texturing, but an extra 40 FPS on top of that. I double checked everything I did, even used a secondary program to monitor my FPS, and confirmed that nothing seemed broken. The ID3DXEffect structure seemed to have been slowing me down the entire time.

My work is not over, the ID3DXEffect structure simplified many things with shaders, likely a testament to it's slowdown. Further work will be involved in expanding my code and making it more flexible and robust. Plus, I still have to make it support Windows XP with it's synchronization functions.

Ten Thousand Cubes Textured 10,000 Textured Cubes, Bilinear filtering (120,000 Triangles)
Ten Thousand Spheres Textured 10,000 Textured Spheres, Bilinear filtering (12,270,000 Triangles)

Site Development and Design by <CS>

Graphic Design by Nathan Schoell