Where is the Problem?
Let's just come to the point: Whenever we want to draw something in Direct3D, we have to pay a little price. Each Draw-Call costs a few CPU-Cycles, which can really hurt the performance when drawing a lot of stuff.
Each time we make such a draw-call, we pass some information about our mesh and other things to the GPU. This is slow and unnecessary when we are drawing just the same mesh a few thousand times.
How can it be solved?
That is where instancing comes into play. By doing instancing, we just register the world-matrices (position, rotation, scale) of all instances of one mesh we want to draw into a list.
Then we do only one Draw-Call and send our list to the GPU, which draws them all in one batch, saving us a lot of CPU cycles.
Results
Here are two shots, comparing the speed of the engine now, and of an older version of [w]tech (We ran them on my crappy old laptop to make the difference more obviously):
Both scenes are running at about 27 FPS.
Oh yeah, asking why we would want to draw one mesh so many times?
Just take a look at this nice grassy scene:
Remember that you can check wtechportal.com for more updates:
Wtechportal.com
Keep it commin! :)