Sunday, November 16, 2008

Code Optimization Techniques

Several common techniques that I've learned in my Optimization class:
  • Instancing: static (pack geometries into the same vertex buffer), dynamic (similar to static, but transformed per frame), Shader (use vertex constants and GPU transforms the data), Hardware (supported by GPU).
  • Reduce draw calls: Since the process of transferring data to the GPU includes overhead, the concept of instancing is to pack more data into the same buffer to improve the performance.

  • Data Dependencies: How to write the code in special ways for the CPU to trade memory for computational speed.

  • Threading: Avoid deadlocks and other abnormalities.

  • Memory allocation: Avoid "new" memory at all cost.

  • Benchmark, bottleneck, and performance tuning.

  • SIMD: Single Instruction Multiple Data.