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.

Saturday, November 1, 2008

OpenGL Rendering

This is my project written with C++ and OpenGL. The goal of this project is to create a real-time 3D playground scene. 3D models are exported into source code and loaded into vertex buffer. The river is an animated mesh which is able to reflect the bridge above, and pointsprite was used to render the grass on the playground.

Highlights:

  • OpenGL API
  • Vertex animation
  • Reflection with Stencil Buffer
  • Pointsprite Grass