Programmer's Book Review

C/C++ Users Journal December, 2004

By Paul Martz

Paul Martz is a software engineer specializing in 3D computer graphics and the OpenGL graphics standard. He can be contacted at pmartz@frii.com.


GPUGems: Programming Techniques, Tips, and Tricks for Real-Time Graphics
Randima Fernando (editor)
Addison-Wesley, 2004
765 pp., $59.99
ISBN 0321228324

For old-school graphics programmers, maybe the future arrived too soon. Just when you've become comfortable with multitexturing and the stencil buffer, the programmable Graphics Processing Unit (GPU) came along yanking the fixed-function pipeline from under your feet and sending you tumbling into an infinitely configurable world. To regain your footing, maybe you've tried rendering the "hello, world" of programmable graphics—a few polygons with procedural textures—and now wonder what else this new technology is capable of.

GPU Gems is a collection of papers by industry experts on how to render a broad range of computer graphics effects in real time using the GPU. The book contains 42 chapters grouped into six sections, and is full color throughout its 765 pages. Subject areas include natural effects such as fire and skin, volume rendering, lighting and shadows, materials, image processing, shader tools, and performance. The book comes with a CD-ROM containing example code, movie files, and precompiled examples.

GPU Gems is not for beginners. You should know C/C++ and the OpenGL or Direct3D graphics interfaces. You should know the basics of vertex- and fragment-shaders (how to store values in uniforms, fetch texels, write pixel color values, and so on), and be familiar with at least one shader language.

As in any Gems-style book, multiple authors contribute to an overall lack of consistency. However, thanks to excellent editing, GPU Gems is better than most in this department. The lack of consistency is most apparent in the source code and CD. Only about half the chapters have content on the CD, build environments differ from one example to the next, and the code is a mix of Cg, HLSL, and OpenGL vertex- and fragment-shader language.

Typically, only a small fraction of the material in a Gems-style book will apply to your current project. This is less of an issue with GPU Gems due to its narrow focus—developing real-time software for state-of-the-art programmable graphics hardware. While specific rendering problems in GPU Gems might not pertain to your work, their solutions often apply globally across GPU programming. In addition, the examples of effective GPU programming found throughout GPU Gems should help transition fixed-function graphics programmers to the programmable GPU model.

This book can help experienced GPU developers think out of the box and take greater advantage of the GPU. The concept of using GPUs to offload nongraphic computation from the CPU is as old as GPUs themselves, but only recently has the GPU's increased horsepower made this a practical option. Two chapters discuss strategies and requirements for nongraphic GPU programming with example code for numerical reduction, sort and search, and fluid dynamics. Nongraphic computation on the GPU presents a problem: How to express an algorithm in terms of rendered primitives? The contributors present elegant and efficient solutions to fit this programming model.

GPU Gems also shines in its treatment of performance. Several contributors discuss vertex- and pixel-shader performance issues. In addition, a full chapter is devoted to this subject alone, which contains an explanation of pipeline bottlenecks, how to identify where they are, and what to do about them.

As an example, you might suspect that your program's performance is throttled by texture memory bandwidth. In contributor Cem Cebenoyan's chapter on performance, he suggests increasing texture mipmap bias to dramatically reduce the texture level of detail, therefore reducing the number of texture memory fetches. If this change increases performance significantly, you've identified a texture memory bandwidth bottleneck. Cebenoyan's suggestions for addressing this bottleneck include reconsidering texture size requirements, using texture compression, avoiding high-precision texture formats, and more extensive use of mipmapping, all of which should reduce texture memory fetches and improve texture cache coherency.

Too often in many graphics programming books, performance receives inadequate treatment. Editor Randima Fernando has ensured that GPU Gems gives it the attention it deserves.

While the value of this book is undeniable, there is room for improvement. With the adoption of the OpenGL Shading Language in OpenGL 2.0, this book risks appearing outdated unless it's revised to include OpenGL Shading Language code examples.

The book also has a clear bias towards NVIDIA hardware. Since the editor is employed by NVIDIA, this is understandable. However, since all of the concepts in the book apply to programmable graphics hardware from any vendor, removing corporate bias in a future revision could expand the book's reader audience.

The shift of graphics hardware from expensive fixed functionality to open and affordable programmability is clearly the most dramatic change in the history of computer graphics. This technology represents the future of graphics programming, and all graphics developers should master it to stay employable. GPU Gems is a thorough exploration of programmable graphics hardware and a valuable resource for today's graphics developers.