2013-06-05 17:55:24 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// Copyright 2013 Pixar
|
2013-06-05 17:55:24 +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-06-05 17:55:24 +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-06-05 17:55:24 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// You may obtain a copy of the Apache License at
|
2013-06-05 17:55:24 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
2013-08-14 16:46:53 +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-06-05 17:55:24 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
#include "../osd/cpuKernel.h"
|
|
|
|
#include "../osd/tbbKernel.h"
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
#include "../osd/types.h"
|
2015-05-29 16:21:14 +00:00
|
|
|
#include "../osd/bufferDescriptor.h"
|
2023-09-07 23:53:12 +00:00
|
|
|
#include "../osd/patchBasis.h"
|
2013-06-05 17:55:24 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
#include <cassert>
|
|
|
|
#include <cstdlib>
|
2013-06-05 17:55:24 +00:00
|
|
|
#include <tbb/parallel_for.h>
|
|
|
|
|
|
|
|
namespace OpenSubdiv {
|
|
|
|
namespace OPENSUBDIV_VERSION {
|
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
namespace Osd {
|
|
|
|
|
2013-06-05 17:55:24 +00:00
|
|
|
#define grain_size 200
|
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
template <class T> T *
|
2015-05-29 16:21:14 +00:00
|
|
|
elementAtIndex(T * src, int index, BufferDescriptor const &desc) {
|
2014-05-09 00:20:54 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
return src + index * desc.stride;
|
2014-05-09 00:20:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
2015-05-29 16:21:14 +00:00
|
|
|
clear(float *dst, BufferDescriptor const &desc) {
|
2014-05-09 00:20:54 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
assert(dst);
|
|
|
|
memset(dst, 0, desc.length*sizeof(float));
|
2014-05-09 00:20:54 +00:00
|
|
|
}
|
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
static inline void
|
|
|
|
addWithWeight(float *dst, const float *src, int srcIndex, float weight,
|
2015-05-29 16:21:14 +00:00
|
|
|
BufferDescriptor const &desc) {
|
2014-05-30 06:02:19 +00:00
|
|
|
|
2016-06-25 21:23:55 +00:00
|
|
|
assert(src && dst);
|
2014-09-05 22:07:46 +00:00
|
|
|
src = elementAtIndex(src, srcIndex, desc);
|
|
|
|
for (int k = 0; k < desc.length; ++k) {
|
|
|
|
dst[k] += src[k] * weight;
|
2014-05-30 06:02:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
static inline void
|
|
|
|
copy(float *dst, int dstIndex, const float *src,
|
2015-05-29 16:21:14 +00:00
|
|
|
BufferDescriptor const &desc) {
|
2014-05-30 06:02:19 +00:00
|
|
|
|
2016-06-25 21:23:55 +00:00
|
|
|
assert(src && dst);
|
2014-05-30 06:02:19 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
dst = elementAtIndex(dst, dstIndex, desc);
|
|
|
|
memcpy(dst, src, desc.length*sizeof(float));
|
2014-05-30 06:02:19 +00:00
|
|
|
}
|
|
|
|
|
2013-06-05 17:55:24 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
class TBBStencilKernel {
|
2013-06-05 17:55:24 +00:00
|
|
|
|
2015-05-29 16:21:14 +00:00
|
|
|
BufferDescriptor _srcDesc;
|
|
|
|
BufferDescriptor _dstDesc;
|
2014-09-05 22:07:46 +00:00
|
|
|
float const * _vertexSrc;
|
|
|
|
float * _vertexDst;
|
2013-06-05 17:55:24 +00:00
|
|
|
|
2015-05-19 17:16:56 +00:00
|
|
|
int const * _sizes;
|
2014-09-05 22:07:46 +00:00
|
|
|
int const * _offsets,
|
|
|
|
* _indices;
|
|
|
|
float const * _weights;
|
2013-06-05 17:55:24 +00:00
|
|
|
|
2014-05-27 22:25:54 +00:00
|
|
|
|
|
|
|
public:
|
2015-05-29 16:21:14 +00:00
|
|
|
TBBStencilKernel(float const *src, BufferDescriptor srcDesc,
|
|
|
|
float *dst, BufferDescriptor dstDesc,
|
2015-05-19 17:16:56 +00:00
|
|
|
int const * sizes, int const * offsets,
|
2015-05-07 23:11:00 +00:00
|
|
|
int const * indices, float const * weights) :
|
|
|
|
_srcDesc(srcDesc),
|
|
|
|
_dstDesc(dstDesc),
|
|
|
|
_vertexSrc(src),
|
|
|
|
_vertexDst(dst),
|
2014-09-05 22:07:46 +00:00
|
|
|
_sizes(sizes),
|
|
|
|
_offsets(offsets),
|
|
|
|
_indices(indices),
|
|
|
|
_weights(weights) { }
|
|
|
|
|
|
|
|
TBBStencilKernel(TBBStencilKernel const & other) {
|
2015-05-07 23:11:00 +00:00
|
|
|
_srcDesc = other._srcDesc;
|
|
|
|
_dstDesc = other._dstDesc;
|
2014-09-05 22:07:46 +00:00
|
|
|
_sizes = other._sizes;
|
|
|
|
_offsets = other._offsets;
|
|
|
|
_indices = other._indices;
|
|
|
|
_weights = other._weights;
|
|
|
|
_vertexSrc = other._vertexSrc;
|
|
|
|
_vertexDst = other._vertexDst;
|
2014-05-27 22:25:54 +00:00
|
|
|
}
|
|
|
|
|
2013-08-15 22:24:42 +00:00
|
|
|
void operator() (tbb::blocked_range<int> const &r) const {
|
2014-09-05 22:07:46 +00:00
|
|
|
#define USE_SIMD
|
|
|
|
#ifdef USE_SIMD
|
2016-06-25 21:23:55 +00:00
|
|
|
if (_srcDesc.length==4 && _srcDesc.stride==4 && _dstDesc.stride==4) {
|
2014-09-05 22:07:46 +00:00
|
|
|
|
|
|
|
// SIMD fast path for aligned primvar data (4 floats)
|
|
|
|
int offset = _offsets[r.begin()];
|
|
|
|
ComputeStencilKernel<4>(_vertexSrc, _vertexDst,
|
|
|
|
_sizes, _indices+offset, _weights+offset, r.begin(), r.end());
|
|
|
|
|
2016-06-25 21:23:55 +00:00
|
|
|
} else if (_srcDesc.length==8 && _srcDesc.stride==4 && _dstDesc.stride==4) {
|
2014-09-05 22:07:46 +00:00
|
|
|
|
|
|
|
// SIMD fast path for aligned primvar data (8 floats)
|
|
|
|
int offset = _offsets[r.begin()];
|
|
|
|
ComputeStencilKernel<8>(_vertexSrc, _vertexDst,
|
|
|
|
_sizes, _indices+offset, _weights+offset, r.begin(), r.end());
|
|
|
|
|
|
|
|
} else {
|
|
|
|
#else
|
|
|
|
{
|
2015-05-07 23:11:00 +00:00
|
|
|
#endif
|
2015-05-19 17:16:56 +00:00
|
|
|
int const * sizes = _sizes;
|
2014-09-05 22:07:46 +00:00
|
|
|
int const * indices = _indices;
|
|
|
|
float const * weights = _weights;
|
|
|
|
|
|
|
|
if (r.begin()>0) {
|
|
|
|
sizes += r.begin();
|
|
|
|
indices += _offsets[r.begin()];
|
|
|
|
weights += _offsets[r.begin()];
|
2013-08-15 22:24:42 +00:00
|
|
|
}
|
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
// Slow path for non-aligned data
|
2015-05-07 23:11:00 +00:00
|
|
|
float * result = (float*)alloca(_srcDesc.length * sizeof(float));
|
2013-06-05 17:55:24 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
for (int i=r.begin(); i<r.end(); ++i, ++sizes) {
|
2013-06-05 17:55:24 +00:00
|
|
|
|
2015-05-07 23:11:00 +00:00
|
|
|
clear(result, _dstDesc);
|
2013-06-05 17:55:24 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
for (int j=0; j<*sizes; ++j) {
|
2015-05-07 23:11:00 +00:00
|
|
|
addWithWeight(result, _vertexSrc, *indices++, *weights++, _srcDesc);
|
2013-06-05 17:55:24 +00:00
|
|
|
}
|
|
|
|
|
2015-05-07 23:11:00 +00:00
|
|
|
copy(_vertexDst, i, result, _dstDesc);
|
2014-06-10 23:31:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
void
|
2015-05-29 16:21:14 +00:00
|
|
|
TbbEvalStencils(float const * src, BufferDescriptor const &srcDesc,
|
|
|
|
float * dst, BufferDescriptor const &dstDesc,
|
2015-05-19 17:16:56 +00:00
|
|
|
int const * sizes,
|
2015-05-09 00:31:26 +00:00
|
|
|
int const * offsets,
|
|
|
|
int const * indices,
|
|
|
|
float const * weights,
|
|
|
|
int start, int end) {
|
2015-05-07 23:11:00 +00:00
|
|
|
|
|
|
|
src += srcDesc.offset;
|
|
|
|
dst += dstDesc.offset;
|
|
|
|
|
|
|
|
TBBStencilKernel kernel(src, srcDesc, dst, dstDesc,
|
|
|
|
sizes, offsets, indices, weights);
|
2013-06-05 17:55:24 +00:00
|
|
|
|
2013-08-15 22:24:42 +00:00
|
|
|
tbb::blocked_range<int> range(start, end, grain_size);
|
2013-06-05 17:55:24 +00:00
|
|
|
|
2013-08-15 22:24:42 +00:00
|
|
|
tbb::parallel_for(range, kernel);
|
2013-06-05 17:55:24 +00:00
|
|
|
}
|
|
|
|
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
void
|
2015-05-29 16:21:14 +00:00
|
|
|
TbbEvalStencils(float const * src, BufferDescriptor const &srcDesc,
|
|
|
|
float * dst, BufferDescriptor const &dstDesc,
|
|
|
|
float * du, BufferDescriptor const &duDesc,
|
|
|
|
float * dv, BufferDescriptor const &dvDesc,
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
int const * sizes,
|
|
|
|
int const * offsets,
|
|
|
|
int const * indices,
|
|
|
|
float const * weights,
|
|
|
|
float const * duWeights,
|
|
|
|
float const * dvWeights,
|
|
|
|
int start, int end) {
|
|
|
|
|
|
|
|
if (src) src += srcDesc.offset;
|
|
|
|
if (dst) dst += dstDesc.offset;
|
|
|
|
if (du) du += duDesc.offset;
|
|
|
|
if (dv) dv += dvDesc.offset;
|
|
|
|
|
|
|
|
// PERFORMANCE: need to combine 3 launches together
|
|
|
|
if (dst) {
|
|
|
|
TBBStencilKernel kernel(src, srcDesc, dst, dstDesc,
|
|
|
|
sizes, offsets, indices, weights);
|
|
|
|
tbb::blocked_range<int> range(start, end, grain_size);
|
|
|
|
tbb::parallel_for(range, kernel);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (du) {
|
|
|
|
TBBStencilKernel kernel(src, srcDesc, du, duDesc,
|
|
|
|
sizes, offsets, indices, duWeights);
|
|
|
|
tbb::blocked_range<int> range(start, end, grain_size);
|
|
|
|
tbb::parallel_for(range, kernel);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dv) {
|
|
|
|
TBBStencilKernel kernel(src, srcDesc, dv, dvDesc,
|
|
|
|
sizes, offsets, indices, dvWeights);
|
|
|
|
tbb::blocked_range<int> range(start, end, grain_size);
|
|
|
|
tbb::parallel_for(range, kernel);
|
|
|
|
}
|
2017-01-26 22:36:30 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TbbEvalStencils(float const * src, BufferDescriptor const &srcDesc,
|
|
|
|
float * dst, BufferDescriptor const &dstDesc,
|
|
|
|
float * du, BufferDescriptor const &duDesc,
|
|
|
|
float * dv, BufferDescriptor const &dvDesc,
|
|
|
|
float * duu, BufferDescriptor const &duuDesc,
|
|
|
|
float * duv, BufferDescriptor const &duvDesc,
|
|
|
|
float * dvv, BufferDescriptor const &dvvDesc,
|
|
|
|
int const * sizes,
|
|
|
|
int const * offsets,
|
|
|
|
int const * indices,
|
|
|
|
float const * weights,
|
|
|
|
float const * duWeights,
|
|
|
|
float const * dvWeights,
|
|
|
|
float const * duuWeights,
|
|
|
|
float const * duvWeights,
|
|
|
|
float const * dvvWeights,
|
|
|
|
int start, int end) {
|
|
|
|
|
|
|
|
if (src) src += srcDesc.offset;
|
|
|
|
if (dst) dst += dstDesc.offset;
|
|
|
|
if (du) du += duDesc.offset;
|
|
|
|
if (dv) dv += dvDesc.offset;
|
|
|
|
if (duu) duu += duuDesc.offset;
|
|
|
|
if (duv) duv += duvDesc.offset;
|
|
|
|
if (dvv) dvv += dvvDesc.offset;
|
|
|
|
|
|
|
|
// PERFORMANCE: need to combine 3 launches together
|
|
|
|
if (dst) {
|
|
|
|
TBBStencilKernel kernel(src, srcDesc, dst, dstDesc,
|
|
|
|
sizes, offsets, indices, weights);
|
|
|
|
tbb::blocked_range<int> range(start, end, grain_size);
|
|
|
|
tbb::parallel_for(range, kernel);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (du) {
|
|
|
|
TBBStencilKernel kernel(src, srcDesc, du, duDesc,
|
|
|
|
sizes, offsets, indices, duWeights);
|
|
|
|
tbb::blocked_range<int> range(start, end, grain_size);
|
|
|
|
tbb::parallel_for(range, kernel);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dv) {
|
|
|
|
TBBStencilKernel kernel(src, srcDesc, dv, dvDesc,
|
|
|
|
sizes, offsets, indices, dvWeights);
|
|
|
|
tbb::blocked_range<int> range(start, end, grain_size);
|
|
|
|
tbb::parallel_for(range, kernel);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (duu) {
|
|
|
|
TBBStencilKernel kernel(src, srcDesc, duu, duuDesc,
|
|
|
|
sizes, offsets, indices, duuWeights);
|
|
|
|
tbb::blocked_range<int> range(start, end, grain_size);
|
|
|
|
tbb::parallel_for(range, kernel);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (duv) {
|
|
|
|
TBBStencilKernel kernel(src, srcDesc, duv, duvDesc,
|
|
|
|
sizes, offsets, indices, duvWeights);
|
|
|
|
tbb::blocked_range<int> range(start, end, grain_size);
|
|
|
|
tbb::parallel_for(range, kernel);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dvv) {
|
|
|
|
TBBStencilKernel kernel(src, srcDesc, dvv, dvvDesc,
|
|
|
|
sizes, offsets, indices, dvvWeights);
|
|
|
|
tbb::blocked_range<int> range(start, end, grain_size);
|
|
|
|
tbb::parallel_for(range, kernel);
|
|
|
|
}
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct BufferAdapter {
|
|
|
|
BufferAdapter(T *p, int length, int stride) :
|
|
|
|
_p(p), _length(length), _stride(stride) { }
|
|
|
|
void Clear() {
|
|
|
|
for (int i = 0; i < _length; ++i) _p[i] = 0;
|
|
|
|
}
|
|
|
|
void AddWithWeight(T const *src, float w) {
|
|
|
|
if (_p) {
|
|
|
|
for (int i = 0; i < _length; ++i) {
|
|
|
|
_p[i] += src[i] * w;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const T *operator[] (int index) const {
|
|
|
|
return _p + _stride * index;
|
|
|
|
}
|
|
|
|
BufferAdapter<T> & operator ++() {
|
|
|
|
if (_p) {
|
|
|
|
_p += _stride;
|
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
T *_p;
|
|
|
|
int _length;
|
|
|
|
int _stride;
|
|
|
|
};
|
|
|
|
|
|
|
|
class TbbEvalPatchesKernel {
|
2015-05-29 16:21:14 +00:00
|
|
|
BufferDescriptor _srcDesc;
|
|
|
|
BufferDescriptor _dstDesc;
|
|
|
|
BufferDescriptor _dstDuDesc;
|
|
|
|
BufferDescriptor _dstDvDesc;
|
2017-01-26 22:36:30 +00:00
|
|
|
BufferDescriptor _dstDuuDesc;
|
|
|
|
BufferDescriptor _dstDuvDesc;
|
|
|
|
BufferDescriptor _dstDvvDesc;
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
float const * _src;
|
|
|
|
float * _dst;
|
|
|
|
float * _dstDu;
|
|
|
|
float * _dstDv;
|
2017-01-26 22:36:30 +00:00
|
|
|
float * _dstDuu;
|
|
|
|
float * _dstDuv;
|
|
|
|
float * _dstDvv;
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
int _numPatchCoords;
|
|
|
|
const PatchCoord *_patchCoords;
|
|
|
|
const PatchArray *_patchArrayBuffer;
|
|
|
|
const int *_patchIndexBuffer;
|
|
|
|
const PatchParam *_patchParamBuffer;
|
|
|
|
|
|
|
|
public:
|
2015-05-29 16:21:14 +00:00
|
|
|
TbbEvalPatchesKernel(float const *src, BufferDescriptor srcDesc,
|
|
|
|
float *dst, BufferDescriptor dstDesc,
|
|
|
|
float *dstDu, BufferDescriptor dstDuDesc,
|
|
|
|
float *dstDv, BufferDescriptor dstDvDesc,
|
2017-01-26 22:36:30 +00:00
|
|
|
float *dstDuu, BufferDescriptor dstDuuDesc,
|
|
|
|
float *dstDuv, BufferDescriptor dstDuvDesc,
|
|
|
|
float *dstDvv, BufferDescriptor dstDvvDesc,
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
int numPatchCoords,
|
|
|
|
const PatchCoord *patchCoords,
|
|
|
|
const PatchArray *patchArrayBuffer,
|
|
|
|
const int *patchIndexBuffer,
|
|
|
|
const PatchParam *patchParamBuffer) :
|
|
|
|
_srcDesc(srcDesc), _dstDesc(dstDesc),
|
|
|
|
_dstDuDesc(dstDuDesc), _dstDvDesc(dstDvDesc),
|
2017-01-26 22:36:30 +00:00
|
|
|
_dstDuuDesc(dstDuuDesc), _dstDuvDesc(dstDuvDesc), _dstDvvDesc(dstDvvDesc),
|
|
|
|
_src(src), _dst(dst),
|
|
|
|
_dstDu(dstDu), _dstDv(dstDv),
|
|
|
|
_dstDuu(dstDuu), _dstDuv(dstDuv), _dstDvv(dstDvv),
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
_numPatchCoords(numPatchCoords),
|
|
|
|
_patchCoords(patchCoords),
|
|
|
|
_patchArrayBuffer(patchArrayBuffer),
|
|
|
|
_patchIndexBuffer(patchIndexBuffer),
|
|
|
|
_patchParamBuffer(patchParamBuffer) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void operator() (tbb::blocked_range<int> const &r) const {
|
|
|
|
if (_dstDu == NULL && _dstDv == NULL) {
|
|
|
|
compute(r);
|
2017-01-26 22:36:30 +00:00
|
|
|
} else if (_dstDuu == NULL && _dstDuv == NULL && _dstDvv == NULL) {
|
|
|
|
computeWith1stDerivative(r);
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
} else {
|
2017-01-26 22:36:30 +00:00
|
|
|
computeWith2ndDerivative(r);
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void compute(tbb::blocked_range<int> const &r) const {
|
Improved patch basis eval for Osd to match Far
This updates the patch basis evaluation functions in Osd
to match recent changes to far/patchBasis.
This also exposes a common facility for dealing with PatchCoord,
PatchArray, and PatchParam. These are exposed as global functions
operating on struct data, since C++ style class methods are not
supported by all of the Osd shader and kernel execution envirionments.
Changes:
- Merged far/patchBasis.cpp to osd/patchBasisCommon{,Types,Eval}.h
- Exposed PatchCoord, PatchArray, and PatchParam to Osd kernels
- exposed OsdEvaluatePatchBasis and OsdEvaluatePatchBasisNormalized
- Updated CPU, TBB, Omp, CUDA, OpenCL, GLSL, HLSL, and Metal evaluators
- Updated glFVarViewer
2018-10-30 07:37:25 +00:00
|
|
|
float wP[20];
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
BufferAdapter<const float> srcT(_src + _srcDesc.offset,
|
|
|
|
_srcDesc.length,
|
|
|
|
_srcDesc.stride);
|
|
|
|
BufferAdapter<float> dstT(_dst + _dstDesc.offset
|
|
|
|
+ r.begin() * _dstDesc.stride,
|
|
|
|
_dstDesc.length,
|
|
|
|
_dstDesc.stride);
|
|
|
|
|
2017-01-26 22:36:30 +00:00
|
|
|
|
|
|
|
for (int i = r.begin(); i < r.end(); ++i) {
|
|
|
|
PatchCoord const &coord = _patchCoords[i];
|
|
|
|
PatchArray const &array = _patchArrayBuffer[coord.handle.arrayIndex];
|
|
|
|
|
Improved patch basis eval for Osd to match Far
This updates the patch basis evaluation functions in Osd
to match recent changes to far/patchBasis.
This also exposes a common facility for dealing with PatchCoord,
PatchArray, and PatchParam. These are exposed as global functions
operating on struct data, since C++ style class methods are not
supported by all of the Osd shader and kernel execution envirionments.
Changes:
- Merged far/patchBasis.cpp to osd/patchBasisCommon{,Types,Eval}.h
- Exposed PatchCoord, PatchArray, and PatchParam to Osd kernels
- exposed OsdEvaluatePatchBasis and OsdEvaluatePatchBasisNormalized
- Updated CPU, TBB, Omp, CUDA, OpenCL, GLSL, HLSL, and Metal evaluators
- Updated glFVarViewer
2018-10-30 07:37:25 +00:00
|
|
|
Osd::PatchParam const & paramStruct =
|
2017-01-26 22:36:30 +00:00
|
|
|
_patchParamBuffer[coord.handle.patchIndex];
|
Improved patch basis eval for Osd to match Far
This updates the patch basis evaluation functions in Osd
to match recent changes to far/patchBasis.
This also exposes a common facility for dealing with PatchCoord,
PatchArray, and PatchParam. These are exposed as global functions
operating on struct data, since C++ style class methods are not
supported by all of the Osd shader and kernel execution envirionments.
Changes:
- Merged far/patchBasis.cpp to osd/patchBasisCommon{,Types,Eval}.h
- Exposed PatchCoord, PatchArray, and PatchParam to Osd kernels
- exposed OsdEvaluatePatchBasis and OsdEvaluatePatchBasisNormalized
- Updated CPU, TBB, Omp, CUDA, OpenCL, GLSL, HLSL, and Metal evaluators
- Updated glFVarViewer
2018-10-30 07:37:25 +00:00
|
|
|
OsdPatchParam param = OsdPatchParamInit(
|
|
|
|
paramStruct.field0, paramStruct.field1, paramStruct.sharpness);
|
|
|
|
|
|
|
|
int patchType = OsdPatchParamIsRegular(param)
|
|
|
|
? array.GetPatchTypeRegular()
|
|
|
|
: array.GetPatchTypeIrregular();
|
2017-01-26 22:36:30 +00:00
|
|
|
|
Improved patch basis eval for Osd to match Far
This updates the patch basis evaluation functions in Osd
to match recent changes to far/patchBasis.
This also exposes a common facility for dealing with PatchCoord,
PatchArray, and PatchParam. These are exposed as global functions
operating on struct data, since C++ style class methods are not
supported by all of the Osd shader and kernel execution envirionments.
Changes:
- Merged far/patchBasis.cpp to osd/patchBasisCommon{,Types,Eval}.h
- Exposed PatchCoord, PatchArray, and PatchParam to Osd kernels
- exposed OsdEvaluatePatchBasis and OsdEvaluatePatchBasisNormalized
- Updated CPU, TBB, Omp, CUDA, OpenCL, GLSL, HLSL, and Metal evaluators
- Updated glFVarViewer
2018-10-30 07:37:25 +00:00
|
|
|
int nPoints = OsdEvaluatePatchBasis(patchType, param,
|
|
|
|
coord.s, coord.t, wP, 0, 0, 0, 0, 0);
|
2017-01-26 22:36:30 +00:00
|
|
|
|
Improved patch basis eval for Osd to match Far
This updates the patch basis evaluation functions in Osd
to match recent changes to far/patchBasis.
This also exposes a common facility for dealing with PatchCoord,
PatchArray, and PatchParam. These are exposed as global functions
operating on struct data, since C++ style class methods are not
supported by all of the Osd shader and kernel execution envirionments.
Changes:
- Merged far/patchBasis.cpp to osd/patchBasisCommon{,Types,Eval}.h
- Exposed PatchCoord, PatchArray, and PatchParam to Osd kernels
- exposed OsdEvaluatePatchBasis and OsdEvaluatePatchBasisNormalized
- Updated CPU, TBB, Omp, CUDA, OpenCL, GLSL, HLSL, and Metal evaluators
- Updated glFVarViewer
2018-10-30 07:37:25 +00:00
|
|
|
int indexBase = array.GetIndexBase() + array.GetStride() *
|
2017-01-26 22:36:30 +00:00
|
|
|
(coord.handle.patchIndex - array.GetPrimitiveIdBase());
|
|
|
|
|
|
|
|
const int *cvs = &_patchIndexBuffer[indexBase];
|
|
|
|
|
|
|
|
dstT.Clear();
|
Improved patch basis eval for Osd to match Far
This updates the patch basis evaluation functions in Osd
to match recent changes to far/patchBasis.
This also exposes a common facility for dealing with PatchCoord,
PatchArray, and PatchParam. These are exposed as global functions
operating on struct data, since C++ style class methods are not
supported by all of the Osd shader and kernel execution envirionments.
Changes:
- Merged far/patchBasis.cpp to osd/patchBasisCommon{,Types,Eval}.h
- Exposed PatchCoord, PatchArray, and PatchParam to Osd kernels
- exposed OsdEvaluatePatchBasis and OsdEvaluatePatchBasisNormalized
- Updated CPU, TBB, Omp, CUDA, OpenCL, GLSL, HLSL, and Metal evaluators
- Updated glFVarViewer
2018-10-30 07:37:25 +00:00
|
|
|
for (int j = 0; j < nPoints; ++j) {
|
2017-01-26 22:36:30 +00:00
|
|
|
dstT.AddWithWeight(srcT[cvs[j]], wP[j]);
|
|
|
|
}
|
|
|
|
++dstT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void computeWith1stDerivative(tbb::blocked_range<int> const &r) const {
|
|
|
|
float wP[20], wDu[20], wDv[20];
|
|
|
|
BufferAdapter<const float> srcT(_src + _srcDesc.offset,
|
|
|
|
_srcDesc.length,
|
|
|
|
_srcDesc.stride);
|
|
|
|
BufferAdapter<float> dstT(_dst + _dstDesc.offset
|
|
|
|
+ r.begin() * _dstDesc.stride,
|
|
|
|
_dstDesc.length,
|
|
|
|
_dstDesc.stride);
|
|
|
|
BufferAdapter<float> dstDuT(_dstDu + _dstDuDesc.offset
|
|
|
|
+ r.begin() * _dstDuDesc.stride,
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
_dstDuDesc.length,
|
|
|
|
_dstDuDesc.stride);
|
2017-01-26 22:36:30 +00:00
|
|
|
BufferAdapter<float> dstDvT(_dstDv + _dstDvDesc.offset
|
|
|
|
+ r.begin() * _dstDvDesc.stride,
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
_dstDvDesc.length,
|
|
|
|
_dstDvDesc.stride);
|
|
|
|
|
|
|
|
for (int i = r.begin(); i < r.end(); ++i) {
|
|
|
|
PatchCoord const &coord = _patchCoords[i];
|
|
|
|
PatchArray const &array = _patchArrayBuffer[coord.handle.arrayIndex];
|
|
|
|
|
Improved patch basis eval for Osd to match Far
This updates the patch basis evaluation functions in Osd
to match recent changes to far/patchBasis.
This also exposes a common facility for dealing with PatchCoord,
PatchArray, and PatchParam. These are exposed as global functions
operating on struct data, since C++ style class methods are not
supported by all of the Osd shader and kernel execution envirionments.
Changes:
- Merged far/patchBasis.cpp to osd/patchBasisCommon{,Types,Eval}.h
- Exposed PatchCoord, PatchArray, and PatchParam to Osd kernels
- exposed OsdEvaluatePatchBasis and OsdEvaluatePatchBasisNormalized
- Updated CPU, TBB, Omp, CUDA, OpenCL, GLSL, HLSL, and Metal evaluators
- Updated glFVarViewer
2018-10-30 07:37:25 +00:00
|
|
|
Osd::PatchParam const & paramStruct =
|
2016-09-29 16:38:32 +00:00
|
|
|
_patchParamBuffer[coord.handle.patchIndex];
|
Improved patch basis eval for Osd to match Far
This updates the patch basis evaluation functions in Osd
to match recent changes to far/patchBasis.
This also exposes a common facility for dealing with PatchCoord,
PatchArray, and PatchParam. These are exposed as global functions
operating on struct data, since C++ style class methods are not
supported by all of the Osd shader and kernel execution envirionments.
Changes:
- Merged far/patchBasis.cpp to osd/patchBasisCommon{,Types,Eval}.h
- Exposed PatchCoord, PatchArray, and PatchParam to Osd kernels
- exposed OsdEvaluatePatchBasis and OsdEvaluatePatchBasisNormalized
- Updated CPU, TBB, Omp, CUDA, OpenCL, GLSL, HLSL, and Metal evaluators
- Updated glFVarViewer
2018-10-30 07:37:25 +00:00
|
|
|
OsdPatchParam param = OsdPatchParamInit(
|
|
|
|
paramStruct.field0, paramStruct.field1, paramStruct.sharpness);
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
|
Improved patch basis eval for Osd to match Far
This updates the patch basis evaluation functions in Osd
to match recent changes to far/patchBasis.
This also exposes a common facility for dealing with PatchCoord,
PatchArray, and PatchParam. These are exposed as global functions
operating on struct data, since C++ style class methods are not
supported by all of the Osd shader and kernel execution envirionments.
Changes:
- Merged far/patchBasis.cpp to osd/patchBasisCommon{,Types,Eval}.h
- Exposed PatchCoord, PatchArray, and PatchParam to Osd kernels
- exposed OsdEvaluatePatchBasis and OsdEvaluatePatchBasisNormalized
- Updated CPU, TBB, Omp, CUDA, OpenCL, GLSL, HLSL, and Metal evaluators
- Updated glFVarViewer
2018-10-30 07:37:25 +00:00
|
|
|
int patchType = OsdPatchParamIsRegular(param)
|
|
|
|
? array.GetPatchTypeRegular()
|
|
|
|
: array.GetPatchTypeIrregular();
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
|
Improved patch basis eval for Osd to match Far
This updates the patch basis evaluation functions in Osd
to match recent changes to far/patchBasis.
This also exposes a common facility for dealing with PatchCoord,
PatchArray, and PatchParam. These are exposed as global functions
operating on struct data, since C++ style class methods are not
supported by all of the Osd shader and kernel execution envirionments.
Changes:
- Merged far/patchBasis.cpp to osd/patchBasisCommon{,Types,Eval}.h
- Exposed PatchCoord, PatchArray, and PatchParam to Osd kernels
- exposed OsdEvaluatePatchBasis and OsdEvaluatePatchBasisNormalized
- Updated CPU, TBB, Omp, CUDA, OpenCL, GLSL, HLSL, and Metal evaluators
- Updated glFVarViewer
2018-10-30 07:37:25 +00:00
|
|
|
int nPoints = OsdEvaluatePatchBasis(patchType, param,
|
|
|
|
coord.s, coord.t, wP, wDu, wDv, 0, 0, 0);
|
|
|
|
|
|
|
|
int indexBase = array.GetIndexBase() + array.GetStride() *
|
2016-09-29 16:56:15 +00:00
|
|
|
(coord.handle.patchIndex - array.GetPrimitiveIdBase());
|
|
|
|
|
|
|
|
const int *cvs = &_patchIndexBuffer[indexBase];
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
|
|
|
|
dstT.Clear();
|
2017-01-26 22:36:30 +00:00
|
|
|
dstDuT.Clear();
|
|
|
|
dstDvT.Clear();
|
Improved patch basis eval for Osd to match Far
This updates the patch basis evaluation functions in Osd
to match recent changes to far/patchBasis.
This also exposes a common facility for dealing with PatchCoord,
PatchArray, and PatchParam. These are exposed as global functions
operating on struct data, since C++ style class methods are not
supported by all of the Osd shader and kernel execution envirionments.
Changes:
- Merged far/patchBasis.cpp to osd/patchBasisCommon{,Types,Eval}.h
- Exposed PatchCoord, PatchArray, and PatchParam to Osd kernels
- exposed OsdEvaluatePatchBasis and OsdEvaluatePatchBasisNormalized
- Updated CPU, TBB, Omp, CUDA, OpenCL, GLSL, HLSL, and Metal evaluators
- Updated glFVarViewer
2018-10-30 07:37:25 +00:00
|
|
|
for (int j = 0; j < nPoints; ++j) {
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
dstT.AddWithWeight(srcT[cvs[j]], wP[j]);
|
2017-01-26 22:36:30 +00:00
|
|
|
dstDuT.AddWithWeight(srcT[cvs[j]], wDu[j]);
|
|
|
|
dstDvT.AddWithWeight(srcT[cvs[j]], wDv[j]);
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
}
|
|
|
|
++dstT;
|
2017-01-26 22:36:30 +00:00
|
|
|
++dstDuT;
|
|
|
|
++dstDvT;
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-26 22:36:30 +00:00
|
|
|
void computeWith2ndDerivative(tbb::blocked_range<int> const &r) const {
|
|
|
|
float wP[20], wDu[20], wDv[20], wDuu[20], wDuv[20], wDvv[20];
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
BufferAdapter<const float> srcT(_src + _srcDesc.offset,
|
|
|
|
_srcDesc.length,
|
|
|
|
_srcDesc.stride);
|
|
|
|
BufferAdapter<float> dstT(_dst + _dstDesc.offset
|
|
|
|
+ r.begin() * _dstDesc.stride,
|
|
|
|
_dstDesc.length,
|
|
|
|
_dstDesc.stride);
|
|
|
|
BufferAdapter<float> dstDuT(_dstDu + _dstDuDesc.offset
|
|
|
|
+ r.begin() * _dstDuDesc.stride,
|
|
|
|
_dstDuDesc.length,
|
|
|
|
_dstDuDesc.stride);
|
|
|
|
BufferAdapter<float> dstDvT(_dstDv + _dstDvDesc.offset
|
|
|
|
+ r.begin() * _dstDvDesc.stride,
|
|
|
|
_dstDvDesc.length,
|
|
|
|
_dstDvDesc.stride);
|
2017-01-26 22:36:30 +00:00
|
|
|
BufferAdapter<float> dstDuuT(_dstDuu + _dstDuuDesc.offset
|
|
|
|
+ r.begin() * _dstDuuDesc.stride,
|
|
|
|
_dstDuuDesc.length,
|
|
|
|
_dstDuuDesc.stride);
|
|
|
|
BufferAdapter<float> dstDuvT(_dstDuv + _dstDuvDesc.offset
|
|
|
|
+ r.begin() * _dstDuvDesc.stride,
|
|
|
|
_dstDuvDesc.length,
|
|
|
|
_dstDuvDesc.stride);
|
|
|
|
BufferAdapter<float> dstDvvT(_dstDvv + _dstDvvDesc.offset
|
|
|
|
+ r.begin() * _dstDvvDesc.stride,
|
|
|
|
_dstDvvDesc.length,
|
|
|
|
_dstDvvDesc.stride);
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
|
|
|
|
for (int i = r.begin(); i < r.end(); ++i) {
|
|
|
|
PatchCoord const &coord = _patchCoords[i];
|
|
|
|
PatchArray const &array = _patchArrayBuffer[coord.handle.arrayIndex];
|
|
|
|
|
Improved patch basis eval for Osd to match Far
This updates the patch basis evaluation functions in Osd
to match recent changes to far/patchBasis.
This also exposes a common facility for dealing with PatchCoord,
PatchArray, and PatchParam. These are exposed as global functions
operating on struct data, since C++ style class methods are not
supported by all of the Osd shader and kernel execution envirionments.
Changes:
- Merged far/patchBasis.cpp to osd/patchBasisCommon{,Types,Eval}.h
- Exposed PatchCoord, PatchArray, and PatchParam to Osd kernels
- exposed OsdEvaluatePatchBasis and OsdEvaluatePatchBasisNormalized
- Updated CPU, TBB, Omp, CUDA, OpenCL, GLSL, HLSL, and Metal evaluators
- Updated glFVarViewer
2018-10-30 07:37:25 +00:00
|
|
|
Osd::PatchParam const & paramStruct =
|
2016-09-29 16:38:32 +00:00
|
|
|
_patchParamBuffer[coord.handle.patchIndex];
|
Improved patch basis eval for Osd to match Far
This updates the patch basis evaluation functions in Osd
to match recent changes to far/patchBasis.
This also exposes a common facility for dealing with PatchCoord,
PatchArray, and PatchParam. These are exposed as global functions
operating on struct data, since C++ style class methods are not
supported by all of the Osd shader and kernel execution envirionments.
Changes:
- Merged far/patchBasis.cpp to osd/patchBasisCommon{,Types,Eval}.h
- Exposed PatchCoord, PatchArray, and PatchParam to Osd kernels
- exposed OsdEvaluatePatchBasis and OsdEvaluatePatchBasisNormalized
- Updated CPU, TBB, Omp, CUDA, OpenCL, GLSL, HLSL, and Metal evaluators
- Updated glFVarViewer
2018-10-30 07:37:25 +00:00
|
|
|
OsdPatchParam param = OsdPatchParamInit(
|
|
|
|
paramStruct.field0, paramStruct.field1, paramStruct.sharpness);
|
|
|
|
|
|
|
|
int patchType = OsdPatchParamIsRegular(param)
|
|
|
|
? array.GetPatchTypeRegular()
|
|
|
|
: array.GetPatchTypeIrregular();
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
|
Improved patch basis eval for Osd to match Far
This updates the patch basis evaluation functions in Osd
to match recent changes to far/patchBasis.
This also exposes a common facility for dealing with PatchCoord,
PatchArray, and PatchParam. These are exposed as global functions
operating on struct data, since C++ style class methods are not
supported by all of the Osd shader and kernel execution envirionments.
Changes:
- Merged far/patchBasis.cpp to osd/patchBasisCommon{,Types,Eval}.h
- Exposed PatchCoord, PatchArray, and PatchParam to Osd kernels
- exposed OsdEvaluatePatchBasis and OsdEvaluatePatchBasisNormalized
- Updated CPU, TBB, Omp, CUDA, OpenCL, GLSL, HLSL, and Metal evaluators
- Updated glFVarViewer
2018-10-30 07:37:25 +00:00
|
|
|
int nPoints = OsdEvaluatePatchBasis(patchType, param,
|
|
|
|
coord.s, coord.t, wP, wDu, wDv, wDuu, wDuv, wDvv);
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
|
Improved patch basis eval for Osd to match Far
This updates the patch basis evaluation functions in Osd
to match recent changes to far/patchBasis.
This also exposes a common facility for dealing with PatchCoord,
PatchArray, and PatchParam. These are exposed as global functions
operating on struct data, since C++ style class methods are not
supported by all of the Osd shader and kernel execution envirionments.
Changes:
- Merged far/patchBasis.cpp to osd/patchBasisCommon{,Types,Eval}.h
- Exposed PatchCoord, PatchArray, and PatchParam to Osd kernels
- exposed OsdEvaluatePatchBasis and OsdEvaluatePatchBasisNormalized
- Updated CPU, TBB, Omp, CUDA, OpenCL, GLSL, HLSL, and Metal evaluators
- Updated glFVarViewer
2018-10-30 07:37:25 +00:00
|
|
|
int indexBase = array.GetIndexBase() + array.GetStride() *
|
2016-09-29 16:56:15 +00:00
|
|
|
(coord.handle.patchIndex - array.GetPrimitiveIdBase());
|
|
|
|
|
|
|
|
const int *cvs = &_patchIndexBuffer[indexBase];
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
|
|
|
|
dstT.Clear();
|
|
|
|
dstDuT.Clear();
|
|
|
|
dstDvT.Clear();
|
2017-01-26 22:36:30 +00:00
|
|
|
dstDuuT.Clear();
|
|
|
|
dstDuvT.Clear();
|
|
|
|
dstDvvT.Clear();
|
Improved patch basis eval for Osd to match Far
This updates the patch basis evaluation functions in Osd
to match recent changes to far/patchBasis.
This also exposes a common facility for dealing with PatchCoord,
PatchArray, and PatchParam. These are exposed as global functions
operating on struct data, since C++ style class methods are not
supported by all of the Osd shader and kernel execution envirionments.
Changes:
- Merged far/patchBasis.cpp to osd/patchBasisCommon{,Types,Eval}.h
- Exposed PatchCoord, PatchArray, and PatchParam to Osd kernels
- exposed OsdEvaluatePatchBasis and OsdEvaluatePatchBasisNormalized
- Updated CPU, TBB, Omp, CUDA, OpenCL, GLSL, HLSL, and Metal evaluators
- Updated glFVarViewer
2018-10-30 07:37:25 +00:00
|
|
|
for (int j = 0; j < nPoints; ++j) {
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
dstT.AddWithWeight(srcT[cvs[j]], wP[j]);
|
2017-01-26 22:36:30 +00:00
|
|
|
dstDuT.AddWithWeight(srcT[cvs[j]], wDu[j]);
|
|
|
|
dstDvT.AddWithWeight(srcT[cvs[j]], wDv[j]);
|
|
|
|
dstDuuT.AddWithWeight(srcT[cvs[j]], wDuu[j]);
|
|
|
|
dstDuvT.AddWithWeight(srcT[cvs[j]], wDuv[j]);
|
|
|
|
dstDvvT.AddWithWeight(srcT[cvs[j]], wDvv[j]);
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
}
|
|
|
|
++dstT;
|
|
|
|
++dstDuT;
|
|
|
|
++dstDvT;
|
2017-01-26 22:36:30 +00:00
|
|
|
++dstDuuT;
|
|
|
|
++dstDuvT;
|
|
|
|
++dstDvvT;
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2015-05-29 16:21:14 +00:00
|
|
|
TbbEvalPatches(float const *src, BufferDescriptor const &srcDesc,
|
|
|
|
float *dst, BufferDescriptor const &dstDesc,
|
|
|
|
float *dstDu, BufferDescriptor const &dstDuDesc,
|
|
|
|
float *dstDv, BufferDescriptor const &dstDvDesc,
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
int numPatchCoords,
|
|
|
|
const PatchCoord *patchCoords,
|
|
|
|
const PatchArray *patchArrayBuffer,
|
|
|
|
const int *patchIndexBuffer,
|
|
|
|
const PatchParam *patchParamBuffer) {
|
|
|
|
|
|
|
|
TbbEvalPatchesKernel kernel(src, srcDesc, dst, dstDesc,
|
|
|
|
dstDu, dstDuDesc, dstDv, dstDvDesc,
|
2017-01-26 22:36:30 +00:00
|
|
|
NULL, BufferDescriptor(),
|
|
|
|
NULL, BufferDescriptor(),
|
|
|
|
NULL, BufferDescriptor(),
|
|
|
|
numPatchCoords, patchCoords,
|
|
|
|
patchArrayBuffer,
|
|
|
|
patchIndexBuffer,
|
|
|
|
patchParamBuffer);
|
|
|
|
|
|
|
|
tbb::blocked_range<int> range(0, numPatchCoords, grain_size);
|
|
|
|
tbb::parallel_for(range, kernel);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
TbbEvalPatches(float const *src, BufferDescriptor const &srcDesc,
|
|
|
|
float *dst, BufferDescriptor const &dstDesc,
|
|
|
|
float *dstDu, BufferDescriptor const &dstDuDesc,
|
|
|
|
float *dstDv, BufferDescriptor const &dstDvDesc,
|
|
|
|
float *dstDuu, BufferDescriptor const &dstDuuDesc,
|
|
|
|
float *dstDuv, BufferDescriptor const &dstDuvDesc,
|
|
|
|
float *dstDvv, BufferDescriptor const &dstDvvDesc,
|
|
|
|
int numPatchCoords,
|
|
|
|
const PatchCoord *patchCoords,
|
|
|
|
const PatchArray *patchArrayBuffer,
|
|
|
|
const int *patchIndexBuffer,
|
|
|
|
const PatchParam *patchParamBuffer) {
|
|
|
|
|
|
|
|
TbbEvalPatchesKernel kernel(src, srcDesc, dst, dstDesc,
|
|
|
|
dstDu, dstDuDesc, dstDv, dstDvDesc,
|
|
|
|
dstDuu, dstDuuDesc,
|
|
|
|
dstDuv, dstDuvDesc,
|
|
|
|
dstDvv, dstDvvDesc,
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
numPatchCoords, patchCoords,
|
|
|
|
patchArrayBuffer,
|
|
|
|
patchIndexBuffer,
|
|
|
|
patchParamBuffer);
|
|
|
|
|
|
|
|
tbb::blocked_range<int> range(0, numPatchCoords, grain_size);
|
|
|
|
tbb::parallel_for(range, kernel);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-09-29 16:56:15 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
} // end namespace Osd
|
2013-06-05 17:55:24 +00:00
|
|
|
|
|
|
|
} // end namespace OPENSUBDIV_VERSION
|
|
|
|
} // end namespace OpenSubdiv
|