AMCS / CS 247 – Scientific Visualization Lecture 10: GPU ... · AMCS / CS 247 – Scientific...
Transcript of AMCS / CS 247 – Scientific Visualization Lecture 10: GPU ... · AMCS / CS 247 – Scientific...
![Page 1: AMCS / CS 247 – Scientific Visualization Lecture 10: GPU ... · AMCS / CS 247 – Scientific Visualization Lecture 10: GPU Basics Markus Hadwiger, KAUST. 2 Reading Assignment #5](https://reader034.fdocuments.in/reader034/viewer/2022042103/5e81144d47091b0e507ca1c0/html5/thumbnails/1.jpg)
AMCS / CS 247 – Scientific VisualizationLecture 10: GPU Basics
Markus Hadwiger, KAUST
![Page 2: AMCS / CS 247 – Scientific Visualization Lecture 10: GPU ... · AMCS / CS 247 – Scientific Visualization Lecture 10: GPU Basics Markus Hadwiger, KAUST. 2 Reading Assignment #5](https://reader034.fdocuments.in/reader034/viewer/2022042103/5e81144d47091b0e507ca1c0/html5/thumbnails/2.jpg)
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)
![Page 3: AMCS / CS 247 – Scientific Visualization Lecture 10: GPU ... · AMCS / CS 247 – Scientific Visualization Lecture 10: GPU Basics Markus Hadwiger, KAUST. 2 Reading Assignment #5](https://reader034.fdocuments.in/reader034/viewer/2022042103/5e81144d47091b0e507ca1c0/html5/thumbnails/3.jpg)
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
![Page 4: AMCS / CS 247 – Scientific Visualization Lecture 10: GPU ... · AMCS / CS 247 – Scientific Visualization Lecture 10: GPU Basics Markus Hadwiger, KAUST. 2 Reading Assignment #5](https://reader034.fdocuments.in/reader034/viewer/2022042103/5e81144d47091b0e507ca1c0/html5/thumbnails/4.jpg)
What can the hardware do?
RasterizationDecomposition into fragmentsInterpolation of colorTexturing
Interpolation/Filtering Fragment Shading
Fragment OperationsDepth Test (Z-Test)Alpha Blending (Compositing)
![Page 5: AMCS / CS 247 – Scientific Visualization Lecture 10: GPU ... · AMCS / CS 247 – Scientific Visualization Lecture 10: GPU Basics Markus Hadwiger, KAUST. 2 Reading Assignment #5](https://reader034.fdocuments.in/reader034/viewer/2022042103/5e81144d47091b0e507ca1c0/html5/thumbnails/5.jpg)
Pixels
Graphics Pipeline
Vertices Primitives Fragments
GeometryProcessing
FragmentOperations
Scene Description Raster Image
Rasterization
![Page 6: AMCS / CS 247 – Scientific Visualization Lecture 10: GPU ... · AMCS / CS 247 – Scientific Visualization Lecture 10: GPU Basics Markus Hadwiger, KAUST. 2 Reading Assignment #5](https://reader034.fdocuments.in/reader034/viewer/2022042103/5e81144d47091b0e507ca1c0/html5/thumbnails/6.jpg)
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
![Page 7: AMCS / CS 247 – Scientific Visualization Lecture 10: GPU ... · AMCS / CS 247 – Scientific Visualization Lecture 10: GPU Basics Markus Hadwiger, KAUST. 2 Reading Assignment #5](https://reader034.fdocuments.in/reader034/viewer/2022042103/5e81144d47091b0e507ca1c0/html5/thumbnails/7.jpg)
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
![Page 8: AMCS / CS 247 – Scientific Visualization Lecture 10: GPU ... · AMCS / CS 247 – Scientific Visualization Lecture 10: GPU Basics Markus Hadwiger, KAUST. 2 Reading Assignment #5](https://reader034.fdocuments.in/reader034/viewer/2022042103/5e81144d47091b0e507ca1c0/html5/thumbnails/8.jpg)
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
![Page 9: AMCS / CS 247 – Scientific Visualization Lecture 10: GPU ... · AMCS / CS 247 – Scientific Visualization Lecture 10: GPU Basics Markus Hadwiger, KAUST. 2 Reading Assignment #5](https://reader034.fdocuments.in/reader034/viewer/2022042103/5e81144d47091b0e507ca1c0/html5/thumbnails/9.jpg)
Pixels
Graphics Hardware
Vertices Primitives Fragments
GeometryProcessing
FragmentOperations
Scene Description Raster Image
RasterizationVertexShader
FragmentShader
Programmable Pipeline
![Page 10: AMCS / CS 247 – Scientific Visualization Lecture 10: GPU ... · AMCS / CS 247 – Scientific Visualization Lecture 10: GPU Basics Markus Hadwiger, KAUST. 2 Reading Assignment #5](https://reader034.fdocuments.in/reader034/viewer/2022042103/5e81144d47091b0e507ca1c0/html5/thumbnails/10.jpg)
10
Direct3D 10 Pipeline
New geometry shader stage:• Vertex -> geometry -> pixel shaders
• Stream output after geometry shader
Courtesy David Blythe, Microsoft
![Page 11: AMCS / CS 247 – Scientific Visualization Lecture 10: GPU ... · AMCS / CS 247 – Scientific Visualization Lecture 10: GPU Basics Markus Hadwiger, KAUST. 2 Reading Assignment #5](https://reader034.fdocuments.in/reader034/viewer/2022042103/5e81144d47091b0e507ca1c0/html5/thumbnails/11.jpg)
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
![Page 12: AMCS / CS 247 – Scientific Visualization Lecture 10: GPU ... · AMCS / CS 247 – Scientific Visualization Lecture 10: GPU Basics Markus Hadwiger, KAUST. 2 Reading Assignment #5](https://reader034.fdocuments.in/reader034/viewer/2022042103/5e81144d47091b0e507ca1c0/html5/thumbnails/12.jpg)
Vertex Shader (1)
Process vertices and their attributes• Position
• Color, texture coordinate(s), ...
12
GLSL 1.20
![Page 13: AMCS / CS 247 – Scientific Visualization Lecture 10: GPU ... · AMCS / CS 247 – Scientific Visualization Lecture 10: GPU Basics Markus Hadwiger, KAUST. 2 Reading Assignment #5](https://reader034.fdocuments.in/reader034/viewer/2022042103/5e81144d47091b0e507ca1c0/html5/thumbnails/13.jpg)
Vertex Shader (2)
“Pass-through“ example• Pass through per-vertex color
• Transform vertex position with OpenGL Model-View-Projection matrix
13
![Page 14: AMCS / CS 247 – Scientific Visualization Lecture 10: GPU ... · AMCS / CS 247 – Scientific Visualization Lecture 10: GPU Basics Markus Hadwiger, KAUST. 2 Reading Assignment #5](https://reader034.fdocuments.in/reader034/viewer/2022042103/5e81144d47091b0e507ca1c0/html5/thumbnails/14.jpg)
Geometry Shader (1)
Process whole primitives• Emit vertices
• Emit primitive(s)
14GL_EXT_geometry_shader4
![Page 15: AMCS / CS 247 – Scientific Visualization Lecture 10: GPU ... · AMCS / CS 247 – Scientific Visualization Lecture 10: GPU Basics Markus Hadwiger, KAUST. 2 Reading Assignment #5](https://reader034.fdocuments.in/reader034/viewer/2022042103/5e81144d47091b0e507ca1c0/html5/thumbnails/15.jpg)
Geometry Shader (2)
“Pass-through“ example• Pass through (emit) all vertices
• Pass through (emit) one primitive
15
![Page 16: AMCS / CS 247 – Scientific Visualization Lecture 10: GPU ... · AMCS / CS 247 – Scientific Visualization Lecture 10: GPU Basics Markus Hadwiger, KAUST. 2 Reading Assignment #5](https://reader034.fdocuments.in/reader034/viewer/2022042103/5e81144d47091b0e507ca1c0/html5/thumbnails/16.jpg)
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
![Page 17: AMCS / CS 247 – Scientific Visualization Lecture 10: GPU ... · AMCS / CS 247 – Scientific Visualization Lecture 10: GPU Basics Markus Hadwiger, KAUST. 2 Reading Assignment #5](https://reader034.fdocuments.in/reader034/viewer/2022042103/5e81144d47091b0e507ca1c0/html5/thumbnails/17.jpg)
Fragment Shader (2)
“Pass-through“ example• Pass through interpolated color as fragment color
17
![Page 18: AMCS / CS 247 – Scientific Visualization Lecture 10: GPU ... · AMCS / CS 247 – Scientific Visualization Lecture 10: GPU Basics Markus Hadwiger, KAUST. 2 Reading Assignment #5](https://reader034.fdocuments.in/reader034/viewer/2022042103/5e81144d47091b0e507ca1c0/html5/thumbnails/18.jpg)
Thank you.
Thanks for material• Helwig Hauser
• Eduard Gröller
• Daniel Weiskopf
• Torsten Möller
• Ronny Peikert
• Philipp Muigg
• Christof Rezk-Salama