2013-03-08 01:50:15 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// Copyright 2013 Pixar
|
2013-03-08 01:50:15 +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:
|
2013-03-08 01:50:15 +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.
|
2013-03-08 01:50:15 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// You may obtain a copy of the Apache License at
|
2013-03-08 01:50:15 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
2013-07-18 21:19:50 +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.
|
2013-03-08 01:50:15 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
|
2013-03-08 01:50:15 +00:00
|
|
|
#ifndef FAR_KERNEL_BATCH_H
|
|
|
|
#define FAR_KERNEL_BATCH_H
|
|
|
|
|
|
|
|
#include "../version.h"
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace OpenSubdiv {
|
|
|
|
namespace OPENSUBDIV_VERSION {
|
|
|
|
|
|
|
|
|
2013-05-07 00:50:58 +00:00
|
|
|
/// \brief A GP Compute Kernel descriptor.
|
|
|
|
///
|
|
|
|
/// Vertex refinement through subdivision schemes requires the successive
|
|
|
|
/// application of dedicated compute kernels. OpenSubdiv groups these vertices
|
|
|
|
/// in batches based on their topology in order to minimize the number of kernel
|
|
|
|
/// switches to process a given primitive.
|
|
|
|
///
|
|
|
|
/// [Subdivision table for kernel k]
|
|
|
|
/// ------+---------------------------------+-----
|
2013-05-07 02:05:50 +00:00
|
|
|
/// | Prim p, Level n |
|
|
|
|
/// ------+---------------------------------+-----
|
|
|
|
/// | | batch range | |
|
2013-05-07 00:50:58 +00:00
|
|
|
/// ------+---------------------------------+-----
|
|
|
|
/// ^ ^ ^
|
|
|
|
/// tableOffset start end
|
|
|
|
/// . .
|
|
|
|
/// . .
|
|
|
|
/// . .
|
|
|
|
/// [VBO] . .
|
|
|
|
/// ------+---------------------------------+-----
|
|
|
|
/// | Prim p, Kernel k, Level n |
|
|
|
|
/// ------+---------------------------------+-----
|
2013-05-07 02:05:50 +00:00
|
|
|
/// | | batch range | |
|
2013-05-07 00:50:58 +00:00
|
|
|
/// ------+---------------------------------+-----
|
|
|
|
/// ^ ^ ^
|
|
|
|
/// vertexOffset start end
|
|
|
|
///
|
|
|
|
class FarKernelBatch {
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
enum KernelType {
|
|
|
|
CATMARK_FACE_VERTEX,
|
|
|
|
CATMARK_EDGE_VERTEX,
|
|
|
|
CATMARK_VERT_VERTEX_A1,
|
|
|
|
CATMARK_VERT_VERTEX_A2,
|
|
|
|
CATMARK_VERT_VERTEX_B,
|
|
|
|
LOOP_EDGE_VERTEX,
|
|
|
|
LOOP_VERT_VERTEX_A1,
|
|
|
|
LOOP_VERT_VERTEX_A2,
|
|
|
|
LOOP_VERT_VERTEX_B,
|
|
|
|
BILINEAR_FACE_VERTEX,
|
|
|
|
BILINEAR_EDGE_VERTEX,
|
|
|
|
BILINEAR_VERT_VERTEX,
|
|
|
|
HIERARCHICAL_EDIT,
|
|
|
|
};
|
|
|
|
|
2013-07-11 01:51:43 +00:00
|
|
|
/// \brief Constructor.
|
2013-05-07 00:50:58 +00:00
|
|
|
///
|
|
|
|
/// @param kernelType the type of compute kernel kernel
|
|
|
|
///
|
|
|
|
/// @param level the level of subdivision of the vertices in the batch
|
|
|
|
///
|
|
|
|
/// @param tableIndex edit index (for the hierarchical edit kernels only)
|
|
|
|
///
|
|
|
|
/// @param start index of the first vertex in the batch
|
|
|
|
///
|
|
|
|
/// @param end index of the last vertex in the batch
|
|
|
|
///
|
|
|
|
/// @param tableOffset XXXX
|
|
|
|
///
|
|
|
|
/// @param vertexOffset XXXX
|
|
|
|
///
|
2013-05-17 21:07:53 +00:00
|
|
|
/// @param meshIndex XXXX
|
|
|
|
///
|
2013-05-07 00:50:58 +00:00
|
|
|
FarKernelBatch( KernelType kernelType,
|
|
|
|
int level,
|
|
|
|
int tableIndex,
|
|
|
|
int start,
|
|
|
|
int end,
|
|
|
|
int tableOffset,
|
2013-05-10 02:16:51 +00:00
|
|
|
int vertexOffset,
|
|
|
|
int meshIndex=0) :
|
2013-05-07 00:50:58 +00:00
|
|
|
_kernelType(kernelType),
|
|
|
|
_level(level),
|
|
|
|
_tableIndex(tableIndex),
|
|
|
|
_start(start),
|
|
|
|
_end(end),
|
|
|
|
_tableOffset(tableOffset),
|
2013-05-10 02:16:51 +00:00
|
|
|
_vertexOffset(vertexOffset),
|
|
|
|
_meshIndex(meshIndex) {
|
2013-03-08 01:50:15 +00:00
|
|
|
}
|
|
|
|
|
2013-07-11 01:51:43 +00:00
|
|
|
/// \brief Returns the type of kernel to apply to the vertices in the batch.
|
2013-05-07 00:50:58 +00:00
|
|
|
KernelType GetKernelType() const {
|
|
|
|
return _kernelType;
|
|
|
|
}
|
2013-03-08 01:50:15 +00:00
|
|
|
|
|
|
|
|
2013-07-11 01:51:43 +00:00
|
|
|
/// \brief Returns the subdivision level of the vertices in the batch
|
2013-05-07 00:50:58 +00:00
|
|
|
int GetLevel() const {
|
|
|
|
return _level;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-07-11 01:51:43 +00:00
|
|
|
/// \brief Returns the index of the first vertex in the batch
|
2013-05-07 00:50:58 +00:00
|
|
|
int GetStart() const {
|
|
|
|
return _start;
|
|
|
|
}
|
|
|
|
|
2013-07-11 01:51:43 +00:00
|
|
|
/// \brief Returns the index of the first vertex in the batch
|
2013-05-07 00:50:58 +00:00
|
|
|
const int * GetStartPtr() const {
|
|
|
|
return & _start;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-07-11 01:51:43 +00:00
|
|
|
/// \brief Returns the index of the last vertex in the batch
|
2013-05-07 00:50:58 +00:00
|
|
|
int GetEnd() const {
|
|
|
|
return _end;
|
|
|
|
}
|
|
|
|
|
2013-07-11 01:51:43 +00:00
|
|
|
/// \brief Returns the index of the last vertex in the batch
|
2013-05-07 00:50:58 +00:00
|
|
|
const int * GetEndPtr() const {
|
|
|
|
return & _end;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-07-11 01:51:43 +00:00
|
|
|
/// \brief Returns the edit index (for the hierarchical edit kernels only)
|
2013-05-07 00:50:58 +00:00
|
|
|
int GetTableIndex() const {
|
|
|
|
return _tableIndex;
|
2013-03-08 01:50:15 +00:00
|
|
|
}
|
|
|
|
|
2013-05-07 00:50:58 +00:00
|
|
|
|
|
|
|
|
2013-07-11 01:51:43 +00:00
|
|
|
/// \brief Returns
|
2013-05-07 00:50:58 +00:00
|
|
|
int GetTableOffset() const {
|
|
|
|
return _tableOffset;
|
2013-03-08 01:50:15 +00:00
|
|
|
}
|
|
|
|
|
2013-07-11 01:51:43 +00:00
|
|
|
/// \brief Returns
|
2013-05-07 00:50:58 +00:00
|
|
|
const int * GetTableOffsetPtr() const {
|
|
|
|
return & _tableOffset;
|
2013-03-08 01:50:15 +00:00
|
|
|
}
|
|
|
|
|
2013-05-07 00:50:58 +00:00
|
|
|
|
|
|
|
|
2013-07-11 01:51:43 +00:00
|
|
|
/// \brief Returns
|
2013-05-07 00:50:58 +00:00
|
|
|
int GetVertexOffset() const {
|
|
|
|
return _vertexOffset;
|
2013-03-08 01:50:15 +00:00
|
|
|
}
|
|
|
|
|
2013-07-11 01:51:43 +00:00
|
|
|
/// \brief Returns
|
2013-05-07 00:50:58 +00:00
|
|
|
const int * GetVertexOffsetPtr() const {
|
|
|
|
return & _vertexOffset;
|
|
|
|
}
|
|
|
|
|
2013-05-10 02:16:51 +00:00
|
|
|
|
2013-07-11 01:51:43 +00:00
|
|
|
/// \brief Returns the mesh index (used in batching)
|
2013-05-10 02:16:51 +00:00
|
|
|
int GetMeshIndex() const {
|
|
|
|
return _meshIndex;
|
|
|
|
}
|
|
|
|
|
2013-05-07 00:50:58 +00:00
|
|
|
private:
|
|
|
|
friend class FarKernelBatchFactory;
|
|
|
|
template <class X, class Y> friend class FarMultiMeshFactory;
|
|
|
|
|
|
|
|
KernelType _kernelType;
|
|
|
|
int _level;
|
|
|
|
int _tableIndex;
|
|
|
|
int _start;
|
|
|
|
int _end;
|
|
|
|
int _tableOffset;
|
|
|
|
int _vertexOffset;
|
2013-05-10 02:16:51 +00:00
|
|
|
int _meshIndex;
|
2013-03-08 01:50:15 +00:00
|
|
|
};
|
|
|
|
|
2013-05-07 00:50:58 +00:00
|
|
|
typedef std::vector<FarKernelBatch> FarKernelBatchVector;
|
|
|
|
|
2013-03-08 01:50:15 +00:00
|
|
|
} // end namespace OPENSUBDIV_VERSION
|
|
|
|
using namespace OPENSUBDIV_VERSION;
|
|
|
|
|
|
|
|
} // end namespace OpenSubdiv
|
|
|
|
|
|
|
|
#endif /* FAR_KERNEL_BATCH_H */
|