DRPU a Programmable Hardware Architecture for Real-Time Ray Tracing of Coherent Dynamic Scenes
Total Page:16
File Type:pdf, Size:1020Kb
DRPU A Programmable Hardware Architecture for Real-time Ray Tracing of Coherent Dynamic Scenes Sven Woop Computer Graphics Group Saarland University 66123 Saarbr¨ucken, Germany Dissertation zur Erlangung des Grades des Doktors der Ingenieurwissenschaften (Dr.-Ing.) der Naturwissenschaftlich-Technischen Fakult¨at I der Universit¨at des Saarlandes Betreuender Hochschullehrer / Supervisor: Prof. Dr.-Ing. Philipp Slusallek Universit¨at des Saarlandes, Saarbr¨ucken, Germany Gutachter / Reviewers: Prof. Dr.-Ing. Philipp Slusallek Universit¨at des Saarlandes, Saarbr¨ucken, Germany Prof. Dr. Wolfgang J. Paul Universit¨at des Saarlandes, Saarbr¨ucken, Germany Prof. Erik Brunvand University of Utah, Salt Lake City, USA Dekan / Dean: Prof. Dr. Thorsten Herfet Universit¨at des Saarlandes, Saarbr¨ucken, Germany Eingereicht am / Thesis submitted on: 19. Dezember 2006 / December 19th, 2006 Datum des Kolloquiums / Date of defense: 18. Juni 2007 / 18th June 2007 Vorsitzender des Kolloquiums: Prof. Gert Smolka Wissenschaftlicher Beisitzer: Rafal Mantiuk, Ph.D. Sven Woop Lehrstuhl f¨ur Computergraphik, Geb. E 1 1 / E08 Im Stadtwald, 66123 Saarbr¨ucken, Germany [email protected] Version 1.1 June 29, 2007 iii Abstract Ray tracing is a rendering technique capable of generating high qual- ity photo-realistic images of three dimensional scenes. Rendering speed has been an issue for a long period, but recently high performance software im- plementations have made real-time ray tracing possible. But reaching per- formance levels comparable to rasterization also requires dedicated hardware solutions. This thesis proposes the DRPU architecture (Dynamic Ray Processing Unit) as the first programmable ray tracing hardware design for coherent dynamic scenes. For programmable shading it contains a shading processor that achieves a high level of efficiency due to SIMD processing of floating point vectors, massive multi-threading, and synchronous execution of pack- ets of threads. A dedicated traversal and intersection unit allows for efficient ray casting even in highly dynamic scenes by using B-KD Trees as spatial index structure - a kind of Bounding Volume Hierarchy. A Skinning Proces- sor is used to compute dynamic scene changes and an Update Processor to update the B-KD Tree node bounds after these changes. A working FPGA prototype implementation specified in the devel- oped hardware description language HWML is presented, which achieves performance levels comparable to commodity CPUs even though clocked at a 50 times lower frequency of 66 MHz. The prototype is mapped to a 130nm CMOS ASIC process that allows precise post layout performance estimates. These results are then extrapolated to a 90nm version with similar hardware complexity to current GPUs. It shows that with a similar amount of hard- ware resources frame-rates of 80 to 280 frames per second would be possible even with complex shading at 1024x768 resolution. This would form a good basis for game play and other real-time applications. iv v Kurzfassung Ray-Tracing ist eine Rendertechnik, mit der man hochqualitative und photorealistische Bilder von dreidimensionalen Szenen erstellen kann. Lange Zeit war die geringe Geschwindigkeit des Ray-Tracing-Algorithmus ein großes Problem, in den letzten Jahren wurde jedoch sogar Echtzeit-Ray-Tracing durch hochperformante Ray-Tracing Software erm¨oglicht. Um die Leis- tungsf¨ahigkeit von Rasterisierungs-Hardware zu erreichen sind jedoch spezielle Hardware-Implementierungen f¨ur Ray-Tracing unerl¨asslich. Diese Arbeit stellt die DRPU-Hardware-Architektur vor (Dynamic Ray Processing Unit), die erste voll programmierbare Ray-Tracing-Hardware- Architektur, die selbst hochdynamische Szenen unterst¨utzt. Die DRPU enth¨alt f¨ur programmierbares Shading einen Shading-Prozessor, der hohe Ef- fizienz durch SIMD-Verarbeitung von Fließkomma-Vektoren, massives Multi- Threading und synchrone Ausf¨uhrung von Paketen von Threads gew¨ahrleistet. Die Verwendung von B-KD-B¨aumen (einer Art Bounding- Volume-Hierarchie) sowie einem speziellen Traversierungs- und Schnittpunkt- Berechnungs-Prozessor erm¨oglicht ein effizientes Verfolgen von Strahlen selbst in hochdynamischen Szenen. Dynamische Ver¨anderungen der Szene k¨onnen effizient durch einen Skinning-Prozessor berechnet werden. Dies erfordert die Neuberechnung der Begrenzungen (Bounds) der Index-Struktur durch einen optimierten Update-Prozessor. Dar¨uber hinaus wird eine lauff¨ahige FPGA-Prototypen- Implementie- rung der Architektur vorgestellt, die eine ¨ahnlich hohe Leistungsf¨ahigkeit wie heutige hochperformante CPUs erreicht, trotz seiner 50-mal niedri- geren Taktfrequenz von nur 66 MHz. Der Prototyp wurde in einer ei- gens entwickelten Hardwarebeschreibungssprache HWML implementiert wo- durch eine einfache Portierung auf einen 130nm CMOS-Prozess erm¨oglicht wurde. Die Ergebnisse von Place und Route werden auf eine 90nm Version mit ¨ahnlicher Hardwarekomplexit¨at wie heutige GPUs hochgerechnet und pr¨azise Geschwindigkeitsabsch¨atzungen durchgef¨uhrt. Selbst f¨ur komplexes Sha- ding w¨aren mit solch einem Chip Bildwiederholraten von 80 bis 280 Bildern pro Sekunde bei einer Aufl¨osung von 1024x768 Pixeln m¨oglich. Dies stellt eine gute Grundlage f¨ur Computerspiele oder sonstige Echtzeitanwendungen dar. vi vii Zusammenfassung In der Echtzeit-Computergrafik ist der Rasterisierungs-Algorithmus der heute dominierende Algorithmus, haupts¨achlich da f¨ur diesen sehr effi- ziente Hardware-Implementierungen existieren. Die Grundidee der Raste- risierung besteht darin, die Szene abzubilden, indem jedes Dreieck einzeln auf die Bildebene projiziert wird und jedes bedeckte Pixel gezeichnet bzw. geshaded wird. Da dieses Verfahren Dreiecke unabh¨angig voneinander be- trachtet, k¨onnen komplexe Effekte wie Schatten oder Reflektionen nicht di- rekt berechnet werden, sondern nur durch ineffiziente Multi-Pass-Verfahren approximiert werden. Ray-Tracing hingegen erm¨oglicht die physikalisch korrekte Berechnung solcher Shading-Effekte, indem es Licht r¨uckw¨arts durch die Szene verfolgt und so beispielsweise durch das Schießen eines Reflektionsstrahls den Beitrag des Lichts aus der Reflektionsrichtung direkt in die Farbberechnung mitein- beziehen kann. Da das Schießen von Strahlen durch die Szene eine hohe Rechenkomplexit¨at erfordert, war Echtzeit-Ray-Tracing lange Zeit undenk- bar. In den letzten Jahren haben effiziente Software-Implementierungen dies jedoch erm¨oglicht. Diese Arbeit beschreibt die DRPU-Hardware-Architektur, die Ray- Tracing nicht nur echtzeitf¨ahig macht, sondern in Performanz und Funk- tionalit¨at nahe zur Rasterisierung bringt. Die DRPU erlaubt einerseits das rekursive Schießen von Strahlen w¨ahrend des voll programmierbaren Sha- dings, andererseits werden jedoch auch hochdynamische Szenen unterst¨utzt, solange eine gewisse Koh¨arenz der Dynamik vorhanden ist. Kapitel 1 gibt eine Einf¨uhrung in das Rendering, indem der Rasterisierungs-Algorithmus und der Ray-Tracing-Algorithmus beschrieben und verglichen werden. In Kapitel 2 wird ein Uberblick¨ ¨uber die DRPU- Architektur gegeben, in dem auf die Zusammenarbeit der einzelnen Hard- wareeinheiten eingegangen wird und wichtige Konzepte wie Multi-Threading oder Paket-Bearbeitung von Threads beschrieben werden. Kapitel 3 besch¨aftigt sich mit speziellen Hardwareeinheiten zum Schießen von Strahlen durch dynamische Szenen. Als eine neue Daten- struktur f¨ur Ray-Tracing von dynamischen Szenen werden B-KD B¨aume beschrieben, die eine Art Bounding-Volume-Hierarchie mit eindimensionalen Begrenzungen darstellen. Durch diese Datenstruktur werden Strahlen von einem Traversierungs-Prozessor (TP) traversiert, sowie Strahlen mit Drei- ecken durch einen Schnittpunkt-Berechnungs-Prozessor (GP) geschnitten. Diese beiden Einheiten erm¨oglichen das effiziente Verfolgen von Strahlen durch die Szene, eine der teuersten Operationen von Ray-Tracing. Um dy- namische Szenen zu unterst¨utzen, m¨ussen Teile der B-KD-B¨aume der Szene aktualisiert werden. Dies geschieht durch einen speziellen Update-Prozessor. Es wird demonstriert, dass ein FPGA-Prototyp, der diese Hardwareeinheiten viii zum Strahlenschießen verwendet, schneller ist als herk¨ommliche Software- Implementierungen. Eine weitere wichtige Operation von Ray-Tracing ist das Shading, das an jedem Auftreffpunkt eines Strahls mit der Szene eine Farbe berechnet. Kapitel 4 beschreibt den speziellen Shading-Prozessor (SP) der DRPU, der einen ¨ahnlichen Befehlssatz wie Fragment-Programme der heutigen GPUs hat. Der Shading Prozessor besitzt jedoch deutlich mehr F¨ahigkeiten, da er einerseits hardwaregest¨utzte Rekursion und zum anderen flexible Speicher- zugriffe erlaubt. F¨ur die Implementierung von rekursivem Ray-Tracing wird insbesondere die Rekursion ben¨otigt, wodurch Ray-Tracing-Effekte sehr ein- fach zu kombinieren sind. Der Shading-Prozessor k¨onnte auch dazu verwendet werden die dyna- mischen Ver¨anderungen der Szene zu berechnen w¨are hierbei jedoch nicht so effizient wie eine spezielle Hardwareeinheit. Deshalb wird in Kapitel 5 ein weiterer Spezial-Prozessor beschrieben, welcher einen weit verbreiteten Skinning-Algorithmus implementiert und sehr effizient ausf¨uhren kann. Da viele bereits vorhandene Hardware-Ressourcen von diesem Skinning Prozes- sor wiederverwendet werden, entstehen durch ihn kaum zus¨atzliche Kosten in der DRPU-Architektur. Kapitel 6 widmet sich einer eigens entwickelten Hardwarebeschreibungs- Bibliothek HWML (Hardware Meta Language) f¨ur die funktionale Program- miersprache ML die die Implementierung der DRPU-Architektur stark ver- einfacht