software renderer accelerated by cuda...

34

Upload: others

Post on 13-Jun-2020

31 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Software Renderer Accelerated by CUDA Technologymaxest.gct-game.net/content/vainmoinen/bachelor_thesis... · 2015-03-10 · Software Renderer Accelerated by CUDA echnologyT Wojciech

Introduction The Graphics Pipeline Project Architecture Demo Performance Tests Conclusions and Future Work

Software Renderer

Accelerated by CUDA Technology

Wojciech Sterna

25th of January, 2011

Wojciech Sterna

Software Renderer Accelerated by CUDA Technology

Page 2: Software Renderer Accelerated by CUDA Technologymaxest.gct-game.net/content/vainmoinen/bachelor_thesis... · 2015-03-10 · Software Renderer Accelerated by CUDA echnologyT Wojciech

Introduction The Graphics Pipeline Project Architecture Demo Performance Tests Conclusions and Future Work

Fundamental Concepts

I rendering � process of generating a 2D image from a 3D data

set

I the graphics pipeline � set of stages the input 3D data set is

passed through to generate the 2D output image

I CUDA � technology from NVIDIA that allows for parallel

general-purpose code execution using graphics cards

Wojciech Sterna

Software Renderer Accelerated by CUDA Technology

Page 3: Software Renderer Accelerated by CUDA Technologymaxest.gct-game.net/content/vainmoinen/bachelor_thesis... · 2015-03-10 · Software Renderer Accelerated by CUDA echnologyT Wojciech

Introduction The Graphics Pipeline Project Architecture Demo Performance Tests Conclusions and Future Work

Fundamental Concepts

I rendering � process of generating a 2D image from a 3D data

set

I the graphics pipeline � set of stages the input 3D data set is

passed through to generate the 2D output image

I CUDA � technology from NVIDIA that allows for parallel

general-purpose code execution using graphics cards

Wojciech Sterna

Software Renderer Accelerated by CUDA Technology

Page 4: Software Renderer Accelerated by CUDA Technologymaxest.gct-game.net/content/vainmoinen/bachelor_thesis... · 2015-03-10 · Software Renderer Accelerated by CUDA echnologyT Wojciech

Introduction The Graphics Pipeline Project Architecture Demo Performance Tests Conclusions and Future Work

Fundamental Concepts

I rendering � process of generating a 2D image from a 3D data

set

I the graphics pipeline � set of stages the input 3D data set is

passed through to generate the 2D output image

I CUDA � technology from NVIDIA that allows for parallel

general-purpose code execution using graphics cards

Wojciech Sterna

Software Renderer Accelerated by CUDA Technology

Page 5: Software Renderer Accelerated by CUDA Technologymaxest.gct-game.net/content/vainmoinen/bachelor_thesis... · 2015-03-10 · Software Renderer Accelerated by CUDA echnologyT Wojciech

Introduction The Graphics Pipeline Project Architecture Demo Performance Tests Conclusions and Future Work

Fundamental Concepts

I rendering � process of generating a 2D image from a 3D data

set

I the graphics pipeline � set of stages the input 3D data set is

passed through to generate the 2D output image

I CUDA � technology from NVIDIA that allows for parallel

general-purpose code execution using graphics cards

Wojciech Sterna

Software Renderer Accelerated by CUDA Technology

Page 6: Software Renderer Accelerated by CUDA Technologymaxest.gct-game.net/content/vainmoinen/bachelor_thesis... · 2015-03-10 · Software Renderer Accelerated by CUDA echnologyT Wojciech

Introduction The Graphics Pipeline Project Architecture Demo Performance Tests Conclusions and Future Work

Goals of the Work

I implement in software a selected subset of OpenGL �

Vainmoinen

I speed the implementation with CUDA

I compare the performance of a reference application using:I Vainmoinen without CUDAI Vainmoinen with CUDAI OpenGL

Wojciech Sterna

Software Renderer Accelerated by CUDA Technology

Page 7: Software Renderer Accelerated by CUDA Technologymaxest.gct-game.net/content/vainmoinen/bachelor_thesis... · 2015-03-10 · Software Renderer Accelerated by CUDA echnologyT Wojciech

Introduction The Graphics Pipeline Project Architecture Demo Performance Tests Conclusions and Future Work

Goals of the Work

I implement in software a selected subset of OpenGL �

Vainmoinen

I speed the implementation with CUDA

