mirror of
https://github.com/PixarAnimationStudios/OpenSubdiv
synced 2024-11-09 13:50:05 +00:00
Reorganized osd/patchBasis and osd/patchBasisTypes
Folded osd/patchBasisCommon.h and osd/patchBasisCommonEval.h into the single header file osd/patchBasis.h and renamed osd/PatchBasisCommonTypes.h to osd/patchBasisTypes.h Moved these into the OpenSubdiv::Osd namespace when compiled for C++ and added a brief comment describing the intended use cases for this code.
This commit is contained in:
parent
18f3b91c28
commit
fa5b57caba
@ -53,9 +53,8 @@ set(PUBLIC_HEADER_FILES
|
||||
)
|
||||
|
||||
list(APPEND KERNEL_FILES
|
||||
patchBasisCommonTypes.h
|
||||
patchBasisCommon.h
|
||||
patchBasisCommonEval.h
|
||||
patchBasisTypes.h
|
||||
patchBasis.h
|
||||
)
|
||||
|
||||
set(DOXY_HEADER_FILES ${PUBLIC_HEADER_FILES})
|
||||
|
@ -42,13 +42,10 @@ static const char *clSource =
|
||||
#include "clKernel.gen.h"
|
||||
;
|
||||
static const char *patchBasisTypesSource =
|
||||
#include "patchBasisCommonTypes.gen.h"
|
||||
#include "patchBasisTypes.gen.h"
|
||||
;
|
||||
static const char *patchBasisSource =
|
||||
#include "patchBasisCommon.gen.h"
|
||||
;
|
||||
static const char *patchBasisEvalSource =
|
||||
#include "patchBasisCommonEval.gen.h"
|
||||
#include "patchBasis.gen.h"
|
||||
;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -175,9 +172,8 @@ CLEvaluator::Compile(BufferDescriptor const &srcDesc,
|
||||
const char *sources[] = { defineStr.c_str(),
|
||||
patchBasisTypesSource,
|
||||
patchBasisSource,
|
||||
patchBasisEvalSource,
|
||||
clSource };
|
||||
_program = clCreateProgramWithSource(_clContext, 5, sources, 0, &errNum);
|
||||
_program = clCreateProgramWithSource(_clContext, 4, sources, 0, &errNum);
|
||||
if (errNum != CL_SUCCESS) {
|
||||
Far::Error(Far::FAR_RUNTIME_ERROR,
|
||||
"clCreateProgramWithSource (%d)", errNum);
|
||||
|
@ -24,9 +24,7 @@
|
||||
|
||||
#include "../osd/cpuEvaluator.h"
|
||||
#include "../osd/cpuKernel.h"
|
||||
#include "../osd/patchBasisCommonTypes.h"
|
||||
#include "../osd/patchBasisCommon.h"
|
||||
#include "../osd/patchBasisCommonEval.h"
|
||||
#include "../osd/patchBasis.h"
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
|
@ -24,9 +24,8 @@
|
||||
|
||||
#include <assert.h>
|
||||
#define OSD_PATCH_BASIS_CUDA
|
||||
#include "../osd/patchBasisCommonTypes.h"
|
||||
#include "../osd/patchBasisCommon.h"
|
||||
#include "../osd/patchBasisCommonEval.h"
|
||||
#include "../osd/patchBasisTypes.h"
|
||||
#include "../osd/patchBasis.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
template<int N> struct DeviceVertex {
|
||||
|
@ -41,13 +41,10 @@ static const char *patchLegacyShaderSource =
|
||||
#include "glslPatchLegacy.gen.h"
|
||||
;
|
||||
static const char *patchBasisTypesShaderSource =
|
||||
#include "patchBasisCommonTypes.gen.h"
|
||||
#include "patchBasisTypes.gen.h"
|
||||
;
|
||||
static const char *patchBasisShaderSource =
|
||||
#include "patchBasisCommon.gen.h"
|
||||
;
|
||||
static const char *patchBasisEvalShaderSource =
|
||||
#include "patchBasisCommonEval.gen.h"
|
||||
#include "patchBasis.gen.h"
|
||||
;
|
||||
static const char *boxSplineTriangleShaderSource =
|
||||
#include "glslPatchBoxSplineTriangle.gen.h"
|
||||
@ -84,7 +81,6 @@ GLSLPatchShaderSource::GetPatchBasisShaderSource() {
|
||||
#endif
|
||||
ss << std::string(patchBasisTypesShaderSource);
|
||||
ss << std::string(patchBasisShaderSource);
|
||||
ss << std::string(patchBasisEvalShaderSource);
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
|
@ -43,13 +43,10 @@ static const char *patchLegacyShaderSource =
|
||||
#include "hlslPatchLegacy.gen.h"
|
||||
;
|
||||
static const char *patchBasisTypesShaderSource =
|
||||
#include "patchBasisCommonTypes.gen.h"
|
||||
#include "patchBasisTypes.gen.h"
|
||||
;
|
||||
static const char *patchBasisShaderSource =
|
||||
#include "patchBasisCommon.gen.h"
|
||||
;
|
||||
static const char *patchBasisEvalShaderSource =
|
||||
#include "patchBasisCommonEval.gen.h"
|
||||
#include "patchBasis.gen.h"
|
||||
;
|
||||
static const char *boxSplineTriangleShaderSource =
|
||||
#include "hlslPatchBoxSplineTriangle.gen.h"
|
||||
@ -86,7 +83,6 @@ HLSLPatchShaderSource::GetPatchBasisShaderSource() {
|
||||
#endif
|
||||
ss << std::string(patchBasisTypesShaderSource);
|
||||
ss << std::string(patchBasisShaderSource);
|
||||
ss << std::string(patchBasisEvalShaderSource);
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
|
@ -44,13 +44,10 @@ static std::string patchLegacyShaderSource(
|
||||
#include "mtlPatchLegacy.gen.h"
|
||||
);
|
||||
static std::string patchBasisTypesShaderSource(
|
||||
#include "patchBasisCommonTypes.gen.h"
|
||||
#include "patchBasisTypes.gen.h"
|
||||
);
|
||||
static std::string patchBasisShaderSource(
|
||||
#include "patchBasisCommon.gen.h"
|
||||
);
|
||||
static std::string patchBasisEvalShaderSource(
|
||||
#include "patchBasisCommonEval.gen.h"
|
||||
#include "patchBasis.gen.h"
|
||||
);
|
||||
static std::string bsplineShaderSource(
|
||||
#include "mtlPatchBSpline.gen.h"
|
||||
@ -171,7 +168,6 @@ MTLPatchShaderSource::GetPatchBasisShaderSource() {
|
||||
#endif
|
||||
ss << patchBasisTypesShaderSource;
|
||||
ss << patchBasisShaderSource;
|
||||
ss << patchBasisEvalShaderSource;
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
|
@ -24,9 +24,7 @@
|
||||
|
||||
#include "../osd/ompEvaluator.h"
|
||||
#include "../osd/ompKernel.h"
|
||||
#include "../osd/patchBasisCommonTypes.h"
|
||||
#include "../osd/patchBasisCommon.h"
|
||||
#include "../osd/patchBasisCommonEval.h"
|
||||
#include "../osd/patchBasis.h"
|
||||
#include <omp.h>
|
||||
|
||||
namespace OpenSubdiv {
|
||||
|
@ -22,8 +22,33 @@
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
#ifndef OPENSUBDIV3_OSD_PATCH_BASIS_COMMON_H
|
||||
#define OPENSUBDIV3_OSD_PATCH_BASIS_COMMON_H
|
||||
#ifndef OPENSUBDIV3_OSD_PATCH_BASIS_H
|
||||
#define OPENSUBDIV3_OSD_PATCH_BASIS_H
|
||||
|
||||
/// This is an implementation of the functionality from far/patchBasis.h
|
||||
/// which can be used from client shader and kernel code, i.e for
|
||||
/// GLSL, HLSL, CUDA, OpenCL, Metal, and C++ shaders and kernels.
|
||||
///
|
||||
/// This is defined within the OpenSubdiv::Osd namespace for C++, but
|
||||
/// the methods and types also have an Osd prefix for consistency with
|
||||
/// environments (e.g. GLSL, etc.) where C++ namespaces are not available.
|
||||
|
||||
#if !defined(OSD_PATCH_BASIS_GLSL) && \
|
||||
!defined(OSD_PATCH_BASIS_HLSL) && \
|
||||
!defined(OSD_PATCH_BASIS_CUDA) && \
|
||||
!defined(OSD_PATCH_BASIS_OPENCL) && \
|
||||
!defined(OSD_PATCH_BASIS_METAL)
|
||||
|
||||
#include "../version.h"
|
||||
|
||||
#include "../osd/patchBasisTypes.h"
|
||||
|
||||
namespace OpenSubdiv {
|
||||
namespace OPENSUBDIV_VERSION {
|
||||
|
||||
namespace Osd {
|
||||
|
||||
#endif
|
||||
|
||||
OSD_FUNCTION_STORAGE_CLASS
|
||||
// template <typename REAL>
|
||||
@ -45,7 +70,6 @@ Osd_EvalBasisLinear(OSD_REAL s, OSD_REAL t,
|
||||
wP[2] = s * t;
|
||||
wP[3] = sC * t;
|
||||
}
|
||||
|
||||
if (OSD_OPTIONAL(wDs && wDt)) {
|
||||
wDs[0] = -tC;
|
||||
wDs[1] = tC;
|
||||
@ -58,7 +82,7 @@ Osd_EvalBasisLinear(OSD_REAL s, OSD_REAL t,
|
||||
wDt[3] = sC;
|
||||
|
||||
if (OSD_OPTIONAL(wDss && wDst && wDtt)) {
|
||||
for(int i=0;i<4;i++) {
|
||||
for(int i = 0; i < 4; ++i) {
|
||||
wDss[i] = 0.0f;
|
||||
wDtt[i] = 0.0f;
|
||||
}
|
||||
@ -199,7 +223,6 @@ Osd_EvalBasisBSpline(OSD_REAL s, OSD_REAL t,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (OSD_OPTIONAL(wDs && wDt)) {
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
for (int j = 0; j < 4; ++j) {
|
||||
@ -285,7 +308,6 @@ Osd_EvalBasisBezier(OSD_REAL s, OSD_REAL t,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (OSD_OPTIONAL(wDs && wDt)) {
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
for (int j = 0; j < 4; ++j) {
|
||||
@ -1415,4 +1437,191 @@ OsdGetGregoryPatchWeights(
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Higher level basis evaluation functions that deal with parameterization and
|
||||
// boundary issues (reflected in PatchParam) for all patch types:
|
||||
//
|
||||
OSD_FUNCTION_STORAGE_CLASS
|
||||
// template <typename REAL>
|
||||
int
|
||||
OsdEvaluatePatchBasisNormalized(
|
||||
int patchType, OsdPatchParam param,
|
||||
OSD_REAL s, OSD_REAL t,
|
||||
OSD_OUT_ARRAY(OSD_REAL, wP, 20),
|
||||
OSD_OUT_ARRAY(OSD_REAL, wDs, 20),
|
||||
OSD_OUT_ARRAY(OSD_REAL, wDt, 20),
|
||||
OSD_OUT_ARRAY(OSD_REAL, wDss, 20),
|
||||
OSD_OUT_ARRAY(OSD_REAL, wDst, 20),
|
||||
OSD_OUT_ARRAY(OSD_REAL, wDtt, 20)) {
|
||||
|
||||
int boundaryMask = OsdPatchParamGetBoundary(param);
|
||||
|
||||
int nPoints = 0;
|
||||
if (patchType == OSD_PATCH_DESCRIPTOR_REGULAR) {
|
||||
#if OSD_ARRAY_ARG_BOUND_OPTIONAL
|
||||
nPoints = Osd_EvalBasisBSpline(s, t, wP, wDs, wDt, wDss, wDst, wDtt);
|
||||
if (boundaryMask != 0) {
|
||||
Osd_boundBasisBSpline(
|
||||
boundaryMask, wP, wDs, wDt, wDss, wDst, wDtt);
|
||||
}
|
||||
#else
|
||||
OSD_REAL wP16[16], wDs16[16], wDt16[16],
|
||||
wDss16[16], wDst16[16], wDtt16[16];
|
||||
nPoints = Osd_EvalBasisBSpline(
|
||||
s, t, wP16, wDs16, wDt16, wDss16, wDst16, wDtt16);
|
||||
if (boundaryMask != 0) {
|
||||
Osd_boundBasisBSpline(
|
||||
boundaryMask, wP16, wDs16, wDt16, wDss16, wDst16, wDtt16);
|
||||
}
|
||||
for (int i=0; i<nPoints; ++i) {
|
||||
wP[i] = wP16[i];
|
||||
wDs[i] = wDs16[i]; wDt[i] = wDt16[i];
|
||||
wDss[i] = wDss16[i]; wDst[i] = wDst16[i]; wDtt[i] = wDtt16[i];
|
||||
}
|
||||
#endif
|
||||
} else if (patchType == OSD_PATCH_DESCRIPTOR_LOOP) {
|
||||
#if OSD_ARRAY_ARG_BOUND_OPTIONAL
|
||||
nPoints = Osd_EvalBasisBoxSplineTri(
|
||||
s, t, wP, wDs, wDt, wDss, wDst, wDtt);
|
||||
if (boundaryMask != 0) {
|
||||
Osd_boundBasisBoxSplineTri(
|
||||
boundaryMask, wP, wDs, wDt, wDss, wDst, wDtt);
|
||||
}
|
||||
#else
|
||||
OSD_REAL wP12[12], wDs12[12], wDt12[12],
|
||||
wDss12[12], wDst12[12], wDtt12[12];
|
||||
nPoints = Osd_EvalBasisBoxSplineTri(
|
||||
s, t, wP12, wDs12, wDt12, wDss12, wDst12, wDtt12);
|
||||
if (boundaryMask != 0) {
|
||||
Osd_boundBasisBoxSplineTri(
|
||||
boundaryMask, wP12, wDs12, wDt12, wDss12, wDst12, wDtt12);
|
||||
}
|
||||
for (int i=0; i<nPoints; ++i) {
|
||||
wP[i] = wP12[i];
|
||||
wDs[i] = wDs12[i]; wDt[i] = wDt12[i];
|
||||
wDss[i] = wDss12[i]; wDst[i] = wDst12[i]; wDtt[i] = wDtt12[i];
|
||||
}
|
||||
#endif
|
||||
} else if (patchType == OSD_PATCH_DESCRIPTOR_GREGORY_BASIS) {
|
||||
nPoints = Osd_EvalBasisGregory(s, t, wP, wDs, wDt, wDss, wDst, wDtt);
|
||||
} else if (patchType == OSD_PATCH_DESCRIPTOR_GREGORY_TRIANGLE) {
|
||||
#if OSD_ARRAY_ARG_BOUND_OPTIONAL
|
||||
nPoints = Osd_EvalBasisGregoryTri(s, t, wP, wDs, wDt, wDss, wDst, wDtt);
|
||||
#else
|
||||
OSD_REAL wP18[18], wDs18[18], wDt18[18],
|
||||
wDss18[18], wDst18[18], wDtt18[18];
|
||||
nPoints = Osd_EvalBasisGregoryTri(
|
||||
s, t, wP18, wDs18, wDt18, wDss18, wDst18, wDtt18);
|
||||
for (int i=0; i<nPoints; ++i) {
|
||||
wP[i] = wP18[i];
|
||||
wDs[i] = wDs18[i]; wDt[i] = wDt18[i];
|
||||
wDss[i] = wDss18[i]; wDst[i] = wDst18[i]; wDtt[i] = wDtt18[i];
|
||||
}
|
||||
#endif
|
||||
} else if (patchType == OSD_PATCH_DESCRIPTOR_QUADS) {
|
||||
#if OSD_ARRAY_ARG_BOUND_OPTIONAL
|
||||
nPoints = Osd_EvalBasisLinear(s, t, wP, wDs, wDt, wDss, wDst, wDtt);
|
||||
#else
|
||||
OSD_REAL wP4[4], wDs4[4], wDt4[4],
|
||||
wDss4[4], wDst4[4], wDtt4[4];
|
||||
nPoints = Osd_EvalBasisLinear(
|
||||
s, t, wP4, wDs4, wDt4, wDss4, wDst4, wDtt4);
|
||||
for (int i=0; i<nPoints; ++i) {
|
||||
wP[i] = wP4[i];
|
||||
wDs[i] = wDs4[i]; wDt[i] = wDt4[i];
|
||||
wDss[i] = wDss4[i]; wDst[i] = wDst4[i]; wDtt[i] = wDtt4[i];
|
||||
}
|
||||
#endif
|
||||
} else if (patchType == OSD_PATCH_DESCRIPTOR_TRIANGLES) {
|
||||
#if OSD_ARRAY_ARG_BOUND_OPTIONAL
|
||||
nPoints = Osd_EvalBasisLinearTri(s, t, wP, wDs, wDt, wDss, wDst, wDtt);
|
||||
#else
|
||||
OSD_REAL wP3[3], wDs3[3], wDt3[3],
|
||||
wDss3[3], wDst3[3], wDtt3[3];
|
||||
nPoints = Osd_EvalBasisLinearTri(
|
||||
s, t, wP3, wDs3, wDt3, wDss3, wDst3, wDtt3);
|
||||
for (int i=0; i<nPoints; ++i) {
|
||||
wP[i] = wP3[i];
|
||||
wDs[i] = wDs3[i]; wDt[i] = wDt3[i];
|
||||
wDss[i] = wDss3[i]; wDst[i] = wDst3[i]; wDtt[i] = wDtt3[i];
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
// assert(0);
|
||||
}
|
||||
return nPoints;
|
||||
}
|
||||
|
||||
OSD_FUNCTION_STORAGE_CLASS
|
||||
// template <typename REAL>
|
||||
int
|
||||
OsdEvaluatePatchBasis(
|
||||
int patchType, OsdPatchParam param,
|
||||
OSD_REAL s, OSD_REAL t,
|
||||
OSD_OUT_ARRAY(OSD_REAL, wP, 20),
|
||||
OSD_OUT_ARRAY(OSD_REAL, wDs, 20),
|
||||
OSD_OUT_ARRAY(OSD_REAL, wDt, 20),
|
||||
OSD_OUT_ARRAY(OSD_REAL, wDss, 20),
|
||||
OSD_OUT_ARRAY(OSD_REAL, wDst, 20),
|
||||
OSD_OUT_ARRAY(OSD_REAL, wDtt, 20)) {
|
||||
|
||||
OSD_REAL derivSign = 1.0f;
|
||||
|
||||
if ((patchType == OSD_PATCH_DESCRIPTOR_LOOP) ||
|
||||
(patchType == OSD_PATCH_DESCRIPTOR_GREGORY_TRIANGLE) ||
|
||||
(patchType == OSD_PATCH_DESCRIPTOR_TRIANGLES)) {
|
||||
OSD_REAL uv[2] = OSD_ARRAY_2(OSD_REAL, s, t);
|
||||
OsdPatchParamNormalizeTriangle(param, uv);
|
||||
s = uv[0];
|
||||
t = uv[1];
|
||||
if (OsdPatchParamIsTriangleRotated(param)) {
|
||||
derivSign = -1.0f;
|
||||
}
|
||||
} else {
|
||||
OSD_REAL uv[2] = OSD_ARRAY_2(OSD_REAL, s, t);
|
||||
OsdPatchParamNormalize(param, uv);
|
||||
s = uv[0];
|
||||
t = uv[1];
|
||||
}
|
||||
|
||||
int nPoints = OsdEvaluatePatchBasisNormalized(
|
||||
patchType, param, s, t, wP, wDs, wDt, wDss, wDst, wDtt);
|
||||
|
||||
if (OSD_OPTIONAL(wDs && wDt)) {
|
||||
OSD_REAL d1Scale =
|
||||
derivSign * OSD_REAL_CAST(1 << OsdPatchParamGetDepth(param));
|
||||
|
||||
for (int i = 0; i < nPoints; ++i) {
|
||||
wDs[i] *= d1Scale;
|
||||
wDt[i] *= d1Scale;
|
||||
}
|
||||
|
||||
if (OSD_OPTIONAL(wDss && wDst && wDtt)) {
|
||||
OSD_REAL d2Scale = derivSign * d1Scale * d1Scale;
|
||||
|
||||
for (int i = 0; i < nPoints; ++i) {
|
||||
wDss[i] *= d2Scale;
|
||||
wDst[i] *= d2Scale;
|
||||
wDtt[i] *= d2Scale;
|
||||
}
|
||||
}
|
||||
}
|
||||
return nPoints;
|
||||
}
|
||||
|
||||
#if !defined(OSD_PATCH_BASIS_GLSL) && \
|
||||
!defined(OSD_PATCH_BASIS_HLSL) && \
|
||||
!defined(OSD_PATCH_BASIS_CUDA) && \
|
||||
!defined(OSD_PATCH_BASIS_OPENCL) && \
|
||||
!defined(OSD_PATCH_BASIS_METAL)
|
||||
|
||||
} // end namespace Osd
|
||||
|
||||
} // end namespace OPENSUBDIV_VERSION
|
||||
using namespace OPENSUBDIV_VERSION;
|
||||
|
||||
} // end namespace OpenSubdiv
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* OPENSUBDIV3_OSD_PATCH_BASIS_H */
|
@ -1,196 +0,0 @@
|
||||
//
|
||||
// Copyright 2018 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.
|
||||
//
|
||||
|
||||
#ifndef OPENSUBDIV3_OSD_PATCH_BASIS_COMMON_EVAL_H
|
||||
#define OPENSUBDIV3_OSD_PATCH_BASIS_COMMON_EVAL_H
|
||||
|
||||
OSD_FUNCTION_STORAGE_CLASS
|
||||
// template <typename REAL>
|
||||
int
|
||||
OsdEvaluatePatchBasisNormalized(
|
||||
int patchType, OsdPatchParam param,
|
||||
OSD_REAL s, OSD_REAL t,
|
||||
OSD_OUT_ARRAY(OSD_REAL, wP, 20),
|
||||
OSD_OUT_ARRAY(OSD_REAL, wDs, 20),
|
||||
OSD_OUT_ARRAY(OSD_REAL, wDt, 20),
|
||||
OSD_OUT_ARRAY(OSD_REAL, wDss, 20),
|
||||
OSD_OUT_ARRAY(OSD_REAL, wDst, 20),
|
||||
OSD_OUT_ARRAY(OSD_REAL, wDtt, 20)) {
|
||||
|
||||
int boundaryMask = OsdPatchParamGetBoundary(param);
|
||||
|
||||
int nPoints = 0;
|
||||
if (patchType == OSD_PATCH_DESCRIPTOR_REGULAR) {
|
||||
#if OSD_ARRAY_ARG_BOUND_OPTIONAL
|
||||
nPoints = Osd_EvalBasisBSpline(s, t, wP, wDs, wDt, wDss, wDst, wDtt);
|
||||
if (boundaryMask != 0) {
|
||||
Osd_boundBasisBSpline(
|
||||
boundaryMask, wP, wDs, wDt, wDss, wDst, wDtt);
|
||||
}
|
||||
#else
|
||||
OSD_REAL wP16[16], wDs16[16], wDt16[16],
|
||||
wDss16[16], wDst16[16], wDtt16[16];
|
||||
nPoints = Osd_EvalBasisBSpline(
|
||||
s, t, wP16, wDs16, wDt16, wDss16, wDst16, wDtt16);
|
||||
if (boundaryMask != 0) {
|
||||
Osd_boundBasisBSpline(
|
||||
boundaryMask, wP16, wDs16, wDt16, wDss16, wDst16, wDtt16);
|
||||
}
|
||||
for (int i=0; i<nPoints; ++i) {
|
||||
wP[i] = wP16[i];
|
||||
wDs[i] = wDs16[i]; wDt[i] = wDt16[i];
|
||||
wDss[i] = wDss16[i]; wDst[i] = wDst16[i]; wDtt[i] = wDtt16[i];
|
||||
}
|
||||
#endif
|
||||
} else if (patchType == OSD_PATCH_DESCRIPTOR_LOOP) {
|
||||
#if OSD_ARRAY_ARG_BOUND_OPTIONAL
|
||||
nPoints = Osd_EvalBasisBoxSplineTri(
|
||||
s, t, wP, wDs, wDt, wDss, wDst, wDtt);
|
||||
if (boundaryMask != 0) {
|
||||
Osd_boundBasisBoxSplineTri(
|
||||
boundaryMask, wP, wDs, wDt, wDss, wDst, wDtt);
|
||||
}
|
||||
#else
|
||||
OSD_REAL wP12[12], wDs12[12], wDt12[12],
|
||||
wDss12[12], wDst12[12], wDtt12[12];
|
||||
nPoints = Osd_EvalBasisBoxSplineTri(
|
||||
s, t, wP12, wDs12, wDt12, wDss12, wDst12, wDtt12);
|
||||
if (boundaryMask != 0) {
|
||||
Osd_boundBasisBoxSplineTri(
|
||||
boundaryMask, wP12, wDs12, wDt12, wDss12, wDst12, wDtt12);
|
||||
}
|
||||
for (int i=0; i<nPoints; ++i) {
|
||||
wP[i] = wP12[i];
|
||||
wDs[i] = wDs12[i]; wDt[i] = wDt12[i];
|
||||
wDss[i] = wDss12[i]; wDst[i] = wDst12[i]; wDtt[i] = wDtt12[i];
|
||||
}
|
||||
#endif
|
||||
} else if (patchType == OSD_PATCH_DESCRIPTOR_GREGORY_BASIS) {
|
||||
nPoints = Osd_EvalBasisGregory(s, t, wP, wDs, wDt, wDss, wDst, wDtt);
|
||||
} else if (patchType == OSD_PATCH_DESCRIPTOR_GREGORY_TRIANGLE) {
|
||||
#if OSD_ARRAY_ARG_BOUND_OPTIONAL
|
||||
nPoints = Osd_EvalBasisGregoryTri(s, t, wP, wDs, wDt, wDss, wDst, wDtt);
|
||||
#else
|
||||
OSD_REAL wP18[18], wDs18[18], wDt18[18],
|
||||
wDss18[18], wDst18[18], wDtt18[18];
|
||||
nPoints = Osd_EvalBasisGregoryTri(
|
||||
s, t, wP18, wDs18, wDt18, wDss18, wDst18, wDtt18);
|
||||
for (int i=0; i<nPoints; ++i) {
|
||||
wP[i] = wP18[i];
|
||||
wDs[i] = wDs18[i]; wDt[i] = wDt18[i];
|
||||
wDss[i] = wDss18[i]; wDst[i] = wDst18[i]; wDtt[i] = wDtt18[i];
|
||||
}
|
||||
#endif
|
||||
} else if (patchType == OSD_PATCH_DESCRIPTOR_QUADS) {
|
||||
#if OSD_ARRAY_ARG_BOUND_OPTIONAL
|
||||
nPoints = Osd_EvalBasisLinear(s, t, wP, wDs, wDt, wDss, wDst, wDtt);
|
||||
#else
|
||||
OSD_REAL wP4[4], wDs4[4], wDt4[4],
|
||||
wDss4[4], wDst4[4], wDtt4[4];
|
||||
nPoints = Osd_EvalBasisLinear(
|
||||
s, t, wP4, wDs4, wDt4, wDss4, wDst4, wDtt4);
|
||||
for (int i=0; i<nPoints; ++i) {
|
||||
wP[i] = wP4[i];
|
||||
wDs[i] = wDs4[i]; wDt[i] = wDt4[i];
|
||||
wDss[i] = wDss4[i]; wDst[i] = wDst4[i]; wDtt[i] = wDtt4[i];
|
||||
}
|
||||
#endif
|
||||
} else if (patchType == OSD_PATCH_DESCRIPTOR_TRIANGLES) {
|
||||
#if OSD_ARRAY_ARG_BOUND_OPTIONAL
|
||||
nPoints = Osd_EvalBasisLinearTri(s, t, wP, wDs, wDt, wDss, wDst, wDtt);
|
||||
#else
|
||||
OSD_REAL wP3[3], wDs3[3], wDt3[3],
|
||||
wDss3[3], wDst3[3], wDtt3[3];
|
||||
nPoints = Osd_EvalBasisLinearTri(
|
||||
s, t, wP3, wDs3, wDt3, wDss3, wDst3, wDtt3);
|
||||
for (int i=0; i<nPoints; ++i) {
|
||||
wP[i] = wP3[i];
|
||||
wDs[i] = wDs3[i]; wDt[i] = wDt3[i];
|
||||
wDss[i] = wDss3[i]; wDst[i] = wDst3[i]; wDtt[i] = wDtt3[i];
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
// assert(0);
|
||||
}
|
||||
return nPoints;
|
||||
}
|
||||
|
||||
OSD_FUNCTION_STORAGE_CLASS
|
||||
// template <typename REAL>
|
||||
int
|
||||
OsdEvaluatePatchBasis(
|
||||
int patchType, OsdPatchParam param,
|
||||
OSD_REAL s, OSD_REAL t,
|
||||
OSD_OUT_ARRAY(OSD_REAL, wP, 20),
|
||||
OSD_OUT_ARRAY(OSD_REAL, wDs, 20),
|
||||
OSD_OUT_ARRAY(OSD_REAL, wDt, 20),
|
||||
OSD_OUT_ARRAY(OSD_REAL, wDss, 20),
|
||||
OSD_OUT_ARRAY(OSD_REAL, wDst, 20),
|
||||
OSD_OUT_ARRAY(OSD_REAL, wDtt, 20)) {
|
||||
|
||||
OSD_REAL derivSign = 1.0f;
|
||||
|
||||
if ((patchType == OSD_PATCH_DESCRIPTOR_LOOP) ||
|
||||
(patchType == OSD_PATCH_DESCRIPTOR_GREGORY_TRIANGLE) ||
|
||||
(patchType == OSD_PATCH_DESCRIPTOR_TRIANGLES)) {
|
||||
OSD_REAL uv[2] = OSD_ARRAY_2(OSD_REAL, s, t);
|
||||
OsdPatchParamNormalizeTriangle(param, uv);
|
||||
s = uv[0];
|
||||
t = uv[1];
|
||||
if (OsdPatchParamIsTriangleRotated(param)) {
|
||||
derivSign = -1.0f;
|
||||
}
|
||||
} else {
|
||||
OSD_REAL uv[2] = OSD_ARRAY_2(OSD_REAL, s, t);
|
||||
OsdPatchParamNormalize(param, uv);
|
||||
s = uv[0];
|
||||
t = uv[1];
|
||||
}
|
||||
|
||||
int nPoints = OsdEvaluatePatchBasisNormalized(
|
||||
patchType, param, s, t, wP, wDs, wDt, wDss, wDst, wDtt);
|
||||
|
||||
if (OSD_OPTIONAL(wDs && wDt)) {
|
||||
OSD_REAL d1Scale =
|
||||
derivSign * OSD_REAL_CAST(1 << OsdPatchParamGetDepth(param));
|
||||
|
||||
for (int i = 0; i < nPoints; ++i) {
|
||||
wDs[i] *= d1Scale;
|
||||
wDt[i] *= d1Scale;
|
||||
}
|
||||
|
||||
if (OSD_OPTIONAL(wDss && wDst && wDtt)) {
|
||||
OSD_REAL d2Scale = derivSign * d1Scale * d1Scale;
|
||||
|
||||
for (int i = 0; i < nPoints; ++i) {
|
||||
wDss[i] *= d2Scale;
|
||||
wDst[i] *= d2Scale;
|
||||
wDtt[i] *= d2Scale;
|
||||
}
|
||||
}
|
||||
}
|
||||
return nPoints;
|
||||
}
|
||||
|
||||
#endif /* OPENSUBDIV3_OSD_PATCH_BASIS_COMMON_EVAL_H */
|
@ -22,8 +22,31 @@
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
#ifndef OPENSUBDIV3_OSD_PATCH_BASIS_COMMON_TYPES_H
|
||||
#define OPENSUBDIV3_OSD_PATCH_BASIS_COMMON_TYPES_H
|
||||
#ifndef OPENSUBDIV3_OSD_PATCH_BASIS_TYPES_H
|
||||
#define OPENSUBDIV3_OSD_PATCH_BASIS_TYPES_H
|
||||
|
||||
/// This is an implementation of the functionality from osd/types.h
|
||||
/// which can be used from client shader and kernel code, i.e for
|
||||
/// GLSL, HLSL, CUDA, OpenCL, Metal, and C++ shaders and kernels.
|
||||
///
|
||||
/// This is defined within the OpenSubdiv::Osd namespace for C++, but
|
||||
/// the methods and types also have an Osd prefix for consistency with
|
||||
/// environments (e.g. GLSL, etc.) where C++ namespaces are not available.
|
||||
|
||||
#if !defined(OSD_PATCH_BASIS_GLSL) && \
|
||||
!defined(OSD_PATCH_BASIS_HLSL) && \
|
||||
!defined(OSD_PATCH_BASIS_CUDA) && \
|
||||
!defined(OSD_PATCH_BASIS_OPENCL) && \
|
||||
!defined(OSD_PATCH_BASIS_METAL)
|
||||
|
||||
#include "../version.h"
|
||||
|
||||
namespace OpenSubdiv {
|
||||
namespace OPENSUBDIV_VERSION {
|
||||
|
||||
namespace Osd {
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(OSD_PATCH_BASIS_GLSL)
|
||||
|
||||
@ -419,4 +442,19 @@ OsdPatchParamUnnormalizeTriangle(
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* OPENSUBDIV3_OSD_PATCH_BASIS_COMMON_TYPES_H */
|
||||
#if !defined(OSD_PATCH_BASIS_GLSL) && \
|
||||
!defined(OSD_PATCH_BASIS_HLSL) && \
|
||||
!defined(OSD_PATCH_BASIS_CUDA) && \
|
||||
!defined(OSD_PATCH_BASIS_OPENCL) && \
|
||||
!defined(OSD_PATCH_BASIS_METAL)
|
||||
|
||||
} // end namespace Osd
|
||||
|
||||
} // end namespace OPENSUBDIV_VERSION
|
||||
using namespace OPENSUBDIV_VERSION;
|
||||
|
||||
} // end namespace OpenSubdiv
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* OPENSUBDIV3_OSD_PATCH_BASIS_TYPES_H */
|
@ -26,9 +26,7 @@
|
||||
#include "../osd/tbbKernel.h"
|
||||
#include "../osd/types.h"
|
||||
#include "../osd/bufferDescriptor.h"
|
||||
#include "../osd/patchBasisCommonTypes.h"
|
||||
#include "../osd/patchBasisCommon.h"
|
||||
#include "../osd/patchBasisCommonEval.h"
|
||||
#include "../osd/patchBasis.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdlib>
|
||||
|
Loading…
Reference in New Issue
Block a user