Top Banner
Two-Level Grids for Ray Tracing on GPUs Javor Kalojanov, Markus Billeter, Philipp Slusallek
32

Two-Level Grids for Ray Tracing on GPUs Javor Kalojanov, Markus Billeter, Philipp Slusallek.

Dec 17, 2015

Download

Documents

Samuel Nash
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Two-Level Grids for Ray Tracing on GPUs Javor Kalojanov, Markus Billeter, Philipp Slusallek.

Two-Level Grids for Ray Tracing on GPUs

Javor Kalojanov, Markus Billeter, Philipp Slusallek

Page 2: Two-Level Grids for Ray Tracing on GPUs Javor Kalojanov, Markus Billeter, Philipp Slusallek.
Page 3: Two-Level Grids for Ray Tracing on GPUs Javor Kalojanov, Markus Billeter, Philipp Slusallek.

• Problems (Acceleration Structures)

– Time to image• Build time• Traversal performance

– High quality structures• Slow construction

– Uniform Grids, LBVH• Slow traversal

Page 4: Two-Level Grids for Ray Tracing on GPUs Javor Kalojanov, Markus Billeter, Philipp Slusallek.
Page 5: Two-Level Grids for Ray Tracing on GPUs Javor Kalojanov, Markus Billeter, Philipp Slusallek.

• Two-Level (Hierarchical) Grids–Work around uniform grids shortcomings

C

B

AD

Page 6: Two-Level Grids for Ray Tracing on GPUs Javor Kalojanov, Markus Billeter, Philipp Slusallek.

• Grid Resolution–Most common heuristic: – – Grid density…• …which minimizes the expected cost for

traversing a random ray

Page 7: Two-Level Grids for Ray Tracing on GPUs Javor Kalojanov, Markus Billeter, Philipp Slusallek.

• Teapot in Stadium

– Intersection tests• Uniform Grid and Two-Level Grid

Page 8: Two-Level Grids for Ray Tracing on GPUs Javor Kalojanov, Markus Billeter, Philipp Slusallek.

Two-Level Grid Construction

Page 9: Two-Level Grids for Ray Tracing on GPUs Javor Kalojanov, Markus Billeter, Philipp Slusallek.

0, 3x3

• Data structure

17,1x118,1x119,1x1

14,1x1 16,1x1

0, 3x39,1x110,2x2

15,1x1

Top Level Cells:

[0,0)[0,0)[0,1)[0,0)[1,2)[2,5)[0,0)[0,0)[5,7)[7,8)

Leaf Array:

C

B

AD

Reference Array:

60 1 2 3 4C CB 105A 7 8 9A B C C D C C 11 12B B2 3 4 CBA

[0,0)[0,0)[0,1)[0,0)[1,2)[2,5)[0,0)[0,0)[5,7)[0,0)[0,0)[0,1)[0,0)[1,2)[2,5)[0,0)[0,0)[5,7)[2,5)

Page 10: Two-Level Grids for Ray Tracing on GPUs Javor Kalojanov, Markus Billeter, Philipp Slusallek.

• Sort-Based Construction

– Spatial index structure = partial ordering– GPU friendly• Works for LBVHs and uniform grids

– Idea• Pair primitives with a key• Sort by the key• Extract the structure from the sorted data

Page 11: Two-Level Grids for Ray Tracing on GPUs Javor Kalojanov, Markus Billeter, Philipp Slusallek.

• Top-Level Cells

C

B

A D (Cell ID, Prim ID)

D2A0 C0B0 C1 C2B3 B4

D2A0 C0B0 C1 C2 B3 B4

Radix Sort

Extract Cells

Sorted Pairs

17,1x118,1x119,1x1

14,1x1 16,1x1

0, 3x39,1x110,2x2

15,1x1

Write Pairs

Page 12: Two-Level Grids for Ray Tracing on GPUs Javor Kalojanov, Markus Billeter, Philipp Slusallek.

• Leaves (Naïve Version)

– Build top level cells consecutively• Sequential slow

