2012-06-09 20:40:48 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// Copyright 2013 Pixar
|
2012-06-09 20:40:48 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
|
|
|
// with the following modification; you may not use this file except in
|
|
|
|
// compliance with the Apache License and the following modification to it:
|
|
|
|
// Section 6. Trademarks. is deleted and replaced with:
|
2012-06-09 20:40:48 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// 6. Trademarks. This License does not grant permission to use the trade
|
|
|
|
// names, trademarks, service marks, or product names of the Licensor
|
|
|
|
// and its affiliates, except as required to comply with Section 4(c) of
|
|
|
|
// the License and to reproduce the content of the NOTICE file.
|
2012-06-09 20:40:48 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// You may obtain a copy of the Apache License at
|
2012-06-09 20:40:48 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
2013-07-18 21:19:50 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the Apache License with the above modification is
|
|
|
|
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
// KIND, either express or implied. See the Apache License for the specific
|
|
|
|
// language governing permissions and limitations under the Apache License.
|
2012-06-09 20:40:48 +00:00
|
|
|
//
|
2012-12-11 01:15:13 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
//------------------------------------------------------------------------------
|
2012-06-09 20:40:48 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
uniform samplerBuffer vertexBuffer;
|
2015-05-07 23:11:00 +00:00
|
|
|
uniform int srcOffset = 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
|
|
|
out float outVertexBuffer[LENGTH];
|
2012-06-09 20:40:48 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
//------------------------------------------------------------------------------
|
2012-06-09 20:40:48 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
struct Vertex {
|
|
|
|
float vertexData[LENGTH];
|
2012-06-09 20:40:48 +00:00
|
|
|
};
|
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
void clear(out Vertex v) {
|
|
|
|
for (int i = 0; i < LENGTH; i++) {
|
2012-12-11 01:15:13 +00:00
|
|
|
v.vertexData[i] = 0;
|
|
|
|
}
|
2012-06-09 20:40:48 +00:00
|
|
|
}
|
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
void addWithWeight(inout Vertex v, Vertex src, float weight) {
|
2015-01-11 01:55:06 +00:00
|
|
|
for(int j = 0; j < LENGTH; j++) {
|
|
|
|
v.vertexData[j] += weight * src.vertexData[j];
|
2012-12-11 01:15:13 +00:00
|
|
|
}
|
2014-05-28 23:46:38 +00:00
|
|
|
}
|
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
Vertex readVertex(int index) {
|
|
|
|
Vertex v;
|
2015-05-07 23:11:00 +00:00
|
|
|
int vertexIndex = srcOffset + index * SRC_STRIDE;
|
2015-01-11 01:55:06 +00:00
|
|
|
for(int j = 0; j < LENGTH; j++) {
|
|
|
|
v.vertexData[j] = texelFetch(vertexBuffer, vertexIndex+j).x;
|
2012-06-09 20:40:48 +00:00
|
|
|
}
|
2014-09-05 22:07:46 +00:00
|
|
|
return v;
|
2012-06-20 01:57:43 +00:00
|
|
|
}
|
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
void writeVertex(Vertex v) {
|
|
|
|
for(int i = 0; i < LENGTH; i++) {
|
|
|
|
outVertexBuffer[i] = v.vertexData[i];
|
2014-06-10 23:31:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-05 22:07:46 +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
|
|
|
|
2017-01-26 22:36:30 +00:00
|
|
|
#if defined(OPENSUBDIV_GLSL_XFB_USE_1ST_DERIVATIVES) && \
|
2017-01-30 19:42:08 +00:00
|
|
|
defined(OPENSUBDIV_GLSL_XFB_INTERLEAVED_1ST_DERIVATIVE_BUFFERS)
|
2017-01-26 22:36:30 +00:00
|
|
|
out float outDeriv1Buffer[2*LENGTH];
|
|
|
|
|
|
|
|
void writeDu(Vertex v) {
|
|
|
|
for(int i = 0; i < LENGTH; i++) {
|
|
|
|
outDeriv1Buffer[i] = v.vertexData[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void writeDv(Vertex v) {
|
|
|
|
for(int i = 0; i < LENGTH; i++) {
|
|
|
|
outDeriv1Buffer[i+LENGTH] = v.vertexData[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#elif defined(OPENSUBDIV_GLSL_XFB_USE_1ST_DERIVATIVES)
|
2015-05-28 00:23:36 +00:00
|
|
|
out float outDuBuffer[LENGTH];
|
|
|
|
out float outDvBuffer[LENGTH];
|
|
|
|
|
|
|
|
void writeDu(Vertex v) {
|
|
|
|
for(int i = 0; i < LENGTH; i++) {
|
|
|
|
outDuBuffer[i] = v.vertexData[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void writeDv(Vertex v) {
|
|
|
|
for(int i = 0; i < LENGTH; i++) {
|
|
|
|
outDvBuffer[i] = v.vertexData[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-01-26 22:36:30 +00:00
|
|
|
#if defined(OPENSUBDIV_GLSL_XFB_USE_2ND_DERIVATIVES) && \
|
2017-01-30 19:42:08 +00:00
|
|
|
defined(OPENSUBDIV_GLSL_XFB_INTERLEAVED_2ND_DERIVATIVE_BUFFERS)
|
2017-01-26 22:36:30 +00:00
|
|
|
out float outDeriv2Buffer[3*LENGTH];
|
|
|
|
|
|
|
|
void writeDuu(Vertex v) {
|
|
|
|
for(int i = 0; i < LENGTH; i++) {
|
|
|
|
outDeriv2Buffer[i] = v.vertexData[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void writeDuv(Vertex v) {
|
|
|
|
for(int i = 0; i < LENGTH; i++) {
|
|
|
|
outDeriv2Buffer[i+LENGTH] = v.vertexData[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void writeDvv(Vertex v) {
|
|
|
|
for(int i = 0; i < LENGTH; i++) {
|
|
|
|
outDeriv2Buffer[i+2*LENGTH] = v.vertexData[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#elif defined(OPENSUBDIV_GLSL_XFB_USE_2ND_DERIVATIVES)
|
|
|
|
out float outDuuBuffer[LENGTH];
|
|
|
|
out float outDuvBuffer[LENGTH];
|
|
|
|
out float outDvvBuffer[LENGTH];
|
|
|
|
|
|
|
|
void writeDuu(Vertex v) {
|
|
|
|
for(int i = 0; i < LENGTH; i++) {
|
|
|
|
outDuuBuffer[i] = v.vertexData[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void writeDuv(Vertex v) {
|
|
|
|
for(int i = 0; i < LENGTH; i++) {
|
|
|
|
outDuvBuffer[i] = v.vertexData[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void writeDvv(Vertex v) {
|
|
|
|
for(int i = 0; i < LENGTH; i++) {
|
|
|
|
outDvvBuffer[i] = v.vertexData[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-05-28 00:23:36 +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
|
|
|
#if defined(OPENSUBDIV_GLSL_XFB_KERNEL_EVAL_STENCILS)
|
|
|
|
|
|
|
|
uniform usamplerBuffer sizes;
|
|
|
|
uniform isamplerBuffer offsets;
|
|
|
|
uniform isamplerBuffer indices;
|
|
|
|
uniform samplerBuffer weights;
|
2015-05-28 00:23:36 +00:00
|
|
|
|
2017-01-26 22:36:30 +00:00
|
|
|
#if defined(OPENSUBDIV_GLSL_XFB_USE_1ST_DERIVATIVES)
|
2015-05-28 00:23:36 +00:00
|
|
|
uniform samplerBuffer duWeights;
|
|
|
|
uniform samplerBuffer dvWeights;
|
|
|
|
#endif
|
|
|
|
|
2017-01-26 22:36:30 +00:00
|
|
|
#if defined(OPENSUBDIV_GLSL_XFB_USE_2ND_DERIVATIVES)
|
|
|
|
uniform samplerBuffer duuWeights;
|
|
|
|
uniform samplerBuffer duvWeights;
|
|
|
|
uniform samplerBuffer dvvWeights;
|
|
|
|
#endif
|
|
|
|
|
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
|
|
|
uniform int batchStart = 0;
|
|
|
|
uniform int batchEnd = 0;
|
|
|
|
|
2015-04-10 22:34:04 +00:00
|
|
|
void main() {
|
2014-09-05 22:07:46 +00:00
|
|
|
int current = gl_VertexID + batchStart;
|
2014-06-10 23:31:44 +00:00
|
|
|
|
2015-01-13 01:02:54 +00:00
|
|
|
if (current>=batchEnd) {
|
2014-09-05 22:07:46 +00:00
|
|
|
return;
|
2014-06-10 23:31:44 +00:00
|
|
|
}
|
|
|
|
|
2017-01-26 22:36:30 +00:00
|
|
|
Vertex dst, du, dv, duu, duv, dvv;
|
2014-06-10 23:31:44 +00:00
|
|
|
clear(dst);
|
2015-05-28 00:23:36 +00:00
|
|
|
clear(du);
|
|
|
|
clear(dv);
|
2017-01-26 22:36:30 +00:00
|
|
|
clear(duu);
|
|
|
|
clear(duv);
|
|
|
|
clear(dvv);
|
2014-06-10 23:31:44 +00:00
|
|
|
|
2015-01-11 01:55:06 +00:00
|
|
|
int offset = texelFetch(offsets, current).x;
|
|
|
|
uint size = texelFetch(sizes, current).x;
|
2014-06-10 23:31:44 +00:00
|
|
|
|
2015-05-28 00:23:36 +00:00
|
|
|
for (int stencil=0; stencil<size; ++stencil) {
|
|
|
|
int index = texelFetch(indices, offset+stencil).x;
|
|
|
|
float weight = texelFetch(weights, offset+stencil).x;
|
2014-09-05 22:07:46 +00:00
|
|
|
addWithWeight(dst, readVertex( index ), weight);
|
2012-06-09 20:40:48 +00:00
|
|
|
|
2017-01-26 22:36:30 +00:00
|
|
|
#if defined(OPENSUBDIV_GLSL_XFB_USE_1ST_DERIVATIVES)
|
2015-05-28 00:23:36 +00:00
|
|
|
float duWeight = texelFetch(duWeights, offset+stencil).x;
|
|
|
|
float dvWeight = texelFetch(dvWeights, offset+stencil).x;
|
|
|
|
addWithWeight(du, readVertex(index), duWeight);
|
|
|
|
addWithWeight(dv, readVertex(index), dvWeight);
|
2017-01-26 22:36:30 +00:00
|
|
|
#endif
|
|
|
|
#if defined(OPENSUBDIV_GLSL_XFB_USE_2ND_DERIVATIVES)
|
|
|
|
float duuWeight = texelFetch(duuWeights, offset+stencil).x;
|
|
|
|
float duvWeight = texelFetch(duvWeights, offset+stencil).x;
|
|
|
|
float dvvWeight = texelFetch(dvvWeights, offset+stencil).x;
|
|
|
|
addWithWeight(duu, readVertex(index), duuWeight);
|
|
|
|
addWithWeight(duv, readVertex(index), duvWeight);
|
|
|
|
addWithWeight(dvv, readVertex(index), dvvWeight);
|
2015-05-28 00:23:36 +00:00
|
|
|
#endif
|
|
|
|
}
|
2012-06-09 20:40:48 +00:00
|
|
|
writeVertex(dst);
|
2015-05-28 00:23:36 +00:00
|
|
|
|
2017-01-26 22:36:30 +00:00
|
|
|
#if defined(OPENSUBDIV_GLSL_XFB_USE_1ST_DERIVATIVES)
|
2015-05-28 00:23:36 +00:00
|
|
|
writeDu(du);
|
|
|
|
writeDv(dv);
|
|
|
|
#endif
|
2017-01-26 22:36:30 +00:00
|
|
|
#if defined(OPENSUBDIV_GLSL_XFB_USE_2ND_DERIVATIVES)
|
|
|
|
writeDuu(duu);
|
|
|
|
writeDuv(duv);
|
|
|
|
writeDvv(dvv);
|
|
|
|
#endif
|
2012-06-09 20:40:48 +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
|
|
|
#endif
|
|
|
|
|
2014-09-05 22:07:46 +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
|
|
|
|
|
|
|
#if defined(OPENSUBDIV_GLSL_XFB_KERNEL_EVAL_PATCHES)
|
|
|
|
|
|
|
|
layout (location = 0) in ivec3 patchHandles;
|
|
|
|
layout (location = 1) in vec2 patchCoords;
|
|
|
|
|
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
|
|
|
layout (std140) uniform PatchArrays {
|
|
|
|
OsdPatchArray patchArrays[2];
|
|
|
|
};
|
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
|
|
|
uniform isamplerBuffer patchParamBuffer;
|
|
|
|
uniform isamplerBuffer patchIndexBuffer;
|
|
|
|
|
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
|
|
|
OsdPatchArray GetPatchArray(int arrayIndex) {
|
|
|
|
return patchArrays[arrayIndex];
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
}
|
|
|
|
|
Improved patch basis eval for Osd to match Far
This updates the patch basis evaluation functions in Osd
to match recent changes to far/patchBasis.
This also exposes a common facility for dealing with PatchCoord,
PatchArray, and PatchParam. These are exposed as global functions
operating on struct data, since C++ style class methods are not
supported by all of the Osd shader and kernel execution envirionments.
Changes:
- Merged far/patchBasis.cpp to osd/patchBasisCommon{,Types,Eval}.h
- Exposed PatchCoord, PatchArray, and PatchParam to Osd kernels
- exposed OsdEvaluatePatchBasis and OsdEvaluatePatchBasisNormalized
- Updated CPU, TBB, Omp, CUDA, OpenCL, GLSL, HLSL, and Metal evaluators
- Updated glFVarViewer
2018-10-30 07:37:25 +00:00
|
|
|
OsdPatchParam GetPatchParam(int patchIndex) {
|
|
|
|
ivec3 patchParamBits = texelFetch(patchParamBuffer, patchIndex).xyz;
|
|
|
|
return OsdPatchParamInit(patchParamBits.x, patchParamBits.y, patchParamBits.z);
|
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 main() {
|
|
|
|
int current = gl_VertexID;
|
|
|
|
|
|
|
|
ivec3 handle = patchHandles;
|
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 arrayIndex = handle.x;
|
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 patchIndex = handle.y;
|
|
|
|
|
|
|
|
vec2 coord = patchCoords;
|
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
|
|
|
|
|
|
|
OsdPatchArray array = GetPatchArray(arrayIndex);
|
|
|
|
OsdPatchParam param = GetPatchParam(patchIndex);
|
|
|
|
|
|
|
|
int patchType = OsdPatchParamIsRegular(param) ? array.regDesc : array.desc;
|
|
|
|
|
|
|
|
float wP[20], wDu[20], wDv[20], wDuu[20], wDuv[20], wDvv[20];
|
|
|
|
int nPoints = OsdEvaluatePatchBasis(patchType, param,
|
|
|
|
coord.x, coord.y, wP, wDu, wDv, wDuu, wDuv, wDvv);
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
|
2017-01-26 22:36:30 +00:00
|
|
|
Vertex dst, du, dv, duu, duv, dvv;
|
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
|
|
|
clear(dst);
|
2015-05-28 00:23:36 +00:00
|
|
|
clear(du);
|
|
|
|
clear(dv);
|
2017-01-26 22:36:30 +00:00
|
|
|
clear(duu);
|
|
|
|
clear(duv);
|
|
|
|
clear(dvv);
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
|
Improved patch basis eval for Osd to match Far
This updates the patch basis evaluation functions in Osd
to match recent changes to far/patchBasis.
This also exposes a common facility for dealing with PatchCoord,
PatchArray, and PatchParam. These are exposed as global functions
operating on struct data, since C++ style class methods are not
supported by all of the Osd shader and kernel execution envirionments.
Changes:
- Merged far/patchBasis.cpp to osd/patchBasisCommon{,Types,Eval}.h
- Exposed PatchCoord, PatchArray, and PatchParam to Osd kernels
- exposed OsdEvaluatePatchBasis and OsdEvaluatePatchBasisNormalized
- Updated CPU, TBB, Omp, CUDA, OpenCL, GLSL, HLSL, and Metal evaluators
- Updated glFVarViewer
2018-10-30 07:37:25 +00:00
|
|
|
int indexBase = array.indexBase + array.stride *
|
|
|
|
(patchIndex - array.primitiveIdBase);
|
2016-09-29 16:56:15 +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
|
|
|
for (int cv = 0; cv < nPoints; ++cv) {
|
2015-05-28 00:23:36 +00:00
|
|
|
int index = texelFetch(patchIndexBuffer, indexBase + cv).x;
|
|
|
|
addWithWeight(dst, readVertex(index), wP[cv]);
|
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
|
|
|
addWithWeight(du, readVertex(index), wDu[cv]);
|
|
|
|
addWithWeight(dv, readVertex(index), wDv[cv]);
|
|
|
|
addWithWeight(duu, readVertex(index), wDuu[cv]);
|
|
|
|
addWithWeight(duv, readVertex(index), wDuv[cv]);
|
|
|
|
addWithWeight(dvv, readVertex(index), wDvv[cv]);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
writeVertex(dst);
|
2015-05-28 00:23:36 +00:00
|
|
|
|
2017-01-26 22:36:30 +00:00
|
|
|
#if defined(OPENSUBDIV_GLSL_XFB_USE_1ST_DERIVATIVES)
|
2015-05-28 00:23:36 +00:00
|
|
|
writeDu(du);
|
|
|
|
writeDv(dv);
|
|
|
|
#endif
|
2017-01-26 22:36:30 +00:00
|
|
|
#if defined(OPENSUBDIV_GLSL_XFB_USE_2ND_DERIVATIVES)
|
|
|
|
writeDuu(duu);
|
|
|
|
writeDuv(duv);
|
|
|
|
writeDvv(dvv);
|
|
|
|
#endif
|
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
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|