190 likes | 292 Vues
Learn about non-blocking BVH creation techniques in ray tracing, optimizing render times for realistic 3D scenes. Compare blocking and non-blocking algorithms for faster tree construction. Experiment and results analysis included.
E N D
Concurrent Non-blocking BVH Creation Adam Kavanaugh Kris K. Rivera
Introduction to Ray Tracing • Graphics technique for rendering objects in 3D space • Used by movie industry to create exceptionally realistic movies.
Introduction to Ray Tracing • 30-50hrs to render a frame • 3D frames about 100hrs
Acceleration Structures • Axis Aligned Bounding Box (AABB) • Uniform Spatial Subdivision (USS) • k-d Tree • Oct Tree • Bounding Volume Hierarchy (BVH)
Bounding Volume Hierarchy • Binary Tree of bounding volumes • Boxes which encapsulate a collection of primitives • Entire scene of triangles surrounded in large bounding volume • Each level is split along a given axis • “Longest” axis usually chosen to split upon • Location of split is determined by a heuristic • Triangles are “sorted” into respective child bounding volumes by their medians • Process recurs for left and right children until one triangle exists as leaf node in its own volume
Non-Blocking BVH Construction • Tree construction is done in a pseudo-breadth first manner • Pseudo-Breadth First because the current build horizon expands independently as threads progress • Each thread acts as producer and consumer of tree nodes • Implemented using Java’s ConcurrentLinkedQueue class • Uses a wait-free algorithm for the class internals • Uses Java’s Atomic variable classes for CAS based counters.
Non-Blocking bvh construction • Main Algorithm • Dispatch n (or more) threads • Each thread spins on the task queue until the tree is completed • When a thread gets a node from the queue, build the node, increment the number of built nodes and place any children nodes onto the task queue • Store the built node • Generate the BVH tree structure • Shared resources • Task Queue • BVH Tree structure • Counters • Number of nodes, threads, etc.
Non-blocking bvh version differences • Version 1 • Child nodes are added to the tree as they are built • Requires size checks for each add to get the index • Spawn threads on-demand until build completes • Version 2 • Child nodes are stored in each parent, and then flattened into the tree once construction is completed • Only spawn required number of threads
Experiment Setup • 7 builders tested • 2 single threaded, 5 concurrent • Using Depth-Firsth and Breadth-First build strategies • 17 models tested • 1010 triangles (Legoman) to 134K (Halo 3 Scene) • All times averaged over 3 trials • Experiment System • Windows 7 • Intel Core i7 Processor • 4GB RAM
Results • For all builders, we see a general trend towards exponential build times in the number of triangles in the scene. • Non-blocking builder is generally as fast as the other blocking methods, except for the blocking BFS builder, which produces the fastest build times. • Additional threads do not linearly decrease built time.
BfS Builder Comparison • The Blocking BFS Builder is faster than the Non-Blocking Builder. • Average 11.8% faster for 2 threads • Average 8.4% faster for 4 threads
conclusion • Demonstrate the use of lock-free and wait-free data structures for use in BVH tree construction • Lock-free implementation is slower, but not by a lot. • Still gains benefits of being lock-free, and using wait-free data structures. • Implementation details matter!