Contents
Introduction
to GPU
High-level shading languages
GPU applications
Introduction to GPU
Slide Credits
Marc
Olano (UMBC)
David
Mark
Rudolph
Randy
GPU
GPU:
Americas Army
matrices
Computational Power
GPUs
are fast
GPUs
Computational Power
Computational Power
Why
fast?
Arithmetic intensity
the specialized nature of GPUs makes it
easier to use additional transistors for
computation
Economics
multi-billion dollar video game market is
a pressure cooker that drives innovation
to exploit this property
GPU
Shade
Rasterize
Fragments (pre-pixels)
CPU
Assemble
Primitives
Transform
& Light
Vertices (3D)
Application
Video
Memory
(Textures)
Render-to-texture
GPU
Programmable
vertex
processor!
Fragment
Shade
Processor
CPU
Rasterize
Fragments (pre-pixels)
Assemble
Primitives
Vertices (3D)
Application
Vertex
Transform
Processor
& Light
Video
Memory
(Textures)
Render-to-texture
Programmable
pixel processor!
Fragment
Processor
GPU
Programmable
primitive
assembly!
CPU
Rasterize
Fragments (pre-pixels)
Geometry
Assemble
Processor
Primitives
Vertices (3D)
Application
Vertex
Processor
Video
Memory
(Textures)
Render-to-texture
More
flexible
memory access!
processor (multiple in
parallel)
Transform from world space to
image space
Compute per-vertex lighting
processor
processors (multiple in
parallel)
Compute a color for each pixel
Optionally read colors from textures
(images)
GPU Parallelism
GPU Programming
Simplified
computational
model
consistent as
hardware changes
All
stages SIMD
Fixed conversion /
remapping
between each
stage
Vertex
(stream)
Geometry
(stream)
Fragment
(array)
Buffer
Example
Vertex
shader
void main()
{
Vertex
gl_FrontColor = gl_Color;
(stream)
gl_Position = gl_ProjectionMatrix
* gl_ModelViewMatrix
* gl_Vertex;
}
Geometry
(stream)
Pixel
shader
void main()
{
gl_FragColor = gl_Color;
}
Fragment
(array)
Buffer
Vertex Shader
One element in / one out
No communication
Can select fragment address
Input:
Output:
Restrictions:
Pixel Shader
Biggest computational resource
One element in / 0 1 out
Cannot change destination address
No communication
Input:
Output:
Restrictions:
Example
Vertex
shader
http://www.lighthouse3d.com/open
gl/glsl/
void main()
{
vec4 v = vec4(gl_Vertex);
v.z = 0.0;
gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix *
gl_Vertex;
}
Pixel
shader
void main()
{
gl_FragColor = vec4(0.8,0.4,0.4,1.0);
}
Geometry Shader
One
Like
vertex:
Input:
Output:
Restrictions:
Geometry Shader
Applications
Fur/fins, procedural
geometry/detailing,
Data visualization techniques,
Wide lines and strokes,
Multiple Passes
Communication
Vertex
(stream)
Geometry
(stream)
Fragment
(array)
Buffer
Example
Depth buffer
Normal buffer
Final result
Silhouettes
Creases
GPU Applications
Bump/Displacement
Height map
mapping
GPU Applications
Volume
texture mapping
GPU Applications
Cloth
simulation
GPU Applications
GPU Applications
Real-time
rendering
Image processing
General purpose GPU (GPGPU)
Contents
Introduction
to GPU
High level shading languages
GPU applications
GPU Applications
Soft
Shadows