I compare the performance of a reference application using:I Vainmoinen without CUDAI Vainmoinen with CUDAI OpenGL

Wojciech Sterna

Software Renderer Accelerated by CUDA Technology

Page 8: Software Renderer Accelerated by CUDA Technologymaxest.gct-game.net/content/vainmoinen/bachelor_thesis... · 2015-03-10 · Software Renderer Accelerated by CUDA echnologyT Wojciech

Introduction The Graphics Pipeline Project Architecture Demo Performance Tests Conclusions and Future Work

Goals of the Work

I implement in software a selected subset of OpenGL �

Vainmoinen

I speed the implementation with CUDA

I compare the performance of a reference application using:I Vainmoinen without CUDAI Vainmoinen with CUDAI OpenGL

Wojciech Sterna

Software Renderer Accelerated by CUDA Technology

Page 9: Software Renderer Accelerated by CUDA Technologymaxest.gct-game.net/content/vainmoinen/bachelor_thesis... · 2015-03-10 · Software Renderer Accelerated by CUDA echnologyT Wojciech

Introduction The Graphics Pipeline Project Architecture Demo Performance Tests Conclusions and Future Work

Goals of the Work

I implement in software a selected subset of OpenGL �

Vainmoinen

I speed the implementation with CUDA

I compare the performance of a reference application using:I Vainmoinen without CUDAI Vainmoinen with CUDAI OpenGL

Wojciech Sterna

Software Renderer Accelerated by CUDA Technology

Page 10: Software Renderer Accelerated by CUDA Technologymaxest.gct-game.net/content/vainmoinen/bachelor_thesis... · 2015-03-10 · Software Renderer Accelerated by CUDA echnologyT Wojciech

Introduction The Graphics Pipeline Project Architecture Demo Performance Tests Conclusions and Future Work

World De�nition

I the world is built with triangles only

I every triangle consists of 3 vertices

I every vertex has a position, color and texture coordinate

Wojciech Sterna

Software Renderer Accelerated by CUDA Technology

Page 11: Software Renderer Accelerated by CUDA Technologymaxest.gct-game.net/content/vainmoinen/bachelor_thesis... · 2015-03-10 · Software Renderer Accelerated by CUDA echnologyT Wojciech

Introduction The Graphics Pipeline Project Architecture Demo Performance Tests Conclusions and Future Work

World De�nition

I the world is built with triangles only

I every triangle consists of 3 vertices

I every vertex has a position, color and texture coordinate

Wojciech Sterna

Software Renderer Accelerated by CUDA Technology

Page 12: Software Renderer Accelerated by CUDA Technologymaxest.gct-game.net/content/vainmoinen/bachelor_thesis... · 2015-03-10 · Software Renderer Accelerated by CUDA echnologyT Wojciech

Introduction The Graphics Pipeline Project Architecture Demo Performance Tests Conclusions and Future Work

Vertex Processing

I input vertex P = (x , y , z) goes through a series of matrixtransformations resulting in vertex P ′ = (x ′, y ′, z ′), where:

I (x ′, y ′) � position of the vertex on the screen in window

coordinatesI z

′ � distance of the vertex to the camera in normalized

[−1, 1] range

Other operations that take place during vertex processing:

I clipping to the near plane

I view frustum culling

I backface culling

Wojciech Sterna

Software Renderer Accelerated by CUDA Technology

Page 13: Software Renderer Accelerated by CUDA Technologymaxest.gct-game.net/content/vainmoinen/bachelor_thesis... · 2015-03-10 · Software Renderer Accelerated by CUDA echnologyT Wojciech

Introduction The Graphics Pipeline Project Architecture Demo Performance Tests Conclusions and Future Work

Vertex Processing

I input vertex P = (x , y , z) goes through a series of matrixtransformations resulting in vertex P ′ = (x ′, y ′, z ′), where:

I (x ′, y ′) � position of the vertex on the screen in window

coordinatesI z

′ � distance of the vertex to the camera in normalized

[−1, 1] range

Other operations that take place during vertex processing:

I clipping to the near plane

I view frustum culling

I backface culling

Wojciech Sterna

Software Renderer Accelerated by CUDA Technology

Page 14: Software Renderer Accelerated by CUDA Technologymaxest.gct-game.net/content/vainmoinen/bachelor_thesis... · 2015-03-10 · Software Renderer Accelerated by CUDA echnologyT Wojciech

Introduction The Graphics Pipeline Project Architecture Demo Performance Tests Conclusions and Future Work

