2015-05-09 00:31:26 +00:00
|
|
|
//
|
|
|
|
// Copyright 2015 Pixar
|
|
|
|
//
|
|
|
|
// 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:
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
// You may obtain a copy of the Apache License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "../osd/cudaEvaluator.h"
|
|
|
|
|
|
|
|
#include <cuda_runtime.h>
|
|
|
|
#include <vector>
|
|
|
|
|
2015-05-22 18:50:01 +00:00
|
|
|
#include "../far/stencilTable.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-09 00:31:26 +00:00
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
void CudaEvalStencils(const float *src,
|
|
|
|
float *dst,
|
|
|
|
int length,
|
|
|
|
int srcStride,
|
|
|
|
int dstStride,
|
2015-05-19 17:16:56 +00:00
|
|
|
const int * sizes,
|
2015-05-09 00:31:26 +00:00
|
|
|
const int * offsets,
|
|
|
|
const int * indices,
|
|
|
|
const float * weights,
|
|
|
|
int start,
|
|
|
|
int end);
|
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 CudaEvalPatches(
|
|
|
|
const float *src, float *dst,
|
|
|
|
int length, int srcStride, int dstStride,
|
|
|
|
int numPatchCoords,
|
|
|
|
const void *patchCoords,
|
|
|
|
const void *patchArrays,
|
|
|
|
const int *patchIndices,
|
|
|
|
const void *patchParams);
|
|
|
|
|
|
|
|
void CudaEvalPatchesWithDerivatives(
|
2017-01-26 22:36:30 +00:00
|
|
|
const float *src, float *dst,
|
|
|
|
float *du, float *dv,
|
|
|
|
float *duu, float *duv, float *dvv,
|
|
|
|
int length, int srcStride, int dstStride,
|
|
|
|
int duStride, int dvStride,
|
|
|
|
int duuStride, int duvStride, int dvvStride,
|
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 void *patchCoords,
|
|
|
|
const void *patchArrays,
|
|
|
|
const int *patchIndices,
|
|
|
|
const void *patchParams);
|
2016-09-29 16:56:15 +00:00
|
|
|
|
2015-05-09 00:31:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace OpenSubdiv {
|
|
|
|
namespace OPENSUBDIV_VERSION {
|
|
|
|
|
|
|
|
namespace Osd {
|
|
|
|
|
|
|
|
template <class T> void *
|
|
|
|
createCudaBuffer(std::vector<T> const & src) {
|
2017-01-26 22:36:30 +00:00
|
|
|
if (src.empty()) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2015-05-09 00:31:26 +00:00
|
|
|
void * devicePtr = 0;
|
|
|
|
|
|
|
|
size_t size = src.size()*sizeof(T);
|
|
|
|
|
|
|
|
cudaError_t err = cudaMalloc(&devicePtr, size);
|
|
|
|
if (err != cudaSuccess) {
|
|
|
|
return devicePtr;
|
|
|
|
}
|
|
|
|
|
|
|
|
err = cudaMemcpy(devicePtr, &src.at(0), size, cudaMemcpyHostToDevice);
|
|
|
|
if (err != cudaSuccess) {
|
|
|
|
cudaFree(devicePtr);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return devicePtr;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2015-05-22 18:50:01 +00:00
|
|
|
CudaStencilTable::CudaStencilTable(Far::StencilTable const *stencilTable) {
|
|
|
|
_numStencils = stencilTable->GetNumStencils();
|
2015-05-09 00:31:26 +00:00
|
|
|
if (_numStencils > 0) {
|
2015-05-22 18:50:01 +00:00
|
|
|
_sizes = createCudaBuffer(stencilTable->GetSizes());
|
|
|
|
_offsets = createCudaBuffer(stencilTable->GetOffsets());
|
|
|
|
_indices = createCudaBuffer(stencilTable->GetControlIndices());
|
|
|
|
_weights = createCudaBuffer(stencilTable->GetWeights());
|
2015-05-28 00:23:36 +00:00
|
|
|
_duWeights = _dvWeights = NULL;
|
2017-01-26 22:36:30 +00:00
|
|
|
_duuWeights = _duvWeights = _dvvWeights = NULL;
|
2015-05-09 00:31:26 +00:00
|
|
|
} else {
|
|
|
|
_sizes = _offsets = _indices = _weights = NULL;
|
2015-05-28 00:23:36 +00:00
|
|
|
_duWeights = _dvWeights = NULL;
|
2017-01-26 22:36:30 +00:00
|
|
|
_duuWeights = _duvWeights = _dvvWeights = NULL;
|
2015-05-28 00:23:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CudaStencilTable::CudaStencilTable(Far::LimitStencilTable const *limitStencilTable) {
|
|
|
|
_numStencils = limitStencilTable->GetNumStencils();
|
|
|
|
if (_numStencils > 0) {
|
|
|
|
_sizes = createCudaBuffer(limitStencilTable->GetSizes());
|
|
|
|
_offsets = createCudaBuffer(limitStencilTable->GetOffsets());
|
|
|
|
_indices = createCudaBuffer(limitStencilTable->GetControlIndices());
|
|
|
|
_weights = createCudaBuffer(limitStencilTable->GetWeights());
|
|
|
|
_duWeights = createCudaBuffer(limitStencilTable->GetDuWeights());
|
|
|
|
_dvWeights = createCudaBuffer(limitStencilTable->GetDvWeights());
|
2017-01-26 22:36:30 +00:00
|
|
|
_duuWeights = createCudaBuffer(limitStencilTable->GetDuuWeights());
|
|
|
|
_duvWeights = createCudaBuffer(limitStencilTable->GetDuvWeights());
|
|
|
|
_dvvWeights = createCudaBuffer(limitStencilTable->GetDvvWeights());
|
2015-05-28 00:23:36 +00:00
|
|
|
} else {
|
|
|
|
_sizes = _offsets = _indices = _weights = NULL;
|
|
|
|
_duWeights = _dvWeights = NULL;
|
2017-01-26 22:36:30 +00:00
|
|
|
_duuWeights = _duvWeights = _dvvWeights = NULL;
|
2015-05-09 00:31:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-22 18:50:01 +00:00
|
|
|
CudaStencilTable::~CudaStencilTable() {
|
2015-05-09 00:31:26 +00:00
|
|
|
if (_sizes) cudaFree(_sizes);
|
|
|
|
if (_offsets) cudaFree(_offsets);
|
|
|
|
if (_indices) cudaFree(_indices);
|
|
|
|
if (_weights) cudaFree(_weights);
|
2015-05-28 00:23:36 +00:00
|
|
|
if (_duWeights) cudaFree(_duWeights);
|
|
|
|
if (_dvWeights) cudaFree(_dvWeights);
|
2017-01-26 22:36:30 +00:00
|
|
|
if (_duuWeights) cudaFree(_duuWeights);
|
|
|
|
if (_duvWeights) cudaFree(_duvWeights);
|
|
|
|
if (_dvvWeights) cudaFree(_dvvWeights);
|
2015-05-09 00:31:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/* static */
|
|
|
|
bool
|
2015-05-29 16:21:14 +00:00
|
|
|
CudaEvaluator::EvalStencils(const float *src, BufferDescriptor const &srcDesc,
|
|
|
|
float *dst, BufferDescriptor const &dstDesc,
|
2015-05-19 17:16:56 +00:00
|
|
|
const int * sizes,
|
2015-05-09 00:31:26 +00:00
|
|
|
const int * offsets,
|
|
|
|
const int * indices,
|
|
|
|
const float * weights,
|
|
|
|
int start,
|
|
|
|
int end) {
|
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
|
|
|
if (dst == NULL) return false;
|
|
|
|
|
2015-05-09 00:31:26 +00:00
|
|
|
CudaEvalStencils(src + srcDesc.offset,
|
|
|
|
dst + dstDesc.offset,
|
|
|
|
srcDesc.length,
|
|
|
|
srcDesc.stride,
|
|
|
|
dstDesc.stride,
|
|
|
|
sizes, offsets, indices, weights,
|
|
|
|
start, end);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
/* static */
|
|
|
|
bool
|
2015-05-29 16:21:14 +00:00
|
|
|
CudaEvaluator::EvalStencils(const float *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
|
|
|
const int * sizes,
|
|
|
|
const int * offsets,
|
|
|
|
const int * indices,
|
|
|
|
const float * weights,
|
|
|
|
const float * duWeights,
|
|
|
|
const float * dvWeights,
|
|
|
|
int start,
|
|
|
|
int end) {
|
|
|
|
// PERFORMANCE: need to combine 3 launches together
|
|
|
|
if (dst) {
|
|
|
|
CudaEvalStencils(src + srcDesc.offset,
|
|
|
|
dst + dstDesc.offset,
|
|
|
|
srcDesc.length,
|
|
|
|
srcDesc.stride,
|
|
|
|
dstDesc.stride,
|
|
|
|
sizes, offsets, indices, weights,
|
|
|
|
start, end);
|
|
|
|
}
|
2015-05-29 16:21:14 +00:00
|
|
|
if (du) {
|
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
|
|
|
CudaEvalStencils(src + srcDesc.offset,
|
2015-05-29 16:21:14 +00:00
|
|
|
du + duDesc.offset,
|
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
|
|
|
srcDesc.length,
|
|
|
|
srcDesc.stride,
|
2015-05-29 16:21:14 +00:00
|
|
|
duDesc.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
|
|
|
sizes, offsets, indices, duWeights,
|
|
|
|
start, end);
|
|
|
|
}
|
2015-05-29 16:21:14 +00:00
|
|
|
if (dv) {
|
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
|
|
|
CudaEvalStencils(src + srcDesc.offset,
|
2015-05-29 16:21:14 +00:00
|
|
|
dv + dvDesc.offset,
|
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
|
|
|
srcDesc.length,
|
|
|
|
srcDesc.stride,
|
2015-05-29 16:21:14 +00:00
|
|
|
dvDesc.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
|
|
|
sizes, offsets, indices, dvWeights,
|
|
|
|
start, end);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-01-26 22:36:30 +00:00
|
|
|
/* static */
|
|
|
|
bool
|
|
|
|
CudaEvaluator::EvalStencils(const float *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,
|
|
|
|
const int * sizes,
|
|
|
|
const int * offsets,
|
|
|
|
const int * indices,
|
|
|
|
const float * weights,
|
|
|
|
const float * duWeights,
|
|
|
|
const float * dvWeights,
|
|
|
|
const float * duuWeights,
|
|
|
|
const float * duvWeights,
|
|
|
|
const float * dvvWeights,
|
|
|
|
int start,
|
|
|
|
int end) {
|
|
|
|
// PERFORMANCE: need to combine 3 launches together
|
|
|
|
if (dst) {
|
|
|
|
CudaEvalStencils(src + srcDesc.offset,
|
|
|
|
dst + dstDesc.offset,
|
|
|
|
srcDesc.length,
|
|
|
|
srcDesc.stride,
|
|
|
|
dstDesc.stride,
|
|
|
|
sizes, offsets, indices, weights,
|
|
|
|
start, end);
|
|
|
|
}
|
|
|
|
if (du) {
|
|
|
|
CudaEvalStencils(src + srcDesc.offset,
|
|
|
|
du + duDesc.offset,
|
|
|
|
srcDesc.length,
|
|
|
|
srcDesc.stride,
|
|
|
|
duDesc.stride,
|
|
|
|
sizes, offsets, indices, duWeights,
|
|
|
|
start, end);
|
|
|
|
}
|
|
|
|
if (dv) {
|
|
|
|
CudaEvalStencils(src + srcDesc.offset,
|
|
|
|
dv + dvDesc.offset,
|
|
|
|
srcDesc.length,
|
|
|
|
srcDesc.stride,
|
|
|
|
dvDesc.stride,
|
|
|
|
sizes, offsets, indices, dvWeights,
|
|
|
|
start, end);
|
|
|
|
}
|
|
|
|
if (duu) {
|
|
|
|
CudaEvalStencils(src + srcDesc.offset,
|
|
|
|
duu + duuDesc.offset,
|
|
|
|
srcDesc.length,
|
|
|
|
srcDesc.stride,
|
|
|
|
duuDesc.stride,
|
|
|
|
sizes, offsets, indices, duuWeights,
|
|
|
|
start, end);
|
|
|
|
}
|
|
|
|
if (duv) {
|
|
|
|
CudaEvalStencils(src + srcDesc.offset,
|
|
|
|
duv + duvDesc.offset,
|
|
|
|
srcDesc.length,
|
|
|
|
srcDesc.stride,
|
|
|
|
duvDesc.stride,
|
|
|
|
sizes, offsets, indices, duvWeights,
|
|
|
|
start, end);
|
|
|
|
}
|
|
|
|
if (dvv) {
|
|
|
|
CudaEvalStencils(src + srcDesc.offset,
|
|
|
|
dvv + dvvDesc.offset,
|
|
|
|
srcDesc.length,
|
|
|
|
srcDesc.stride,
|
|
|
|
dvvDesc.stride,
|
|
|
|
sizes, offsets, indices, dvvWeights,
|
|
|
|
start, end);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
/* static */
|
|
|
|
bool
|
|
|
|
CudaEvaluator::EvalPatches(const float *src,
|
2015-05-29 16:21:14 +00:00
|
|
|
BufferDescriptor const &srcDesc,
|
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 *dst,
|
2015-05-29 16:21:14 +00:00
|
|
|
BufferDescriptor const &dstDesc,
|
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 *patchArrays,
|
|
|
|
const int *patchIndices,
|
|
|
|
const PatchParam *patchParams) {
|
2015-05-26 18:13:30 +00:00
|
|
|
if (src) src += srcDesc.offset;
|
|
|
|
if (dst) dst += dstDesc.offset;
|
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
|
|
|
|
|
|
|
CudaEvalPatches(src, dst,
|
|
|
|
srcDesc.length, srcDesc.stride, dstDesc.stride,
|
|
|
|
numPatchCoords, patchCoords, patchArrays, patchIndices, patchParams);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */
|
|
|
|
bool
|
|
|
|
CudaEvaluator::EvalPatches(
|
2015-05-29 16:21:14 +00:00
|
|
|
const float *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 numPatchCoords,
|
|
|
|
const PatchCoord *patchCoords,
|
|
|
|
const PatchArray *patchArrays,
|
|
|
|
const int *patchIndices,
|
|
|
|
const PatchParam *patchParams) {
|
|
|
|
|
|
|
|
if (src) src += srcDesc.offset;
|
|
|
|
if (dst) dst += dstDesc.offset;
|
|
|
|
if (du) du += duDesc.offset;
|
|
|
|
if (dv) dv += dvDesc.offset;
|
|
|
|
|
|
|
|
CudaEvalPatchesWithDerivatives(
|
2017-01-26 22:36:30 +00:00
|
|
|
src, dst, du, dv, NULL, NULL, NULL,
|
|
|
|
srcDesc.length, srcDesc.stride, dstDesc.stride,
|
|
|
|
duDesc.stride, dvDesc.stride, 0, 0, 0,
|
|
|
|
numPatchCoords, patchCoords, patchArrays, patchIndices, patchParams);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */
|
|
|
|
bool
|
|
|
|
CudaEvaluator::EvalPatches(
|
|
|
|
const float *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 numPatchCoords,
|
|
|
|
const PatchCoord *patchCoords,
|
|
|
|
const PatchArray *patchArrays,
|
|
|
|
const int *patchIndices,
|
|
|
|
const PatchParam *patchParams) {
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
CudaEvalPatchesWithDerivatives(
|
|
|
|
src, dst, du, dv, duu, duv, dvv,
|
|
|
|
srcDesc.length, srcDesc.stride, dstDesc.stride,
|
|
|
|
duDesc.stride, dvDesc.stride,
|
|
|
|
duuDesc.stride, duvDesc.stride, dvvDesc.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
|
|
|
numPatchCoords, patchCoords, patchArrays, patchIndices, patchParams);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-05-09 00:31:26 +00:00
|
|
|
/* static */
|
|
|
|
void
|
|
|
|
CudaEvaluator::Synchronize(void * /*deviceContext*/) {
|
|
|
|
cudaThreadSynchronize();
|
|
|
|
}
|
|
|
|
|
|
|
|
} // end namespace Osd
|
|
|
|
|
|
|
|
} // end namespace OPENSUBDIV_VERSION
|
|
|
|
} // end namespace OpenSubdiv
|