opensubdiv/osd/tbbEvaluator.h Source File

- Main Page
- Namespaces
- Classes
- Files

- File List

tbbEvaluator.h
Go to the documentation of this file.
1 //
2 // Copyright 2015 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24
25 #ifndef OPENSUBDIV3_OSD_TBB_EVALUATOR_H
26 #define OPENSUBDIV3_OSD_TBB_EVALUATOR_H
27
28 #include "../version.h"
29 #include "../osd/types.h"
30 #include "../osd/bufferDescriptor.h"
31 #include "../far/patchTable.h"
32
33 #include <cstddef>
34
35 namespace OpenSubdiv {
36 namespace OPENSUBDIV_VERSION {
37
38 namespace Osd {
39
40 class TbbEvaluator {
41 public:
47
72 template <typename SRC_BUFFER, typename DST_BUFFER, typename STENCIL_TABLE>
73 static bool EvalStencils(
74 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
75 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
76 STENCIL_TABLE const *stencilTable,
77 TbbEvaluator const *instance = NULL,
78 void *deviceContext = NULL) {
79
80 (void)instance; // unused
81 (void)deviceContext; // unused
82
83 return EvalStencils(srcBuffer->BindCpuBuffer(), srcDesc,
84 dstBuffer->BindCpuBuffer(), dstDesc,
85 &stencilTable->GetSizes()[0],
86 &stencilTable->GetOffsets()[0],
87 &stencilTable->GetControlIndices()[0],
88 &stencilTable->GetWeights()[0],
89 /*start = */ 0,
90 /*end = */ stencilTable->GetNumStencils());
91 }
92
120 static bool EvalStencils(
121 const float *src, BufferDescriptor const &srcDesc,
122 float *dst, BufferDescriptor const &dstDesc,
123 const int *sizes,
124 const int *offsets,
125 const int *indices,
126 const float *weights,
127 int start, int end);
128
166 template <typename SRC_BUFFER, typename DST_BUFFER, typename STENCIL_TABLE>
167 static bool EvalStencils(
168 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
169 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
170 DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
171 DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
172 STENCIL_TABLE const *stencilTable,
173 const TbbEvaluator *instance = NULL,
174 void * deviceContext = NULL) {
175
176 (void)instance; // unused
177 (void)deviceContext; // unused
178
179 return EvalStencils(srcBuffer->BindCpuBuffer(), srcDesc,
180 dstBuffer->BindCpuBuffer(), dstDesc,
181 duBuffer->BindCpuBuffer(), duDesc,
182 dvBuffer->BindCpuBuffer(), dvDesc,
183 &stencilTable->GetSizes()[0],
184 &stencilTable->GetOffsets()[0],
185 &stencilTable->GetControlIndices()[0],
186 &stencilTable->GetWeights()[0],
187 &stencilTable->GetDuWeights()[0],
188 &stencilTable->GetDvWeights()[0],
189 /*start = */ 0,
190 /*end = */ stencilTable->GetNumStencils());
191 }
192
234 static bool EvalStencils(
235 const float *src, BufferDescriptor const &srcDesc,
236 float *dst, BufferDescriptor const &dstDesc,
237 float *du, BufferDescriptor const &duDesc,
238 float *dv, BufferDescriptor const &dvDesc,
239 const int * sizes,
240 const int * offsets,
241 const int * indices,
242 const float * weights,
243 const float * duWeights,
244 const float * dvWeights,
245 int start, int end);
246
252
279 template <typename SRC_BUFFER, typename DST_BUFFER,
280 typename PATCHCOORD_BUFFER, typename PATCH_TABLE>
281 static bool EvalPatches(
282 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
283 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
284 int numPatchCoords,
285 PATCHCOORD_BUFFER *patchCoords,
286 PATCH_TABLE *patchTable,
287 TbbEvaluator const *instance = NULL,
288 void * deviceContext = NULL) {
289
290 (void)instance; // unused
291 (void)deviceContext; // unused
292
293 return EvalPatches(srcBuffer->BindCpuBuffer(),
294 srcDesc,
295 dstBuffer->BindCpuBuffer(),
296 dstDesc,
297 numPatchCoords,
298 (const PatchCoord*)patchCoords->BindCpuBuffer(),
299 patchTable->GetPatchArrayBuffer(),
300 patchTable->GetPatchIndexBuffer(),
301 patchTable->GetPatchParamBuffer());
302 }
303
342 template <typename SRC_BUFFER, typename DST_BUFFER,
343 typename PATCHCOORD_BUFFER, typename PATCH_TABLE>
344 static bool EvalPatches(
345 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
346 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
347 DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
348 DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
349 int numPatchCoords,
350 PATCHCOORD_BUFFER *patchCoords,
351 PATCH_TABLE *patchTable,
352 TbbEvaluator const *instance = NULL,
353 void * deviceContext = NULL) {
354
355 (void)instance; // unused
356 (void)deviceContext; // unused
357
358 return EvalPatches(
359 srcBuffer->BindCpuBuffer(), srcDesc,
360 dstBuffer->BindCpuBuffer(), dstDesc,
361 duBuffer->BindCpuBuffer(), duDesc,
362 dvBuffer->BindCpuBuffer(), dvDesc,
363 numPatchCoords,
364 (const PatchCoord*)patchCoords->BindCpuBuffer(),
365 patchTable->GetPatchArrayBuffer(),
366 patchTable->GetPatchIndexBuffer(),
367 patchTable->GetPatchParamBuffer());
368 }
369
397 static bool EvalPatches(
398 const float *src, BufferDescriptor const &srcDesc,
399 float *dst, BufferDescriptor const &dstDesc,
400 int numPatchCoords,
401 const PatchCoord *patchCoords,
402 const PatchArray *patchArrays,
403 const int *patchIndexBuffer,
404 const PatchParam *patchParamBuffer);
405
443 static bool EvalPatches(
444 const float *src, BufferDescriptor const &srcDesc,
445 float *dst, BufferDescriptor const &dstDesc,
446 float *du, BufferDescriptor const &duDesc,
447 float *dv, BufferDescriptor const &dvDesc,
448 int numPatchCoords,
449 const PatchCoord *patchCoords,
450 const PatchArray *patchArrays,
451 const int *patchIndexBuffer,
452 const PatchParam *patchParamBuffer);
453
459
461 static void Synchronize(void *deviceContext = NULL);
462
468 static void SetNumThreads(int numThreads);
469 };
470
471
472 } // end namespace Osd
473
474 } // end namespace OPENSUBDIV_VERSION
475 using namespace OPENSUBDIV_VERSION;
476
477 } // end namespace OpenSubdiv
478
479
480 #endif // OPENSUBDIV3_OSD_TBB_EVALUATOR_H
OpenSubdiv::OPENSUBDIV_VERSION::Osd::TbbEvaluator::SetNumThreads
static void SetNumThreads(int numThreads)
initialize tbb task schedular (optional: client may use tbb::task_scheduler_init) ...
OpenSubdiv::OPENSUBDIV_VERSION::Osd::TbbEvaluator::EvalPatches
static bool EvalPatches(SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc, DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc, int numPatchCoords, PATCHCOORD_BUFFER *patchCoords, PATCH_TABLE *patchTable, TbbEvaluator const *instance=NULL, void *deviceContext=NULL)
Generic limit eval function. This function has a same signature as other device kernels have so that ...
Definition: tbbEvaluator.h:281
OpenSubdiv::OPENSUBDIV_VERSION::Osd::BufferDescriptor
BufferDescriptor is a struct which describes buffer elements in interleaved data buffers. Almost all Osd Evaluator APIs take BufferDescriptors along with device-specific buffer objects.
Definition: bufferDescriptor.h:61
OpenSubdiv
Definition: error.h:30
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchCoord
Coordinates set on a patch table.
Definition: types.h:40
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchParam
Definition: types.h:93
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray
Definition: types.h:64
OpenSubdiv::OPENSUBDIV_VERSION::Osd::TbbEvaluator::EvalStencils
static bool EvalStencils(SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc, DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc, STENCIL_TABLE const *stencilTable, TbbEvaluator const *instance=NULL, void *deviceContext=NULL)
Generic static eval stencils function. This function has a same signature as other device kernels hav...
Definition: tbbEvaluator.h:73
OpenSubdiv::OPENSUBDIV_VERSION::Osd::TbbEvaluator
Definition: tbbEvaluator.h:40
OpenSubdiv::OPENSUBDIV_VERSION::Osd::TbbEvaluator::EvalPatches
static bool EvalPatches(SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc, DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc, DST_BUFFER *duBuffer, BufferDescriptor const &duDesc, DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc, int numPatchCoords, PATCHCOORD_BUFFER *patchCoords, PATCH_TABLE *patchTable, TbbEvaluator const *instance=NULL, void *deviceContext=NULL)
Generic limit eval function with derivatives. This function has a same signature as other device kern...
Definition: tbbEvaluator.h:344
OpenSubdiv::OPENSUBDIV_VERSION::Osd::TbbEvaluator::EvalStencils
static bool EvalStencils(SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc, DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc, DST_BUFFER *duBuffer, BufferDescriptor const &duDesc, DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc, STENCIL_TABLE const *stencilTable, const TbbEvaluator *instance=NULL, void *deviceContext=NULL)
Generic static eval stencils function with derivatives. This function has a same signature as other d...
Definition: tbbEvaluator.h:167
OpenSubdiv::OPENSUBDIV_VERSION::Osd::TbbEvaluator::Synchronize
static void Synchronize(void *deviceContext=NULL)
synchronize all asynchronous computation invoked on this device.