Vertex Processing

I input vertex P = (x , y , z) goes through a series of matrixtransformations resulting in vertex P ′ = (x ′, y ′, z ′), where:

I (x ′, y ′) � position of the vertex on the screen in window

coordinatesI z

′ � distance of the vertex to the camera in normalized

[−1, 1] range

Other operations that take place during vertex processing:

I clipping to the near plane

I view frustum culling

I backface culling

Wojciech Sterna

Software Renderer Accelerated by CUDA Technology

Page 15: Software Renderer Accelerated by CUDA Technologymaxest.gct-game.net/content/vainmoinen/bachelor_thesis... · 2015-03-10 · Software Renderer Accelerated by CUDA echnologyT Wojciech

Introduction The Graphics Pipeline Project Architecture Demo Performance Tests Conclusions and Future Work

Pixel Processing

I loop through the pixels of every triangle

I use barycentric coordinates to get the interpolated values

(color and texture coordinate) at every pixel, given the values

at the vertices of the triangle being processed

Wojciech Sterna

Software Renderer Accelerated by CUDA Technology

Page 16: Software Renderer Accelerated by CUDA Technologymaxest.gct-game.net/content/vainmoinen/bachelor_thesis... · 2015-03-10 · Software Renderer Accelerated by CUDA echnologyT Wojciech

Introduction The Graphics Pipeline Project Architecture Demo Performance Tests Conclusions and Future Work

Pixel Processing

I loop through the pixels of every triangle

I use barycentric coordinates to get the interpolated values

(color and texture coordinate) at every pixel, given the values

at the vertices of the triangle being processed

Wojciech Sterna

Software Renderer Accelerated by CUDA Technology

Page 17: Software Renderer Accelerated by CUDA Technologymaxest.gct-game.net/content/vainmoinen/bachelor_thesis... · 2015-03-10 · Software Renderer Accelerated by CUDA echnologyT Wojciech

Introduction The Graphics Pipeline Project Architecture Demo Performance Tests Conclusions and Future Work

Pixel Processing

Naive interpolation leads to incorrectly rendered image:

Solution � perspective-correct interpolation:

Wojciech Sterna

Software Renderer Accelerated by CUDA Technology

Page 18: Software Renderer Accelerated by CUDA Technologymaxest.gct-game.net/content/vainmoinen/bachelor_thesis... · 2015-03-10 · Software Renderer Accelerated by CUDA echnologyT Wojciech

Introduction The Graphics Pipeline Project Architecture Demo Performance Tests Conclusions and Future Work

Pixel Processing

Naive interpolation leads to incorrectly rendered image:

Solution � perspective-correct interpolation:

Wojciech Sterna

Software Renderer Accelerated by CUDA Technology

Page 19: Software Renderer Accelerated by CUDA Technologymaxest.gct-game.net/content/vainmoinen/bachelor_thesis... · 2015-03-10 · Software Renderer Accelerated by CUDA echnologyT Wojciech

Introduction The Graphics Pipeline Project Architecture Demo Performance Tests Conclusions and Future Work

Pixel Processing

Texture magni�cation:

Solution � bilinear �ltering:

Wojciech Sterna

Software Renderer Accelerated by CUDA Technology

Page 20: Software Renderer Accelerated by CUDA Technologymaxest.gct-game.net/content/vainmoinen/bachelor_thesis... · 2015-03-10 · Software Renderer Accelerated by CUDA echnologyT Wojciech

Introduction The Graphics Pipeline Project Architecture Demo Performance Tests Conclusions and Future Work

Pixel Processing

Texture magni�cation:

Solution � bilinear �ltering:

Wojciech Sterna

Software Renderer Accelerated by CUDA Technology

Page 21: Software Renderer Accelerated by CUDA Technologymaxest.gct-game.net/content/vainmoinen/bachelor_thesis... · 2015-03-10 · Software Renderer Accelerated by CUDA echnologyT Wojciech

Introduction The Graphics Pipeline Project Architecture Demo Performance Tests Conclusions and Future Work

Pixel ProcessingTexture mini�cation:

Solution � mipmapping:

Wojciech Sterna

Software Renderer Accelerated by CUDA Technology

Page 22: Software Renderer Accelerated by CUDA Technologymaxest.gct-game.net/content/vainmoinen/bachelor_thesis... · 2015-03-10 · Software Renderer Accelerated by CUDA echnologyT Wojciech