– One thread per cell• Poor work distribution slow

Top Cells

D2A0 C0B0 C1 C2 B3 B4 17,1x118,1x119,1x114,1x1 16,1x10, 3x39,1x110,2x2

15,1x1

Page 13: Two-Level Grids for Ray Tracing on GPUs Javor Kalojanov, Markus Billeter, Philipp Slusallek.

• Leaves

Write Pairs

Top Cells

(Leaf ID, Prim ID)

D2A0 C0B0 C1 C2 B3 B4

A4 B8 D1A5 B5 C2 C5 C8 C0 B0C2 C3 B0

17,1x118,1x119,1x114,1x1 16,1x10, 3x39,1x110,2x2

15,1x1

C0 B0 B0

Same Leaf!

Page 14: Two-Level Grids for Ray Tracing on GPUs Javor Kalojanov, Markus Billeter, Philipp Slusallek.

• Which Key?

– Keys and leaf cells must be one-one correspondence

– Use the leaf positions in the array as keys

[0,0)[0,0)[0,1)[0,0)[1,2)[2,5)[0,0)[0,0)[5,7)[7,8)

Leaf Array:

0 1 2 3 4 5 6 7 8 9

Page 15: Two-Level Grids for Ray Tracing on GPUs Javor Kalojanov, Markus Billeter, Philipp Slusallek.

• Leaves (2)– Single sort for all leaves

Write Pairs

[0,0) [0,0) [0,1) [0,0) [1,2) [0,0) [8,9)[2,5) [0,0) [0,0) [5,7) [7,8)

Top Cells

(Key, Prim ID)

Radix Sort

Extract Leaves

Sorted Pairs

D2A0 C0B0 C1 C2 B3 B4

A4 B8 D11A5 B5 C2 C5 C8 C9 B15C12 C13 B14

A5 B8 D11A4 B5C2 C5 C8 C9 B15C12 C13 B14

17,1x118,1x119,1x114,1x1 16,1x10, 3x39,1x110,2x2

15,1x1

Page 16: Two-Level Grids for Ray Tracing on GPUs Javor Kalojanov, Markus Billeter, Philipp Slusallek.

• Build Performance– Very scalable • 100M pairs per second

– Small memory footprint

0.0M

Fairy

0.5M

Dragon 0.9M

1.5M2.0M

Conference 2.3M

3.0M

Venice 3.7M

4.0M4.5M

5.0M6.0M

Soda 6

.6M0

1020304050607080

Time (ms)LinearMemory (MB)

Page 17: Two-Level Grids for Ray Tracing on GPUs Javor Kalojanov, Markus Billeter, Philipp Slusallek.

Two-Level Grid Traversal

Page 18: Two-Level Grids for Ray Tracing on GPUs Javor Kalojanov, Markus Billeter, Philipp Slusallek.

• Two-Level Grid Traversal on GPUs

– Uniform grid traversal• For the first level• For the second level

– Avoid code divergence

– Coherent memory access for coherent rays• Must start in the same cell

Page 19: Two-Level Grids for Ray Tracing on GPUs Javor Kalojanov, Markus Billeter, Philipp Slusallek.

• Ray Coherence–Memory coherence for rays starting in

the same cell

1

Page 20: Two-Level Grids for Ray Tracing on GPUs Javor Kalojanov, Markus Billeter, Philipp Slusallek.

• Ray Coherence–Memory coherence for rays starting in

the same cell

2

2

Page 21: Two-Level Grids for Ray Tracing on GPUs Javor Kalojanov, Markus Billeter, Philipp Slusallek.

• Ray Coherence–Memory coherence for rays starting in

the same cell

3

Page 22: Two-Level Grids for Ray Tracing on GPUs Javor Kalojanov, Markus Billeter, Philipp Slusallek.

• Ray Incoherence– SIMD inefficiency due to early

terminationThread Activity

Thread 1: active

Thread 2: active

Thread 3: active

Thread 6: idle

Thread 7: idle

Thread 4: active

