All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
clEvaluator.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_CL_EVALUATOR_H
26 #define OPENSUBDIV3_OSD_CL_EVALUATOR_H
27 
28 #include "../version.h"
29 
30 #include "../osd/opencl.h"
31 #include "../osd/types.h"
32 #include "../osd/bufferDescriptor.h"
33 
34 namespace OpenSubdiv {
35 namespace OPENSUBDIV_VERSION {
36 
37 namespace Far {
38  class PatchTable;
39  class StencilTable;
40  class LimitStencilTable;
41 }
42 
43 namespace Osd {
44 
53 public:
54  template <typename DEVICE_CONTEXT>
55  static CLStencilTable *Create(Far::StencilTable const *stencilTable,
56  DEVICE_CONTEXT context) {
57  return new CLStencilTable(stencilTable, context->GetContext());
58  }
59 
60  template <typename DEVICE_CONTEXT>
62  Far::LimitStencilTable const *limitStencilTable,
63  DEVICE_CONTEXT context) {
64  return new CLStencilTable(limitStencilTable, context->GetContext());
65  }
66 
67  CLStencilTable(Far::StencilTable const *stencilTable,
68  cl_context clContext);
69  CLStencilTable(Far::LimitStencilTable const *limitStencilTable,
70  cl_context clContext);
72 
73  // interfaces needed for CLComputeKernel
74  cl_mem GetSizesBuffer() const { return _sizes; }
75  cl_mem GetOffsetsBuffer() const { return _offsets; }
76  cl_mem GetIndicesBuffer() const { return _indices; }
77  cl_mem GetWeightsBuffer() const { return _weights; }
78  cl_mem GetDuWeightsBuffer() const { return _duWeights; }
79  cl_mem GetDvWeightsBuffer() const { return _dvWeights; }
80  cl_mem GetDuuWeightsBuffer() const { return _duuWeights; }
81  cl_mem GetDuvWeightsBuffer() const { return _duvWeights; }
82  cl_mem GetDvvWeightsBuffer() const { return _dvvWeights; }
83  int GetNumStencils() const { return _numStencils; }
84 
85 private:
86  cl_mem _sizes;
87  cl_mem _offsets;
88  cl_mem _indices;
89  cl_mem _weights;
90  cl_mem _duWeights;
91  cl_mem _dvWeights;
92  cl_mem _duuWeights;
93  cl_mem _duvWeights;
94  cl_mem _dvvWeights;
95  int _numStencils;
96 };
97 
98 // ---------------------------------------------------------------------------
99 
100 class CLEvaluator {
101 public:
102  typedef bool Instantiatable;
103 
105  template <typename DEVICE_CONTEXT>
106  static CLEvaluator *Create(BufferDescriptor const &srcDesc,
107  BufferDescriptor const &dstDesc,
108  BufferDescriptor const &duDesc,
109  BufferDescriptor const &dvDesc,
110  DEVICE_CONTEXT deviceContext) {
111  return Create(srcDesc, dstDesc, duDesc, dvDesc,
112  deviceContext->GetContext(),
113  deviceContext->GetCommandQueue());
114  }
115 
116  static CLEvaluator * Create(BufferDescriptor const &srcDesc,
117  BufferDescriptor const &dstDesc,
118  BufferDescriptor const &duDesc,
119  BufferDescriptor const &dvDesc,
120  cl_context clContext,
121  cl_command_queue clCommandQueue) {
122  CLEvaluator *instance = new CLEvaluator(clContext, clCommandQueue);
123  if (instance->Compile(srcDesc, dstDesc, duDesc, dvDesc))
124  return instance;
125  delete instance;
126  return NULL;
127  }
128 
130  template <typename DEVICE_CONTEXT>
131  static CLEvaluator *Create(BufferDescriptor const &srcDesc,
132  BufferDescriptor const &dstDesc,
133  BufferDescriptor const &duDesc,
134  BufferDescriptor const &dvDesc,
135  BufferDescriptor const &duuDesc,
136  BufferDescriptor const &duvDesc,
137  BufferDescriptor const &dvvDesc,
138  DEVICE_CONTEXT deviceContext) {
139  return Create(srcDesc, dstDesc, duDesc, dvDesc,
140  duuDesc, duvDesc, dvvDesc,
141  deviceContext->GetContext(),
142  deviceContext->GetCommandQueue());
143  }
144 
145  static CLEvaluator * Create(BufferDescriptor const &srcDesc,
146  BufferDescriptor const &dstDesc,
147  BufferDescriptor const &duDesc,
148  BufferDescriptor const &dvDesc,
149  BufferDescriptor const &duuDesc,
150  BufferDescriptor const &duvDesc,
151  BufferDescriptor const &dvvDesc,
152  cl_context clContext,
153  cl_command_queue clCommandQueue) {
154  CLEvaluator *instance = new CLEvaluator(clContext, clCommandQueue);
155  if (instance->Compile(srcDesc, dstDesc, duDesc, dvDesc,
156  duuDesc, duvDesc, dvvDesc))
157  return instance;
158  delete instance;
159  return NULL;
160  }
161 
163  CLEvaluator(cl_context context, cl_command_queue queue);
164 
166  ~CLEvaluator();
167 
173 
217  template <typename SRC_BUFFER, typename DST_BUFFER,
218  typename STENCIL_TABLE, typename DEVICE_CONTEXT>
219  static bool EvalStencils(
220  SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
221  DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
222  STENCIL_TABLE const *stencilTable,
223  CLEvaluator const *instance,
224  DEVICE_CONTEXT deviceContext,
225  unsigned int numStartEvents=0,
226  const cl_event* startEvents=NULL,
227  cl_event* endEvent=NULL) {
228 
229  if (instance) {
230  return instance->EvalStencils(srcBuffer, srcDesc,
231  dstBuffer, dstDesc,
232  stencilTable,
233  numStartEvents, startEvents, endEvent);
234  } else {
235  // Create an instance on demand (slow)
236  instance = Create(srcDesc, dstDesc,
239  deviceContext);
240  if (instance) {
241  bool r = instance->EvalStencils(srcBuffer, srcDesc,
242  dstBuffer, dstDesc,
243  stencilTable,
244  numStartEvents, startEvents, endEvent);
245  delete instance;
246  return r;
247  }
248  return false;
249  }
250  }
251 
307  template <typename SRC_BUFFER, typename DST_BUFFER,
308  typename STENCIL_TABLE, typename DEVICE_CONTEXT>
309  static bool EvalStencils(
310  SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
311  DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
312  DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
313  DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
314  STENCIL_TABLE const *stencilTable,
315  CLEvaluator const *instance,
316  DEVICE_CONTEXT deviceContext,
317  unsigned int numStartEvents=0,
318  const cl_event* startEvents=NULL,
319  cl_event* endEvent=NULL) {
320 
321  if (instance) {
322  return instance->EvalStencils(srcBuffer, srcDesc,
323  dstBuffer, dstDesc,
324  duBuffer, duDesc,
325  dvBuffer, dvDesc,
326  stencilTable,
327  numStartEvents, startEvents, endEvent);
328  } else {
329  // Create an instance on demand (slow)
330  instance = Create(srcDesc, dstDesc, duDesc, dvDesc,
331  deviceContext);
332  if (instance) {
333  bool r = instance->EvalStencils(srcBuffer, srcDesc,
334  dstBuffer, dstDesc,
335  duBuffer, duDesc,
336  dvBuffer, dvDesc,
337  stencilTable,
338  numStartEvents, startEvents, endEvent);
339  delete instance;
340  return r;
341  }
342  return false;
343  }
344  }
345 
419  template <typename SRC_BUFFER, typename DST_BUFFER,
420  typename STENCIL_TABLE, typename DEVICE_CONTEXT>
421  static bool EvalStencils(
422  SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
423  DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
424  DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
425  DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
426  DST_BUFFER *duuBuffer, BufferDescriptor const &duuDesc,
427  DST_BUFFER *duvBuffer, BufferDescriptor const &duvDesc,
428  DST_BUFFER *dvvBuffer, BufferDescriptor const &dvvDesc,
429  STENCIL_TABLE const *stencilTable,
430  CLEvaluator const *instance,
431  DEVICE_CONTEXT deviceContext,
432  unsigned int numStartEvents=0,
433  const cl_event* startEvents=NULL,
434  cl_event* endEvent=NULL) {
435 
436  if (instance) {
437  return instance->EvalStencils(srcBuffer, srcDesc,
438  dstBuffer, dstDesc,
439  duBuffer, duDesc,
440  dvBuffer, dvDesc,
441  duuBuffer, duuDesc,
442  duvBuffer, duvDesc,
443  dvvBuffer, dvvDesc,
444  stencilTable,
445  numStartEvents, startEvents, endEvent);
446  } else {
447  // Create an instance on demand (slow)
448  instance = Create(srcDesc, dstDesc,
449  duDesc, dvDesc,
450  duuDesc, duvDesc, dvvDesc,
451  deviceContext);
452  if (instance) {
453  bool r = instance->EvalStencils(srcBuffer, srcDesc,
454  dstBuffer, dstDesc,
455  duBuffer, duDesc,
456  dvBuffer, dvDesc,
457  duuBuffer, duuDesc,
458  duvBuffer, duvDesc,
459  dvvBuffer, dvvDesc,
460  stencilTable,
461  numStartEvents, startEvents, endEvent);
462  delete instance;
463  return r;
464  }
465  return false;
466  }
467  }
468 
499  template <typename SRC_BUFFER, typename DST_BUFFER, typename STENCIL_TABLE>
501  SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
502  DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
503  STENCIL_TABLE const *stencilTable,
504  unsigned int numStartEvents=0,
505  const cl_event* startEvents=NULL,
506  cl_event* endEvent=NULL) const {
507  return EvalStencils(srcBuffer->BindCLBuffer(_clCommandQueue), srcDesc,
508  dstBuffer->BindCLBuffer(_clCommandQueue), dstDesc,
509  stencilTable->GetSizesBuffer(),
510  stencilTable->GetOffsetsBuffer(),
511  stencilTable->GetIndicesBuffer(),
512  stencilTable->GetWeightsBuffer(),
513  0,
514  stencilTable->GetNumStencils(),
515  numStartEvents, startEvents, endEvent);
516  }
517 
560  template <typename SRC_BUFFER, typename DST_BUFFER, typename STENCIL_TABLE>
562  SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
563  DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
564  DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
565  DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
566  STENCIL_TABLE const *stencilTable,
567  unsigned int numStartEvents=0,
568  const cl_event* startEvents=NULL,
569  cl_event* endEvent=NULL) const {
570  return EvalStencils(srcBuffer->BindCLBuffer(_clCommandQueue), srcDesc,
571  dstBuffer->BindCLBuffer(_clCommandQueue), dstDesc,
572  duBuffer->BindCLBuffer(_clCommandQueue), duDesc,
573  dvBuffer->BindCLBuffer(_clCommandQueue), dvDesc,
574  stencilTable->GetSizesBuffer(),
575  stencilTable->GetOffsetsBuffer(),
576  stencilTable->GetIndicesBuffer(),
577  stencilTable->GetWeightsBuffer(),
578  stencilTable->GetDuWeightsBuffer(),
579  stencilTable->GetDvWeightsBuffer(),
580  0,
581  stencilTable->GetNumStencils(),
582  numStartEvents, startEvents, endEvent);
583  }
584 
645  template <typename SRC_BUFFER, typename DST_BUFFER, typename STENCIL_TABLE>
647  SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
648  DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
649  DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
650  DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
651  DST_BUFFER *duuBuffer, BufferDescriptor const &duuDesc,
652  DST_BUFFER *duvBuffer, BufferDescriptor const &duvDesc,
653  DST_BUFFER *dvvBuffer, BufferDescriptor const &dvvDesc,
654  STENCIL_TABLE const *stencilTable,
655  unsigned int numStartEvents=0,
656  const cl_event* startEvents=NULL,
657  cl_event* endEvent=NULL) const {
658  return EvalStencils(srcBuffer->BindCLBuffer(_clCommandQueue), srcDesc,
659  dstBuffer->BindCLBuffer(_clCommandQueue), dstDesc,
660  duBuffer->BindCLBuffer(_clCommandQueue), duDesc,
661  dvBuffer->BindCLBuffer(_clCommandQueue), dvDesc,
662  duuBuffer->BindCLBuffer(_clCommandQueue), duuDesc,
663  duvBuffer->BindCLBuffer(_clCommandQueue), duvDesc,
664  dvvBuffer->BindCLBuffer(_clCommandQueue), dvvDesc,
665  stencilTable->GetSizesBuffer(),
666  stencilTable->GetOffsetsBuffer(),
667  stencilTable->GetIndicesBuffer(),
668  stencilTable->GetWeightsBuffer(),
669  stencilTable->GetDuWeightsBuffer(),
670  stencilTable->GetDvWeightsBuffer(),
671  stencilTable->GetDuuWeightsBuffer(),
672  stencilTable->GetDuvWeightsBuffer(),
673  stencilTable->GetDvvWeightsBuffer(),
674  0,
675  stencilTable->GetNumStencils(),
676  numStartEvents, startEvents, endEvent);
677  }
678 
681  bool EvalStencils(cl_mem src, BufferDescriptor const &srcDesc,
682  cl_mem dst, BufferDescriptor const &dstDesc,
683  cl_mem sizes,
684  cl_mem offsets,
685  cl_mem indices,
686  cl_mem weights,
687  int start,
688  int end,
689  unsigned int numStartEvents=0,
690  const cl_event* startEvents=NULL,
691  cl_event* endEvent=NULL) const;
692 
741  bool EvalStencils(cl_mem src, BufferDescriptor const &srcDesc,
742  cl_mem dst, BufferDescriptor const &dstDesc,
743  cl_mem du, BufferDescriptor const &duDesc,
744  cl_mem dv, BufferDescriptor const &dvDesc,
745  cl_mem sizes,
746  cl_mem offsets,
747  cl_mem indices,
748  cl_mem weights,
749  cl_mem duWeights,
750  cl_mem dvWeights,
751  int start,
752  int end,
753  unsigned int numStartEvents=0,
754  const cl_event* startEvents=NULL,
755  cl_event* endEvent=NULL) const;
756 
823  bool EvalStencils(cl_mem src, BufferDescriptor const &srcDesc,
824  cl_mem dst, BufferDescriptor const &dstDesc,
825  cl_mem du, BufferDescriptor const &duDesc,
826  cl_mem dv, BufferDescriptor const &dvDesc,
827  cl_mem duu, BufferDescriptor const &duuDesc,
828  cl_mem duv, BufferDescriptor const &duvDesc,
829  cl_mem dvv, BufferDescriptor const &dvvDesc,
830  cl_mem sizes,
831  cl_mem offsets,
832  cl_mem indices,
833  cl_mem weights,
834  cl_mem duWeights,
835  cl_mem dvWeights,
836  cl_mem duuWeights,
837  cl_mem duvWeights,
838  cl_mem dvvWeights,
839  int start,
840  int end,
841  unsigned int numStartEvents=0,
842  const cl_event* startEvents=NULL,
843  cl_event* endEvent=NULL) const;
844 
850 
899  template <typename SRC_BUFFER, typename DST_BUFFER,
900  typename PATCHCOORD_BUFFER, typename PATCH_TABLE,
901  typename DEVICE_CONTEXT>
902  static bool EvalPatches(
903  SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
904  DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
905  int numPatchCoords,
906  PATCHCOORD_BUFFER *patchCoords,
907  PATCH_TABLE *patchTable,
908  CLEvaluator const *instance,
909  DEVICE_CONTEXT deviceContext,
910  unsigned int numStartEvents=0,
911  const cl_event* startEvents=NULL,
912  cl_event* endEvent=NULL) {
913 
914  if (instance) {
915  return instance->EvalPatches(srcBuffer, srcDesc,
916  dstBuffer, dstDesc,
917  numPatchCoords, patchCoords,
918  patchTable,
919  numStartEvents, startEvents, endEvent);
920  } else {
921  // Create an instance on demand (slow)
922  (void)deviceContext; // unused
923  instance = Create(srcDesc, dstDesc,
926  deviceContext);
927  if (instance) {
928  bool r = instance->EvalPatches(srcBuffer, srcDesc,
929  dstBuffer, dstDesc,
930  numPatchCoords, patchCoords,
931  patchTable,
932  numStartEvents, startEvents, endEvent);
933  delete instance;
934  return r;
935  }
936  return false;
937  }
938  }
939 
1000  template <typename SRC_BUFFER, typename DST_BUFFER,
1001  typename PATCHCOORD_BUFFER, typename PATCH_TABLE,
1002  typename DEVICE_CONTEXT>
1003  static bool EvalPatches(
1004  SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
1005  DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
1006  DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
1007  DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
1008  int numPatchCoords,
1009  PATCHCOORD_BUFFER *patchCoords,
1010  PATCH_TABLE *patchTable,
1011  CLEvaluator const *instance,
1012  DEVICE_CONTEXT deviceContext,
1013  unsigned int numStartEvents=0,
1014  const cl_event* startEvents=NULL,
1015  cl_event* endEvent=NULL) {
1016 
1017  if (instance) {
1018  return instance->EvalPatches(srcBuffer, srcDesc,
1019  dstBuffer, dstDesc,
1020  duBuffer, duDesc,
1021  dvBuffer, dvDesc,
1022  numPatchCoords, patchCoords,
1023  patchTable,
1024  numStartEvents, startEvents, endEvent);
1025  } else {
1026  // Create an instance on demand (slow)
1027  (void)deviceContext; // unused
1028  instance = Create(srcDesc, dstDesc, duDesc, dvDesc, deviceContext);
1029  if (instance) {
1030  bool r = instance->EvalPatches(srcBuffer, srcDesc,
1031  dstBuffer, dstDesc,
1032  duBuffer, duDesc,
1033  dvBuffer, dvDesc,
1034  numPatchCoords, patchCoords,
1035  patchTable,
1036  numStartEvents, startEvents, endEvent);
1037  delete instance;
1038  return r;
1039  }
1040  return false;
1041  }
1042  }
1043 
1122  template <typename SRC_BUFFER, typename DST_BUFFER,
1123  typename PATCHCOORD_BUFFER, typename PATCH_TABLE,
1124  typename DEVICE_CONTEXT>
1125  static bool EvalPatches(
1126  SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
1127  DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
1128  DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
1129  DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
1130  DST_BUFFER *duuBuffer, BufferDescriptor const &duuDesc,
1131  DST_BUFFER *duvBuffer, BufferDescriptor const &duvDesc,
1132  DST_BUFFER *dvvBuffer, BufferDescriptor const &dvvDesc,
1133  int numPatchCoords,
1134  PATCHCOORD_BUFFER *patchCoords,
1135  PATCH_TABLE *patchTable,
1136  CLEvaluator const *instance,
1137  DEVICE_CONTEXT deviceContext,
1138  unsigned int numStartEvents=0,
1139  const cl_event* startEvents=NULL,
1140  cl_event* endEvent=NULL) {
1141 
1142  if (instance) {
1143  return instance->EvalPatches(srcBuffer, srcDesc,
1144  dstBuffer, dstDesc,
1145  duBuffer, duDesc,
1146  dvBuffer, dvDesc,
1147  duuBuffer, duuDesc,
1148  duvBuffer, duvDesc,
1149  dvvBuffer, dvvDesc,
1150  numPatchCoords, patchCoords,
1151  patchTable,
1152  numStartEvents, startEvents, endEvent);
1153  } else {
1154  // Create an instance on demand (slow)
1155  (void)deviceContext; // unused
1156  instance = Create(srcDesc, dstDesc,
1157  duDesc, dvDesc,
1158  duuDesc, duvDesc, dvvDesc,
1159  deviceContext);
1160  if (instance) {
1161  bool r = instance->EvalPatches(srcBuffer, srcDesc,
1162  dstBuffer, dstDesc,
1163  duBuffer, duDesc,
1164  dvBuffer, dvDesc,
1165  duuBuffer, duuDesc,
1166  duvBuffer, duvDesc,
1167  dvvBuffer, dvvDesc,
1168  numPatchCoords, patchCoords,
1169  patchTable,
1170  numStartEvents, startEvents, endEvent);
1171  delete instance;
1172  return r;
1173  }
1174  return false;
1175  }
1176  }
1177 
1215  template <typename SRC_BUFFER, typename DST_BUFFER,
1216  typename PATCHCOORD_BUFFER, typename PATCH_TABLE>
1218  SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
1219  DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
1220  int numPatchCoords,
1221  PATCHCOORD_BUFFER *patchCoords,
1222  PATCH_TABLE *patchTable,
1223  unsigned int numStartEvents=0,
1224  const cl_event* startEvents=NULL,
1225  cl_event* endEvent=NULL) const {
1226 
1227  return EvalPatches(srcBuffer->BindCLBuffer(_clCommandQueue), srcDesc,
1228  dstBuffer->BindCLBuffer(_clCommandQueue), dstDesc,
1229  0, BufferDescriptor(),
1230  0, BufferDescriptor(),
1231  numPatchCoords,
1232  patchCoords->BindCLBuffer(_clCommandQueue),
1233  patchTable->GetPatchArrayBuffer(),
1234  patchTable->GetPatchIndexBuffer(),
1235  patchTable->GetPatchParamBuffer(),
1236  numStartEvents, startEvents, endEvent);
1237  }
1238 
1286  template <typename SRC_BUFFER, typename DST_BUFFER,
1287  typename PATCHCOORD_BUFFER, typename PATCH_TABLE>
1289  SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
1290  DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
1291  DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
1292  DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
1293  int numPatchCoords,
1294  PATCHCOORD_BUFFER *patchCoords,
1295  PATCH_TABLE *patchTable,
1296  unsigned int numStartEvents=0,
1297  const cl_event* startEvents=NULL,
1298  cl_event* endEvent=NULL) const {
1299 
1300  return EvalPatches(srcBuffer->BindCLBuffer(_clCommandQueue), srcDesc,
1301  dstBuffer->BindCLBuffer(_clCommandQueue), dstDesc,
1302  duBuffer->BindCLBuffer(_clCommandQueue), duDesc,
1303  dvBuffer->BindCLBuffer(_clCommandQueue), dvDesc,
1304  numPatchCoords,
1305  patchCoords->BindCLBuffer(_clCommandQueue),
1306  patchTable->GetPatchArrayBuffer(),
1307  patchTable->GetPatchIndexBuffer(),
1308  patchTable->GetPatchParamBuffer(),
1309  numStartEvents, startEvents, endEvent);
1310  }
1311 
1377  template <typename SRC_BUFFER, typename DST_BUFFER,
1378  typename PATCHCOORD_BUFFER, typename PATCH_TABLE>
1380  SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
1381  DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
1382  DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
1383  DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
1384  DST_BUFFER *duuBuffer, BufferDescriptor const &duuDesc,
1385  DST_BUFFER *duvBuffer, BufferDescriptor const &duvDesc,
1386  DST_BUFFER *dvvBuffer, BufferDescriptor const &dvvDesc,
1387  int numPatchCoords,
1388  PATCHCOORD_BUFFER *patchCoords,
1389  PATCH_TABLE *patchTable,
1390  unsigned int numStartEvents=0,
1391  const cl_event* startEvents=NULL,
1392  cl_event* endEvent=NULL) const {
1393 
1394  return EvalPatches(srcBuffer->BindCLBuffer(_clCommandQueue), srcDesc,
1395  dstBuffer->BindCLBuffer(_clCommandQueue), dstDesc,
1396  duBuffer->BindCLBuffer(_clCommandQueue), duDesc,
1397  dvBuffer->BindCLBuffer(_clCommandQueue), dvDesc,
1398  duuBuffer->BindCLBuffer(_clCommandQueue), duuDesc,
1399  duvBuffer->BindCLBuffer(_clCommandQueue), duvDesc,
1400  dvvBuffer->BindCLBuffer(_clCommandQueue), dvvDesc,
1401  numPatchCoords,
1402  patchCoords->BindCLBuffer(_clCommandQueue),
1403  patchTable->GetPatchArrayBuffer(),
1404  patchTable->GetPatchIndexBuffer(),
1405  patchTable->GetPatchParamBuffer(),
1406  numStartEvents, startEvents, endEvent);
1407  }
1408 
1409  bool EvalPatches(cl_mem src, BufferDescriptor const &srcDesc,
1410  cl_mem dst, BufferDescriptor const &dstDesc,
1411  cl_mem du, BufferDescriptor const &duDesc,
1412  cl_mem dv, BufferDescriptor const &dvDesc,
1413  int numPatchCoords,
1414  cl_mem patchCoordsBuffer,
1415  cl_mem patchArrayBuffer,
1416  cl_mem patchIndexBuffer,
1417  cl_mem patchParamsBuffer,
1418  unsigned int numStartEvents=0,
1419  const cl_event* startEvents=NULL,
1420  cl_event* endEvent=NULL) const;
1421 
1422  bool EvalPatches(cl_mem src, BufferDescriptor const &srcDesc,
1423  cl_mem dst, BufferDescriptor const &dstDesc,
1424  cl_mem du, BufferDescriptor const &duDesc,
1425  cl_mem dv, BufferDescriptor const &dvDesc,
1426  cl_mem duu, BufferDescriptor const &duuDesc,
1427  cl_mem duv, BufferDescriptor const &duvDesc,
1428  cl_mem dvv, BufferDescriptor const &dvvDesc,
1429  int numPatchCoords,
1430  cl_mem patchCoordsBuffer,
1431  cl_mem patchArrayBuffer,
1432  cl_mem patchIndexBuffer,
1433  cl_mem patchParamsBuffer,
1434  unsigned int numStartEvents=0,
1435  const cl_event* startEvents=NULL,
1436  cl_event* endEvent=NULL) const;
1437 
1486  template <typename SRC_BUFFER, typename DST_BUFFER,
1487  typename PATCHCOORD_BUFFER, typename PATCH_TABLE,
1488  typename DEVICE_CONTEXT>
1489  static bool EvalPatchesVarying(
1490  SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
1491  DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
1492  int numPatchCoords,
1493  PATCHCOORD_BUFFER *patchCoords,
1494  PATCH_TABLE *patchTable,
1495  CLEvaluator const *instance,
1496  DEVICE_CONTEXT deviceContext,
1497  unsigned int numStartEvents=0,
1498  const cl_event* startEvents=NULL,
1499  cl_event* endEvent=NULL) {
1500 
1501  if (instance) {
1502  return instance->EvalPatchesVarying(
1503  srcBuffer, srcDesc,
1504  dstBuffer, dstDesc,
1505  numPatchCoords, patchCoords,
1506  patchTable,
1507  numStartEvents, startEvents, endEvent);
1508  } else {
1509  // Create an instance on demand (slow)
1510  (void)deviceContext; // unused
1511  instance = Create(srcDesc, dstDesc,
1512  BufferDescriptor(),
1513  BufferDescriptor(),
1514  deviceContext);
1515  if (instance) {
1516  bool r = instance->EvalPatchesVarying(
1517  srcBuffer, srcDesc,
1518  dstBuffer, dstDesc,
1519  numPatchCoords, patchCoords,
1520  patchTable,
1521  numStartEvents, startEvents, endEvent);
1522  delete instance;
1523  return r;
1524  }
1525  return false;
1526  }
1527  }
1528 
1566  template <typename SRC_BUFFER, typename DST_BUFFER,
1567  typename PATCHCOORD_BUFFER, typename PATCH_TABLE>
1569  SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
1570  DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
1571  int numPatchCoords,
1572  PATCHCOORD_BUFFER *patchCoords,
1573  PATCH_TABLE *patchTable,
1574  unsigned int numStartEvents=0,
1575  const cl_event* startEvents=NULL,
1576  cl_event* endEvent=NULL) const {
1577 
1578  return EvalPatches(srcBuffer->BindCLBuffer(_clCommandQueue), srcDesc,
1579  dstBuffer->BindCLBuffer(_clCommandQueue), dstDesc,
1580  0, BufferDescriptor(),
1581  0, BufferDescriptor(),
1582  numPatchCoords,
1583  patchCoords->BindCLBuffer(_clCommandQueue),
1584  patchTable->GetVaryingPatchArrayBuffer(),
1585  patchTable->GetVaryingPatchIndexBuffer(),
1586  patchTable->GetPatchParamBuffer(),
1587  numStartEvents, startEvents, endEvent);
1588  }
1589 
1650  template <typename SRC_BUFFER, typename DST_BUFFER,
1651  typename PATCHCOORD_BUFFER, typename PATCH_TABLE,
1652  typename DEVICE_CONTEXT>
1653  static bool EvalPatchesVarying(
1654  SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
1655  DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
1656  DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
1657  DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
1658  int numPatchCoords,
1659  PATCHCOORD_BUFFER *patchCoords,
1660  PATCH_TABLE *patchTable,
1661  CLEvaluator const *instance,
1662  DEVICE_CONTEXT deviceContext,
1663  unsigned int numStartEvents=0,
1664  const cl_event* startEvents=NULL,
1665  cl_event* endEvent=NULL) {
1666 
1667  if (instance) {
1668  return instance->EvalPatchesVarying(
1669  srcBuffer, srcDesc,
1670  dstBuffer, dstDesc,
1671  duBuffer, duDesc,
1672  dvBuffer, dvDesc,
1673  numPatchCoords, patchCoords,
1674  patchTable,
1675  numStartEvents, startEvents, endEvent);
1676  } else {
1677  // Create an instance on demand (slow)
1678  (void)deviceContext; // unused
1679  instance = Create(srcDesc, dstDesc,
1680  duDesc, dvDesc,
1681  deviceContext);
1682  if (instance) {
1683  bool r = instance->EvalPatchesVarying(
1684  srcBuffer, srcDesc,
1685  dstBuffer, dstDesc,
1686  duBuffer, duDesc,
1687  dvBuffer, dvDesc,
1688  numPatchCoords, patchCoords,
1689  patchTable,
1690  numStartEvents, startEvents, endEvent);
1691  delete instance;
1692  return r;
1693  }
1694  return false;
1695  }
1696  }
1697 
1747  template <typename SRC_BUFFER, typename DST_BUFFER,
1748  typename PATCHCOORD_BUFFER, typename PATCH_TABLE>
1750  SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
1751  DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
1752  DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
1753  DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
1754  int numPatchCoords,
1755  PATCHCOORD_BUFFER *patchCoords,
1756  PATCH_TABLE *patchTable,
1757  unsigned int numStartEvents=0,
1758  const cl_event* startEvents=NULL,
1759  cl_event* endEvent=NULL) const {
1760 
1761  return EvalPatches(srcBuffer->BindCLBuffer(_clCommandQueue), srcDesc,
1762  dstBuffer->BindCLBuffer(_clCommandQueue), dstDesc,
1763  duBuffer->BindCLBuffer(_clCommandQueue), duDesc,
1764  dvBuffer->BindCLBuffer(_clCommandQueue), dvDesc,
1765  numPatchCoords,
1766  patchCoords->BindCLBuffer(_clCommandQueue),
1767  patchTable->GetVaryingPatchArrayBuffer(),
1768  patchTable->GetVaryingPatchIndexBuffer(),
1769  patchTable->GetPatchParamBuffer(),
1770  numStartEvents, startEvents, endEvent);
1771  }
1772 
1851  template <typename SRC_BUFFER, typename DST_BUFFER,
1852  typename PATCHCOORD_BUFFER, typename PATCH_TABLE,
1853  typename DEVICE_CONTEXT>
1854  static bool EvalPatchesVarying(
1855  SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
1856  DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
1857  DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
1858  DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
1859  DST_BUFFER *duuBuffer, BufferDescriptor const &duuDesc,
1860  DST_BUFFER *duvBuffer, BufferDescriptor const &duvDesc,
1861  DST_BUFFER *dvvBuffer, BufferDescriptor const &dvvDesc,
1862  int numPatchCoords,
1863  PATCHCOORD_BUFFER *patchCoords,
1864  PATCH_TABLE *patchTable,
1865  CLEvaluator const *instance,
1866  DEVICE_CONTEXT deviceContext,
1867  unsigned int numStartEvents=0,
1868  const cl_event* startEvents=NULL,
1869  cl_event* endEvent=NULL) {
1870 
1871  if (instance) {
1872  return instance->EvalPatchesVarying(
1873  srcBuffer, srcDesc,
1874  dstBuffer, dstDesc,
1875  duBuffer, duDesc,
1876  dvBuffer, dvDesc,
1877  duuBuffer, duuDesc,
1878  duvBuffer, duvDesc,
1879  dvvBuffer, dvvDesc,
1880  numPatchCoords, patchCoords,
1881  patchTable,
1882  numStartEvents, startEvents, endEvent);
1883  } else {
1884  // Create an instance on demand (slow)
1885  (void)deviceContext; // unused
1886  instance = Create(srcDesc, dstDesc,
1887  duDesc, dvDesc,
1888  duuDesc, duvDesc, dvvDesc,
1889  deviceContext);
1890  if (instance) {
1891  bool r = instance->EvalPatchesVarying(
1892  srcBuffer, srcDesc,
1893  dstBuffer, dstDesc,
1894  duBuffer, duDesc,
1895  dvBuffer, dvDesc,
1896  duuBuffer, duuDesc,
1897  duvBuffer, duvDesc,
1898  dvvBuffer, dvvDesc,
1899  numPatchCoords, patchCoords,
1900  patchTable,
1901  numStartEvents, startEvents, endEvent);
1902  delete instance;
1903  return r;
1904  }
1905  return false;
1906  }
1907  }
1908 
1976  template <typename SRC_BUFFER, typename DST_BUFFER,
1977  typename PATCHCOORD_BUFFER, typename PATCH_TABLE>
1979  SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
1980  DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
1981  DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
1982  DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
1983  DST_BUFFER *duuBuffer, BufferDescriptor const &duuDesc,
1984  DST_BUFFER *duvBuffer, BufferDescriptor const &duvDesc,
1985  DST_BUFFER *dvvBuffer, BufferDescriptor const &dvvDesc,
1986  int numPatchCoords,
1987  PATCHCOORD_BUFFER *patchCoords,
1988  PATCH_TABLE *patchTable,
1989  unsigned int numStartEvents=0,
1990  const cl_event* startEvents=NULL,
1991  cl_event* endEvent=NULL) const {
1992 
1993  return EvalPatches(srcBuffer->BindCLBuffer(_clCommandQueue), srcDesc,
1994  dstBuffer->BindCLBuffer(_clCommandQueue), dstDesc,
1995  duBuffer->BindCLBuffer(_clCommandQueue), duDesc,
1996  dvBuffer->BindCLBuffer(_clCommandQueue), dvDesc,
1997  duuBuffer->BindCLBuffer(_clCommandQueue), duuDesc,
1998  duvBuffer->BindCLBuffer(_clCommandQueue), duvDesc,
1999  dvvBuffer->BindCLBuffer(_clCommandQueue), dvvDesc,
2000  numPatchCoords,
2001  patchCoords->BindCLBuffer(_clCommandQueue),
2002  patchTable->GetVaryingPatchArrayBuffer(),
2003  patchTable->GetVaryingPatchIndexBuffer(),
2004  patchTable->GetPatchParamBuffer(),
2005  numStartEvents, startEvents, endEvent);
2006  }
2007 
2058  template <typename SRC_BUFFER, typename DST_BUFFER,
2059  typename PATCHCOORD_BUFFER, typename PATCH_TABLE,
2060  typename DEVICE_CONTEXT>
2062  SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
2063  DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
2064  int numPatchCoords,
2065  PATCHCOORD_BUFFER *patchCoords,
2066  PATCH_TABLE *patchTable,
2067  int fvarChannel,
2068  CLEvaluator const *instance,
2069  DEVICE_CONTEXT deviceContext,
2070  unsigned int numStartEvents=0,
2071  const cl_event* startEvents=NULL,
2072  cl_event* endEvent=NULL) {
2073 
2074  if (instance) {
2075  return instance->EvalPatchesFaceVarying(
2076  srcBuffer, srcDesc,
2077  dstBuffer, dstDesc,
2078  numPatchCoords, patchCoords,
2079  patchTable, fvarChannel,
2080  numStartEvents, startEvents, endEvent);
2081  } else {
2082  // Create an instance on demand (slow)
2083  (void)deviceContext; // unused
2084  instance = Create(srcDesc, dstDesc,
2085  BufferDescriptor(),
2086  BufferDescriptor(),
2087  deviceContext);
2088  if (instance) {
2089  bool r = instance->EvalPatchesFaceVarying(
2090  srcBuffer, srcDesc,
2091  dstBuffer, dstDesc,
2092  numPatchCoords, patchCoords,
2093  patchTable, fvarChannel,
2094  numStartEvents, startEvents, endEvent);
2095  delete instance;
2096  return r;
2097  }
2098  return false;
2099  }
2100  }
2101 
2141  template <typename SRC_BUFFER, typename DST_BUFFER,
2142  typename PATCHCOORD_BUFFER, typename PATCH_TABLE>
2144  SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
2145  DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
2146  int numPatchCoords,
2147  PATCHCOORD_BUFFER *patchCoords,
2148  PATCH_TABLE *patchTable,
2149  int fvarChannel = 0,
2150  unsigned int numStartEvents=0,
2151  const cl_event* startEvents=NULL,
2152  cl_event* endEvent=NULL) const {
2153 
2154  return EvalPatches(srcBuffer->BindCLBuffer(_clCommandQueue), srcDesc,
2155  dstBuffer->BindCLBuffer(_clCommandQueue), dstDesc,
2156  0, BufferDescriptor(),
2157  0, BufferDescriptor(),
2158  numPatchCoords,
2159  patchCoords->BindCLBuffer(_clCommandQueue),
2160  patchTable->GetFVarPatchArrayBuffer(fvarChannel),
2161  patchTable->GetFVarPatchIndexBuffer(fvarChannel),
2162  patchTable->GetFVarPatchParamBuffer(fvarChannel),
2163  numStartEvents, startEvents, endEvent);
2164  }
2165 
2228  template <typename SRC_BUFFER, typename DST_BUFFER,
2229  typename PATCHCOORD_BUFFER, typename PATCH_TABLE,
2230  typename DEVICE_CONTEXT>
2232  SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
2233  DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
2234  DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
2235  DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
2236  int numPatchCoords,
2237  PATCHCOORD_BUFFER *patchCoords,
2238  PATCH_TABLE *patchTable,
2239  int fvarChannel,
2240  CLEvaluator const *instance,
2241  DEVICE_CONTEXT deviceContext,
2242  unsigned int numStartEvents=0,
2243  const cl_event* startEvents=NULL,
2244  cl_event* endEvent=NULL) {
2245 
2246  if (instance) {
2247  return instance->EvalPatchesFaceVarying(
2248  srcBuffer, srcDesc,
2249  dstBuffer, dstDesc,
2250  duBuffer, duDesc,
2251  dvBuffer, dvDesc,
2252  numPatchCoords, patchCoords,
2253  patchTable, fvarChannel,
2254  numStartEvents, startEvents, endEvent);
2255  } else {
2256  // Create an instance on demand (slow)
2257  (void)deviceContext; // unused
2258  instance = Create(srcDesc, dstDesc,
2259  duDesc, dvDesc, deviceContext);
2260  if (instance) {
2261  bool r = instance->EvalPatchesFaceVarying(
2262  srcBuffer, srcDesc,
2263  dstBuffer, dstDesc,
2264  duBuffer, duDesc,
2265  dvBuffer, dvDesc,
2266  numPatchCoords, patchCoords,
2267  patchTable, fvarChannel,
2268  numStartEvents, startEvents, endEvent);
2269  delete instance;
2270  return r;
2271  }
2272  return false;
2273  }
2274  }
2275 
2327  template <typename SRC_BUFFER, typename DST_BUFFER,
2328  typename PATCHCOORD_BUFFER, typename PATCH_TABLE>
2330  SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
2331  DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
2332  DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
2333  DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
2334  int numPatchCoords,
2335  PATCHCOORD_BUFFER *patchCoords,
2336  PATCH_TABLE *patchTable,
2337  int fvarChannel = 0,
2338  unsigned int numStartEvents=0,
2339  const cl_event* startEvents=NULL,
2340  cl_event* endEvent=NULL) const {
2341 
2342  return EvalPatches(srcBuffer->BindCLBuffer(_clCommandQueue), srcDesc,
2343  dstBuffer->BindCLBuffer(_clCommandQueue), dstDesc,
2344  duBuffer->BindCLBuffer(_clCommandQueue), duDesc,
2345  dvBuffer->BindCLBuffer(_clCommandQueue), dvDesc,
2346  numPatchCoords,
2347  patchCoords->BindCLBuffer(_clCommandQueue),
2348  patchTable->GetFVarPatchArrayBuffer(fvarChannel),
2349  patchTable->GetFVarPatchIndexBuffer(fvarChannel),
2350  patchTable->GetFVarPatchParamBuffer(fvarChannel),
2351  numStartEvents, startEvents, endEvent);
2352  }
2353 
2434  template <typename SRC_BUFFER, typename DST_BUFFER,
2435  typename PATCHCOORD_BUFFER, typename PATCH_TABLE,
2436  typename DEVICE_CONTEXT>
2438  SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
2439  DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
2440  DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
2441  DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
2442  DST_BUFFER *duuBuffer, BufferDescriptor const &duuDesc,
2443  DST_BUFFER *duvBuffer, BufferDescriptor const &duvDesc,
2444  DST_BUFFER *dvvBuffer, BufferDescriptor const &dvvDesc,
2445  int numPatchCoords,
2446  PATCHCOORD_BUFFER *patchCoords,
2447  PATCH_TABLE *patchTable,
2448  int fvarChannel,
2449  CLEvaluator const *instance,
2450  DEVICE_CONTEXT deviceContext,
2451  unsigned int numStartEvents=0,
2452  const cl_event* startEvents=NULL,
2453  cl_event* endEvent=NULL) {
2454 
2455  if (instance) {
2456  return instance->EvalPatchesFaceVarying(
2457  srcBuffer, srcDesc,
2458  dstBuffer, dstDesc,
2459  duBuffer, duDesc,
2460  dvBuffer, dvDesc,
2461  duuBuffer, duuDesc,
2462  duvBuffer, duvDesc,
2463  dvvBuffer, dvvDesc,
2464  numPatchCoords, patchCoords,
2465  patchTable, fvarChannel,
2466  numStartEvents, startEvents, endEvent);
2467  } else {
2468  // Create an instance on demand (slow)
2469  (void)deviceContext; // unused
2470  instance = Create(srcDesc, dstDesc,
2471  duDesc, dvDesc,
2472  duuDesc, duvDesc, dvvDesc,
2473  deviceContext);
2474  if (instance) {
2475  bool r = instance->EvalPatchesFaceVarying(
2476  srcBuffer, srcDesc,
2477  dstBuffer, dstDesc,
2478  duBuffer, duDesc,
2479  dvBuffer, dvDesc,
2480  duuBuffer, duuDesc,
2481  duvBuffer, duvDesc,
2482  dvvBuffer, dvvDesc,
2483  numPatchCoords, patchCoords,
2484  patchTable, fvarChannel,
2485  numStartEvents, startEvents, endEvent);
2486  delete instance;
2487  return r;
2488  }
2489  return false;
2490  }
2491  }
2492 
2562  template <typename SRC_BUFFER, typename DST_BUFFER,
2563  typename PATCHCOORD_BUFFER, typename PATCH_TABLE>
2565  SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
2566  DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
2567  DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
2568  DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
2569  DST_BUFFER *duuBuffer, BufferDescriptor const &duuDesc,
2570  DST_BUFFER *duvBuffer, BufferDescriptor const &duvDesc,
2571  DST_BUFFER *dvvBuffer, BufferDescriptor const &dvvDesc,
2572  int numPatchCoords,
2573  PATCHCOORD_BUFFER *patchCoords,
2574  PATCH_TABLE *patchTable,
2575  int fvarChannel = 0,
2576  unsigned int numStartEvents=0,
2577  const cl_event* startEvents=NULL,
2578  cl_event* endEvent=NULL) const {
2579 
2580  return EvalPatches(srcBuffer->BindCLBuffer(_clCommandQueue), srcDesc,
2581  dstBuffer->BindCLBuffer(_clCommandQueue), dstDesc,
2582  duBuffer->BindCLBuffer(_clCommandQueue), duDesc,
2583  dvBuffer->BindCLBuffer(_clCommandQueue), dvDesc,
2584  duuBuffer->BindCLBuffer(_clCommandQueue), duuDesc,
2585  duvBuffer->BindCLBuffer(_clCommandQueue), duvDesc,
2586  dvvBuffer->BindCLBuffer(_clCommandQueue), dvvDesc,
2587  numPatchCoords,
2588  patchCoords->BindCLBuffer(_clCommandQueue),
2589  patchTable->GetFVarPatchArrayBuffer(fvarChannel),
2590  patchTable->GetFVarPatchIndexBuffer(fvarChannel),
2591  patchTable->GetFVarPatchParamBuffer(fvarChannel),
2592  numStartEvents, startEvents, endEvent);
2593  }
2594 
2600 
2603  bool Compile(BufferDescriptor const &srcDesc,
2604  BufferDescriptor const &dstDesc,
2605  BufferDescriptor const &duDesc = BufferDescriptor(),
2606  BufferDescriptor const &dvDesc = BufferDescriptor(),
2607  BufferDescriptor const &duuDesc = BufferDescriptor(),
2608  BufferDescriptor const &duvDesc = BufferDescriptor(),
2609  BufferDescriptor const &dvvDesc = BufferDescriptor());
2610 
2612  template <typename DEVICE_CONTEXT>
2613  static void Synchronize(DEVICE_CONTEXT deviceContext) {
2614  Synchronize(deviceContext->GetCommandQueue());
2615  }
2616 
2617  static void Synchronize(cl_command_queue queue);
2618 
2619 private:
2620  cl_context _clContext;
2621  cl_command_queue _clCommandQueue;
2622  cl_program _program;
2623  cl_kernel _stencilKernel;
2624  cl_kernel _stencilDerivKernel;
2625  cl_kernel _patchKernel;
2626 };
2627 
2628 } // end namespace Osd
2629 
2630 } // end namespace OPENSUBDIV_VERSION
2631 using namespace OPENSUBDIV_VERSION;
2632 
2633 } // end namespace OpenSubdiv
2634 
2635 
2636 #endif // OPENSUBDIV3_OSD_CL_EVALUATOR_H
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, DST_BUFFER *duuBuffer, BufferDescriptor const &duuDesc, DST_BUFFER *duvBuffer, BufferDescriptor const &duvDesc, DST_BUFFER *dvvBuffer, BufferDescriptor const &dvvDesc, int numPatchCoords, PATCHCOORD_BUFFER *patchCoords, PATCH_TABLE *patchTable, CLEvaluator const *instance, DEVICE_CONTEXT deviceContext, unsigned int numStartEvents=0, const cl_event *startEvents=NULL, cl_event *endEvent=NULL)
Generic limit eval function. This function has a same signature as other device kernels have so that ...
Definition: clEvaluator.h:1125
static bool EvalPatchesFaceVarying(SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc, DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc, int numPatchCoords, PATCHCOORD_BUFFER *patchCoords, PATCH_TABLE *patchTable, int fvarChannel, CLEvaluator const *instance, DEVICE_CONTEXT deviceContext, unsigned int numStartEvents=0, const cl_event *startEvents=NULL, cl_event *endEvent=NULL)
Generic limit eval function. This function has a same signature as other device kernels have so that ...
Definition: clEvaluator.h:2061
static CLStencilTable * Create(Far::LimitStencilTable const *limitStencilTable, DEVICE_CONTEXT context)
Definition: clEvaluator.h:61
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, unsigned int numStartEvents=0, const cl_event *startEvents=NULL, cl_event *endEvent=NULL)
Generic limit eval function. This function has a same signature as other device kernels have so that ...
Definition: clEvaluator.h:902
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, unsigned int numStartEvents=0, const cl_event *startEvents=NULL, cl_event *endEvent=NULL)
Generic static stencil function. This function has a same signature as other device kernels have so t...
Definition: clEvaluator.h:219
static CLEvaluator * Create(BufferDescriptor const &srcDesc, BufferDescriptor const &dstDesc, BufferDescriptor const &duDesc, BufferDescriptor const &dvDesc, DEVICE_CONTEXT deviceContext)
Generic creator template.
Definition: clEvaluator.h:106
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 EvalPatchesVarying(SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc, DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc, int numPatchCoords, PATCHCOORD_BUFFER *patchCoords, PATCH_TABLE *patchTable, unsigned int numStartEvents=0, const cl_event *startEvents=NULL, cl_event *endEvent=NULL) const
Generic limit eval function. This function has a same signature as other device kernels have so that ...
Definition: clEvaluator.h:1568
static bool EvalPatchesFaceVarying(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, int fvarChannel, CLEvaluator const *instance, DEVICE_CONTEXT deviceContext, unsigned int numStartEvents=0, const cl_event *startEvents=NULL, cl_event *endEvent=NULL)
Generic limit eval function. This function has a same signature as other device kernels have so that ...
Definition: clEvaluator.h:2231
Limit stencil table class wrapping the template for compatibility.
Definition: stencilTable.h:583
bool Compile(BufferDescriptor const &srcDesc, BufferDescriptor const &dstDesc, BufferDescriptor const &duDesc=BufferDescriptor(), BufferDescriptor const &dvDesc=BufferDescriptor(), BufferDescriptor const &duuDesc=BufferDescriptor(), BufferDescriptor const &duvDesc=BufferDescriptor(), BufferDescriptor const &dvvDesc=BufferDescriptor())
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, unsigned int numStartEvents=0, const cl_event *startEvents=NULL, cl_event *endEvent=NULL)
Generic limit eval function. This function has a same signature as other device kernels have so that ...
Definition: clEvaluator.h:1003
static CLEvaluator * Create(BufferDescriptor const &srcDesc, BufferDescriptor const &dstDesc, BufferDescriptor const &duDesc, BufferDescriptor const &dvDesc, BufferDescriptor const &duuDesc, BufferDescriptor const &duvDesc, BufferDescriptor const &dvvDesc, DEVICE_CONTEXT deviceContext)
Generic creator template.
Definition: clEvaluator.h:131
bool EvalPatchesFaceVarying(SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc, DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc, DST_BUFFER *duBuffer, BufferDescriptor const &duDesc, DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc, DST_BUFFER *duuBuffer, BufferDescriptor const &duuDesc, DST_BUFFER *duvBuffer, BufferDescriptor const &duvDesc, DST_BUFFER *dvvBuffer, BufferDescriptor const &dvvDesc, int numPatchCoords, PATCHCOORD_BUFFER *patchCoords, PATCH_TABLE *patchTable, int fvarChannel=0, unsigned int numStartEvents=0, const cl_event *startEvents=NULL, cl_event *endEvent=NULL) const
Generic limit eval function. This function has a same signature as other device kernels have so that ...
Definition: clEvaluator.h:2564
bool EvalPatchesVarying(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, unsigned int numStartEvents=0, const cl_event *startEvents=NULL, cl_event *endEvent=NULL) const
Generic limit eval function. This function has a same signature as other device kernels have so that ...
Definition: clEvaluator.h:1749
static bool EvalPatchesVarying(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, unsigned int numStartEvents=0, const cl_event *startEvents=NULL, cl_event *endEvent=NULL)
Generic limit eval function. This function has a same signature as other device kernels have so that ...
Definition: clEvaluator.h:1489
static bool EvalPatchesVarying(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, unsigned int numStartEvents=0, const cl_event *startEvents=NULL, cl_event *endEvent=NULL)
Generic limit eval function. This function has a same signature as other device kernels have so that ...
Definition: clEvaluator.h:1653
static CLEvaluator * Create(BufferDescriptor const &srcDesc, BufferDescriptor const &dstDesc, BufferDescriptor const &duDesc, BufferDescriptor const &dvDesc, BufferDescriptor const &duuDesc, BufferDescriptor const &duvDesc, BufferDescriptor const &dvvDesc, cl_context clContext, cl_command_queue clCommandQueue)
Definition: clEvaluator.h:145
static CLStencilTable * Create(Far::StencilTable const *stencilTable, DEVICE_CONTEXT context)
Definition: clEvaluator.h:55
static void Synchronize(DEVICE_CONTEXT deviceContext)
Wait the OpenCL kernels finish.
Definition: clEvaluator.h:2613
static bool EvalPatchesVarying(SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc, DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc, DST_BUFFER *duBuffer, BufferDescriptor const &duDesc, DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc, DST_BUFFER *duuBuffer, BufferDescriptor const &duuDesc, DST_BUFFER *duvBuffer, BufferDescriptor const &duvDesc, DST_BUFFER *dvvBuffer, BufferDescriptor const &dvvDesc, int numPatchCoords, PATCHCOORD_BUFFER *patchCoords, PATCH_TABLE *patchTable, CLEvaluator const *instance, DEVICE_CONTEXT deviceContext, unsigned int numStartEvents=0, const cl_event *startEvents=NULL, cl_event *endEvent=NULL)
Generic limit eval function. This function has a same signature as other device kernels have so that ...
Definition: clEvaluator.h:1854
bool EvalPatchesVarying(SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc, DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc, DST_BUFFER *duBuffer, BufferDescriptor const &duDesc, DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc, DST_BUFFER *duuBuffer, BufferDescriptor const &duuDesc, DST_BUFFER *duvBuffer, BufferDescriptor const &duvDesc, DST_BUFFER *dvvBuffer, BufferDescriptor const &dvvDesc, int numPatchCoords, PATCHCOORD_BUFFER *patchCoords, PATCH_TABLE *patchTable, unsigned int numStartEvents=0, const cl_event *startEvents=NULL, cl_event *endEvent=NULL) const
Generic limit eval function. This function has a same signature as other device kernels have so that ...
Definition: clEvaluator.h:1978
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, unsigned int numStartEvents=0, const cl_event *startEvents=NULL, cl_event *endEvent=NULL)
Generic static stencil function. This function has a same signature as other device kernels have so t...
Definition: clEvaluator.h:309
static CLEvaluator * Create(BufferDescriptor const &srcDesc, BufferDescriptor const &dstDesc, BufferDescriptor const &duDesc, BufferDescriptor const &dvDesc, cl_context clContext, cl_command_queue clCommandQueue)
Definition: clEvaluator.h:116
CLStencilTable(Far::StencilTable const *stencilTable, cl_context clContext)
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, DST_BUFFER *duuBuffer, BufferDescriptor const &duuDesc, DST_BUFFER *duvBuffer, BufferDescriptor const &duvDesc, DST_BUFFER *dvvBuffer, BufferDescriptor const &dvvDesc, STENCIL_TABLE const *stencilTable, CLEvaluator const *instance, DEVICE_CONTEXT deviceContext, unsigned int numStartEvents=0, const cl_event *startEvents=NULL, cl_event *endEvent=NULL)
Generic static stencil function. This function has a same signature as other device kernels have so t...
Definition: clEvaluator.h:421
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, DST_BUFFER *duuBuffer, BufferDescriptor const &duuDesc, DST_BUFFER *duvBuffer, BufferDescriptor const &duvDesc, DST_BUFFER *dvvBuffer, BufferDescriptor const &dvvDesc, STENCIL_TABLE const *stencilTable, unsigned int numStartEvents=0, const cl_event *startEvents=NULL, cl_event *endEvent=NULL) const
Generic stencil function.
Definition: clEvaluator.h:646
bool EvalStencils(SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc, DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc, STENCIL_TABLE const *stencilTable, unsigned int numStartEvents=0, const cl_event *startEvents=NULL, cl_event *endEvent=NULL) const
Generic stencil function.
Definition: clEvaluator.h:500
bool EvalPatchesFaceVarying(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, int fvarChannel=0, unsigned int numStartEvents=0, const cl_event *startEvents=NULL, cl_event *endEvent=NULL) const
Generic limit eval function. This function has a same signature as other device kernels have so that ...
Definition: clEvaluator.h:2329
bool EvalPatches(SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc, DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc, int numPatchCoords, PATCHCOORD_BUFFER *patchCoords, PATCH_TABLE *patchTable, unsigned int numStartEvents=0, const cl_event *startEvents=NULL, cl_event *endEvent=NULL) const
Generic limit eval function. This function has a same signature as other device kernels have so that ...
Definition: clEvaluator.h:1217
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, DST_BUFFER *duuBuffer, BufferDescriptor const &duuDesc, DST_BUFFER *duvBuffer, BufferDescriptor const &duvDesc, DST_BUFFER *dvvBuffer, BufferDescriptor const &dvvDesc, int numPatchCoords, PATCHCOORD_BUFFER *patchCoords, PATCH_TABLE *patchTable, unsigned int numStartEvents=0, const cl_event *startEvents=NULL, cl_event *endEvent=NULL) const
Generic limit eval function with derivatives. This function has a same signature as other device kern...
Definition: clEvaluator.h:1379
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, unsigned int numStartEvents=0, const cl_event *startEvents=NULL, cl_event *endEvent=NULL) const
Generic limit eval function with derivatives. This function has a same signature as other device kern...
Definition: clEvaluator.h:1288
Stencil table class wrapping the template for compatibility.
Definition: stencilTable.h:273
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, unsigned int numStartEvents=0, const cl_event *startEvents=NULL, cl_event *endEvent=NULL) const
Generic stencil function.
Definition: clEvaluator.h:561
static bool EvalPatchesFaceVarying(SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc, DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc, DST_BUFFER *duBuffer, BufferDescriptor const &duDesc, DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc, DST_BUFFER *duuBuffer, BufferDescriptor const &duuDesc, DST_BUFFER *duvBuffer, BufferDescriptor const &duvDesc, DST_BUFFER *dvvBuffer, BufferDescriptor const &dvvDesc, int numPatchCoords, PATCHCOORD_BUFFER *patchCoords, PATCH_TABLE *patchTable, int fvarChannel, CLEvaluator const *instance, DEVICE_CONTEXT deviceContext, unsigned int numStartEvents=0, const cl_event *startEvents=NULL, cl_event *endEvent=NULL)
Generic limit eval function. This function has a same signature as other device kernels have so that ...
Definition: clEvaluator.h:2437
bool EvalPatchesFaceVarying(SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc, DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc, int numPatchCoords, PATCHCOORD_BUFFER *patchCoords, PATCH_TABLE *patchTable, int fvarChannel=0, unsigned int numStartEvents=0, const cl_event *startEvents=NULL, cl_event *endEvent=NULL) const
Generic limit eval function. This function has a same signature as other device kernels have so that ...
Definition: clEvaluator.h:2143