Introduction The Graphics Pipeline Project Architecture Demo Performance Tests Conclusions and Future Work

Pixel ProcessingTexture mini�cation:

Solution � mipmapping:

Wojciech Sterna

Software Renderer Accelerated by CUDA Technology

Page 23: Software Renderer Accelerated by CUDA Technologymaxest.gct-game.net/content/vainmoinen/bachelor_thesis... · 2015-03-10 · Software Renderer Accelerated by CUDA echnologyT Wojciech

Introduction The Graphics Pipeline Project Architecture Demo Performance Tests Conclusions and Future Work

UML Class Diagram

Wojciech Sterna

Software Renderer Accelerated by CUDA Technology

Page 24: Software Renderer Accelerated by CUDA Technologymaxest.gct-game.net/content/vainmoinen/bachelor_thesis... · 2015-03-10 · Software Renderer Accelerated by CUDA echnologyT Wojciech

Introduction The Graphics Pipeline Project Architecture Demo Performance Tests Conclusions and Future Work

Demo

Wojciech Sterna

Software Renderer Accelerated by CUDA Technology

Page 25: Software Renderer Accelerated by CUDA Technologymaxest.gct-game.net/content/vainmoinen/bachelor_thesis... · 2015-03-10 · Software Renderer Accelerated by CUDA echnologyT Wojciech

Introduction The Graphics Pipeline Project Architecture Demo Performance Tests Conclusions and Future Work

Performance Tests

Test 1 � a few of huge triangles:

Renderer Time

Vainmoinen without CUDA 10400 ms

Vainmoinen with CUDA (One-Call-One-Triangle) 225 ms

Vainmoinen with CUDA (One-Call-Many-Triangles) 2200 ms

OpenGL 32 ms

Test 2 � a lot of tiny triangles:

Renderer Time

Vainmoinen without CUDA 24 ms

Vainmoinen with CUDA (One-Call-One-Triangle) 415 ms

Vainmoinen with CUDA (One-Call-Many-Triangles) 33 ms

OpenGL 22 ms

Wojciech Sterna

Software Renderer Accelerated by CUDA Technology

Page 26: Software Renderer Accelerated by CUDA Technologymaxest.gct-game.net/content/vainmoinen/bachelor_thesis... · 2015-03-10 · Software Renderer Accelerated by CUDA echnologyT Wojciech

Introduction The Graphics Pipeline Project Architecture Demo Performance Tests Conclusions and Future Work

Performance TestsTest 1 � a few of huge triangles:

Renderer Time

Vainmoinen without CUDA 10400 ms

Vainmoinen with CUDA (One-Call-One-Triangle) 225 ms

Vainmoinen with CUDA (One-Call-Many-Triangles) 2200 ms

OpenGL 32 ms

Test 2 � a lot of tiny triangles:

Renderer Time

Vainmoinen without CUDA 24 ms

Vainmoinen with CUDA (One-Call-One-Triangle) 415 ms

Vainmoinen with CUDA (One-Call-Many-Triangles) 33 ms

OpenGL 22 ms

Wojciech Sterna

Software Renderer Accelerated by CUDA Technology

Page 27: Software Renderer Accelerated by CUDA Technologymaxest.gct-game.net/content/vainmoinen/bachelor_thesis... · 2015-03-10 · Software Renderer Accelerated by CUDA echnologyT Wojciech

Introduction The Graphics Pipeline Project Architecture Demo Performance Tests Conclusions and Future Work

Performance TestsTest 1 � a few of huge triangles:

Renderer Time

Vainmoinen without CUDA 10400 ms

Vainmoinen with CUDA (One-Call-One-Triangle) 225 ms

Vainmoinen with CUDA (One-Call-Many-Triangles) 2200 ms

OpenGL 32 ms

Test 2 � a lot of tiny triangles:

Renderer Time

Vainmoinen without CUDA 24 ms

Vainmoinen with CUDA (One-Call-One-Triangle) 415 ms

Vainmoinen with CUDA (One-Call-Many-Triangles) 33 ms

OpenGL 22 ms

Wojciech Sterna

Software Renderer Accelerated by CUDA Technology

Page 28: Software Renderer Accelerated by CUDA Technologymaxest.gct-game.net/content/vainmoinen/bachelor_thesis... · 2015-03-10 · Software Renderer Accelerated by CUDA echnologyT Wojciech

