Chapter 7
OpenSubdiv: Interoperating GPU Compute
and Drawing
Manuel Kraemer
Pixar Animation Studios
7.1 Representing Shapes . . . . . .. . . . . . . . . . .. . . . . . . . .. . . . . . . . . . .. . . . . . . . . . .. . . . . . . . . . . 164
7.1.1 Why Fast Subdivision? . .. . . . . . . . . . .. . . . . . . . . . .. . . . . . . . .. . . . . . . . . . .. . . . 165
7.1.2 Legacy . . . .. .. . . . . . . . .. . . . . . . . . . .. . . . . . . . . . .. . . . . . . . . . .. . . . . . . . . . .. . . . . . 165
7.1.3 OpenSubdiv . . . . . . . . . .. . . . . . . . . . .. . . . . . . . . . .. . . . . . . . . . .. . . . . . . . .. . . . . . . 166
7.2 The Control Cage . . . . . . . .. . . . . . . . .. .. . . . . . . . .. . . . . . . . . . .. . . . . . . . . . .. . . . . . . . . . .. 166
7.2.1 Patches and Arbitrary Topology . . . .. . . . . . . . .. . . . . . . . . . .. . . . . . . . . . .. . . 166
7.2.2 Topological Data Structures . . . . . . . . . . .. . . . . . . . . . .. . . . . . . . . . .. . . . . . . . . . 167
7.2.3 Manifold Surfaces . . . . . . . . . . .. . . . . . . . . . .. . . . . . . . . . .. . . . . . . . . . . . . . . . . . . .. 167
7.2.4 The Limit Surface . . . . . . . . . . .. . . . . . . . . . .. . . . . . . . . . .. . . . . . . . .. . . . . . . . . . . 168
7.3 Uniform Subdivision . . . . . .. . . . . . . . . . .. . . . . . . . .. . . . . . . . . . .. . . . . . . . . . .. . . . . . . . . . . 169
7.3.1 Implementing Subdivision Schemata . . . . . . . . . . .. . . . . . . . . . .. . . . . . . . . . .. 169
7.4 Serializing the Mesh Representation . . . . . .. . . . . . . . . . .. . . . . . . . .. . . . . . . . . . .. . . . . . 170
7.4.1 Case Study: Subdividing a Pyramid . .. . . . . . . . . . .. . . . . . . . . . .. . . . . . . . . . 170
7.4.2 Generating Indexing Tables . . . . . . .. . . . . . . . . . .. . . . . . . . .. .. . . . . . . . .. . . . . 170
7.4.3 Preparing for Parallel Execution . . . . . . . . . . .. . . . . . . . . . .. . . . . . . . . . .. . . . . 172
7.5 Transition from Multicores to Many-Cores. . . . . . . . .. . . . . . . . .. .. . . . . . . . .. . . . . . . 173
7.5.1 Streaming Multiprocessors and SIMT . . . . . .. . . . . . . . . . .. . . . . . . . . . .. . . . . 173
7.5.2 Practical Implementation with OpenCL . . . .. . . . . . . . . . .. . . . . . . . .. .. . . . 174
7.6 Reducing Branching Divergence . . . . . . . . .. . . . . . . . . . .. . . . . . . . .. . . . . . . . . . .. . . . . . . 175
7.6.1 Sorting Vertices by Type . . . . . .. . . . . . . . . . .. . . . . . . . . . .. . . . . . . . .. .. . . . . . . 176
7.6.2 Further Vertex Sorting . .. . . . . . . . .. .. . . . . . . . .. . . . . . . . . . .. . . . . . . . . . .. . . . 176
7.7 Optimization Trade-Offs . . . . . .. . . . . . . . . . .. . . . . . . . . . .. . . . . . . . . . .. . . . . . . . . . .. . . . . 179
7.7.1 Alternative Strategy: NVIDIA Dynamic Parallelism . . . . . . .. . . . . . . . .. 179
7.7.2 Alternative Strategy: Vertex Stencils . . . . . .. . . . . . . . . . .. . . . . . . . . . .. . . . . 180
7.7.3 Memory Bottlenecks . . . . . . . . . . .. . . . . . . . . . .. . . . . . . . . . .. . . . . . . . . . . . . . . . . . 181
7.8 Evaluating Our Progress . .. . . . . . . . .. .. . . . . . . . .. . . . . . . . . . .. . . . . . . . . . .. . . . . . . . .. . 182
7.9 Fundamental Limitations of Uniform Subdivision . . . . . . . . . . .. . . . . . . . . . .. . . . . . . 183
7.9.1 Exponential Growth . .. . . . . . . . .. .. . . . . . . . .. . . . . . . . . . .. . . . . . . . . . .. . . . . . . 184
7.9.2 Geometric Fidelity . . . .. . . . . . . . .. . . . . . . . . . .. . . . . . . . . . .. . . . . . . . . . .. . . . . . . 184
7.9.3 Animating Subdivision Surfaces . . . . . . . . . . .. . . . . . . . . . .. . . . . . . . . . .. . . . . . 185
7.9.4 Better, Faster, Different . . . . . . .. . . . . . . . . . .. . . . . . . . . . .. . . . . . . . . . .. . . . . . . 185
7.10 Feature-Adaptive Subdivision . . . . . . . . . . .. . . . . . . . .. . . . . . . . . . .. . . . . . . . . . .. . . . . . . . 186
7.10.1 GPU Hardware Tessellation . . . . . .. . . . . . . . . . .. . . . . . . . . . .. . . . . . . . . . .. . . . 186
7.10.2 Catmull-Clark Terminology . . . . . . .. . . . . . . . . . .. . . . . . . . .. .. . . . . . . . .. . . . . 187
7.10.3 Bi-Cubic Patch Representation . . . . . . . . . .. . . . . . . . . . .. . . . . . . . .. .. . . . . . . . 188
7.10.4 Feature-Adaptive Subdivision . . . . . . . . . . .. . . . . . . . . . .. . . . . . . . . . .. . . . . . . . 189
7.11 Implementing the GPU Rendering Engine . . . . . . . . . . .. . . . . . . . . . .. . . . . . . . . . .. . . 190
163

Get Multithreading for Visual Effects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.