Thread 5: idle

Thread 8: idle

Page 23: Two-Level Grids for Ray Tracing on GPUs Javor Kalojanov, Markus Billeter, Philipp Slusallek.

• Secondary Rays– SIMD inefficiency due to incoherence

Thread Activity

Thread 1: active

Thread 2: active

Thread 3: idle

Thread 6: idle

Thread 7: idle

Thread 4: idle

Thread 5: idle

Thread 8: idle

Page 24: Two-Level Grids for Ray Tracing on GPUs Javor Kalojanov, Markus Billeter, Philipp Slusallek.

• Work Distribution for Incoherent Workloads– Standard packet ray tracer

R1 R2 R3 R4 R5 R6 R7 R8

intersection candidates

rays

Page 25: Two-Level Grids for Ray Tracing on GPUs Javor Kalojanov, Markus Billeter, Philipp Slusallek.

• Work Distribution for Incoherent Workloads– Vertical parallelization

R1 R2 R3 R4 R5 R6 R7 R8

intersection candidates

rays

Page 26: Two-Level Grids for Ray Tracing on GPUs Javor Kalojanov, Markus Billeter, Philipp Slusallek.

• Hybrid Intersector

– Detect rays with high workload• Compute intersections for single ray in

parallel

– Proceed with the remaining rays

– Up to 25% overall speedup• Brute force path tracing• No other optimizations

– No overhead on Fermi GPUs

Page 27: Two-Level Grids for Ray Tracing on GPUs Javor Kalojanov, Markus Billeter, Philipp Slusallek.

Results

Page 28: Two-Level Grids for Ray Tracing on GPUs Javor Kalojanov, Markus Billeter, Philipp Slusallek.

• Results

Times for primary rays and simple shading (no shadows). Frame rate does not include build time. GeForce 280 GTX

Model(Triangles)

LBVH Grid 2lvl Grid Hybrid BVH

Fairy(174K)

10.3 ms1.8 fps

24 ms3.5 fps

8 ms 9.2 fps

124 ms11.6 fps

Bunny/Dragon (252K)

17 ms7.3 fps

13 ms7.7 fps

13 ms10.3 fps

66 ms7.6 fps

Conference(284K)

19 ms6.7 fps

27 ms7.0 fps

17 ms12 fps

105 ms22.9 fps

Soda Hall(2.2M)

66 ms3.0 fps

130 ms6.3 fps

67 ms12.6 fps

445 ms20.7 fps

Page 29: Two-Level Grids for Ray Tracing on GPUs Javor Kalojanov, Markus Billeter, Philipp Slusallek.

• Results (2)

Model(Triangles)

Simple Shading

FPS (MRays/s)

Direct Illumination

FPS (MRays/s)

Path TracingFPS

(MRays/s)

Ogre (50K) 31 fps ( 31 ) 7.8 fps ( 39 ) 3.4 fps ( 10.2 )

Fairy (174K) 15 fps ( 15 ) 2.7 fps ( 13.5 ) 2.1 fps ( 6.3 )

Conference (284K)

22 fps ( 22 ) 3.0 fps ( 15 ) 1.6 fps ( 4.8 )

Venice (1.2M) 18 fps ( 18 ) 3.3 fps ( 16.5 ) 1.4 fps ( 4.2 )GeForce 280 GTX

Page 30: Two-Level Grids for Ray Tracing on GPUs Javor Kalojanov, Markus Billeter, Philipp Slusallek.

• Conclusion

– Fast(est) rebuild from scratch• Data parallel and scalable

– Fast time to image• Even for “Teapot in Stadium” – scenes• (Almost) no code divergence during traversal

Page 31: Two-Level Grids for Ray Tracing on GPUs Javor Kalojanov, Markus Billeter, Philipp Slusallek.

• Acknowledgements

– Anonymous Reviewers

– Vincent Pegoraro

Page 32: Two-Level Grids for Ray Tracing on GPUs Javor Kalojanov, Markus Billeter, Philipp Slusallek.

Thank You!