25 #ifndef OPENSUBDIV_OPENSUBDIV3_OSD_CL_EVALUATOR_H
26 #define OPENSUBDIV_OPENSUBDIV3_OSD_CL_EVALUATOR_H
28 #include "../version.h"
30 #include "../osd/opencl.h"
31 #include "../osd/types.h"
32 #include "../osd/bufferDescriptor.h"
35 namespace OPENSUBDIV_VERSION {
52 template <
typename DEVICE_CONTEXT>
54 DEVICE_CONTEXT context) {
58 template <
typename DEVICE_CONTEXT>
61 DEVICE_CONTEXT context) {
62 return new CLStencilTable(limitStencilTable, context->GetContext());
66 cl_context clContext);
68 cl_context clContext);
96 CLEvaluator(cl_context context, cl_command_queue queue);
102 template <
typename DEVICE_CONTEXT>
107 DEVICE_CONTEXT deviceContext) {
108 return Create(srcDesc, dstDesc, duDesc, dvDesc,
109 deviceContext->GetContext(),
110 deviceContext->GetCommandQueue());
117 cl_context clContext,
118 cl_command_queue clCommandQueue) {
120 if (kernel->
Compile(srcDesc, dstDesc, duDesc, dvDesc))
return kernel;
161 template <
typename SRC_BUFFER,
typename DST_BUFFER,
162 typename STENCIL_TABLE,
typename DEVICE_CONTEXT>
166 STENCIL_TABLE
const *stencilTable,
168 DEVICE_CONTEXT deviceContext) {
176 instance =
Create(srcDesc, dstDesc,
233 template <
typename SRC_BUFFER,
typename DST_BUFFER,
234 typename STENCIL_TABLE,
typename DEVICE_CONTEXT>
240 STENCIL_TABLE
const *stencilTable,
242 DEVICE_CONTEXT deviceContext) {
252 instance =
Create(srcDesc, dstDesc, duDesc, dvDesc,
270 template <
typename SRC_BUFFER,
typename DST_BUFFER,
typename STENCIL_TABLE>
274 STENCIL_TABLE
const *stencilTable)
const {
275 return EvalStencils(srcBuffer->BindCLBuffer(_clCommandQueue), srcDesc,
276 dstBuffer->BindCLBuffer(_clCommandQueue), dstDesc,
277 stencilTable->GetSizesBuffer(),
278 stencilTable->GetOffsetsBuffer(),
279 stencilTable->GetIndicesBuffer(),
280 stencilTable->GetWeightsBuffer(),
282 stencilTable->GetNumStencils());
288 template <
typename SRC_BUFFER,
typename DST_BUFFER,
typename STENCIL_TABLE>
294 STENCIL_TABLE
const *stencilTable)
const {
295 return EvalStencils(srcBuffer->BindCLBuffer(_clCommandQueue), srcDesc,
296 dstBuffer->BindCLBuffer(_clCommandQueue), dstDesc,
297 duBuffer->BindCLBuffer(_clCommandQueue), duDesc,
298 dvBuffer->BindCLBuffer(_clCommandQueue), dvDesc,
299 stencilTable->GetSizesBuffer(),
300 stencilTable->GetOffsetsBuffer(),
301 stencilTable->GetIndicesBuffer(),
302 stencilTable->GetWeightsBuffer(),
303 stencilTable->GetDuWeightsBuffer(),
304 stencilTable->GetDvWeightsBuffer(),
306 stencilTable->GetNumStencils());
376 template <
typename SRC_BUFFER,
typename DST_BUFFER,
377 typename PATCHCOORD_BUFFER,
typename PATCH_TABLE,
378 typename DEVICE_CONTEXT>
383 PATCHCOORD_BUFFER *patchCoords,
384 PATCH_TABLE *patchTable,
386 DEVICE_CONTEXT deviceContext) {
391 numPatchCoords, patchCoords,
396 instance =
Create(srcDesc, dstDesc,
403 numPatchCoords, patchCoords,
455 template <
typename SRC_BUFFER,
typename DST_BUFFER,
456 typename PATCHCOORD_BUFFER,
typename PATCH_TABLE,
457 typename DEVICE_CONTEXT>
464 PATCHCOORD_BUFFER *patchCoords,
465 PATCH_TABLE *patchTable,
467 DEVICE_CONTEXT deviceContext) {
474 numPatchCoords, patchCoords,
479 instance =
Create(srcDesc, dstDesc, duDesc, dvDesc, deviceContext);
485 numPatchCoords, patchCoords,
518 template <
typename SRC_BUFFER,
typename DST_BUFFER,
519 typename PATCHCOORD_BUFFER,
typename PATCH_TABLE>
524 PATCHCOORD_BUFFER *patchCoords,
525 PATCH_TABLE *patchTable)
const {
527 return EvalPatches(srcBuffer->BindCLBuffer(_clCommandQueue), srcDesc,
528 dstBuffer->BindCLBuffer(_clCommandQueue), dstDesc,
532 patchCoords->BindCLBuffer(_clCommandQueue),
533 patchTable->GetPatchArrayBuffer(),
534 patchTable->GetPatchIndexBuffer(),
535 patchTable->GetPatchParamBuffer());
572 template <
typename SRC_BUFFER,
typename DST_BUFFER,
573 typename PATCHCOORD_BUFFER,
typename PATCH_TABLE>
580 PATCHCOORD_BUFFER *patchCoords,
581 PATCH_TABLE *patchTable)
const {
583 return EvalPatches(srcBuffer->BindCLBuffer(_clCommandQueue), srcDesc,
584 dstBuffer->BindCLBuffer(_clCommandQueue), dstDesc,
585 duBuffer->BindCLBuffer(_clCommandQueue), duDesc,
586 dvBuffer->BindCLBuffer(_clCommandQueue), dvDesc,
588 patchCoords->BindCLBuffer(_clCommandQueue),
589 patchTable->GetPatchArrayBuffer(),
590 patchTable->GetPatchIndexBuffer(),
591 patchTable->GetPatchParamBuffer());
599 cl_mem patchCoordsBuffer,
600 cl_mem patchArrayBuffer,
601 cl_mem patchIndexBuffer,
602 cl_mem patchParamsBuffer)
const;
618 template <
typename DEVICE_CONTEXT>
626 cl_context _clContext;
627 cl_command_queue _clCommandQueue;
629 cl_kernel _stencilKernel;
630 cl_kernel _stencilDerivKernel;
631 cl_kernel _patchKernel;
638 using namespace OPENSUBDIV_VERSION;
643 #endif // OPENSUBDIV_OPENSUBDIV3_OSD_CL_EVALUATOR_H
static CLStencilTable * Create(Far::LimitStencilTable const *limitStencilTable, DEVICE_CONTEXT context)
static CLEvaluator * Create(BufferDescriptor const &srcDesc, BufferDescriptor const &dstDesc, BufferDescriptor const &duDesc, BufferDescriptor const &dvDesc, DEVICE_CONTEXT deviceContext)
Generic creator template.
cl_mem GetSizesBuffer() const
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, CLEvaluator const *instance, DEVICE_CONTEXT deviceContext)
Generic static compute function. This function has a same signature as other device kernels have so t...
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.
bool EvalStencils(SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc, DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc, STENCIL_TABLE const *stencilTable) const
cl_mem GetDuWeightsBuffer() const
static bool EvalStencils(SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc, DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc, STENCIL_TABLE const *stencilTable, CLEvaluator const *instance, DEVICE_CONTEXT deviceContext)
Generic static compute function. This function has a same signature as other device kernels have so t...
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, CLEvaluator const *instance, DEVICE_CONTEXT deviceContext)
Generic limit eval function. This function has a same signature as other device kernels have so that ...
static CLStencilTable * Create(Far::StencilTable const *stencilTable, DEVICE_CONTEXT context)
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) const
Generic limit eval function with derivatives. This function has a same signature as other device kern...
static void Synchronize(DEVICE_CONTEXT deviceContext)
Wait the OpenCL kernels finish.
cl_mem GetWeightsBuffer() const
Table of subdivision stencils.
static CLEvaluator * Create(BufferDescriptor const &srcDesc, BufferDescriptor const &dstDesc, BufferDescriptor const &duDesc, BufferDescriptor const &dvDesc, cl_context clContext, cl_command_queue clCommandQueue)
CLStencilTable(Far::StencilTable const *stencilTable, cl_context clContext)
CLEvaluator(cl_context context, cl_command_queue queue)
Constructor.
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
~CLEvaluator()
Desctructor.
int GetNumStencils() const
static bool EvalPatches(SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc, DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc, int numPatchCoords, PATCHCOORD_BUFFER *patchCoords, PATCH_TABLE *patchTable, CLEvaluator const *instance, DEVICE_CONTEXT deviceContext)
Generic limit eval function. This function has a same signature as other device kernels have so that ...
cl_mem GetDvWeightsBuffer() const
bool EvalPatches(SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc, DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc, int numPatchCoords, PATCHCOORD_BUFFER *patchCoords, PATCH_TABLE *patchTable) const
Generic limit eval function. This function has a same signature as other device kernels have so that ...
bool Compile(BufferDescriptor const &srcDesc, BufferDescriptor const &dstDesc, BufferDescriptor const &duDesc, BufferDescriptor const &dvDesc)
cl_mem GetOffsetsBuffer() const
Table of limit subdivision stencils.
cl_mem GetIndicesBuffer() const