One of the latest challenges in computer gaming is modeling the game environment, with a high degree of realism. The most gaming obvious improvements in the last 25 years have been graphical – from the early days of 2D sprites like Metroid or King’s Quest, to 3D rendering with Glide and later DirectX and OpenGL, powering the latest games like Crysis. Features such as multi-sample anti-aliasing and anisotropic filtering produce more attractive images and increasing amounts of effort and computational capacity are spent on accurately portraying difficult phenomena such as smoke, water reflections, hair and shadows. However, an accurate visualization of an object is only as convincing and realistic as the modeling of the object itself; a glass hurled against a wall that bounces away harmlessly is unlikely to be convincing, no matter how beautifully rasterized (or ray traced). Consequently, as graphics have improved, modeling the underlying behavior becomes increasingly important. This article delves into the recent history of real-time game physics libraries (specifically PhysX), and analyzes the performance characteristics of PhysX. In particular, through our experiments we found that PhysX uses an exceptionally high degree of x87 code and no SSE, which is a known recipe for poor performance on any modern CPU.
History of PhysX
Advances in semiconductor manufacturing have pushed Moore’s Law inexorably forward over the last 25 years. Graphics, by it’s nature, is a trivially parallel application and has taken full advantage of the additional transistors and integration offered by Moore’s Law. Each generation of new hardware is increasingly more powerful and enables new levels of graphical quality. In this context, real-time physics engines were developed to help games accurately model the behavior of objects, according to the relevant laws of physics (e.g. Newtonian mechanics). In 2006, Ageia, a little known hardware start up out of Washington University in St. Louis, launched a dedicated coprocessor for physics. Ageia’s physics engine was cleverly known as PhysX and ran on a specialized Physics Processing Unit (PPU). Ageia was hoping and betting (unwisely) that the PPU would transform the video game industry in the same way that 3dfx’s Voodoo graphics cards did in the 1990’s. Unfortunately, there is not room for more than two processors in a modern PC, and the CPU and GPU have already made their mark. Even two separate processors is somewhat dubious, given that the vast majority of the market is comfortable with integrated graphics. More problematic, software developers were reluctant to fully embrace the PhysX API, given that few gamers were buying the hardware – the perennial chicken-and-egg problem. Unsurprisingly, the company was bought at fire sale prices by Nvidia in 2008…so in that sense, Ageia did live up the legacy of 3dfx.
The Ageia PPU (below in Figure 1) itself was not particularly revolutionary. In many respects, it resembled Sony’s Emotion Engine in the PS2 or the Cell in the PS3; it was a primitive throughput optimized processor, albeit with a familiar instruction set. The PPU had a 32-bit MIPS control processor with many vector execution units. It was 183mm2 manufactured on a 130nm TSMC process, which was hardly modern; contemporary CPUs were using a 65nm process.
Figure 1 – Ageia’s Physics Processing Unit (PPU), courtesy of the Tech Report
At Nvidia, the PPU was wisely discontinued and PhysX was ported to the proprietary CUDA programming environment. The goal was to execute on Nvidia’s GPUs (instead of the PPU) and demonstrate the benefits of GPU computing (sometimes known as GPGPU) for consumers. One of the advantages of executing on an Nvidia GPU rather than the PPU is that many gamers actually own Nvidia GPUs; thus solving part of the chicken-and-egg problem for software developers. Of course, PhysX can also execute on the CPU, albeit with reduced performance. This guarantees that games written with PhysX will function correctly on any PC platform; however, there are no performance guarantees. Additionally, PhysX continues to be used as a software library on the three major consoles, yet another incentive for developer adoption.