Rewrite based on NVidia example (http://www.nvidia.com/content/GTC/documents/1055_GTC09.pdf)