This is making me very sad. Why was DirectDraw deprecated?
Here’s the situation. I’m making a tile based game in C# using MDX and Direct3D. I’m trying to achieve real time framerates and having a dismal time at it.
I have done some benchmarking with a PerformanceTimer and I’ve determined my problem is that I am calling DrawPrimative once for every visible tile. That is, to draw the map, I transform the world coordinates, call DP on a square vertex buffer, then move to the next tile. Typically I have about 1000 tiles on the screen at once. So this didn’t seem like it would be a problem, even if this is not the way to draw a 3D scene.
To draw the whole 100×100 map this way, without textures, gives 1.5 FPS. I did an experiment and made a single vertex buffer to render the whole map with one DP call (still passing in 60,000 vertices) and my FPS jumped to 40-80 (variance probably due to the presentation params and the vblank).
I now have 3 options, that I can tell, all of them unappealing.
1. Trying using the MDX Sprite class. I hear different things about it’s performance from different people.
2. Put all my textures into one big texture, put my whole map in one big vertex buffer, set all the texture coords of the individual tiles right, and blast the whole mess to the GPU with one DP call. This is not ideal since it makes updating the tilemap complicated. Especially for layers above the ground layer (critters, items, ect) that are sparse and would need constant updating. Also I would need to batch my textures if they don’t fit on a single large texture in video mem.
3. Use DirectDraw, even though it is deprecated. Or use OpenGL, which doesn’t have this problem of the DP-equivalent call costing so much. OpenGL is not natively supported by C#, so I’d rather not. There’s also stuff like SDL.Net — but it doesn’t seem I should need a 3rd party lib to draw a tilemap. I mean, come on.
So… What should I do?
Discontinuing DirectDraw was so short-sighted. D3D really isn’t a substitute. Why is the latency of DP so high? Modern GPUs had GBs of bandwidth, and I’m not close to using all mine.