Upload
others
View
7
Download
0
Embed Size (px)
Citation preview
AMCS / CS 247 – Scientific VisualizationLecture 10: GPU Basics
Markus Hadwiger, KAUST
2
Reading Assignment #5 (until Sep 22)
Read (required):• Real-Time Volume Graphics, Chapter 2 (GPU Programming)
• Real-Time Volume Graphics, Chapter 5.3 (Gradient-Based Illumination)
• Real-Time Volume Graphics, Chapter 5.4.1 (Blinn-Phong Illumination)
3
What‘s in a GPU?
Lots of floating point processing power• Stream processing cores
different names:stream processors,CUDA cores, ...
• Was vector processing, now scalar cores!
Still lots of fixed graphics functionality• Attribute interpolation (per-vertex -> per-fragment)
• Rasterization (turning triangles into fragments/pixels)
• Texture sampling and filtering
• Depth buffering (per-pixel visibility)
• Blending/compositing (semi-transparent geometry, ...)
• Frame buffers
What can the hardware do?
RasterizationDecomposition into fragmentsInterpolation of colorTexturing
Interpolation/Filtering Fragment Shading
Fragment OperationsDepth Test (Z-Test)Alpha Blending (Compositing)
Pixels
Graphics Pipeline
Vertices Primitives Fragments
GeometryProcessing
FragmentOperations
Scene Description Raster Image
Rasterization
Geometry Processing
Per-VertexLightingClipping,
Perspect.DividePrimitiveAssemblyTransformation
Multiplication withModelview and
Projection Matrix
Per-VertexLocal Illumination
(Blinn/Phong)
GeometricPrimitives
(Points, LinesTriangles)
Primitives
Clip SpaceTo
Screen Space
Vertices
GeometryProcessing Rasterization Fragment
Operations
GeometryProcessing Rasterization Fragment
OperationsFragment
Operations
TextureFetchTexture
ApplicationPolygon
Rasterization
PrimitiveVertices
Decompositionof primitives
into fragments
Interpolation oftexture coordinates
Filtering oftexture color
Primitives Fragments
Rasterization
Combination ofprimary color with
texture color
Combination ofprimary color with
texture color
Fragment Operations
StencilTestAlpha
BlendingDepthTest
AlphaTest
Discard allfragments within
a certain alpha range
Discard afragment ifthe stencil buffer is set
Discard alloccludedfragments
GeometryProcessing Rasterization Fragment
Operations
Pixels
Graphics Hardware
Vertices Primitives Fragments
GeometryProcessing
FragmentOperations
Scene Description Raster Image
RasterizationVertexShader
FragmentShader
Programmable Pipeline
10
Direct3D 10 Pipeline
New geometry shader stage:• Vertex -> geometry -> pixel shaders
• Stream output after geometry shader
Courtesy David Blythe, Microsoft
Programmable Processing Stages
GLSL 1.50 (OpenGL 3.2)• Vertex shaders (run on vertex processors)
• Geometry shaders (run on geometry processors)
• Fragment shaders (run on fragment processors)
From the language / API perspective it is useful to consider separate types of processors, even when all of these shaders are in reality executed on identical processing cores on current GPUs!
11
Vertex Shader (1)
Process vertices and their attributes• Position
• Color, texture coordinate(s), ...
12
GLSL 1.20
Vertex Shader (2)
“Pass-through“ example• Pass through per-vertex color
• Transform vertex position with OpenGL Model-View-Projection matrix
13
Geometry Shader (1)
Process whole primitives• Emit vertices
• Emit primitive(s)
14GL_EXT_geometry_shader4
Geometry Shader (2)
“Pass-through“ example• Pass through (emit) all vertices
• Pass through (emit) one primitive
15
Fragment Shader (1)
Process fragments• Write one or more output fragments
• Use input color, texture coordinates, ...
• Compute shading, sample textures, ...
• Optionally discard fragment
• MRT: multiple render targets
16
GLSL 1.20
Fragment Shader (2)
“Pass-through“ example• Pass through interpolated color as fragment color
17
Thank you.
Thanks for material• Helwig Hauser
• Eduard Gröller
• Daniel Weiskopf
• Torsten Möller
• Ronny Peikert
• Philipp Muigg
• Christof Rezk-Salama