96 Computer
HOW THINGS WORK
I
n the early 1990s, ubiquitous
interactive 3D graphics was still
the stuff of science fiction. By the
end of the decade, nearly every
new computer contained a graph-
ics processing unit (GPU) dedicated to
providing a high-performance, visu-
ally rich, interactive 3D experience.
This dramatic shift was the in-
evitable consequence of consumer
demand for videogames, advances in
manufacturing technology, and the
exploitation of the inherent paral-
lelism in the feed-forward graphics
pipeline. Today, the raw computa-
tional power of a GPU dwarfs that of
the most powerful CPU, and the gap is
steadily widening.
Furthermore, GPUs have moved
away from the traditional fixed-func-
tion 3D graphics pipeline toward
a flexible general-purpose compu-
tational engine. Today, GPUs can
implement many parallel algorithms
directly using graphics hardware.
Well-suited algorithms that leverage
all the underlying computational
horsepower often achieve tremendous
speedups. Truly, the GPU is the first
widely deployed commodity desktop
parallel computer.
THE GRAPHICS PIPELINE
The task of any 3D graphics system
is to synthesize an image from a
description of a scene—60 times per
second for real-time graphics such as
videogames. This scene contains the
geometric primitives to be viewed as
well as descriptions of the lights illu-
minating the scene, the way that each
object reflects light, and the viewer’s
position and orientation.
GPU designers traditionally have
expressed this image-synthesis process
as a hardware pipeline of specialized
stages. Here, we provide a high-level
overview of the classic graphics
pipeline; our goal is to highlight those
aspects of the real-time rendering cal-
culation that allow graphics applica-
tion developers to exploit modern
GPUs as general-purpose parallel
computation engines.
Pipeline input
Most real-time graphics systems
assume that everything is made of tri-
angles, and they first carve up any more
complex shapes, such as quadrilaterals
or curved surface patches, into trian-
gles. The developer uses a computer
graphics library (such as OpenGL or
Direct3D) to provide each triangle to
the graphics pipeline one vertex at a
time; the GPU assembles vertices into
triangles as needed.
Model transformations
A GPU can specify each logical
object in a scene in its own locally
defined coordinate system, which is
convenient for objects that are natu-
rally defined hierarchically. This con-
venience comes at a price: before
rendering, the GPU must first trans-
form all objects into a common coor-
dinate system. To ensure that triangles
aren’t warped or twisted into curved
shapes, this transformation is limited
to simple affine operations such as
rotations, translations, scalings, and
the like.
As the “Homogeneous Coordinates”
sidebar explains, by representing each
vertex in homogeneous coordinates,
the graphics system can perform the
entire hierarchy of transformations
simultaneously with a single matrix-
vector multiply. The need for efficient
hardware to perform floating-point
vector arithmetic for millions of ver-
tices each second has helped drive the
GPU parallel-computing revolution.
The output of this stage of the
pipeline is a stream of triangles, all
expressed in a common 3D coordinate
system in which the viewer is located
at the origin, and the direction of view
is aligned with the z-axis.
Lighting
Once each triangle is in a global
coordinate system, the GPU can com-
pute its color based on the lights in the
scene. As an example, we describe the
calculations for a single-point light
source (imagine a very small lightbulb).
The GPU handles multiple lights by
summing the contributions of each
individual light. The traditional graph-
ics pipeline supports the Phong light-
ing equation (B-T. Phong, “Illumina-
tion for Computer-Generated Images,”
Comm. ACM, June 1975, pp. 311-
317), a phenomenological appearance
model that approximates the look of
plastic. These materials combine a dull
diffuse base with a shiny specular high-
How GPUs
Work
David Luebke, NVIDIA Research
Greg Humphreys, University of Virginia
GPUs have moved away from
the traditional fixed-function
3D graphics pipeline toward
a flexible general-purpose
computational engine.