mirror of
https://github.com/PixarAnimationStudios/OpenSubdiv
synced 2024-12-23 08:20:06 +00:00
Update TBB C&C's with Sheng's (shengfuintel) latest code
Git cherry-picking of the original pull request missed a few changes to these files. Thanks again to Sheng for this most excellent contribution !
This commit is contained in:
parent
22b1cddfc9
commit
d28dad10e5
@ -26,7 +26,6 @@
|
||||
#include "../osd/cpuComputeContext.h"
|
||||
#include "../osd/tbbComputeController.h"
|
||||
#include "../osd/tbbKernel.h"
|
||||
#include "../osd/table.h"
|
||||
|
||||
#ifdef OPENSUBDIV_HAS_TBB
|
||||
#include <tbb/task_scheduler_init.h>
|
||||
@ -57,8 +56,8 @@ OsdTbbComputeController::ApplyBilinearFaceVerticesKernel(
|
||||
context->GetVertexDescriptor(),
|
||||
context->GetCurrentVertexBuffer(),
|
||||
context->GetCurrentVaryingBuffer(),
|
||||
(const int*)context->GetTable(Table::F_IT)->GetBuffer(),
|
||||
(const int*)context->GetTable(Table::F_ITa)->GetBuffer(),
|
||||
(const int*)context->GetTable(FarSubdivisionTables<OsdVertex>::F_IT)->GetBuffer(),
|
||||
(const int*)context->GetTable(FarSubdivisionTables<OsdVertex>::F_ITa)->GetBuffer(),
|
||||
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd());
|
||||
}
|
||||
|
||||
@ -74,7 +73,7 @@ OsdTbbComputeController::ApplyBilinearEdgeVerticesKernel(
|
||||
context->GetVertexDescriptor(),
|
||||
context->GetCurrentVertexBuffer(),
|
||||
context->GetCurrentVaryingBuffer(),
|
||||
(const int*)context->GetTable(Table::E_IT)->GetBuffer(),
|
||||
(const int*)context->GetTable(FarSubdivisionTables<OsdVertex>::E_IT)->GetBuffer(),
|
||||
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd());
|
||||
}
|
||||
|
||||
@ -90,7 +89,7 @@ OsdTbbComputeController::ApplyBilinearVertexVerticesKernel(
|
||||
context->GetVertexDescriptor(),
|
||||
context->GetCurrentVertexBuffer(),
|
||||
context->GetCurrentVaryingBuffer(),
|
||||
(const int*)context->GetTable(Table::V_ITa)->GetBuffer(),
|
||||
(const int*)context->GetTable(FarSubdivisionTables<OsdVertex>::V_ITa)->GetBuffer(),
|
||||
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd());
|
||||
}
|
||||
|
||||
@ -106,8 +105,8 @@ OsdTbbComputeController::ApplyCatmarkFaceVerticesKernel(
|
||||
context->GetVertexDescriptor(),
|
||||
context->GetCurrentVertexBuffer(),
|
||||
context->GetCurrentVaryingBuffer(),
|
||||
(const int*)context->GetTable(Table::F_IT)->GetBuffer(),
|
||||
(const int*)context->GetTable(Table::F_ITa)->GetBuffer(),
|
||||
(const int*)context->GetTable(FarSubdivisionTables<OsdVertex>::F_IT)->GetBuffer(),
|
||||
(const int*)context->GetTable(FarSubdivisionTables<OsdVertex>::F_ITa)->GetBuffer(),
|
||||
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd());
|
||||
}
|
||||
|
||||
@ -123,8 +122,8 @@ OsdTbbComputeController::ApplyCatmarkEdgeVerticesKernel(
|
||||
context->GetVertexDescriptor(),
|
||||
context->GetCurrentVertexBuffer(),
|
||||
context->GetCurrentVaryingBuffer(),
|
||||
(const int*)context->GetTable(Table::E_IT)->GetBuffer(),
|
||||
(const float*)context->GetTable(Table::E_W)->GetBuffer(),
|
||||
(const int*)context->GetTable(FarSubdivisionTables<OsdVertex>::E_IT)->GetBuffer(),
|
||||
(const float*)context->GetTable(FarSubdivisionTables<OsdVertex>::E_W)->GetBuffer(),
|
||||
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd());
|
||||
}
|
||||
|
||||
@ -140,9 +139,9 @@ OsdTbbComputeController::ApplyCatmarkVertexVerticesKernelB(
|
||||
context->GetVertexDescriptor(),
|
||||
context->GetCurrentVertexBuffer(),
|
||||
context->GetCurrentVaryingBuffer(),
|
||||
(const int*)context->GetTable(Table::V_ITa)->GetBuffer(),
|
||||
(const int*)context->GetTable(Table::V_IT)->GetBuffer(),
|
||||
(const float*)context->GetTable(Table::V_W)->GetBuffer(),
|
||||
(const int*)context->GetTable(FarSubdivisionTables<OsdVertex>::V_ITa)->GetBuffer(),
|
||||
(const int*)context->GetTable(FarSubdivisionTables<OsdVertex>::V_IT)->GetBuffer(),
|
||||
(const float*)context->GetTable(FarSubdivisionTables<OsdVertex>::V_W)->GetBuffer(),
|
||||
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd());
|
||||
}
|
||||
|
||||
@ -158,8 +157,8 @@ OsdTbbComputeController::ApplyCatmarkVertexVerticesKernelA1(
|
||||
context->GetVertexDescriptor(),
|
||||
context->GetCurrentVertexBuffer(),
|
||||
context->GetCurrentVaryingBuffer(),
|
||||
(const int*)context->GetTable(Table::V_ITa)->GetBuffer(),
|
||||
(const float*)context->GetTable(Table::V_W)->GetBuffer(),
|
||||
(const int*)context->GetTable(FarSubdivisionTables<OsdVertex>::V_ITa)->GetBuffer(),
|
||||
(const float*)context->GetTable(FarSubdivisionTables<OsdVertex>::V_W)->GetBuffer(),
|
||||
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd(), false);
|
||||
}
|
||||
|
||||
@ -175,8 +174,8 @@ OsdTbbComputeController::ApplyCatmarkVertexVerticesKernelA2(
|
||||
context->GetVertexDescriptor(),
|
||||
context->GetCurrentVertexBuffer(),
|
||||
context->GetCurrentVaryingBuffer(),
|
||||
(const int*)context->GetTable(Table::V_ITa)->GetBuffer(),
|
||||
(const float*)context->GetTable(Table::V_W)->GetBuffer(),
|
||||
(const int*)context->GetTable(FarSubdivisionTables<OsdVertex>::V_ITa)->GetBuffer(),
|
||||
(const float*)context->GetTable(FarSubdivisionTables<OsdVertex>::V_W)->GetBuffer(),
|
||||
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd(), true);
|
||||
}
|
||||
|
||||
@ -192,8 +191,8 @@ OsdTbbComputeController::ApplyLoopEdgeVerticesKernel(
|
||||
context->GetVertexDescriptor(),
|
||||
context->GetCurrentVertexBuffer(),
|
||||
context->GetCurrentVaryingBuffer(),
|
||||
(const int*)context->GetTable(Table::E_IT)->GetBuffer(),
|
||||
(const float*)context->GetTable(Table::E_W)->GetBuffer(),
|
||||
(const int*)context->GetTable(FarSubdivisionTables<OsdVertex>::E_IT)->GetBuffer(),
|
||||
(const float*)context->GetTable(FarSubdivisionTables<OsdVertex>::E_W)->GetBuffer(),
|
||||
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd());
|
||||
}
|
||||
|
||||
@ -209,9 +208,9 @@ OsdTbbComputeController::ApplyLoopVertexVerticesKernelB(
|
||||
context->GetVertexDescriptor(),
|
||||
context->GetCurrentVertexBuffer(),
|
||||
context->GetCurrentVaryingBuffer(),
|
||||
(const int*)context->GetTable(Table::V_ITa)->GetBuffer(),
|
||||
(const int*)context->GetTable(Table::V_IT)->GetBuffer(),
|
||||
(const float*)context->GetTable(Table::V_W)->GetBuffer(),
|
||||
(const int*)context->GetTable(FarSubdivisionTables<OsdVertex>::V_ITa)->GetBuffer(),
|
||||
(const int*)context->GetTable(FarSubdivisionTables<OsdVertex>::V_IT)->GetBuffer(),
|
||||
(const float*)context->GetTable(FarSubdivisionTables<OsdVertex>::V_W)->GetBuffer(),
|
||||
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd());
|
||||
}
|
||||
|
||||
@ -227,8 +226,8 @@ OsdTbbComputeController::ApplyLoopVertexVerticesKernelA1(
|
||||
context->GetVertexDescriptor(),
|
||||
context->GetCurrentVertexBuffer(),
|
||||
context->GetCurrentVaryingBuffer(),
|
||||
(const int*)context->GetTable(Table::V_ITa)->GetBuffer(),
|
||||
(const float*)context->GetTable(Table::V_W)->GetBuffer(),
|
||||
(const int*)context->GetTable(FarSubdivisionTables<OsdVertex>::V_ITa)->GetBuffer(),
|
||||
(const float*)context->GetTable(FarSubdivisionTables<OsdVertex>::V_W)->GetBuffer(),
|
||||
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd(), false);
|
||||
}
|
||||
|
||||
@ -244,8 +243,8 @@ OsdTbbComputeController::ApplyLoopVertexVerticesKernelA2(
|
||||
context->GetVertexDescriptor(),
|
||||
context->GetCurrentVertexBuffer(),
|
||||
context->GetCurrentVaryingBuffer(),
|
||||
(const int*)context->GetTable(Table::V_ITa)->GetBuffer(),
|
||||
(const float*)context->GetTable(Table::V_W)->GetBuffer(),
|
||||
(const int*)context->GetTable(FarSubdivisionTables<OsdVertex>::V_ITa)->GetBuffer(),
|
||||
(const float*)context->GetTable(FarSubdivisionTables<OsdVertex>::V_W)->GetBuffer(),
|
||||
batch.GetVertexOffset(), batch.GetTableOffset(), batch.GetStart(), batch.GetEnd(), true);
|
||||
}
|
||||
|
||||
|
@ -34,9 +34,9 @@
|
||||
namespace OpenSubdiv {
|
||||
namespace OPENSUBDIV_VERSION {
|
||||
|
||||
/// \brief Compute controller for launching OpenMP subdivision kernels.
|
||||
/// \brief Compute controller for launching TBB subdivision kernels.
|
||||
///
|
||||
/// OsdTbbComputeController is a compute controller class to launch OpenMP
|
||||
/// OsdTbbComputeController is a compute controller class to launch TBB
|
||||
/// threaded subdivision kernels. It requires OsdCpuVertexBufferInterface
|
||||
/// as arguments of Refine function.
|
||||
///
|
||||
@ -72,8 +72,6 @@ public:
|
||||
VERTEX_BUFFER * vertexBuffer,
|
||||
VARYING_BUFFER * varyingBuffer) {
|
||||
|
||||
omp_set_num_threads(_numThreads);
|
||||
|
||||
context->Bind(vertexBuffer, varyingBuffer);
|
||||
FarDispatcher::Refine(this,
|
||||
batches,
|
||||
|
@ -36,16 +36,16 @@ namespace OPENSUBDIV_VERSION {
|
||||
#define grain_size 200
|
||||
|
||||
class TBBFaceKernel {
|
||||
const OsdVertexDescriptor *vdesc;
|
||||
OsdVertexDescriptor const *vdesc;
|
||||
float *vertex;
|
||||
float *varying;
|
||||
const int *F_IT;
|
||||
const int *F_ITa;
|
||||
int const *F_IT;
|
||||
int const *F_ITa;
|
||||
int vertexOffset;
|
||||
int tableOffset;
|
||||
|
||||
public:
|
||||
void operator() (const tbb::blocked_range<int> &r) const {
|
||||
|
||||
public:
|
||||
void operator() (tbb::blocked_range<int> const &r) const {
|
||||
if(vdesc->numVertexElements == 4 && varying == NULL) {
|
||||
ComputeFaceKernel<4>
|
||||
(vertex, F_IT, F_ITa, vertexOffset, tableOffset, r.begin(), r.end());
|
||||
@ -70,11 +70,11 @@ public:
|
||||
vdesc->AddWithWeight(vertex, dstIndex, index, weight);
|
||||
vdesc->AddVaryingWithWeight(varying, dstIndex, index, weight);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TBBFaceKernel(const TBBFaceKernel &other)
|
||||
TBBFaceKernel(TBBFaceKernel const &other)
|
||||
{
|
||||
this->vdesc = other.vdesc;
|
||||
this->vertex = other.vertex;
|
||||
@ -84,12 +84,12 @@ public:
|
||||
this->vertexOffset = other.vertexOffset;
|
||||
this->tableOffset = other.tableOffset;
|
||||
}
|
||||
|
||||
TBBFaceKernel(const OsdVertexDescriptor *vdesc_in,
|
||||
|
||||
TBBFaceKernel(OsdVertexDescriptor const *vdesc_in,
|
||||
float *vertex_in,
|
||||
float *varying_in,
|
||||
const int *F_IT_in,
|
||||
const int *F_ITa_in,
|
||||
int const *F_IT_in,
|
||||
int const *F_ITa_in,
|
||||
int vertexOffset_in,
|
||||
int tableOffset_in) :
|
||||
vdesc (vdesc_in),
|
||||
@ -99,38 +99,38 @@ public:
|
||||
F_ITa (F_ITa_in),
|
||||
vertexOffset(vertexOffset_in),
|
||||
tableOffset(tableOffset_in)
|
||||
{};
|
||||
{};
|
||||
};
|
||||
|
||||
void OsdTbbComputeFace(
|
||||
const OsdVertexDescriptor *vdesc, float * vertex, float * varying,
|
||||
const int *F_IT, const int *F_ITa, int vertexOffset, int tableOffset,
|
||||
OsdVertexDescriptor const &vdesc, float * vertex, float * varying,
|
||||
int const *F_IT, int const *F_ITa, int vertexOffset, int tableOffset,
|
||||
int start, int end) {
|
||||
|
||||
TBBFaceKernel kernel(vdesc, vertex, varying, F_IT, F_ITa,
|
||||
TBBFaceKernel kernel(&vdesc, vertex, varying, F_IT, F_ITa,
|
||||
vertexOffset, tableOffset);
|
||||
tbb::blocked_range<int> range(start, end, grain_size);
|
||||
tbb::blocked_range<int> range(start, end, grain_size);
|
||||
tbb::parallel_for(range, kernel);
|
||||
}
|
||||
|
||||
class TBBEdgeKernel {
|
||||
const OsdVertexDescriptor *vdesc;
|
||||
OsdVertexDescriptor const *vdesc;
|
||||
float *vertex;
|
||||
float *varying;
|
||||
const int *E_IT;
|
||||
const float *E_W;
|
||||
int const *E_IT;
|
||||
float const *E_W;
|
||||
int vertexOffset;
|
||||
int tableOffset;
|
||||
|
||||
public:
|
||||
void operator() (const tbb::blocked_range<int> &r) const {
|
||||
|
||||
public:
|
||||
void operator() (tbb::blocked_range<int> const &r) const {
|
||||
if(vdesc->numVertexElements == 4 && varying == NULL) {
|
||||
ComputeEdgeKernel<4>(vertex, E_IT, E_W, vertexOffset, tableOffset,
|
||||
r.begin(), r.end());
|
||||
r.begin(), r.end());
|
||||
}
|
||||
else if(vdesc->numVertexElements == 8 && varying == NULL) {
|
||||
ComputeEdgeKernel<8>(vertex, E_IT, E_W, vertexOffset, tableOffset,
|
||||
r.begin(), r.end());
|
||||
r.begin(), r.end());
|
||||
}
|
||||
else {
|
||||
for (int i = r.begin() + tableOffset; i < r.end() + tableOffset; i++) {
|
||||
@ -156,11 +156,11 @@ public:
|
||||
|
||||
vdesc->AddVaryingWithWeight(varying, dstIndex, eidx0, 0.5f);
|
||||
vdesc->AddVaryingWithWeight(varying, dstIndex, eidx1, 0.5f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TBBEdgeKernel(const TBBEdgeKernel &other)
|
||||
TBBEdgeKernel(TBBEdgeKernel const &other)
|
||||
{
|
||||
this->vdesc = other.vdesc;
|
||||
this->vertex = other.vertex;
|
||||
@ -170,12 +170,12 @@ public:
|
||||
this->vertexOffset = other.vertexOffset;
|
||||
this->tableOffset = other.tableOffset;
|
||||
}
|
||||
|
||||
TBBEdgeKernel(const OsdVertexDescriptor *vdesc_in,
|
||||
|
||||
TBBEdgeKernel(OsdVertexDescriptor const *vdesc_in,
|
||||
float *vertex_in,
|
||||
float *varying_in,
|
||||
const int *E_IT_in,
|
||||
const float *E_W_in,
|
||||
int const *E_IT_in,
|
||||
float const *E_W_in,
|
||||
int vertexOffset_in,
|
||||
int tableOffset_in) :
|
||||
vdesc (vdesc_in),
|
||||
@ -185,32 +185,32 @@ public:
|
||||
E_W (E_W_in),
|
||||
vertexOffset(vertexOffset_in),
|
||||
tableOffset(tableOffset_in)
|
||||
{};
|
||||
{};
|
||||
};
|
||||
|
||||
|
||||
void OsdTbbComputeEdge(
|
||||
const OsdVertexDescriptor *vdesc, float *vertex, float *varying,
|
||||
const int *E_IT, const float *E_W, int vertexOffset, int tableOffset,
|
||||
OsdVertexDescriptor const &vdesc, float *vertex, float *varying,
|
||||
int const *E_IT, float const *E_W, int vertexOffset, int tableOffset,
|
||||
int start, int end) {
|
||||
tbb::blocked_range<int> range(start, end, grain_size);
|
||||
TBBEdgeKernel kernel(vdesc, vertex, varying, E_IT, E_W,
|
||||
vertexOffset, tableOffset);
|
||||
tbb::blocked_range<int> range(start, end, grain_size);
|
||||
TBBEdgeKernel kernel(&vdesc, vertex, varying, E_IT, E_W,
|
||||
vertexOffset, tableOffset);
|
||||
tbb::parallel_for(range, kernel);
|
||||
}
|
||||
|
||||
class TBBVertexKernelA {
|
||||
const OsdVertexDescriptor *vdesc;
|
||||
OsdVertexDescriptor const *vdesc;
|
||||
float *vertex;
|
||||
float *varying;
|
||||
const int *V_ITa;
|
||||
const float *V_W;
|
||||
int const *V_ITa;
|
||||
float const *V_W;
|
||||
int vertexOffset;
|
||||
int tableOffset;
|
||||
int pass;
|
||||
|
||||
public:
|
||||
void operator() (const tbb::blocked_range<int> &r) const {
|
||||
|
||||
public:
|
||||
void operator() (tbb::blocked_range<int> const &r) const {
|
||||
if(vdesc->numVertexElements == 4 && varying == NULL) {
|
||||
ComputeVertexAKernel<4>(vertex, V_ITa, V_W, vertexOffset, tableOffset,
|
||||
r.begin(), r.end(), pass);
|
||||
@ -218,7 +218,7 @@ public:
|
||||
else if (vdesc->numVertexElements == 8 && varying == NULL) {
|
||||
ComputeVertexAKernel<8>(vertex, V_ITa, V_W, vertexOffset, tableOffset,
|
||||
r.begin(), r.end(), pass);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (int i = r.begin() + tableOffset; i < r.end() + tableOffset; i++) {
|
||||
int n = V_ITa[5*i+1];
|
||||
@ -246,14 +246,14 @@ public:
|
||||
vdesc->AddWithWeight(vertex, dstIndex, eidx0, weight * 0.125f);
|
||||
vdesc->AddWithWeight(vertex, dstIndex, eidx1, weight * 0.125f);
|
||||
}
|
||||
|
||||
if (not pass)
|
||||
vdesc->AddVaryingWithWeight(varying, dstIndex, p, 1.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TBBVertexKernelA(const TBBVertexKernelA &other)
|
||||
if (not pass)
|
||||
vdesc->AddVaryingWithWeight(varying, dstIndex, p, 1.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TBBVertexKernelA(TBBVertexKernelA const &other)
|
||||
{
|
||||
this->vdesc = other.vdesc;
|
||||
this->vertex = other.vertex;
|
||||
@ -264,12 +264,12 @@ public:
|
||||
this->tableOffset = other.tableOffset;
|
||||
this->pass = other.pass;
|
||||
}
|
||||
|
||||
TBBVertexKernelA(const OsdVertexDescriptor *vdesc_in,
|
||||
|
||||
TBBVertexKernelA(OsdVertexDescriptor const *vdesc_in,
|
||||
float *vertex_in,
|
||||
float *varying_in,
|
||||
const int *V_ITa_in,
|
||||
const float *V_W_in,
|
||||
int const *V_ITa_in,
|
||||
float const *V_W_in,
|
||||
int vertexOffset_in,
|
||||
int tableOffset_in,
|
||||
int pass_in) :
|
||||
@ -280,33 +280,32 @@ public:
|
||||
V_W (V_W_in),
|
||||
vertexOffset(vertexOffset_in),
|
||||
tableOffset(tableOffset_in),
|
||||
pass(pass_in)
|
||||
{};
|
||||
pass(pass_in)
|
||||
{};
|
||||
};
|
||||
|
||||
void OsdTbbComputeVertexA(
|
||||
const OsdVertexDescriptor *vdesc, float *vertex, float *varying,
|
||||
const int *V_ITa, const float *V_W, int vertexOffset, int tableOffset,
|
||||
OsdVertexDescriptor const &vdesc, float *vertex, float *varying,
|
||||
int const *V_ITa, float const *V_W, int vertexOffset, int tableOffset,
|
||||
int start, int end, int pass) {
|
||||
tbb::blocked_range<int> range(start, end, grain_size);
|
||||
TBBVertexKernelA kernel(vdesc, vertex, varying, V_ITa, V_W,
|
||||
vertexOffset, tableOffset, pass);
|
||||
tbb::blocked_range<int> range(start, end, grain_size);
|
||||
TBBVertexKernelA kernel(&vdesc, vertex, varying, V_ITa, V_W,
|
||||
vertexOffset, tableOffset, pass);
|
||||
tbb::parallel_for(range, kernel);
|
||||
}
|
||||
|
||||
class TBBVertexKernelB {
|
||||
const OsdVertexDescriptor *vdesc;
|
||||
OsdVertexDescriptor const *vdesc;
|
||||
float *vertex;
|
||||
float *varying;
|
||||
const int *V_ITa;
|
||||
const int *V_IT;
|
||||
const float *V_W;
|
||||
int const *V_ITa;
|
||||
int const *V_IT;
|
||||
float const *V_W;
|
||||
int vertexOffset;
|
||||
int tableOffset;
|
||||
int pass;
|
||||
|
||||
public:
|
||||
void operator() (const tbb::blocked_range<int> &r) const {
|
||||
|
||||
public:
|
||||
void operator() (tbb::blocked_range<int> const &r) const {
|
||||
if(vdesc->numVertexElements == 4 && varying == NULL) {
|
||||
ComputeVertexBKernel<4>(vertex, V_ITa, V_IT, V_W,
|
||||
vertexOffset, tableOffset, r.begin(), r.end());
|
||||
@ -314,7 +313,7 @@ public:
|
||||
else if(vdesc->numVertexElements == 8 && varying == NULL) {
|
||||
ComputeVertexBKernel<8>(vertex, V_ITa, V_IT, V_W,
|
||||
vertexOffset, tableOffset, r.begin(), r.end());
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (int i = r.begin() + tableOffset; i < r.end() + tableOffset; i++) {
|
||||
int h = V_ITa[5*i];
|
||||
@ -336,10 +335,10 @@ public:
|
||||
}
|
||||
vdesc->AddVaryingWithWeight(varying, dstIndex, p, 1.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TBBVertexKernelB(const TBBVertexKernelB &other)
|
||||
TBBVertexKernelB(TBBVertexKernelB const &other)
|
||||
{
|
||||
this->vdesc = other.vdesc;
|
||||
this->vertex = other.vertex;
|
||||
@ -349,59 +348,58 @@ public:
|
||||
this->V_W = other.V_W;
|
||||
this->vertexOffset = other.vertexOffset;
|
||||
this->tableOffset = other.tableOffset;
|
||||
this->pass = other.pass;
|
||||
}
|
||||
|
||||
TBBVertexKernelB(const OsdVertexDescriptor *vdesc_in,
|
||||
|
||||
TBBVertexKernelB(OsdVertexDescriptor const *vdesc_in,
|
||||
float *vertex_in,
|
||||
float *varying_in,
|
||||
const int *V_IT_in,
|
||||
const int *V_ITa_in,
|
||||
const float *V_W_in,
|
||||
int const *V_ITa_in,
|
||||
int const *V_IT_in,
|
||||
float const *V_W_in,
|
||||
int vertexOffset_in,
|
||||
int tableOffset_in) :
|
||||
vdesc (vdesc_in),
|
||||
vertex (vertex_in),
|
||||
varying(varying_in),
|
||||
V_IT (V_IT_in),
|
||||
V_ITa (V_ITa_in),
|
||||
V_IT (V_IT_in),
|
||||
V_W (V_W_in),
|
||||
vertexOffset(vertexOffset_in),
|
||||
tableOffset(tableOffset_in)
|
||||
{};
|
||||
{};
|
||||
};
|
||||
|
||||
void OsdTbbComputeVertexB(
|
||||
const OsdVertexDescriptor *vdesc, float *vertex, float *varying,
|
||||
const int *V_ITa, const int *V_IT, const float *V_W,
|
||||
OsdVertexDescriptor const &vdesc, float *vertex, float *varying,
|
||||
int const *V_ITa, int const *V_IT, float const *V_W,
|
||||
int vertexOffset, int tableOffset, int start, int end) {
|
||||
|
||||
tbb::blocked_range<int> range(start, end, grain_size);
|
||||
TBBVertexKernelB kernel(vdesc, vertex, varying, V_IT, V_ITa, V_W,
|
||||
vertexOffset, tableOffset);
|
||||
tbb::blocked_range<int> range(start, end, grain_size);
|
||||
TBBVertexKernelB kernel(&vdesc, vertex, varying, V_ITa, V_IT, V_W,
|
||||
vertexOffset, tableOffset);
|
||||
tbb::parallel_for(range, kernel);
|
||||
}
|
||||
|
||||
class TBBLoopVertexKernelB {
|
||||
const OsdVertexDescriptor *vdesc;
|
||||
OsdVertexDescriptor const *vdesc;
|
||||
float *vertex;
|
||||
float *varying;
|
||||
const int *V_ITa;
|
||||
const int *V_IT;
|
||||
const float *V_W;
|
||||
int const *V_ITa;
|
||||
int const *V_IT;
|
||||
float const *V_W;
|
||||
int vertexOffset;
|
||||
int tableOffset;
|
||||
|
||||
public:
|
||||
void operator() (const tbb::blocked_range<int> &r) const {
|
||||
|
||||
public:
|
||||
void operator() (tbb::blocked_range<int> const &r) const {
|
||||
if(vdesc->numVertexElements == 4 && varying == NULL) {
|
||||
ComputeLoopVertexBKernel<4>(vertex, V_ITa, V_IT, V_W, vertexOffset,
|
||||
ComputeLoopVertexBKernel<4>(vertex, V_ITa, V_IT, V_W, vertexOffset,
|
||||
tableOffset, r.begin(), r.end());
|
||||
}
|
||||
else if(vdesc->numVertexElements == 8 && varying == NULL) {
|
||||
ComputeLoopVertexBKernel<8>(vertex, V_ITa, V_IT, V_W, vertexOffset,
|
||||
tableOffset, r.begin(), r.end());
|
||||
}
|
||||
ComputeLoopVertexBKernel<8>(vertex, V_ITa, V_IT, V_W, vertexOffset,
|
||||
tableOffset, r.begin(), r.end());
|
||||
}
|
||||
else {
|
||||
for (int i = r.begin() + tableOffset; i < r.end() + tableOffset; i++) {
|
||||
int h = V_ITa[5*i];
|
||||
@ -423,11 +421,11 @@ public:
|
||||
vdesc->AddWithWeight(vertex, dstIndex, V_IT[h+j], weight * beta);
|
||||
|
||||
vdesc->AddVaryingWithWeight(varying, dstIndex, p, 1.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TBBLoopVertexKernelB(const TBBLoopVertexKernelB &other)
|
||||
TBBLoopVertexKernelB(TBBLoopVertexKernelB const &other)
|
||||
{
|
||||
this->vdesc = other.vdesc;
|
||||
this->vertex = other.vertex;
|
||||
@ -438,54 +436,54 @@ public:
|
||||
this->vertexOffset = other.vertexOffset;
|
||||
this->tableOffset = other.tableOffset;
|
||||
}
|
||||
|
||||
TBBLoopVertexKernelB(const OsdVertexDescriptor *vdesc_in,
|
||||
float *vertex_in,
|
||||
float *varying_in,
|
||||
const int *V_ITa_in,
|
||||
const int *V_IT_in,
|
||||
const float *V_W_in,
|
||||
int vertexOffset_in,
|
||||
int tableOffset_in) :
|
||||
vdesc (vdesc_in),
|
||||
vertex (vertex_in),
|
||||
varying(varying_in),
|
||||
V_ITa (V_ITa_in),
|
||||
V_IT (V_IT_in),
|
||||
V_W (V_W_in),
|
||||
vertexOffset(vertexOffset_in),
|
||||
tableOffset(tableOffset_in)
|
||||
{};
|
||||
|
||||
TBBLoopVertexKernelB(OsdVertexDescriptor const *vdesc_in,
|
||||
float *vertex_in,
|
||||
float *varying_in,
|
||||
int const *V_ITa_in,
|
||||
int const *V_IT_in,
|
||||
float const *V_W_in,
|
||||
int vertexOffset_in,
|
||||
int tableOffset_in) :
|
||||
vdesc (vdesc_in),
|
||||
vertex (vertex_in),
|
||||
varying(varying_in),
|
||||
V_ITa (V_ITa_in),
|
||||
V_IT (V_IT_in),
|
||||
V_W (V_W_in),
|
||||
vertexOffset(vertexOffset_in),
|
||||
tableOffset(tableOffset_in)
|
||||
{};
|
||||
};
|
||||
|
||||
void OsdTbbComputeLoopVertexB(
|
||||
const OsdVertexDescriptor *vdesc, float *vertex, float *varying,
|
||||
const int *V_ITa, const int *V_IT, const float *V_W,
|
||||
OsdVertexDescriptor const &vdesc, float *vertex, float *varying,
|
||||
int const *V_ITa, int const *V_IT, float const *V_W,
|
||||
int vertexOffset, int tableOffset, int start, int end) {
|
||||
tbb::blocked_range<int> range(start, end, grain_size);
|
||||
TBBLoopVertexKernelB kernel(vdesc, vertex, varying, V_ITa, V_IT, V_W,
|
||||
vertexOffset, tableOffset);
|
||||
|
||||
tbb::blocked_range<int> range(start, end, grain_size);
|
||||
TBBLoopVertexKernelB kernel(&vdesc, vertex, varying, V_ITa, V_IT, V_W,
|
||||
vertexOffset, tableOffset);
|
||||
|
||||
tbb::parallel_for(range, kernel);
|
||||
}
|
||||
|
||||
class TBBBilinearEdgeKernel {
|
||||
const OsdVertexDescriptor *vdesc;
|
||||
OsdVertexDescriptor const *vdesc;
|
||||
float *vertex;
|
||||
float *varying;
|
||||
const int *E_IT;
|
||||
int const *E_IT;
|
||||
int vertexOffset;
|
||||
int tableOffset;
|
||||
|
||||
public:
|
||||
void operator() (const tbb::blocked_range<int> &r) const {
|
||||
|
||||
public:
|
||||
void operator() (tbb::blocked_range<int> const &r) const {
|
||||
if(vdesc->numVertexElements == 4 && varying == NULL) {
|
||||
ComputeBilinearEdgeKernel<4>(vertex, E_IT, vertexOffset, tableOffset,
|
||||
ComputeBilinearEdgeKernel<4>(vertex, E_IT, vertexOffset, tableOffset,
|
||||
r.begin(), r.end());
|
||||
}
|
||||
else if(vdesc->numVertexElements == 8 && varying == NULL) {
|
||||
ComputeBilinearEdgeKernel<8>(vertex, E_IT, vertexOffset, tableOffset,
|
||||
r.begin(), r.end());
|
||||
ComputeBilinearEdgeKernel<8>(vertex, E_IT, vertexOffset, tableOffset,
|
||||
r.begin(), r.end());
|
||||
}
|
||||
else {
|
||||
for (int i = r.begin() + tableOffset; i < r.end() + tableOffset; i++) {
|
||||
@ -500,11 +498,11 @@ public:
|
||||
|
||||
vdesc->AddVaryingWithWeight(varying, dstIndex, eidx0, 0.5f);
|
||||
vdesc->AddVaryingWithWeight(varying, dstIndex, eidx1, 0.5f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TBBBilinearEdgeKernel(const TBBBilinearEdgeKernel &other)
|
||||
TBBBilinearEdgeKernel(TBBBilinearEdgeKernel const &other)
|
||||
{
|
||||
this->vdesc = other.vdesc;
|
||||
this->vertex = other.vertex;
|
||||
@ -513,59 +511,59 @@ public:
|
||||
this->vertexOffset = other.vertexOffset;
|
||||
this->tableOffset = other.tableOffset;
|
||||
}
|
||||
|
||||
TBBBilinearEdgeKernel(const OsdVertexDescriptor *vdesc_in,
|
||||
float *vertex_in,
|
||||
float *varying_in,
|
||||
const int *E_IT_in,
|
||||
int vertexOffset_in,
|
||||
int tableOffset_in) :
|
||||
vdesc (vdesc_in),
|
||||
vertex (vertex_in),
|
||||
varying(varying_in),
|
||||
E_IT (E_IT_in),
|
||||
vertexOffset(vertexOffset_in),
|
||||
tableOffset(tableOffset_in)
|
||||
{};
|
||||
|
||||
TBBBilinearEdgeKernel(OsdVertexDescriptor const *vdesc_in,
|
||||
float *vertex_in,
|
||||
float *varying_in,
|
||||
int const *E_IT_in,
|
||||
int vertexOffset_in,
|
||||
int tableOffset_in) :
|
||||
vdesc (vdesc_in),
|
||||
vertex (vertex_in),
|
||||
varying(varying_in),
|
||||
E_IT (E_IT_in),
|
||||
vertexOffset(vertexOffset_in),
|
||||
tableOffset(tableOffset_in)
|
||||
{};
|
||||
};
|
||||
|
||||
void OsdTbbComputeBilinearEdge(
|
||||
const OsdVertexDescriptor *vdesc, float *vertex, float *varying,
|
||||
const int *E_IT, int vertexOffset, int tableOffset, int start, int end) {
|
||||
tbb::blocked_range<int> range(start, end, grain_size);
|
||||
TBBBilinearEdgeKernel kernel(vdesc, vertex, varying, E_IT, vertexOffset, tableOffset);
|
||||
tbb::parallel_for(range, kernel);
|
||||
OsdVertexDescriptor const &vdesc, float *vertex, float *varying,
|
||||
int const *E_IT, int vertexOffset, int tableOffset, int start, int end) {
|
||||
tbb::blocked_range<int> range(start, end, grain_size);
|
||||
TBBBilinearEdgeKernel kernel(&vdesc, vertex, varying, E_IT, vertexOffset, tableOffset);
|
||||
tbb::parallel_for(range, kernel);
|
||||
}
|
||||
|
||||
class TBBBilinearVertexKernel {
|
||||
const OsdVertexDescriptor *vdesc;
|
||||
OsdVertexDescriptor const *vdesc;
|
||||
float *vertex;
|
||||
float *varying;
|
||||
const int *V_ITa;
|
||||
int const *V_ITa;
|
||||
int vertexOffset;
|
||||
int tableOffset;
|
||||
|
||||
public:
|
||||
void operator() (const tbb::blocked_range<int> &r) const {
|
||||
|
||||
public:
|
||||
void operator() (tbb::blocked_range<int> const &r) const {
|
||||
int numVertexElements = vdesc->numVertexElements;
|
||||
int numVaryingElements = vdesc->numVaryingElements;
|
||||
float *src, *des;
|
||||
float *src, *des;
|
||||
for (int i = r.begin() + tableOffset; i < r.end() + tableOffset; i++) {
|
||||
int p = V_ITa[i];
|
||||
|
||||
int dstIndex = i + vertexOffset - tableOffset;
|
||||
int dstIndex = i + vertexOffset - tableOffset;
|
||||
src = vertex + p * numVertexElements;
|
||||
des = vertex + dstIndex * numVertexElements;
|
||||
des = vertex + dstIndex * numVertexElements;
|
||||
memcpy(des, src, sizeof(float)*numVertexElements);
|
||||
if(varying) {
|
||||
src = varying + p * numVaryingElements;
|
||||
des = varying + dstIndex * numVaryingElements;
|
||||
des = varying + dstIndex * numVaryingElements;
|
||||
memcpy(des, src, sizeof(float)*numVaryingElements);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TBBBilinearVertexKernel(const TBBBilinearVertexKernel &other)
|
||||
TBBBilinearVertexKernel(TBBBilinearVertexKernel const &other)
|
||||
{
|
||||
this->vdesc = other.vdesc;
|
||||
this->vertex = other.vertex;
|
||||
@ -574,57 +572,57 @@ public:
|
||||
this->vertexOffset = other.vertexOffset;
|
||||
this->tableOffset = other.tableOffset;
|
||||
}
|
||||
|
||||
TBBBilinearVertexKernel(const OsdVertexDescriptor *vdesc_in,
|
||||
|
||||
TBBBilinearVertexKernel(OsdVertexDescriptor const *vdesc_in,
|
||||
float *vertex_in,
|
||||
float *varying_in,
|
||||
const int *V_ITa_in,
|
||||
int const *V_ITa_in,
|
||||
int vertexOffset_in,
|
||||
int tableOffset_in) :
|
||||
vdesc (vdesc_in),
|
||||
vertex (vertex_in),
|
||||
varying(varying_in),
|
||||
V_ITa (V_ITa_in),
|
||||
V_ITa (V_ITa_in),
|
||||
vertexOffset(vertexOffset_in),
|
||||
tableOffset(tableOffset_in)
|
||||
{};
|
||||
{};
|
||||
};
|
||||
|
||||
void OsdTbbComputeBilinearVertex(
|
||||
const OsdVertexDescriptor *vdesc, float *vertex, float *varying,
|
||||
const int *V_ITa, int vertexOffset, int tableOffset, int start, int end) {
|
||||
tbb::blocked_range<int> range(start, end, grain_size);
|
||||
TBBBilinearVertexKernel kernel(vdesc, vertex, varying, V_ITa, vertexOffset, tableOffset);
|
||||
tbb::parallel_for(range, kernel);
|
||||
OsdVertexDescriptor const &vdesc, float *vertex, float *varying,
|
||||
int const *V_ITa, int vertexOffset, int tableOffset, int start, int end) {
|
||||
tbb::blocked_range<int> range(start, end, grain_size);
|
||||
TBBBilinearVertexKernel kernel(&vdesc, vertex, varying, V_ITa, vertexOffset, tableOffset);
|
||||
tbb::parallel_for(range, kernel);
|
||||
}
|
||||
|
||||
void OsdTbbEditVertexAdd(
|
||||
const OsdVertexDescriptor *vdesc, float *vertex,
|
||||
OsdVertexDescriptor const &vdesc, float *vertex,
|
||||
int primVarOffset, int primVarWidth, int vertexOffset, int tableOffset,
|
||||
int start, int end,
|
||||
const unsigned int *editIndices, const float *editValues) {
|
||||
|
||||
unsigned int const *editIndices, float const *editValues) {
|
||||
|
||||
for (int i = start+tableOffset; i < end+tableOffset; i++) {
|
||||
vdesc->ApplyVertexEditAdd(vertex,
|
||||
primVarOffset,
|
||||
primVarWidth,
|
||||
editIndices[i] + vertexOffset,
|
||||
&editValues[i*primVarWidth]);
|
||||
}
|
||||
vdesc.ApplyVertexEditAdd(vertex,
|
||||
primVarOffset,
|
||||
primVarWidth,
|
||||
editIndices[i] + vertexOffset,
|
||||
&editValues[i*primVarWidth]);
|
||||
}
|
||||
}
|
||||
|
||||
void OsdTbbEditVertexSet(
|
||||
const OsdVertexDescriptor *vdesc, float *vertex,
|
||||
OsdVertexDescriptor const &vdesc, float *vertex,
|
||||
int primVarOffset, int primVarWidth, int vertexOffset, int tableOffset,
|
||||
int start, int end,
|
||||
const unsigned int *editIndices, const float *editValues) {
|
||||
unsigned int const *editIndices, float const *editValues) {
|
||||
|
||||
for (int i = start+tableOffset; i < end+tableOffset; i++) {
|
||||
vdesc->ApplyVertexEditSet(vertex,
|
||||
primVarOffset,
|
||||
primVarWidth,
|
||||
editIndices[i] + vertexOffset,
|
||||
&editValues[i*primVarWidth]);
|
||||
vdesc.ApplyVertexEditSet(vertex,
|
||||
primVarOffset,
|
||||
primVarWidth,
|
||||
editIndices[i] + vertexOffset,
|
||||
&editValues[i*primVarWidth]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,62 +33,62 @@ namespace OPENSUBDIV_VERSION {
|
||||
|
||||
struct OsdVertexDescriptor;
|
||||
|
||||
void OsdTbbComputeFace(const OsdVertexDescriptor *vdesc,
|
||||
void OsdTbbComputeFace(OsdVertexDescriptor const &vdesc,
|
||||
float * vertex, float * varying,
|
||||
const int *F_IT, const int *F_ITa,
|
||||
int const *F_IT, int const *F_ITa,
|
||||
int vertexOffset, int tableOffset,
|
||||
int start, int end);
|
||||
|
||||
void OsdTbbComputeEdge(const OsdVertexDescriptor *vdesc,
|
||||
void OsdTbbComputeEdge(OsdVertexDescriptor const &vdesc,
|
||||
float *vertex, float * varying,
|
||||
const int *E_IT, const float *E_ITa,
|
||||
int const *E_IT, float const *E_ITa,
|
||||
int vertexOffset, int tableOffset,
|
||||
int start, int end);
|
||||
|
||||
void OsdTbbComputeVertexA(const OsdVertexDescriptor *vdesc,
|
||||
void OsdTbbComputeVertexA(OsdVertexDescriptor const &vdesc,
|
||||
float *vertex, float * varying,
|
||||
const int *V_ITa, const float *V_IT,
|
||||
int const *V_ITa, float const *V_IT,
|
||||
int vertexOffset, int tableOffset,
|
||||
int start, int end, int pass);
|
||||
|
||||
void OsdTbbComputeVertexB(const OsdVertexDescriptor *vdesc,
|
||||
void OsdTbbComputeVertexB(OsdVertexDescriptor const &vdesc,
|
||||
float *vertex, float * varying,
|
||||
const int *V_ITa, const int *V_IT, const float *V_W,
|
||||
int const *V_ITa, int const *V_IT, float const *V_W,
|
||||
int vertexOffset, int tableOffset,
|
||||
int start, int end);
|
||||
|
||||
void OsdTbbComputeLoopVertexB(const OsdVertexDescriptor *vdesc,
|
||||
void OsdTbbComputeLoopVertexB(OsdVertexDescriptor const &vdesc,
|
||||
float *vertex, float * varying,
|
||||
const int *V_ITa, const int *V_IT,
|
||||
const float *V_W,
|
||||
int const *V_ITa, int const *V_IT,
|
||||
float const *V_W,
|
||||
int vertexOffset, int tableOffset,
|
||||
int start, int end);
|
||||
|
||||
void OsdTbbComputeBilinearEdge(const OsdVertexDescriptor *vdesc,
|
||||
void OsdTbbComputeBilinearEdge(OsdVertexDescriptor const &vdesc,
|
||||
float *vertex, float * varying,
|
||||
const int *E_IT,
|
||||
int const *E_IT,
|
||||
int vertexOffset, int tableOffset,
|
||||
int start, int end);
|
||||
|
||||
void OsdTbbComputeBilinearVertex(const OsdVertexDescriptor *vdesc,
|
||||
void OsdTbbComputeBilinearVertex(OsdVertexDescriptor const &vdesc,
|
||||
float *vertex, float * varying,
|
||||
const int *V_ITa,
|
||||
int const *V_ITa,
|
||||
int vertexOffset, int tableOffset,
|
||||
int start, int end);
|
||||
|
||||
void OsdTbbEditVertexAdd(const OsdVertexDescriptor *vdesc, float *vertex,
|
||||
void OsdTbbEditVertexAdd(OsdVertexDescriptor const &vdesc, float *vertex,
|
||||
int primVarOffset, int primVarWidth,
|
||||
int vertexOffset, int tableOffset,
|
||||
int start, int end,
|
||||
const unsigned int *editIndices,
|
||||
const float *editValues);
|
||||
unsigned int const *editIndices,
|
||||
float const *editValues);
|
||||
|
||||
void OsdTbbEditVertexSet(const OsdVertexDescriptor *vdesc, float *vertex,
|
||||
void OsdTbbEditVertexSet(OsdVertexDescriptor const &vdesc, float *vertex,
|
||||
int primVarOffset, int primVarWidth,
|
||||
int vertexOffset, int tableOffset,
|
||||
int start, int end,
|
||||
const unsigned int *editIndices,
|
||||
const float *editValues);
|
||||
unsigned int const *editIndices,
|
||||
float const *editValues);
|
||||
|
||||
} // end namespace OPENSUBDIV_VERSION
|
||||
using namespace OPENSUBDIV_VERSION;
|
||||
|
Loading…
Reference in New Issue
Block a user