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.
|
|
|
|
//
|
|
|
|
|
2020-03-03 23:05:41 +00:00
|
|
|
#include "glLoader.h"
|
|
|
|
|
2015-05-09 00:31:26 +00:00
|
|
|
#include "../osd/glComputeEvaluator.h"
|
2016-09-29 16:56:15 +00:00
|
|
|
#include "../osd/glslPatchShaderSource.h"
|
2015-05-09 00:31:26 +00:00
|
|
|
|
2020-03-03 23:05:41 +00:00
|
|
|
#include "../far/error.h"
|
|
|
|
#include "../far/stencilTable.h"
|
|
|
|
|
2015-05-09 00:31:26 +00:00
|
|
|
#include <cassert>
|
|
|
|
#include <sstream>
|
2022-08-30 19:13:44 +00:00
|
|
|
#include <cstring>
|
2015-05-09 00:31:26 +00:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
|
|
namespace OpenSubdiv {
|
|
|
|
namespace OPENSUBDIV_VERSION {
|
|
|
|
|
|
|
|
namespace Osd {
|
|
|
|
|
|
|
|
static const char *shaderSource =
|
|
|
|
#include "../osd/glslComputeKernel.gen.h"
|
|
|
|
;
|
|
|
|
|
|
|
|
template <class T> GLuint
|
|
|
|
createSSBO(std::vector<T> const & src) {
|
2017-01-26 22:36:30 +00:00
|
|
|
if (src.empty()) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-05-09 00:31:26 +00:00
|
|
|
GLuint devicePtr = 0;
|
|
|
|
|
2020-03-04 17:49:53 +00:00
|
|
|
#if defined(GL_ARB_direct_state_access)
|
|
|
|
if (OSD_OPENGL_HAS(ARB_direct_state_access)) {
|
|
|
|
glCreateBuffers(1, &devicePtr);
|
|
|
|
glNamedBufferData(devicePtr, src.size()*sizeof(T),
|
|
|
|
&src.at(0), GL_STATIC_DRAW);
|
|
|
|
} else
|
2015-05-09 00:31:26 +00:00
|
|
|
#endif
|
2020-03-04 17:49:53 +00:00
|
|
|
{
|
2015-05-09 00:31:26 +00:00
|
|
|
GLint prev = 0;
|
|
|
|
glGetIntegerv(GL_SHADER_STORAGE_BUFFER_BINDING, &prev);
|
2020-03-04 17:49:53 +00:00
|
|
|
glGenBuffers(1, &devicePtr);
|
2015-05-09 00:31:26 +00:00
|
|
|
glBindBuffer(GL_SHADER_STORAGE_BUFFER, devicePtr);
|
|
|
|
glBufferData(GL_SHADER_STORAGE_BUFFER, src.size()*sizeof(T),
|
|
|
|
&src.at(0), GL_STATIC_DRAW);
|
|
|
|
glBindBuffer(GL_SHADER_STORAGE_BUFFER, prev);
|
|
|
|
}
|
|
|
|
|
|
|
|
return devicePtr;
|
|
|
|
}
|
|
|
|
|
2015-05-22 18:50:01 +00:00
|
|
|
GLStencilTableSSBO::GLStencilTableSSBO(
|
|
|
|
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 = createSSBO(stencilTable->GetSizes());
|
|
|
|
_offsets = createSSBO(stencilTable->GetOffsets());
|
|
|
|
_indices = createSSBO(stencilTable->GetControlIndices());
|
|
|
|
_weights = createSSBO(stencilTable->GetWeights());
|
2015-05-28 00:23:36 +00:00
|
|
|
_duWeights = _dvWeights = 0;
|
2017-01-26 22:36:30 +00:00
|
|
|
_duuWeights = _duvWeights = _dvvWeights = 0;
|
2015-05-09 00:31:26 +00:00
|
|
|
} else {
|
|
|
|
_sizes = _offsets = _indices = _weights = 0;
|
2015-05-28 00:23:36 +00:00
|
|
|
_duWeights = _dvWeights = 0;
|
2017-01-26 22:36:30 +00:00
|
|
|
_duuWeights = _duvWeights = _dvvWeights = 0;
|
2015-05-28 00:23:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GLStencilTableSSBO::GLStencilTableSSBO(
|
|
|
|
Far::LimitStencilTable const *limitStencilTable) {
|
|
|
|
_numStencils = limitStencilTable->GetNumStencils();
|
|
|
|
if (_numStencils > 0) {
|
|
|
|
_sizes = createSSBO(limitStencilTable->GetSizes());
|
|
|
|
_offsets = createSSBO(limitStencilTable->GetOffsets());
|
|
|
|
_indices = createSSBO(limitStencilTable->GetControlIndices());
|
|
|
|
_weights = createSSBO(limitStencilTable->GetWeights());
|
|
|
|
_duWeights = createSSBO(limitStencilTable->GetDuWeights());
|
|
|
|
_dvWeights = createSSBO(limitStencilTable->GetDvWeights());
|
2017-01-26 22:36:30 +00:00
|
|
|
_duuWeights = createSSBO(limitStencilTable->GetDuuWeights());
|
|
|
|
_duvWeights = createSSBO(limitStencilTable->GetDuvWeights());
|
|
|
|
_dvvWeights = createSSBO(limitStencilTable->GetDvvWeights());
|
2015-05-28 00:23:36 +00:00
|
|
|
} else {
|
|
|
|
_sizes = _offsets = _indices = _weights = 0;
|
|
|
|
_duWeights = _dvWeights = 0;
|
2017-01-26 22:36:30 +00:00
|
|
|
_duuWeights = _duvWeights = _dvvWeights = 0;
|
2015-05-09 00:31:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-22 18:50:01 +00:00
|
|
|
GLStencilTableSSBO::~GLStencilTableSSBO() {
|
2015-05-09 00:31:26 +00:00
|
|
|
if (_sizes) glDeleteBuffers(1, &_sizes);
|
|
|
|
if (_offsets) glDeleteBuffers(1, &_offsets);
|
|
|
|
if (_indices) glDeleteBuffers(1, &_indices);
|
2015-05-28 00:23:36 +00:00
|
|
|
if (_weights) glDeleteBuffers(1, &_weights);
|
|
|
|
if (_duWeights) glDeleteBuffers(1, &_duWeights);
|
|
|
|
if (_dvWeights) glDeleteBuffers(1, &_dvWeights);
|
2017-01-26 22:36:30 +00:00
|
|
|
if (_duuWeights) glDeleteBuffers(1, &_duuWeights);
|
|
|
|
if (_duvWeights) glDeleteBuffers(1, &_duvWeights);
|
|
|
|
if (_dvvWeights) glDeleteBuffers(1, &_dvvWeights);
|
2015-05-09 00:31:26 +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
|
|
|
GLComputeEvaluator::GLComputeEvaluator()
|
|
|
|
: _workGroupSize(64),
|
|
|
|
_patchArraysSSBO(0) {
|
2022-08-30 19:13:44 +00:00
|
|
|
std::memset((void*) &_stencilKernel, 0, sizeof(_stencilKernel));
|
|
|
|
std::memset((void*) &_patchKernel, 0, sizeof(_patchKernel));
|
2020-03-04 17:47:36 +00:00
|
|
|
|
|
|
|
// Initialize internal OpenGL loader library if necessary
|
|
|
|
OpenSubdiv::internal::GLLoader::libraryInitializeGL();
|
2015-05-09 00:31:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GLComputeEvaluator::~GLComputeEvaluator() {
|
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
|
|
|
if (_patchArraysSSBO) {
|
|
|
|
glDeleteBuffers(1, &_patchArraysSSBO);
|
|
|
|
}
|
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
|
|
|
}
|
2015-05-09 00:31:26 +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
|
|
|
static GLuint
|
2015-05-29 16:21:14 +00:00
|
|
|
compileKernel(BufferDescriptor const &srcDesc,
|
|
|
|
BufferDescriptor const &dstDesc,
|
2017-01-26 22:36:30 +00:00
|
|
|
BufferDescriptor const & duDesc,
|
|
|
|
BufferDescriptor const & dvDesc,
|
|
|
|
BufferDescriptor const & duuDesc,
|
|
|
|
BufferDescriptor const & duvDesc,
|
|
|
|
BufferDescriptor const & dvvDesc,
|
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 char *kernelDefine,
|
|
|
|
int workGroupSize) {
|
|
|
|
GLuint program = glCreateProgram();
|
2015-05-09 00:31:26 +00:00
|
|
|
|
|
|
|
GLuint shader = glCreateShader(GL_COMPUTE_SHADER);
|
|
|
|
|
2016-09-29 16:56:15 +00:00
|
|
|
std::string patchBasisShaderSource =
|
|
|
|
GLSLPatchShaderSource::GetPatchBasisShaderSource();
|
|
|
|
const char *patchBasisShaderSourceDefine = "#define OSD_PATCH_BASIS_GLSL\n";
|
|
|
|
|
2015-05-09 00:31:26 +00:00
|
|
|
std::ostringstream defines;
|
|
|
|
defines << "#define LENGTH " << srcDesc.length << "\n"
|
|
|
|
<< "#define SRC_STRIDE " << srcDesc.stride << "\n"
|
|
|
|
<< "#define DST_STRIDE " << dstDesc.stride << "\n"
|
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
|
|
|
<< "#define WORK_GROUP_SIZE " << workGroupSize << "\n"
|
2016-09-29 16:56:15 +00:00
|
|
|
<< kernelDefine << "\n"
|
|
|
|
<< patchBasisShaderSourceDefine << "\n";
|
2017-01-26 22:36:30 +00:00
|
|
|
|
|
|
|
bool deriv1 = (duDesc.length > 0 || dvDesc.length > 0);
|
|
|
|
bool deriv2 = (duuDesc.length > 0 || duvDesc.length > 0 || dvvDesc.length > 0);
|
|
|
|
if (deriv1) {
|
|
|
|
defines << "#define OPENSUBDIV_GLSL_COMPUTE_USE_1ST_DERIVATIVES\n";
|
|
|
|
}
|
|
|
|
if (deriv2) {
|
|
|
|
defines << "#define OPENSUBDIV_GLSL_COMPUTE_USE_2ND_DERIVATIVES\n";
|
|
|
|
}
|
|
|
|
|
2015-05-09 00:31:26 +00:00
|
|
|
std::string defineStr = defines.str();
|
|
|
|
|
2016-09-29 16:56:15 +00:00
|
|
|
const char *shaderSources[4] = {"#version 430\n", 0, 0, 0};
|
|
|
|
|
2015-05-09 00:31:26 +00:00
|
|
|
shaderSources[1] = defineStr.c_str();
|
2016-09-29 16:56:15 +00:00
|
|
|
shaderSources[2] = patchBasisShaderSource.c_str();
|
|
|
|
shaderSources[3] = shaderSource;
|
|
|
|
glShaderSource(shader, 4, shaderSources, NULL);
|
2015-05-09 00:31:26 +00:00
|
|
|
glCompileShader(shader);
|
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
|
|
|
glAttachShader(program, shader);
|
2015-05-09 00:31:26 +00:00
|
|
|
|
|
|
|
GLint linked = 0;
|
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
|
|
|
glLinkProgram(program);
|
|
|
|
glGetProgramiv(program, GL_LINK_STATUS, &linked);
|
2015-05-09 00:31:26 +00:00
|
|
|
|
|
|
|
if (linked == GL_FALSE) {
|
|
|
|
char buffer[1024];
|
|
|
|
glGetShaderInfoLog(shader, 1024, NULL, buffer);
|
|
|
|
Far::Error(Far::FAR_RUNTIME_ERROR, buffer);
|
|
|
|
|
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
|
|
|
glGetProgramInfoLog(program, 1024, NULL, buffer);
|
2015-05-09 00:31:26 +00:00
|
|
|
Far::Error(Far::FAR_RUNTIME_ERROR, buffer);
|
|
|
|
|
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
|
|
|
glDeleteProgram(program);
|
|
|
|
return 0;
|
2015-05-09 00:31:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
glDeleteShader(shader);
|
|
|
|
|
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
|
|
|
return program;
|
|
|
|
}
|
2015-05-09 00:31:26 +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
|
|
|
bool
|
2015-05-29 16:21:14 +00:00
|
|
|
GLComputeEvaluator::Compile(BufferDescriptor const &srcDesc,
|
|
|
|
BufferDescriptor const &dstDesc,
|
|
|
|
BufferDescriptor const &duDesc,
|
2017-01-26 22:36:30 +00:00
|
|
|
BufferDescriptor const &dvDesc,
|
|
|
|
BufferDescriptor const &duuDesc,
|
|
|
|
BufferDescriptor const &duvDesc,
|
|
|
|
BufferDescriptor const &dvvDesc) {
|
2015-05-28 00:23:36 +00:00
|
|
|
|
|
|
|
// create a stencil kernel
|
2017-01-26 22:36:30 +00:00
|
|
|
if (!_stencilKernel.Compile(srcDesc, dstDesc,
|
|
|
|
duDesc, dvDesc,
|
|
|
|
duuDesc, duvDesc, dvvDesc,
|
2015-05-28 00:23:36 +00:00
|
|
|
_workGroupSize)) {
|
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
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-05-28 00:23:36 +00:00
|
|
|
// create a patch kernel
|
2017-01-26 22:36:30 +00:00
|
|
|
if (!_patchKernel.Compile(srcDesc, dstDesc,
|
|
|
|
duDesc, dvDesc,
|
|
|
|
duuDesc, duvDesc, dvvDesc,
|
2015-05-28 00:23:36 +00:00
|
|
|
_workGroupSize)) {
|
|
|
|
return false;
|
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
|
|
|
}
|
2015-05-09 00:31:26 +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
|
|
|
// create a patch arrays buffer
|
|
|
|
if (!_patchArraysSSBO) {
|
|
|
|
glGenBuffers(1, &_patchArraysSSBO);
|
|
|
|
}
|
|
|
|
|
2015-05-09 00:31:26 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */
|
|
|
|
void
|
|
|
|
GLComputeEvaluator::Synchronize(void * /*kernel*/) {
|
|
|
|
// XXX: this is currently just for the performance measuring purpose.
|
|
|
|
// need to be reimplemented by fence and sync.
|
|
|
|
glFinish();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2015-05-28 00:23:36 +00:00
|
|
|
GLComputeEvaluator::EvalStencils(
|
2015-05-29 16:21:14 +00:00
|
|
|
GLuint srcBuffer, BufferDescriptor const &srcDesc,
|
|
|
|
GLuint dstBuffer, BufferDescriptor const &dstDesc,
|
|
|
|
GLuint duBuffer, BufferDescriptor const &duDesc,
|
|
|
|
GLuint dvBuffer, BufferDescriptor const &dvDesc,
|
2015-05-28 00:23:36 +00:00
|
|
|
GLuint sizesBuffer,
|
|
|
|
GLuint offsetsBuffer,
|
|
|
|
GLuint indicesBuffer,
|
|
|
|
GLuint weightsBuffer,
|
|
|
|
GLuint duWeightsBuffer,
|
|
|
|
GLuint dvWeightsBuffer,
|
|
|
|
int start, int end) const {
|
|
|
|
|
2017-01-26 22:36:30 +00:00
|
|
|
return EvalStencils(srcBuffer, srcDesc,
|
|
|
|
dstBuffer, dstDesc,
|
|
|
|
duBuffer, duDesc,
|
|
|
|
dvBuffer, dvDesc,
|
|
|
|
0, BufferDescriptor(),
|
|
|
|
0, BufferDescriptor(),
|
|
|
|
0, BufferDescriptor(),
|
|
|
|
sizesBuffer, offsetsBuffer, indicesBuffer,
|
|
|
|
weightsBuffer,
|
|
|
|
duWeightsBuffer, dvWeightsBuffer,
|
|
|
|
0, 0, 0,
|
|
|
|
start, end);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
GLComputeEvaluator::EvalStencils(
|
|
|
|
GLuint srcBuffer, BufferDescriptor const &srcDesc,
|
|
|
|
GLuint dstBuffer, BufferDescriptor const &dstDesc,
|
|
|
|
GLuint duBuffer, BufferDescriptor const &duDesc,
|
|
|
|
GLuint dvBuffer, BufferDescriptor const &dvDesc,
|
|
|
|
GLuint duuBuffer, BufferDescriptor const &duuDesc,
|
|
|
|
GLuint duvBuffer, BufferDescriptor const &duvDesc,
|
|
|
|
GLuint dvvBuffer, BufferDescriptor const &dvvDesc,
|
|
|
|
GLuint sizesBuffer,
|
|
|
|
GLuint offsetsBuffer,
|
|
|
|
GLuint indicesBuffer,
|
|
|
|
GLuint weightsBuffer,
|
|
|
|
GLuint duWeightsBuffer,
|
|
|
|
GLuint dvWeightsBuffer,
|
|
|
|
GLuint duuWeightsBuffer,
|
|
|
|
GLuint duvWeightsBuffer,
|
|
|
|
GLuint dvvWeightsBuffer,
|
|
|
|
int start, int end) const {
|
|
|
|
|
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 (!_stencilKernel.program) return false;
|
2015-05-09 00:31:26 +00:00
|
|
|
int count = end - start;
|
|
|
|
if (count <= 0) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, srcBuffer);
|
|
|
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, dstBuffer);
|
2015-05-28 00:23:36 +00:00
|
|
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, duBuffer);
|
|
|
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 3, dvBuffer);
|
2017-01-26 22:36:30 +00:00
|
|
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 10, duuBuffer);
|
|
|
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 11, duvBuffer);
|
|
|
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 12, dvvBuffer);
|
2015-05-28 00:23:36 +00:00
|
|
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 4, sizesBuffer);
|
|
|
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 5, offsetsBuffer);
|
|
|
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 6, indicesBuffer);
|
|
|
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 7, weightsBuffer);
|
|
|
|
if (duWeightsBuffer)
|
|
|
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 8, duWeightsBuffer);
|
|
|
|
if (dvWeightsBuffer)
|
|
|
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 9, dvWeightsBuffer);
|
2017-01-26 22:36:30 +00:00
|
|
|
if (duuWeightsBuffer)
|
|
|
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 13, duuWeightsBuffer);
|
|
|
|
if (duvWeightsBuffer)
|
|
|
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 14, duvWeightsBuffer);
|
|
|
|
if (dvvWeightsBuffer)
|
|
|
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 15, dvvWeightsBuffer);
|
2015-05-09 00:31:26 +00:00
|
|
|
|
2022-06-26 16:08:38 +00:00
|
|
|
GLint activeProgram;
|
|
|
|
glGetIntegerv(GL_CURRENT_PROGRAM, &activeProgram);
|
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
|
|
|
glUseProgram(_stencilKernel.program);
|
2015-05-09 00:31:26 +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
|
|
|
glUniform1i(_stencilKernel.uniformStart, start);
|
|
|
|
glUniform1i(_stencilKernel.uniformEnd, end);
|
|
|
|
glUniform1i(_stencilKernel.uniformSrcOffset, srcDesc.offset);
|
|
|
|
glUniform1i(_stencilKernel.uniformDstOffset, dstDesc.offset);
|
2015-05-28 00:23:36 +00:00
|
|
|
if (_stencilKernel.uniformDuDesc > 0) {
|
|
|
|
glUniform3i(_stencilKernel.uniformDuDesc,
|
|
|
|
duDesc.offset, duDesc.length, duDesc.stride);
|
|
|
|
}
|
|
|
|
if (_stencilKernel.uniformDvDesc > 0) {
|
|
|
|
glUniform3i(_stencilKernel.uniformDvDesc,
|
|
|
|
dvDesc.offset, dvDesc.length, dvDesc.stride);
|
|
|
|
}
|
2017-01-26 22:36:30 +00:00
|
|
|
if (_stencilKernel.uniformDuuDesc > 0) {
|
|
|
|
glUniform3i(_stencilKernel.uniformDuuDesc,
|
|
|
|
duuDesc.offset, duuDesc.length, duuDesc.stride);
|
|
|
|
}
|
|
|
|
if (_stencilKernel.uniformDuvDesc > 0) {
|
|
|
|
glUniform3i(_stencilKernel.uniformDuvDesc,
|
|
|
|
duvDesc.offset, duvDesc.length, duvDesc.stride);
|
|
|
|
}
|
|
|
|
if (_stencilKernel.uniformDvvDesc > 0) {
|
|
|
|
glUniform3i(_stencilKernel.uniformDvvDesc,
|
|
|
|
dvvDesc.offset, dvvDesc.length, dvvDesc.stride);
|
|
|
|
}
|
2015-05-09 00:31:26 +00:00
|
|
|
|
|
|
|
glDispatchCompute((count + _workGroupSize - 1) / _workGroupSize, 1, 1);
|
|
|
|
|
2022-06-26 16:08:38 +00:00
|
|
|
glUseProgram(activeProgram);
|
2015-05-09 00:31:26 +00:00
|
|
|
|
|
|
|
glMemoryBarrier(GL_TEXTURE_FETCH_BARRIER_BIT);
|
2017-01-26 22:36:30 +00:00
|
|
|
for (int i = 0; i < 16; ++i) {
|
2015-05-28 00:23:36 +00:00
|
|
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, i, 0);
|
|
|
|
}
|
2015-05-09 00:31:26 +00:00
|
|
|
|
|
|
|
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
|
|
|
bool
|
|
|
|
GLComputeEvaluator::EvalPatches(
|
2015-05-29 16:21:14 +00:00
|
|
|
GLuint srcBuffer, BufferDescriptor const &srcDesc,
|
|
|
|
GLuint dstBuffer, BufferDescriptor const &dstDesc,
|
|
|
|
GLuint duBuffer, BufferDescriptor const &duDesc,
|
|
|
|
GLuint dvBuffer, 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,
|
|
|
|
GLuint patchCoordsBuffer,
|
|
|
|
const PatchArrayVector &patchArrays,
|
|
|
|
GLuint patchIndexBuffer,
|
|
|
|
GLuint patchParamsBuffer) const {
|
|
|
|
|
2017-01-26 22:36:30 +00:00
|
|
|
return EvalPatches(srcBuffer, srcDesc,
|
|
|
|
dstBuffer, dstDesc,
|
|
|
|
duBuffer, duDesc,
|
|
|
|
dvBuffer, dvDesc,
|
|
|
|
0, BufferDescriptor(),
|
|
|
|
0, BufferDescriptor(),
|
|
|
|
0, BufferDescriptor(),
|
|
|
|
numPatchCoords,
|
|
|
|
patchCoordsBuffer,
|
|
|
|
patchArrays,
|
|
|
|
patchIndexBuffer,
|
|
|
|
patchParamsBuffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
GLComputeEvaluator::EvalPatches(
|
|
|
|
GLuint srcBuffer, BufferDescriptor const &srcDesc,
|
|
|
|
GLuint dstBuffer, BufferDescriptor const &dstDesc,
|
|
|
|
GLuint duBuffer, BufferDescriptor const &duDesc,
|
|
|
|
GLuint dvBuffer, BufferDescriptor const &dvDesc,
|
|
|
|
GLuint duuBuffer, BufferDescriptor const &duuDesc,
|
|
|
|
GLuint duvBuffer, BufferDescriptor const &duvDesc,
|
|
|
|
GLuint dvvBuffer, BufferDescriptor const &dvvDesc,
|
|
|
|
int numPatchCoords,
|
|
|
|
GLuint patchCoordsBuffer,
|
|
|
|
const PatchArrayVector &patchArrays,
|
|
|
|
GLuint patchIndexBuffer,
|
|
|
|
GLuint patchParamsBuffer) const {
|
|
|
|
|
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 (!_patchKernel.program) return false;
|
|
|
|
|
|
|
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, srcBuffer);
|
|
|
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, dstBuffer);
|
|
|
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, duBuffer);
|
|
|
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 3, dvBuffer);
|
2017-01-26 22:36:30 +00:00
|
|
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 10, duuBuffer);
|
|
|
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 11, duvBuffer);
|
|
|
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 12, dvvBuffer);
|
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
|
|
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 5, patchCoordsBuffer);
|
|
|
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 6, patchIndexBuffer);
|
|
|
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 7, patchParamsBuffer);
|
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
|
|
|
|
2022-06-26 16:08:38 +00:00
|
|
|
GLint activeProgram;
|
|
|
|
glGetIntegerv(GL_CURRENT_PROGRAM, &activeProgram);
|
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
|
|
|
glUseProgram(_patchKernel.program);
|
|
|
|
|
|
|
|
glUniform1i(_patchKernel.uniformSrcOffset, srcDesc.offset);
|
|
|
|
glUniform1i(_patchKernel.uniformDstOffset, dstDesc.offset);
|
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 patchArraySize = sizeof(PatchArray);
|
|
|
|
glBindBuffer(GL_SHADER_STORAGE_BUFFER, _patchArraysSSBO);
|
|
|
|
glBufferData(GL_SHADER_STORAGE_BUFFER,
|
|
|
|
patchArrays.size()*patchArraySize, NULL, GL_STATIC_DRAW);
|
|
|
|
for (int i=0; i<(int)patchArrays.size(); ++i) {
|
|
|
|
glBufferSubData(GL_SHADER_STORAGE_BUFFER,
|
|
|
|
i*patchArraySize, sizeof(PatchArray), &patchArrays[i]);
|
|
|
|
}
|
|
|
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 4, _patchArraysSSBO);
|
2017-01-26 22:36:30 +00:00
|
|
|
|
|
|
|
if (_patchKernel.uniformDuDesc > 0) {
|
|
|
|
glUniform3i(_patchKernel.uniformDuDesc,
|
|
|
|
duDesc.offset, duDesc.length, duDesc.stride);
|
|
|
|
}
|
|
|
|
if (_patchKernel.uniformDvDesc > 0) {
|
|
|
|
glUniform3i(_patchKernel.uniformDvDesc,
|
|
|
|
dvDesc.offset, dvDesc.length, dvDesc.stride);
|
|
|
|
}
|
|
|
|
if (_patchKernel.uniformDuuDesc > 0) {
|
|
|
|
glUniform3i(_patchKernel.uniformDuuDesc,
|
|
|
|
duuDesc.offset, duuDesc.length, duuDesc.stride);
|
|
|
|
}
|
|
|
|
if (_patchKernel.uniformDuvDesc > 0) {
|
|
|
|
glUniform3i(_patchKernel.uniformDuvDesc,
|
|
|
|
duvDesc.offset, duvDesc.length, duvDesc.stride);
|
|
|
|
}
|
|
|
|
if (_patchKernel.uniformDvvDesc > 0) {
|
|
|
|
glUniform3i(_patchKernel.uniformDvvDesc,
|
|
|
|
dvvDesc.offset, dvvDesc.length, 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
|
|
|
|
|
|
|
glDispatchCompute((numPatchCoords + _workGroupSize - 1) / _workGroupSize, 1, 1);
|
|
|
|
|
2022-06-26 16:08:38 +00:00
|
|
|
glUseProgram(activeProgram);
|
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
|
|
|
|
|
|
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, 0);
|
|
|
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, 0);
|
|
|
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, 0);
|
|
|
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 3, 0);
|
|
|
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 4, 0);
|
|
|
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 5, 0);
|
|
|
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 6, 0);
|
|
|
|
|
2017-01-26 22:36:30 +00:00
|
|
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 10, 0);
|
|
|
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 11, 0);
|
|
|
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 12, 0);
|
|
|
|
|
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
|
|
|
return true;
|
|
|
|
}
|
2015-05-28 00:23:36 +00:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
GLComputeEvaluator::_StencilKernel::_StencilKernel() : program(0) {
|
|
|
|
}
|
|
|
|
GLComputeEvaluator::_StencilKernel::~_StencilKernel() {
|
|
|
|
if (program) {
|
|
|
|
glDeleteProgram(program);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2015-05-29 16:21:14 +00:00
|
|
|
GLComputeEvaluator::_StencilKernel::Compile(BufferDescriptor const &srcDesc,
|
|
|
|
BufferDescriptor const &dstDesc,
|
|
|
|
BufferDescriptor const &duDesc,
|
|
|
|
BufferDescriptor const &dvDesc,
|
2017-01-26 22:36:30 +00:00
|
|
|
BufferDescriptor const &duuDesc,
|
|
|
|
BufferDescriptor const &duvDesc,
|
|
|
|
BufferDescriptor const &dvvDesc,
|
2015-05-29 16:21:14 +00:00
|
|
|
int workGroupSize) {
|
2015-05-28 00:23:36 +00:00
|
|
|
// create stencil kernel
|
|
|
|
if (program) {
|
|
|
|
glDeleteProgram(program);
|
|
|
|
}
|
|
|
|
|
2017-01-26 22:36:30 +00:00
|
|
|
const char * kernelDefine =
|
|
|
|
"#define OPENSUBDIV_GLSL_COMPUTE_KERNEL_EVAL_STENCILS\n";
|
2015-05-28 00:23:36 +00:00
|
|
|
|
2017-01-26 22:36:30 +00:00
|
|
|
program = compileKernel(srcDesc, dstDesc,
|
|
|
|
duDesc, dvDesc, duuDesc, duvDesc, dvvDesc,
|
|
|
|
kernelDefine, workGroupSize);
|
2015-05-28 00:23:36 +00:00
|
|
|
if (program == 0) return false;
|
|
|
|
|
|
|
|
// cache uniform locations (TODO: use uniform block)
|
|
|
|
uniformStart = glGetUniformLocation(program, "batchStart");
|
|
|
|
uniformEnd = glGetUniformLocation(program, "batchEnd");
|
|
|
|
uniformSrcOffset = glGetUniformLocation(program, "srcOffset");
|
|
|
|
uniformDstOffset = glGetUniformLocation(program, "dstOffset");
|
|
|
|
uniformDuDesc = glGetUniformLocation(program, "duDesc");
|
|
|
|
uniformDvDesc = glGetUniformLocation(program, "dvDesc");
|
2017-01-26 22:36:30 +00:00
|
|
|
uniformDuuDesc = glGetUniformLocation(program, "duuDesc");
|
|
|
|
uniformDuvDesc = glGetUniformLocation(program, "duvDesc");
|
|
|
|
uniformDvvDesc = glGetUniformLocation(program, "dvvDesc");
|
2015-05-28 00:23:36 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
GLComputeEvaluator::_PatchKernel::_PatchKernel() : program(0) {
|
|
|
|
}
|
|
|
|
GLComputeEvaluator::_PatchKernel::~_PatchKernel() {
|
|
|
|
if (program) {
|
|
|
|
glDeleteProgram(program);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2015-05-29 16:21:14 +00:00
|
|
|
GLComputeEvaluator::_PatchKernel::Compile(BufferDescriptor const &srcDesc,
|
|
|
|
BufferDescriptor const &dstDesc,
|
|
|
|
BufferDescriptor const &duDesc,
|
|
|
|
BufferDescriptor const &dvDesc,
|
2017-01-26 22:36:30 +00:00
|
|
|
BufferDescriptor const &duuDesc,
|
|
|
|
BufferDescriptor const &duvDesc,
|
|
|
|
BufferDescriptor const &dvvDesc,
|
2015-05-28 00:23:36 +00:00
|
|
|
int workGroupSize) {
|
|
|
|
// create stencil kernel
|
|
|
|
if (program) {
|
|
|
|
glDeleteProgram(program);
|
|
|
|
}
|
|
|
|
|
2017-01-26 22:36:30 +00:00
|
|
|
const char * kernelDefine =
|
|
|
|
"#define OPENSUBDIV_GLSL_COMPUTE_KERNEL_EVAL_PATCHES\n";
|
2015-05-28 00:23:36 +00:00
|
|
|
|
2017-01-26 22:36:30 +00:00
|
|
|
program = compileKernel(srcDesc, dstDesc,
|
|
|
|
duDesc, dvDesc, duuDesc, duvDesc, dvvDesc,
|
|
|
|
kernelDefine, workGroupSize);
|
2015-05-28 00:23:36 +00:00
|
|
|
if (program == 0) return false;
|
|
|
|
|
|
|
|
// cache uniform locations
|
|
|
|
uniformSrcOffset = glGetUniformLocation(program, "srcOffset");
|
|
|
|
uniformDstOffset = glGetUniformLocation(program, "dstOffset");
|
|
|
|
uniformPatchArray = glGetUniformLocation(program, "patchArray");
|
|
|
|
uniformDuDesc = glGetUniformLocation(program, "duDesc");
|
|
|
|
uniformDvDesc = glGetUniformLocation(program, "dvDesc");
|
2017-01-26 22:36:30 +00:00
|
|
|
uniformDuuDesc = glGetUniformLocation(program, "duuDesc");
|
|
|
|
uniformDuvDesc = glGetUniformLocation(program, "duvDesc");
|
|
|
|
uniformDvvDesc = glGetUniformLocation(program, "dvvDesc");
|
2015-05-28 00:23:36 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
2015-05-09 00:31:26 +00:00
|
|
|
} // end namespace Osd
|
|
|
|
|
|
|
|
} // end namespace OPENSUBDIV_VERSION
|
|
|
|
} // end namespace OpenSubdiv
|