2014-09-05 22:07:46 +00:00
|
|
|
..
|
2013-09-26 19:04:57 +00:00
|
|
|
Copyright 2013 Pixar
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2013-09-26 19:04:57 +00:00
|
|
|
Licensed under the Apache License, Version 2.0 (the "Apache License")
|
|
|
|
with the following modification; you may not use this file except in
|
|
|
|
compliance with the Apache License and the following modification to it:
|
|
|
|
Section 6. Trademarks. is deleted and replaced with:
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2013-09-26 19:04:57 +00:00
|
|
|
6. Trademarks. This License does not grant permission to use the trade
|
|
|
|
names, trademarks, service marks, or product names of the Licensor
|
|
|
|
and its affiliates, except as required to comply with Section 4(c) of
|
|
|
|
the License and to reproduce the content of the NOTICE file.
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2013-09-26 19:04:57 +00:00
|
|
|
You may obtain a copy of the Apache License at
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2013-09-26 19:04:57 +00:00
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2013-09-26 19:04:57 +00:00
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the Apache License with the above modification is
|
|
|
|
distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
KIND, either express or implied. See the Apache License for the specific
|
|
|
|
language governing permissions and limitations under the Apache License.
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2013-07-30 02:14:19 +00:00
|
|
|
|
|
|
|
OSD Overview
|
|
|
|
------------
|
|
|
|
|
|
|
|
.. contents::
|
|
|
|
:local:
|
|
|
|
:backlinks: none
|
|
|
|
|
|
|
|
OpenSubdiv (Osd)
|
|
|
|
================
|
|
|
|
|
2015-06-22 01:37:20 +00:00
|
|
|
**Osd** contains device dependent code that makes *Far* structures
|
|
|
|
available on various backends such as TBB, CUDA, OpenCL, GLSL, etc.
|
2015-06-18 00:26:09 +00:00
|
|
|
The main roles of **Osd** are:
|
|
|
|
|
2015-06-18 22:11:41 +00:00
|
|
|
- **Refinement**
|
2015-06-18 00:26:09 +00:00
|
|
|
Compute stencil-based uniform/adaptive subdivision on CPU/GPU backends
|
2015-06-18 22:11:41 +00:00
|
|
|
- **Limit Stencil Evaluation**
|
2015-06-18 00:26:09 +00:00
|
|
|
Compute limit surfaces by limit stencils on CPU/GPU backends
|
2015-06-18 22:11:41 +00:00
|
|
|
- **Limit Evaluation with PatchTable**
|
2015-06-18 00:26:09 +00:00
|
|
|
Compute limit surfaces by patch evaluation on CPU/GPU backends
|
2015-06-18 22:11:41 +00:00
|
|
|
- **OpenGL/DX11 Drawing with hardware tessellation**
|
2015-06-18 00:26:09 +00:00
|
|
|
Provide GLSL/HLSL tessellation functions for patch table
|
2015-06-18 22:11:41 +00:00
|
|
|
- **Interleaved/Batched buffer configuration**
|
2015-06-18 00:26:09 +00:00
|
|
|
Provide consistent buffer descriptor to deal with arbitrary buffer layout.
|
2015-06-18 22:11:41 +00:00
|
|
|
- **Cross-Platform Implementation**
|
2015-06-18 00:26:09 +00:00
|
|
|
Provide convenient classes to interop between compute and draw APIs
|
2013-07-30 02:14:19 +00:00
|
|
|
|
2015-06-22 01:37:20 +00:00
|
|
|
These are independently used by clients. For example, a client can use only
|
2015-06-22 20:26:01 +00:00
|
|
|
the limit stencil evaluation, or a client can refine subdivision surfaces
|
|
|
|
and draw them with the PatchTable and **Osd** tessellation shaders.
|
|
|
|
All device specific evaluation kernels are implemented in the Evaluator classes.
|
|
|
|
Since Evaluators don't own vertex buffers, clients should provide their own
|
|
|
|
buffers as a source and destination. There are some interop classes defined
|
|
|
|
in **Osd** for convenience.
|
2013-07-30 02:14:19 +00:00
|
|
|
|
2015-06-22 20:26:01 +00:00
|
|
|
OpenSubdiv utilizes a series of regression tests to compare and enforce
|
|
|
|
identical results across different computational devices.
|
2013-07-30 02:14:19 +00:00
|
|
|
|
2015-06-18 00:26:09 +00:00
|
|
|
----
|
2013-07-30 02:14:19 +00:00
|
|
|
|
2015-06-18 00:26:09 +00:00
|
|
|
Refinement
|
|
|
|
==========
|
2013-07-30 02:14:19 +00:00
|
|
|
|
2015-06-18 00:26:09 +00:00
|
|
|
**Osd** supports both `uniform subdivision <subdivision_surfaces.html#uniform-subdivision>`__
|
|
|
|
and `adaptive subdivision <subdivision_surfaces.html#feature-adaptive-subdivision>`__.
|
2013-07-30 02:14:19 +00:00
|
|
|
|
|
|
|
|
2015-06-18 00:26:09 +00:00
|
|
|
.. image:: images/osd_refinement.png
|
2013-07-30 02:14:19 +00:00
|
|
|
:align: center
|
|
|
|
|
2015-06-22 01:37:20 +00:00
|
|
|
Once clients create a Far::StencilTable for the topology, they can convert it into
|
2015-06-18 00:26:09 +00:00
|
|
|
device-specific stencil tables if necessary. The following table shows which evaluator
|
|
|
|
classes and stencil table interfaces can be used together. Note that while **Osd**
|
2015-06-22 01:37:20 +00:00
|
|
|
provides these stencil table classes which can be easily constructed from Far::StencilTable,
|
2015-06-18 00:26:09 +00:00
|
|
|
clients aren't required to use these table classes. Clients may have their own entities
|
2015-06-22 01:37:20 +00:00
|
|
|
as a stencil tables as long as Evaluator::EvalStencils() can access the necessary interfaces.
|
2015-06-18 00:26:09 +00:00
|
|
|
|
|
|
|
+-----------------------------+-----------------------+-------------------------+
|
|
|
|
| Backend | Evaluator class | compatible stencil table|
|
|
|
|
+=============================+=======================+=========================+
|
|
|
|
| CPU (CPU single-threaded) | CpuEvaluator | Far::StencilTable |
|
|
|
|
+-----------------------------+-----------------------+-------------------------+
|
|
|
|
| TBB (CPU multi-threaded) | TbbEvaluator | Far::StencilTable |
|
|
|
|
+-----------------------------+-----------------------+-------------------------+
|
|
|
|
| OpenMP (CPU multi-threaded) | OmpEvaluator | Far::StencilTable |
|
|
|
|
+-----------------------------+-----------------------+-------------------------+
|
|
|
|
| CUDA (GPU) | CudaEvaluator | CudaStencilTable |
|
|
|
|
+-----------------------------+-----------------------+-------------------------+
|
|
|
|
| OpenCL (CPU/GPU) | CLEvaluator | CLStencilTable |
|
|
|
|
+-----------------------------+-----------------------+-------------------------+
|
|
|
|
| GL ComputeShader (GPU) | GLComputeEvaluator | GLStencilTableSSBO |
|
|
|
|
+-----------------------------+-----------------------+-------------------------+
|
|
|
|
| GL Transform Feedback (GPU) | GLXFBEvaluator | GLStencilTableTBO |
|
|
|
|
+-----------------------------+-----------------------+-------------------------+
|
|
|
|
| DX11 ComputeShader (GPU) | D3D11ComputeEvaluator | D3D11StencilTable |
|
|
|
|
+-----------------------------+-----------------------+-------------------------+
|
|
|
|
|
|
|
|
|
|
|
|
Limit Stencil Evaluation
|
|
|
|
========================
|
|
|
|
|
2015-06-22 20:26:01 +00:00
|
|
|
Limit stencil evaluation is quite similar to refinement in **Osd**. At first
|
|
|
|
clients create Far::LimitStencilTable for the locations to evaluate the limit
|
|
|
|
surfaces, then convert it into an evaluator compatible stencil table and call
|
|
|
|
Evaluator::EvalStencils().
|
2015-06-18 00:26:09 +00:00
|
|
|
|
|
|
|
.. image:: images/osd_limitstencil.png
|
|
|
|
:align: center
|
2013-07-30 02:14:19 +00:00
|
|
|
|
2015-06-18 00:26:09 +00:00
|
|
|
Limit Evaluation with PatchTable
|
|
|
|
================================
|
2013-07-30 02:14:19 +00:00
|
|
|
|
2015-06-22 20:26:01 +00:00
|
|
|
Another way to evaluate the limit surfaces is to use the PatchTable.
|
|
|
|
Once all control vertices and local points are resolved by the stencil evaluation,
|
|
|
|
**Osd** can evaluate the limit surfaces through the PatchTable.
|
2013-07-30 02:14:19 +00:00
|
|
|
|
2015-06-18 00:26:09 +00:00
|
|
|
.. image:: images/osd_limiteval.png
|
|
|
|
:align: center
|
2013-07-30 02:14:19 +00:00
|
|
|
|
2015-06-18 00:26:09 +00:00
|
|
|
+-----------------------------+-------------------------+-------------------------+
|
|
|
|
| Backend | Evaluator class | compatible patch table|
|
|
|
|
+=============================+=========================+=========================+
|
|
|
|
| CPU (CPU single-threaded) | CpuEvaluator | CpuPatchTable |
|
|
|
|
+-----------------------------+-------------------------+-------------------------+
|
|
|
|
| TBB (CPU multi-threaded) | TbbEvaluator | CpuPatchTable |
|
|
|
|
+-----------------------------+-------------------------+-------------------------+
|
|
|
|
| OpenMP (CPU multi-threaded) | OmpEvaluator | CpuPatchTable |
|
|
|
|
+-----------------------------+-------------------------+-------------------------+
|
|
|
|
| CUDA (GPU) | CudaEvaluator | CudaPatchTable |
|
|
|
|
+-----------------------------+-------------------------+-------------------------+
|
|
|
|
| OpenCL (CPU/GPU) | CLEvaluator | CLPatchTable |
|
|
|
|
+-----------------------------+-------------------------+-------------------------+
|
|
|
|
| GL ComputeShader (GPU) | GLComputeEvaluator | GLPatchTable |
|
|
|
|
+-----------------------------+-------------------------+-------------------------+
|
|
|
|
| GL Transform Feedback (GPU) | GLXFBEvaluator | GLPatchTable |
|
|
|
|
+-----------------------------+-------------------------+-------------------------+
|
|
|
|
| DX11 ComputeShader (GPU) | | D3D11ComputeEvaluator | D3D11PatchTable |
|
|
|
|
| | | (*)not yet supported | |
|
|
|
|
+-----------------------------+-------------------------+-------------------------+
|
2013-07-30 02:14:19 +00:00
|
|
|
|
2015-06-19 18:00:52 +00:00
|
|
|
.. container:: notebox
|
2013-07-30 02:14:19 +00:00
|
|
|
|
2015-06-18 00:26:09 +00:00
|
|
|
**Release Notes (3.0.0)**
|
2013-07-30 02:14:19 +00:00
|
|
|
|
2015-06-22 01:37:20 +00:00
|
|
|
* GPU limit evaluation backends (Evaluator::EvalPatches()) only support
|
2015-06-18 00:26:09 +00:00
|
|
|
BSpline patches. Clients need to specify BSpline approximation for endcap
|
|
|
|
when creating a patch table. See `end capping <far_overview.html#endcap>`__.
|
2013-07-30 02:14:19 +00:00
|
|
|
|
2015-06-22 01:37:20 +00:00
|
|
|
OpenGL/DX11 Drawing with Hardware Tessellation
|
2015-06-18 00:26:09 +00:00
|
|
|
==============================================
|
2013-07-30 02:14:19 +00:00
|
|
|
|
2015-06-22 01:37:20 +00:00
|
|
|
One of the most interesting use cases of the **Osd** layer is realtime drawing
|
|
|
|
of subdivision surfaces using hardware tessellation. This is somewhat similar to
|
2015-06-18 00:26:09 +00:00
|
|
|
limit evaluation with PatchTable described above. Drawing differs from limit
|
|
|
|
evaluation in that **Osd** provides shader snippets for patch evaluation and
|
|
|
|
clients will inject them into their own shader source.
|
2013-07-30 02:14:19 +00:00
|
|
|
|
2015-06-18 00:26:09 +00:00
|
|
|
.. image:: images/osd_draw.png
|
|
|
|
:align: center
|
2013-07-30 02:14:19 +00:00
|
|
|
|
2015-06-22 01:37:20 +00:00
|
|
|
See `shader interface <osd_shader_interface.html>`__ for a more detailed discussion of the shader interface.
|
2013-07-30 02:14:19 +00:00
|
|
|
|
|
|
|
----
|
|
|
|
|
2015-06-22 01:37:20 +00:00
|
|
|
Interleaved/Batched Buffer Configuration
|
2015-06-18 00:26:09 +00:00
|
|
|
========================================
|
2013-07-30 02:14:19 +00:00
|
|
|
|
2015-06-18 00:26:09 +00:00
|
|
|
All **Osd** layer APIs assume that each primitive variables to be computed
|
2015-06-22 01:37:20 +00:00
|
|
|
(points, colors, uvs ...) are contiguous arrays of 32bit floating point values.
|
|
|
|
The **Osd** API refers to such an array as a "buffer". A buffer can exist on CPU memory or
|
2015-06-18 00:26:09 +00:00
|
|
|
GPU memory. **Osd** Evaluators typically take one source buffer and one destination
|
|
|
|
buffer, or three destination buffers if derivatives are being computed.
|
|
|
|
**Osd** Evaluators also take BufferDescriptors,
|
2015-06-22 01:37:20 +00:00
|
|
|
that are used to specify the layout of the source and destination buffers.
|
|
|
|
A BufferDescriptor is a struct of 3 integers which specify an offset, length and stride.
|
2013-07-30 02:14:19 +00:00
|
|
|
|
2015-06-18 00:26:09 +00:00
|
|
|
For example:
|
2013-07-30 02:14:19 +00:00
|
|
|
|
2015-06-18 00:26:09 +00:00
|
|
|
+-----------+-----------+-----------+
|
|
|
|
| Vertex 0 | Vertex 1 | ... |
|
|
|
|
+---+---+---+---+---+---+-----------+
|
|
|
|
| X | Y | Z | X | Y | Z | ... |
|
|
|
|
+---+---+---+---+---+---+-----------+
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2015-06-18 00:26:09 +00:00
|
|
|
The layout of this buffer can be described as
|
2015-04-07 02:41:09 +00:00
|
|
|
|
2015-06-18 00:26:09 +00:00
|
|
|
.. code:: c++
|
2013-07-30 02:14:19 +00:00
|
|
|
|
2015-06-18 00:26:09 +00:00
|
|
|
Osd::BufferDescriptor desc(/*offset = */ 0, /*length = */ 3, /*stride = */ 3);
|
2013-07-30 02:14:19 +00:00
|
|
|
|
2015-06-22 01:37:20 +00:00
|
|
|
BufferDescriptor can be used for an interleaved buffer too.
|
2013-07-30 02:14:19 +00:00
|
|
|
|
2015-06-18 00:26:09 +00:00
|
|
|
+---------------------------+---------------------------+-------+
|
|
|
|
| Vertex 0 | Vertex 1 | ... |
|
|
|
|
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+-------+
|
|
|
|
| X | Y | Z | R | G | B | A | X | Y | Z | R | G | B | A | ... |
|
|
|
|
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+-------+
|
2013-07-30 02:14:19 +00:00
|
|
|
|
2015-06-18 00:26:09 +00:00
|
|
|
.. code:: c++
|
2013-07-30 02:14:19 +00:00
|
|
|
|
2015-06-18 00:26:09 +00:00
|
|
|
Osd::BufferDescriptor xyzDesc(0, 3, 7);
|
|
|
|
Osd::BufferDescriptor rgbaDesc(3, 4, 7);
|
2013-07-30 02:14:19 +00:00
|
|
|
|
2015-06-22 20:26:01 +00:00
|
|
|
Although the source and destination buffers don't need to be the same buffer for
|
|
|
|
EvalStencils(), adaptive patch tables are constructed to first index the coarse
|
|
|
|
vertices and the refined vertices immediately afterward. In this case, the
|
2015-06-18 00:26:09 +00:00
|
|
|
BufferDescriptor for the destination should include the offset as the number of coarse
|
|
|
|
vertices to be skipped.
|
2013-07-30 02:14:19 +00:00
|
|
|
|
2015-06-18 00:26:09 +00:00
|
|
|
+-----------------------------------+-----------------------------------+
|
|
|
|
| Coarse vertices (n) : Src | Refined vertices : Dst |
|
|
|
|
+-----------+-----------+-----------+-----------+-----------+-----------+
|
|
|
|
| Vertex 0 | Vertex 1 | ... | Vertex n | Vertex n+1| |
|
|
|
|
+---+---+---+---+---+---+-----------+---+---+---+---+---+---+-----------+
|
|
|
|
| X | Y | Z | X | Y | Z | ... | X | Y | Z | X | Y | Z | ... |
|
|
|
|
+---+---+---+---+---+---+-----------+---+---+---+---+---+---+-----------+
|
2013-07-30 02:14:19 +00:00
|
|
|
|
2015-06-18 00:26:09 +00:00
|
|
|
.. code:: c++
|
2013-07-30 02:14:19 +00:00
|
|
|
|
2015-06-18 00:26:09 +00:00
|
|
|
Osd::BufferDescriptor srcDesc(0, 3, 3);
|
|
|
|
Osd::BufferDescriptor dstDesc(n*3, 3, 3);
|
2013-07-30 02:14:19 +00:00
|
|
|
|
2015-06-22 01:37:20 +00:00
|
|
|
Also note that the source descriptor doesn't have to start with offset = 0.
|
|
|
|
This is useful when a client has a big buffer with multiple objects batched together.
|
2013-07-30 02:14:19 +00:00
|
|
|
|
|
|
|
|
2015-06-18 00:26:09 +00:00
|
|
|
----
|
2013-07-30 02:14:19 +00:00
|
|
|
|
2015-06-18 00:26:09 +00:00
|
|
|
Cross-Platform Implementation
|
|
|
|
=============================
|
2013-07-30 02:14:19 +00:00
|
|
|
|
2015-06-18 00:26:09 +00:00
|
|
|
One of the key goals of OpenSubdiv is to achieve as much cross-platform flexibility
|
|
|
|
as possible and leverage all optimized hardware paths where available. This can
|
2015-06-22 01:37:20 +00:00
|
|
|
be very challenging as there is a very large variety of plaftorms and APIs
|
|
|
|
available, with very distinct capabilities.
|
2015-06-18 00:26:09 +00:00
|
|
|
|
|
|
|
In **Osd**, Evaluators don't care about interops between those APIs. All Evaluators
|
|
|
|
have two kinds of APIs for both EvalStencils() and EvalPatches().
|
|
|
|
|
|
|
|
- Explicit signatures which directly take device-specific buffer representation
|
2015-06-22 01:37:20 +00:00
|
|
|
(e.g., pointer for CpuEvaluator, GLuint buffer for GLComputeEvaluator, etc.)
|
2015-06-18 00:26:09 +00:00
|
|
|
- Generic signatures which take arbitrary buffer classes. The buffer class
|
|
|
|
is required to have a certain method to return the device-specific buffer representation.
|
|
|
|
|
|
|
|
The later interface is useful if the client supports multiple backends at the same time.
|
2015-06-22 01:37:20 +00:00
|
|
|
The methods that need to be implemented for the Evaluators are:
|
2015-06-18 00:26:09 +00:00
|
|
|
|
|
|
|
+-----------------------+------------------------+------------------+
|
|
|
|
| Evaluator class | object | method |
|
|
|
|
+=======================+========================+==================+
|
|
|
|
| | CpuEvaluator | pointer to cpu memory | BindCpuBuffer() |
|
|
|
|
| | TbbEvaluator | | |
|
|
|
|
| | OmpEvaluator | | |
|
|
|
|
+-----------------------+------------------------+------------------+
|
|
|
|
| CudaEvaluator | pointer to cuda memory | BindCudaBuffer() |
|
|
|
|
+-----------------------+------------------------+------------------+
|
|
|
|
| CLEvaluator | cl_mem | BindCLBuffer() |
|
|
|
|
+-----------------------+------------------------+------------------+
|
|
|
|
| | GLComputeEvaluator | GL buffer object | BindVBO() |
|
|
|
|
| | GLXFBEvaluator | | |
|
|
|
|
+-----------------------+------------------------+------------------+
|
|
|
|
| D3D11ComputeEvaluator | D3D11 UAV | BindD3D11UAV() |
|
|
|
|
+-----------------------+------------------------+------------------+
|
|
|
|
|
2015-06-22 01:37:20 +00:00
|
|
|
The buffers can use these methods as a trigger of interop. **Osd** provides a default
|
|
|
|
implementation of interop buffer for most of the backend combinations.
|
|
|
|
For example, if the client wants to use CUDA as a computation backend and use OpenGL
|
|
|
|
as the drawing API, Osd::CudaGLVertexBuffer fits the case since it implements
|
2015-06-18 00:26:09 +00:00
|
|
|
BindCudaBuffer() and BindVBO(). Again, clients can implement their own buffer
|
2015-06-22 01:37:20 +00:00
|
|
|
class and pass it to the Evaluators.
|