opensubdiv/osd/ompEvaluator.h Source File

- Main Page
- Namespaces
- Classes
- Files

- File List

ompEvaluator.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_OMP_EVALUATOR_H
26 #define OPENSUBDIV3_OSD_OMP_EVALUATOR_H
27
28 #include "../version.h"
29
30 #include <cstddef>
31 #include "../osd/types.h"
32 #include "../osd/bufferDescriptor.h"
33
34 namespace OpenSubdiv {
35 namespace OPENSUBDIV_VERSION {
36
37 namespace Osd {
38
39 class OmpEvaluator {
40 public:
46
71 template <typename SRC_BUFFER, typename DST_BUFFER, typename STENCIL_TABLE>
72 static bool EvalStencils(
73 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
74 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
75 STENCIL_TABLE const *stencilTable,
76 const OmpEvaluator *instance = NULL,
77 void * deviceContext = NULL) {
78
79 (void)instance; // unused
80 (void)deviceContext; // unused
81
82 if (stencilTable->GetNumStencils() == 0)
83 return false;
84
85 return EvalStencils(srcBuffer->BindCpuBuffer(), srcDesc,
86 dstBuffer->BindCpuBuffer(), dstDesc,
87 &stencilTable->GetSizes()[0],
88 &stencilTable->GetOffsets()[0],
89 &stencilTable->GetControlIndices()[0],
90 &stencilTable->GetWeights()[0],
91 /*start = */ 0,
92 /*end = */ stencilTable->GetNumStencils());
93 }
94
122 static bool EvalStencils(
123 const float *src, BufferDescriptor const &srcDesc,
124 float *dst, BufferDescriptor const &dstDesc,
125 const int * sizes,
126 const int * offsets,
127 const int * indices,
128 const float * weights,
129 int start, int end);
130
168 template <typename SRC_BUFFER, typename DST_BUFFER, typename STENCIL_TABLE>
169 static bool EvalStencils(
170 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
171 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
172 DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
173 DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
174 STENCIL_TABLE const *stencilTable,
175 const OmpEvaluator *instance = NULL,
176 void * deviceContext = NULL) {
177
178 (void)instance; // unused
179 (void)deviceContext; // unused
180
181 return EvalStencils(srcBuffer->BindCpuBuffer(), srcDesc,
182 dstBuffer->BindCpuBuffer(), dstDesc,
183 duBuffer->BindCpuBuffer(), duDesc,
184 dvBuffer->BindCpuBuffer(), dvDesc,
185 &stencilTable->GetSizes()[0],
186 &stencilTable->GetOffsets()[0],
187 &stencilTable->GetControlIndices()[0],
188 &stencilTable->GetWeights()[0],
189 &stencilTable->GetDuWeights()[0],
190 &stencilTable->GetDvWeights()[0],
191 /*start = */ 0,
192 /*end = */ stencilTable->GetNumStencils());
193 }
194
235 static bool EvalStencils(
236 const float *src, BufferDescriptor const &srcDesc,
237 float *dst, BufferDescriptor const &dstDesc,
238 float *du, BufferDescriptor const &duDesc,
239 float *dv, BufferDescriptor const &dvDesc,
240 const int * sizes,
241 const int * offsets,
242 const int * indices,
243 const float * weights,
244 const float * duWeights,
245 const float * dvWeights,
246 int start, int end);
247
253
282 template <typename SRC_BUFFER, typename DST_BUFFER,
283 typename PATCHCOORD_BUFFER, typename PATCH_TABLE>
284 static bool EvalPatches(
285 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
286 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
287 int numPatchCoords,
288 PATCHCOORD_BUFFER *patchCoords,
289 PATCH_TABLE *patchTable,
290 OmpEvaluator const *instance = NULL,
291 void * deviceContext = NULL) {
292
293 (void)instance; // unused
294 (void)deviceContext; // unused
295
296 return EvalPatches(srcBuffer->BindCpuBuffer(), srcDesc,
297 dstBuffer->BindCpuBuffer(), dstDesc,
298 numPatchCoords,
299 (const PatchCoord*)patchCoords->BindCpuBuffer(),
300 patchTable->GetPatchArrayBuffer(),
301 patchTable->GetPatchIndexBuffer(),
302 patchTable->GetPatchParamBuffer());
303 }
304
345 template <typename SRC_BUFFER, typename DST_BUFFER,
346 typename PATCHCOORD_BUFFER, typename PATCH_TABLE>
347 static bool EvalPatches(
348 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
349 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
350 DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
351 DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
352 int numPatchCoords,
353 PATCHCOORD_BUFFER *patchCoords,
354 PATCH_TABLE *patchTable,
355 OmpEvaluator const *instance = NULL,
356 void * deviceContext = NULL) {
357 (void)instance; // unused
358 (void)deviceContext; // unused
359
360 // XXX: PatchCoords is somewhat abusing vertex primvar buffer interop.
361 // ideally all buffer classes should have templated by datatype
362 // so that downcast isn't needed there.
363 // (e.g. Osd::CpuBuffer<PatchCoord> )
364 //
365 return EvalPatches(srcBuffer->BindCpuBuffer(), srcDesc,
366 dstBuffer->BindCpuBuffer(), dstDesc,
367 duBuffer->BindCpuBuffer(), duDesc,
368 dvBuffer->BindCpuBuffer(), dvDesc,
369 numPatchCoords,
370 (const PatchCoord*)patchCoords->BindCpuBuffer(),
371 patchTable->GetPatchArrayBuffer(),
372 patchTable->GetPatchIndexBuffer(),
373 patchTable->GetPatchParamBuffer());
374 }
375
403 static bool EvalPatches(
404 const float *src, BufferDescriptor const &srcDesc,
405 float *dst, BufferDescriptor const &dstDesc,
406 int numPatchCoords,
407 const PatchCoord *patchCoords,
408 const PatchArray *patchArrays,
409 const int *patchIndexBuffer,
410 const PatchParam *patchParamBuffer);
411
449 static bool EvalPatches(
450 const float *src, BufferDescriptor const &srcDesc,
451 float *dst, BufferDescriptor const &dstDesc,
452 float *du, BufferDescriptor const &duDesc,
453 float *dv, BufferDescriptor const &dvDesc,
454 int numPatchCoords,
455 PatchCoord const *patchCoords,
456 PatchArray const *patchArrays,
457 const int *patchIndexBuffer,
458 PatchParam const *patchParamBuffer);
459
465
466 static void Synchronize(void *deviceContext = NULL);
467
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_OMP_EVALUATOR_H
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::OmpEvaluator::SetNumThreads
static void SetNumThreads(int numThreads)
OpenSubdiv::OPENSUBDIV_VERSION::Osd::OmpEvaluator
Definition: ompEvaluator.h:39
OpenSubdiv::OPENSUBDIV_VERSION::Osd::OmpEvaluator::Synchronize
static void Synchronize(void *deviceContext=NULL)
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray
Definition: types.h:64
OpenSubdiv::OPENSUBDIV_VERSION::Osd::OmpEvaluator::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 OmpEvaluator *instance=NULL, void *deviceContext=NULL)
Generic static eval stencils function with derivatives. This function has a same signature as other d...
Definition: ompEvaluator.h:169
OpenSubdiv::OPENSUBDIV_VERSION::Osd::OmpEvaluator::EvalStencils
static bool EvalStencils(SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc, DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc, STENCIL_TABLE const *stencilTable, const OmpEvaluator *instance=NULL, void *deviceContext=NULL)
Generic static eval stencils function. This function has a same signature as other device kernels hav...
Definition: ompEvaluator.h:72
OpenSubdiv::OPENSUBDIV_VERSION::Osd::OmpEvaluator::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, OmpEvaluator const *instance=NULL, void *deviceContext=NULL)
Generic limit eval function with derivatives. This function has a same signature as other device kern...
Definition: ompEvaluator.h:347
OpenSubdiv::OPENSUBDIV_VERSION::Osd::OmpEvaluator::EvalPatches
static bool EvalPatches(SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc, DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc, int numPatchCoords, PATCHCOORD_BUFFER *patchCoords, PATCH_TABLE *patchTable, OmpEvaluator const *instance=NULL, void *deviceContext=NULL)
Generic limit eval function. This function has a same signature as other device kernels have so that ...
Definition: ompEvaluator.h:284