Introduction The Graphics Pipeline Project Architecture Demo Performance Tests Conclusions and Future Work

Conclusions and Future Work

I implementation of the renderer itself has proven not to be

that di�cult

I gaining the mathematical background needed to know how to

implement the renderer has proven to be di�cult

it was also a great fun by the way

I CUDA can greatly speed up calculations

I further development of Vainmoinen would simply involve

implementation of additional features

Wojciech Sterna

Software Renderer Accelerated by CUDA Technology

Page 29: Software Renderer Accelerated by CUDA Technologymaxest.gct-game.net/content/vainmoinen/bachelor_thesis... · 2015-03-10 · Software Renderer Accelerated by CUDA echnologyT Wojciech

Introduction The Graphics Pipeline Project Architecture Demo Performance Tests Conclusions and Future Work

Conclusions and Future Work

I implementation of the renderer itself has proven not to be

that di�cult

I gaining the mathematical background needed to know how to

implement the renderer has proven to be di�cult

it was also a great fun by the way

I CUDA can greatly speed up calculations

I further development of Vainmoinen would simply involve

implementation of additional features

Wojciech Sterna

Software Renderer Accelerated by CUDA Technology

Page 30: Software Renderer Accelerated by CUDA Technologymaxest.gct-game.net/content/vainmoinen/bachelor_thesis... · 2015-03-10 · Software Renderer Accelerated by CUDA echnologyT Wojciech

Introduction The Graphics Pipeline Project Architecture Demo Performance Tests Conclusions and Future Work

Conclusions and Future Work

I implementation of the renderer itself has proven not to be

that di�cult

I gaining the mathematical background needed to know how to

implement the renderer has proven to be di�cult

it was also a great fun by the way

I CUDA can greatly speed up calculations

I further development of Vainmoinen would simply involve

implementation of additional features

Wojciech Sterna

Software Renderer Accelerated by CUDA Technology

Page 31: Software Renderer Accelerated by CUDA Technologymaxest.gct-game.net/content/vainmoinen/bachelor_thesis... · 2015-03-10 · Software Renderer Accelerated by CUDA echnologyT Wojciech

Introduction The Graphics Pipeline Project Architecture Demo Performance Tests Conclusions and Future Work

Conclusions and Future Work

I implementation of the renderer itself has proven not to be

that di�cult

I gaining the mathematical background needed to know how to

implement the renderer has proven to be di�cult

it was also a great fun by the way

I CUDA can greatly speed up calculations

I further development of Vainmoinen would simply involve

implementation of additional features

Wojciech Sterna

Software Renderer Accelerated by CUDA Technology

Page 32: Software Renderer Accelerated by CUDA Technologymaxest.gct-game.net/content/vainmoinen/bachelor_thesis... · 2015-03-10 · Software Renderer Accelerated by CUDA echnologyT Wojciech

Introduction The Graphics Pipeline Project Architecture Demo Performance Tests Conclusions and Future Work

Conclusions and Future Work

I implementation of the renderer itself has proven not to be

that di�cult

I gaining the mathematical background needed to know how to

implement the renderer has proven to be di�cult

it was also a great fun by the way

I CUDA can greatly speed up calculations

I further development of Vainmoinen would simply involve

implementation of additional features

Wojciech Sterna

Software Renderer Accelerated by CUDA Technology

Page 33: Software Renderer Accelerated by CUDA Technologymaxest.gct-game.net/content/vainmoinen/bachelor_thesis... · 2015-03-10 · Software Renderer Accelerated by CUDA echnologyT Wojciech

Introduction The Graphics Pipeline Project Architecture Demo Performance Tests Conclusions and Future Work

Conclusions and Future Work

I implementation of the renderer itself has proven not to be

that di�cult

I gaining the mathematical background needed to know how to

implement the renderer has proven to be di�cult

it was also a great fun by the way

I CUDA can greatly speed up calculations

I further development of Vainmoinen would simply involve

implementation of additional features

Wojciech Sterna

Software Renderer Accelerated by CUDA Technology

Page 34: Software Renderer Accelerated by CUDA Technologymaxest.gct-game.net/content/vainmoinen/bachelor_thesis... · 2015-03-10 · Software Renderer Accelerated by CUDA echnologyT Wojciech

Introduction The Graphics Pipeline Project Architecture Demo Performance Tests Conclusions and Future Work

Thank you for the attention!

Wojciech Sterna

Software Renderer Accelerated by CUDA Technology