Patience, technical skill and endurance.
First point is that a DX Demo is primarily a teaching aid so it's done for clarity not speed of execution.
It's a pretty big subject to condense but games development is primarily about understanding your data and your execution paths to an almost pathological degree.
- Your code is designed around two things - your data and your target hardware.
- The fastest code is the code that never gets executed - sort your data into batches and only do expensive operations on data you need to
- How you store your data is key - aim for contiguous access this allows you to batch process at high speed.
- Parellise everything you possibly can
- Modern CPUs are fast, modern RAM is very slow. Cache misses are deadly.
- Push as much to the GPU as you can - it has fast local memory so can blaze through the data but you need to help it out by organising your data correctly.
- Avoid doing lots of renderstate switches ( again batch similar vertex data together ) as this causes the GPU to stall
- Swizzle your textures and ensure they are powers of two - this improves texture cache performance on the GPU.
- Use levels of detail as much as you can -- low/medium/high versions of 3D models and switch based on distance from camera player - no point rendering a high-res version if it's only 5 pixels on screen.