Presented at Russian Game Developers Conference 2011.
Depth of Field (DoF) is an optical focus effect widely used in photography, movies, 3D graphics and games for bringing the attention of the viewer to some part of the scene. Until recently, this effect has been too computationally expensive to do in realtime, but with the growing power of graphic processors, DoF is becoming widely used in modern computer games, raising the level of visual experience.
Physically correct DoF effect could be achieved with ray-tracing or accumulation buffer still being too compute intensive to be done in real-time. Like many effects in computer graphics, there is no “right” way to do Depth of Field in a real time application. Depth of Field Explorer offers developers a way to compare and contrast many different methods of calculating DoF and make an informed decision on the right balance between quality and performance on Sandy Bridge processors.
We present multiple DoF techniques along with a set of adjustable parameters which allow the user to explore their performance and quality characteristics. All DoF techniques have traditional implementations for GPU and some of them additionally have novel “CPU Onloaded” implementations, demonstrating advantages of integrated processor graphics on Sandy Bridge. The techniques presented are Poisson disk filter, separable Gaussian filter, Gaussian filter combined with Poisson disk, simple and advanced mipmap interpolation, and summed area tables (SAT) gather and scatter.
DoF Explorer demonstrates innovative “CPU Onloading” approaches to the Gaussian blur and summed area tables based DoF techniques. CPU Onloading moves compute intensive work from the GPU to the CPU, allowing faster DoF post-processing with better load balancing between graphics and central processor cores. CPU kernels demonstrate optimizations with SSE vector instructions and multi-threading on TBB along with asynchronous execution of tasks on GPU and CPU. Using run-time controls, Depth of Field Explorer enables developers to compare the performance of traditional GPU-based implementations with the CPU versions.
Depth of Field Explorer is implemented as a DirectX application based on the DXUT framework and custom post-processing pipeline infrastructure to facilitate running many different Depth of Field techniques. The pipeline infrastructure enables running the sequence of multiple stages either on GPU or on CPU with support of asynchronous execution, which enables hiding data-transfer latency between CPU and GPU. It was made easy to analyze DoF techniques performance with help of integrated Oscilloscope performance monitor, displaying charts of CPU and GPU execution times with breakdown by stages.
CPU Onloaded implementations of summed area tables gather and scatter techniques have been significantly accelerated in comparison with their traditional GPU implementations, showing 3x and 8x speedup appropriately on mobile system with Core i7 2720QM.