OpenSubdiv
Loading...
Searching...
No Matches
mtlComputeEvaluator.h
Go to the documentation of this file.
1//
2// Copyright 2013 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_MTL_COMPUTE_EVALUATOR_H
26#define OPENSUBDIV3_OSD_MTL_COMPUTE_EVALUATOR_H
27
28#include "../version.h"
29
30#include "../osd/types.h"
31#include "../osd/bufferDescriptor.h"
32#include "../osd/mtlCommon.h"
33
34@protocol MTLDevice;
35@protocol MTLBuffer;
36@protocol MTLLibrary;
37@protocol MTLComputePipelineState;
38
39namespace OpenSubdiv {
40namespace OPENSUBDIV_VERSION {
41
42namespace Far {
43 class PatchTable;
44 class StencilTable;
45 class LimitStencilTable;
46}
47
48namespace Osd {
49
51{
52public:
53 template<typename STENCIL_TABLE, typename DEVICE_CONTEXT>
54 static MTLStencilTable* Create(STENCIL_TABLE* stencilTable,
55 DEVICE_CONTEXT context)
56 {
57 return new MTLStencilTable(stencilTable, context);
58 }
59
60
61 MTLStencilTable(Far::StencilTable const* stencilTable, MTLContext* context);
62 MTLStencilTable(Far::LimitStencilTable const* stencilTable, MTLContext* context);
64
65 id<MTLBuffer> GetSizesBuffer() const { return _sizesBuffer; }
66 id<MTLBuffer> GetOffsetsBuffer() const { return _offsetsBuffer; }
67 id<MTLBuffer> GetIndicesBuffer() const { return _indicesBuffer; }
68 id<MTLBuffer> GetWeightsBuffer() const { return _weightsBuffer; }
69 id<MTLBuffer> GetDuWeightsBuffer() const { return _duWeightsBuffer; }
70 id<MTLBuffer> GetDvWeightsBuffer() const { return _dvWeightsBuffer; }
71 id<MTLBuffer> GetDuuWeightsBuffer() const { return _duuWeightsBuffer; }
72 id<MTLBuffer> GetDuvWeightsBuffer() const { return _duvWeightsBuffer; }
73 id<MTLBuffer> GetDvvWeightsBuffer() const { return _dvvWeightsBuffer; }
74
75 int GetNumStencils() const { return _numStencils; }
76
77private:
78 id<MTLBuffer> _sizesBuffer;
79 id<MTLBuffer> _offsetsBuffer;
80 id<MTLBuffer> _indicesBuffer;
81 id<MTLBuffer> _weightsBuffer;
82 id<MTLBuffer> _duWeightsBuffer;
83 id<MTLBuffer> _dvWeightsBuffer;
84 id<MTLBuffer> _duuWeightsBuffer;
85 id<MTLBuffer> _duvWeightsBuffer;
86 id<MTLBuffer> _dvvWeightsBuffer;
87
88 int _numStencils;
89};
90
92{
93public:
94 typedef bool Instantiatable;
95
97 BufferDescriptor const &dstDesc,
98 BufferDescriptor const &duDesc,
99 BufferDescriptor const &dvDesc,
100 MTLContext* context);
101
103 BufferDescriptor const &dstDesc,
104 BufferDescriptor const &duDesc,
105 BufferDescriptor const &dvDesc,
106 BufferDescriptor const &duuDesc,
107 BufferDescriptor const &duvDesc,
108 BufferDescriptor const &dvvDesc,
109 MTLContext* context);
110
113
119
148 template <typename SRC_BUFFER, typename DST_BUFFER, typename STENCIL_TABLE>
149 static bool EvalStencils(
150 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
151 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
152 STENCIL_TABLE const *stencilTable,
153 MTLComputeEvaluator const *instance,
154 MTLContext* context)
155 {
156 if (instance) {
157 return instance->EvalStencils(srcBuffer, srcDesc,
158 dstBuffer, dstDesc,
159 stencilTable,
160 context);
161 } else {
162 // Create an instance on demand (slow)
163 instance = Create(srcDesc, dstDesc,
166 context);
167 if (instance) {
168 bool r = instance->EvalStencils(srcBuffer, srcDesc,
169 dstBuffer, dstDesc,
170 stencilTable,
171 context);
172 delete instance;
173 return r;
174 }
175 return false;
176 }
177 }
178
219 template <typename SRC_BUFFER, typename DST_BUFFER, typename STENCIL_TABLE>
220 static bool EvalStencils(
221 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
222 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
223 DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
224 DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
225 STENCIL_TABLE const *stencilTable,
226 MTLComputeEvaluator const *instance,
227 MTLContext* context) {
228
229 if (instance) {
230 return instance->EvalStencils(srcBuffer, srcDesc,
231 dstBuffer, dstDesc,
232 duBuffer, duDesc,
233 dvBuffer, dvDesc,
234 stencilTable,
235 context);
236 } else {
237 // Create an instance on demand (slow)
238 instance = Create(srcDesc, dstDesc, duDesc, dvDesc, context);
239 if (instance) {
240 bool r = instance->EvalStencils(srcBuffer, srcDesc,
241 dstBuffer, dstDesc,
242 duBuffer, duDesc,
243 dvBuffer, dvDesc,
244 stencilTable,
245 context);
246 delete instance;
247 return r;
248 }
249 return false;
250 }
251 }
252
311 template <typename SRC_BUFFER, typename DST_BUFFER, typename STENCIL_TABLE>
312 static bool EvalStencils(
313 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
314 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
315 DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
316 DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
317 DST_BUFFER *duuBuffer, BufferDescriptor const &duuDesc,
318 DST_BUFFER *duvBuffer, BufferDescriptor const &duvDesc,
319 DST_BUFFER *dvvBuffer, BufferDescriptor const &dvvDesc,
320 STENCIL_TABLE const *stencilTable,
321 MTLComputeEvaluator const *instance,
322 MTLContext* context) {
323
324 if (instance) {
325 return instance->EvalStencils(srcBuffer, srcDesc,
326 dstBuffer, dstDesc,
327 duBuffer, duDesc,
328 dvBuffer, dvDesc,
329 duuBuffer, duuDesc,
330 duvBuffer, duvDesc,
331 dvvBuffer, dvvDesc,
332 stencilTable,
333 context);
334 } else {
335 // Create an instance on demand (slow)
336 instance = Create(srcDesc, dstDesc, duDesc, dvDesc,
337 duuDesc, duvDesc, dvvDesc, context);
338 if (instance) {
339 bool r = instance->EvalStencils(srcBuffer, srcDesc,
340 dstBuffer, dstDesc,
341 duBuffer, duDesc,
342 dvBuffer, dvDesc,
343 duuBuffer, duuDesc,
344 duvBuffer, duvDesc,
345 dvvBuffer, dvvDesc,
346 stencilTable,
347 context);
348 delete instance;
349 return r;
350 }
351 return false;
352 }
353 }
354
375 template <typename SRC_BUFFER, typename DST_BUFFER, typename STENCIL_TABLE>
377 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
378 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
379 STENCIL_TABLE const *stencilTable,
380 MTLContext* context) const
381 {
382 return EvalStencils(srcBuffer->BindMTLBuffer(context), srcDesc,
383 dstBuffer->BindMTLBuffer(context), dstDesc,
384 0, BufferDescriptor(),
385 0, BufferDescriptor(),
386 stencilTable->GetSizesBuffer(),
387 stencilTable->GetOffsetsBuffer(),
388 stencilTable->GetIndicesBuffer(),
389 stencilTable->GetWeightsBuffer(),
390 0,
391 0,
392 /* start = */ 0,
393 /* end = */ stencilTable->GetNumStencils(),
394 context);
395 }
396
429 template <typename SRC_BUFFER, typename DST_BUFFER, typename STENCIL_TABLE>
431 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
432 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
433 DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
434 DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
435 STENCIL_TABLE const *stencilTable,
436 MTLContext* context) const
437 {
438 return EvalStencils(srcBuffer->BindMTLBuffer(context), srcDesc,
439 dstBuffer->BindMTLBuffer(context), dstDesc,
440 duBuffer->BindMTLBuffer(context), duDesc,
441 dvBuffer->BindMTLBuffer(context), dvDesc,
442 stencilTable->GetSizesBuffer(),
443 stencilTable->GetOffsetsBuffer(),
444 stencilTable->GetIndicesBuffer(),
445 stencilTable->GetWeightsBuffer(),
446 stencilTable->GetDuWeightsBuffer(),
447 stencilTable->GetDvWeightsBuffer(),
448 /* start = */ 0,
449 /* end = */ stencilTable->GetNumStencils(),
450 context);
451 }
452
503 template <typename SRC_BUFFER, typename DST_BUFFER, typename STENCIL_TABLE>
505 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
506 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
507 DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
508 DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
509 DST_BUFFER *duuBuffer, BufferDescriptor const &duuDesc,
510 DST_BUFFER *duvBuffer, BufferDescriptor const &duvDesc,
511 DST_BUFFER *dvvBuffer, BufferDescriptor const &dvvDesc,
512 STENCIL_TABLE const *stencilTable,
513 MTLContext* context) const
514 {
515 return EvalStencils(srcBuffer->BindMTLBuffer(context), srcDesc,
516 dstBuffer->BindMTLBuffer(context), dstDesc,
517 duBuffer->BindMTLBuffer(context), duDesc,
518 dvBuffer->BindMTLBuffer(context), dvDesc,
519 duuBuffer->BindMTLBuffer(context), duuDesc,
520 duvBuffer->BindMTLBuffer(context), duvDesc,
521 dvvBuffer->BindMTLBuffer(context), dvvDesc,
522 stencilTable->GetSizesBuffer(),
523 stencilTable->GetOffsetsBuffer(),
524 stencilTable->GetIndicesBuffer(),
525 stencilTable->GetWeightsBuffer(),
526 stencilTable->GetDuWeightsBuffer(),
527 stencilTable->GetDvWeightsBuffer(),
528 stencilTable->GetDuuWeightsBuffer(),
529 stencilTable->GetDuvWeightsBuffer(),
530 stencilTable->GetDvvWeightsBuffer(),
531 /* start = */ 0,
532 /* end = */ stencilTable->GetNumStencils(),
533 context);
534 }
535
574 bool EvalStencils(id<MTLBuffer> srcBuffer, BufferDescriptor const &srcDesc,
575 id<MTLBuffer> dstBuffer, BufferDescriptor const &dstDesc,
576 id<MTLBuffer> duBuffer, BufferDescriptor const &duDesc,
577 id<MTLBuffer> dvBuffer, BufferDescriptor const &dvDesc,
578 id<MTLBuffer> sizesBuffer,
579 id<MTLBuffer> offsetsBuffer,
580 id<MTLBuffer> indicesBuffer,
581 id<MTLBuffer> weightsBuffer,
582 id<MTLBuffer> duWeightsBuffer,
583 id<MTLBuffer> dvWeightsBuffer,
584 int start,
585 int end,
586 MTLContext* context) const;
587
644 bool EvalStencils(id<MTLBuffer> srcBuffer, BufferDescriptor const &srcDesc,
645 id<MTLBuffer> dstBuffer, BufferDescriptor const &dstDesc,
646 id<MTLBuffer> duBuffer, BufferDescriptor const &duDesc,
647 id<MTLBuffer> dvBuffer, BufferDescriptor const &dvDesc,
648 id<MTLBuffer> duuBuffer, BufferDescriptor const &duuDesc,
649 id<MTLBuffer> duvBuffer, BufferDescriptor const &duvDesc,
650 id<MTLBuffer> dvvBuffer, BufferDescriptor const &dvvDesc,
651 id<MTLBuffer> sizesBuffer,
652 id<MTLBuffer> offsetsBuffer,
653 id<MTLBuffer> indicesBuffer,
654 id<MTLBuffer> weightsBuffer,
655 id<MTLBuffer> duWeightsBuffer,
656 id<MTLBuffer> dvWeightsBuffer,
657 id<MTLBuffer> duuWeightsBuffer,
658 id<MTLBuffer> duvWeightsBuffer,
659 id<MTLBuffer> dvvWeightsBuffer,
660 int start,
661 int end,
662 MTLContext* context) const;
663
669
703 template <typename SRC_BUFFER, typename DST_BUFFER,
704 typename PATCHCOORD_BUFFER, typename PATCH_TABLE>
705 static bool EvalPatches(
706 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
707 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
708 int numPatchCoords,
709 PATCHCOORD_BUFFER *patchCoords,
710 PATCH_TABLE *patchTable,
711 MTLComputeEvaluator const *instance,
712 MTLContext* context) {
713
714 if (instance) {
715 return instance->EvalPatches(srcBuffer, srcDesc,
716 dstBuffer, dstDesc,
717 numPatchCoords, patchCoords,
718 patchTable,
719 context);
720 } else {
721 // Create an instance on demand (slow)
722 instance = Create(srcDesc, dstDesc,
725 context);
726 if (instance) {
727 bool r = instance->EvalPatches(srcBuffer, srcDesc,
728 dstBuffer, dstDesc,
729 numPatchCoords, patchCoords,
730 patchTable,
731 context);
732 delete instance;
733 return r;
734 }
735 return false;
736 }
737 }
738
784 template <typename SRC_BUFFER, typename DST_BUFFER,
785 typename PATCHCOORD_BUFFER, typename PATCH_TABLE>
786 static bool EvalPatches(
787 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
788 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
789 DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
790 DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
791 int numPatchCoords,
792 PATCHCOORD_BUFFER *patchCoords,
793 PATCH_TABLE *patchTable,
794 MTLComputeEvaluator* instance,
795 MTLContext* context) {
796
797 if (instance) {
798 return instance->EvalPatches(srcBuffer, srcDesc,
799 dstBuffer, dstDesc,
800 duBuffer, duDesc,
801 dvBuffer, dvDesc,
802 numPatchCoords, patchCoords,
803 patchTable,
804 context);
805 } else {
806 // Create an instance on demand (slow)
807 instance = Create(srcDesc, dstDesc,
808 duDesc, dvDesc, context);
809 if (instance) {
810 bool r = instance->EvalPatches(srcBuffer, srcDesc,
811 dstBuffer, dstDesc,
812 duBuffer, duDesc,
813 dvBuffer, dvDesc,
814 numPatchCoords, patchCoords,
815 patchTable,
816 context);
817 delete instance;
818 return r;
819 }
820 return false;
821 }
822 }
823
887 template <typename SRC_BUFFER, typename DST_BUFFER,
888 typename PATCHCOORD_BUFFER, typename PATCH_TABLE>
889 static bool EvalPatches(
890 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
891 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
892 DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
893 DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
894 DST_BUFFER *duuBuffer, BufferDescriptor const &duuDesc,
895 DST_BUFFER *duvBuffer, BufferDescriptor const &duvDesc,
896 DST_BUFFER *dvvBuffer, BufferDescriptor const &dvvDesc,
897 int numPatchCoords,
898 PATCHCOORD_BUFFER *patchCoords,
899 PATCH_TABLE *patchTable,
900 MTLComputeEvaluator* instance,
901 MTLContext* context) {
902
903 if (instance) {
904 return instance->EvalPatches(srcBuffer, srcDesc,
905 dstBuffer, dstDesc,
906 duBuffer, duDesc,
907 dvBuffer, dvDesc,
908 duuBuffer, duuDesc,
909 duvBuffer, duvDesc,
910 dvvBuffer, dvvDesc,
911 numPatchCoords, patchCoords,
912 patchTable,
913 context);
914 } else {
915 // Create an instance on demand (slow)
916 instance = Create(srcDesc, dstDesc,
917 duDesc, dvDesc,
918 duuDesc, duvDesc, dvvDesc, context);
919 if (instance) {
920 bool r = instance->EvalPatches(srcBuffer, srcDesc,
921 dstBuffer, dstDesc,
922 duBuffer, duDesc,
923 dvBuffer, dvDesc,
924 duuBuffer, duuDesc,
925 duvBuffer, duvDesc,
926 dvvBuffer, dvvDesc,
927 numPatchCoords, patchCoords,
928 patchTable,
929 context);
930 delete instance;
931 return r;
932 }
933 return false;
934 }
935 }
936
964 template <typename SRC_BUFFER, typename DST_BUFFER,
965 typename PATCHCOORD_BUFFER, typename PATCH_TABLE>
967 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
968 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
969 int numPatchCoords,
970 PATCHCOORD_BUFFER *patchCoords,
971 PATCH_TABLE *patchTable,
972 MTLContext* context) const {
973
974 return EvalPatches(srcBuffer->BindMTLBuffer(context), srcDesc,
975 dstBuffer->BindMTLBuffer(context), dstDesc,
976 0, BufferDescriptor(),
977 0, BufferDescriptor(),
978 numPatchCoords,
979 patchCoords->BindMTLBuffer(context),
980 patchTable->GetPatchArrays(),
981 patchTable->GetPatchIndexBuffer(),
982 patchTable->GetPatchParamBuffer(),
983 context);
984 }
985
1023 template <typename SRC_BUFFER, typename DST_BUFFER,
1024 typename PATCHCOORD_BUFFER, typename PATCH_TABLE>
1026 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
1027 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
1028 DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
1029 DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
1030 int numPatchCoords,
1031 PATCHCOORD_BUFFER *patchCoords,
1032 PATCH_TABLE *patchTable,
1033 MTLContext* context) const {
1034
1035 return EvalPatches(srcBuffer->BindMTLBuffer(context), srcDesc,
1036 dstBuffer->BindMTLBuffer(context), dstDesc,
1037 duBuffer->BindMTLBuffer(context), duDesc,
1038 dvBuffer->BindMTLBuffer(context), dvDesc,
1039 numPatchCoords,
1040 patchCoords->BindMTLBuffer(context),
1041 patchTable->GetPatchArrays(),
1042 patchTable->GetPatchIndexBuffer(),
1043 patchTable->GetPatchParamBuffer(),
1044 context);
1045 }
1046
1102 template <typename SRC_BUFFER, typename DST_BUFFER,
1103 typename PATCHCOORD_BUFFER, typename PATCH_TABLE>
1105 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
1106 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
1107 DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
1108 DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
1109 DST_BUFFER *duuBuffer, BufferDescriptor const &duuDesc,
1110 DST_BUFFER *duvBuffer, BufferDescriptor const &duvDesc,
1111 DST_BUFFER *dvvBuffer, BufferDescriptor const &dvvDesc,
1112 int numPatchCoords,
1113 PATCHCOORD_BUFFER *patchCoords,
1114 PATCH_TABLE *patchTable,
1115 MTLContext* context) const {
1116
1117 return EvalPatches(srcBuffer->BindMTLBuffer(context), srcDesc,
1118 dstBuffer->BindMTLBuffer(context), dstDesc,
1119 duBuffer->BindMTLBuffer(context), duDesc,
1120 dvBuffer->BindMTLBuffer(context), dvDesc,
1121 duuBuffer->BindMTLBuffer(context), duuDesc,
1122 duvBuffer->BindMTLBuffer(context), duvDesc,
1123 dvvBuffer->BindMTLBuffer(context), dvvDesc,
1124 numPatchCoords,
1125 patchCoords->BindMTLBuffer(context),
1126 patchTable->GetPatchArrays(),
1127 patchTable->GetPatchIndexBuffer(),
1128 patchTable->GetPatchParamBuffer(),
1129 context);
1130 }
1131
1132 bool EvalPatches(id<MTLBuffer> srcBuffer, BufferDescriptor const &srcDesc,
1133 id<MTLBuffer> dstBuffer, BufferDescriptor const &dstDesc,
1134 id<MTLBuffer> duBuffer, BufferDescriptor const &duDesc,
1135 id<MTLBuffer> dvBuffer, BufferDescriptor const &dvDesc,
1136 int numPatchCoords,
1137 id<MTLBuffer> patchCoordsBuffer,
1138 const PatchArrayVector &patchArrays,
1139 id<MTLBuffer> patchIndexBuffer,
1140 id<MTLBuffer> patchParamsBuffer,
1141 MTLContext* context) const;
1142
1143 bool EvalPatches(id<MTLBuffer> srcBuffer, BufferDescriptor const &srcDesc,
1144 id<MTLBuffer> dstBuffer, BufferDescriptor const &dstDesc,
1145 id<MTLBuffer> duBuffer, BufferDescriptor const &duDesc,
1146 id<MTLBuffer> dvBuffer, BufferDescriptor const &dvDesc,
1147 id<MTLBuffer> duuBuffer, BufferDescriptor const &duuDesc,
1148 id<MTLBuffer> duvBuffer, BufferDescriptor const &duvDesc,
1149 id<MTLBuffer> dvvBuffer, BufferDescriptor const &dvvDesc,
1150 int numPatchCoords,
1151 id<MTLBuffer> patchCoordsBuffer,
1152 const PatchArrayVector &patchArrays,
1153 id<MTLBuffer> patchIndexBuffer,
1154 id<MTLBuffer> patchParamsBuffer,
1155 MTLContext* context) const;
1156
1190 template <typename SRC_BUFFER, typename DST_BUFFER,
1191 typename PATCHCOORD_BUFFER, typename PATCH_TABLE>
1193 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
1194 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
1195 int numPatchCoords,
1196 PATCHCOORD_BUFFER *patchCoords,
1197 PATCH_TABLE *patchTable,
1198 MTLComputeEvaluator const *instance,
1199 MTLContext* deviceContext) {
1200
1201 if (instance) {
1202 return instance->EvalPatchesVarying(
1203 srcBuffer, srcDesc,
1204 dstBuffer, dstDesc,
1205 numPatchCoords, patchCoords,
1206 patchTable,
1207 deviceContext);
1208 } else {
1209 // Create an instance on demand (slow)
1210 instance = Create(srcDesc, dstDesc,
1213 deviceContext);
1214 if (instance) {
1215 bool r = instance->EvalPatchesVarying(
1216 srcBuffer, srcDesc,
1217 dstBuffer, dstDesc,
1218 numPatchCoords, patchCoords,
1219 patchTable,
1220 deviceContext);
1221 delete instance;
1222 return r;
1223 }
1224 return false;
1225 }
1226 }
1227
1255 template <typename SRC_BUFFER, typename DST_BUFFER,
1256 typename PATCHCOORD_BUFFER, typename PATCH_TABLE>
1258 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
1259 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
1260 int numPatchCoords,
1261 PATCHCOORD_BUFFER *patchCoords,
1262 PATCH_TABLE *patchTable,
1263 MTLContext* deviceContext) const {
1264
1265 return EvalPatches(srcBuffer->BindMTLBuffer(deviceContext), srcDesc,
1266 dstBuffer->BindMTLBuffer(deviceContext), dstDesc,
1267 0, BufferDescriptor(),
1268 0, BufferDescriptor(),
1269 numPatchCoords,
1270 patchCoords->BindMTLBuffer(deviceContext),
1271 patchTable->GetVaryingPatchArrays(),
1272 patchTable->GetVaryingPatchIndexBuffer(),
1273 patchTable->GetPatchParamBuffer(),
1274 deviceContext
1275 );
1276 }
1277
1323 template <typename SRC_BUFFER, typename DST_BUFFER,
1324 typename PATCHCOORD_BUFFER, typename PATCH_TABLE>
1326 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
1327 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
1328 DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
1329 DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
1330 int numPatchCoords,
1331 PATCHCOORD_BUFFER *patchCoords,
1332 PATCH_TABLE *patchTable,
1333 MTLComputeEvaluator const *instance,
1334 MTLContext* deviceContext) {
1335
1336 if (instance) {
1337 return instance->EvalPatchesVarying(
1338 srcBuffer, srcDesc,
1339 dstBuffer, dstDesc,
1340 duBuffer, duDesc,
1341 dvBuffer, dvDesc,
1342 numPatchCoords, patchCoords,
1343 patchTable,
1344 deviceContext);
1345 } else {
1346 // Create an instance on demand (slow)
1347 instance = Create(srcDesc, dstDesc,
1348 duDesc, dvDesc,
1349 deviceContext);
1350 if (instance) {
1351 bool r = instance->EvalPatchesVarying(
1352 srcBuffer, srcDesc,
1353 dstBuffer, dstDesc,
1354 duBuffer, duDesc,
1355 dvBuffer, dvDesc,
1356 numPatchCoords, patchCoords,
1357 patchTable,
1358 deviceContext);
1359 delete instance;
1360 return r;
1361 }
1362 return false;
1363 }
1364 }
1365
1405 template <typename SRC_BUFFER, typename DST_BUFFER,
1406 typename PATCHCOORD_BUFFER, typename PATCH_TABLE>
1408 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
1409 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
1410 DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
1411 DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
1412 int numPatchCoords,
1413 PATCHCOORD_BUFFER *patchCoords,
1414 PATCH_TABLE *patchTable,
1415 MTLContext* deviceContext) const {
1416
1417 return EvalPatches(srcBuffer->BindMTLBuffer(deviceContext), srcDesc,
1418 dstBuffer->BindMTLBuffer(deviceContext), dstDesc,
1419 duBuffer->BindMTLBuffer(deviceContext), duDesc,
1420 dvBuffer->BindMTLBuffer(deviceContext), dvDesc,
1421 numPatchCoords,
1422 patchCoords->BindMTLBuffer(deviceContext),
1423 patchTable->GetVaryingPatchArrays(),
1424 patchTable->GetVaryingPatchIndexBuffer(),
1425 patchTable->GetPatchParamBuffer(),
1426 deviceContext
1427 );
1428 }
1429
1430
1494 template <typename SRC_BUFFER, typename DST_BUFFER,
1495 typename PATCHCOORD_BUFFER, typename PATCH_TABLE>
1497 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
1498 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
1499 DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
1500 DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
1501 DST_BUFFER *duuBuffer, BufferDescriptor const &duuDesc,
1502 DST_BUFFER *duvBuffer, BufferDescriptor const &duvDesc,
1503 DST_BUFFER *dvvBuffer, BufferDescriptor const &dvvDesc,
1504 int numPatchCoords,
1505 PATCHCOORD_BUFFER *patchCoords,
1506 PATCH_TABLE *patchTable,
1507 MTLComputeEvaluator const *instance,
1508 MTLContext* deviceContext) {
1509
1510 if (instance) {
1511 return instance->EvalPatchesVarying(
1512 srcBuffer, srcDesc,
1513 dstBuffer, dstDesc,
1514 duBuffer, duDesc,
1515 dvBuffer, dvDesc,
1516 duuBuffer, duuDesc,
1517 duvBuffer, duvDesc,
1518 dvvBuffer, dvvDesc,
1519 numPatchCoords, patchCoords,
1520 patchTable,
1521 deviceContext);
1522 } else {
1523 // Create an instance on demand (slow)
1524 instance = Create(srcDesc, dstDesc,
1525 duDesc, dvDesc,
1526 duuDesc, duvDesc, dvvDesc,
1527 deviceContext);
1528 if (instance) {
1529 bool r = instance->EvalPatchesVarying(
1530 srcBuffer, srcDesc,
1531 dstBuffer, dstDesc,
1532 duBuffer, duDesc,
1533 dvBuffer, dvDesc,
1534 duuBuffer, duuDesc,
1535 duvBuffer, duvDesc,
1536 dvvBuffer, dvvDesc,
1537 numPatchCoords, patchCoords,
1538 patchTable,
1539 deviceContext);
1540 delete instance;
1541 return r;
1542 }
1543 return false;
1544 }
1545 }
1546
1604 template <typename SRC_BUFFER, typename DST_BUFFER,
1605 typename PATCHCOORD_BUFFER, typename PATCH_TABLE>
1607 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
1608 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
1609 DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
1610 DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
1611 DST_BUFFER *duuBuffer, BufferDescriptor const &duuDesc,
1612 DST_BUFFER *duvBuffer, BufferDescriptor const &duvDesc,
1613 DST_BUFFER *dvvBuffer, BufferDescriptor const &dvvDesc,
1614 int numPatchCoords,
1615 PATCHCOORD_BUFFER *patchCoords,
1616 PATCH_TABLE *patchTable,
1617 MTLContext* deviceContext) const {
1618
1619 return EvalPatches(srcBuffer->BindMTLBuffer(deviceContext), srcDesc,
1620 dstBuffer->BindMTLBuffer(deviceContext), dstDesc,
1621 duBuffer->BindMTLBuffer(deviceContext), duDesc,
1622 dvBuffer->BindMTLBuffer(deviceContext), dvDesc,
1623 duuBuffer->BindMTLBuffer(deviceContext), duuDesc,
1624 duvBuffer->BindMTLBuffer(deviceContext), duvDesc,
1625 dvvBuffer->BindMTLBuffer(deviceContext), dvvDesc,
1626 numPatchCoords,
1627 patchCoords->BindMTLBuffer(deviceContext),
1628 patchTable->GetVaryingPatchArrays(),
1629 patchTable->GetVaryingPatchIndexBuffer(),
1630 patchTable->GetPatchParamBuffer(),
1631 deviceContext
1632 );
1633 }
1634
1670 template <typename SRC_BUFFER, typename DST_BUFFER,
1671 typename PATCHCOORD_BUFFER, typename PATCH_TABLE>
1673 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
1674 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
1675 int numPatchCoords,
1676 PATCHCOORD_BUFFER *patchCoords,
1677 PATCH_TABLE *patchTable,
1678 int fvarChannel,
1679 MTLComputeEvaluator const *instance,
1680 MTLContext* deviceContext) {
1681
1682 if (instance) {
1683 return instance->EvalPatchesFaceVarying(
1684 srcBuffer, srcDesc,
1685 dstBuffer, dstDesc,
1686 numPatchCoords, patchCoords,
1687 patchTable,
1688 fvarChannel,
1689 deviceContext);
1690 } else {
1691 // Create an instance on demand (slow)
1692 instance = Create(srcDesc, dstDesc,
1695 deviceContext);
1696 if (instance) {
1697 bool r = instance->EvalPatchesFaceVarying(
1698 srcBuffer, srcDesc,
1699 dstBuffer, dstDesc,
1700 numPatchCoords, patchCoords,
1701 patchTable,
1702 fvarChannel,
1703 deviceContext);
1704 delete instance;
1705 return r;
1706 }
1707 return false;
1708 }
1709 }
1710
1740 template <typename SRC_BUFFER, typename DST_BUFFER,
1741 typename PATCHCOORD_BUFFER, typename PATCH_TABLE>
1743 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
1744 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
1745 int numPatchCoords,
1746 PATCHCOORD_BUFFER *patchCoords,
1747 PATCH_TABLE *patchTable,
1748 int fvarChannel,
1749 MTLContext* deviceContext) const {
1750
1751 return EvalPatches(srcBuffer->BindMTLBuffer(deviceContext), srcDesc,
1752 dstBuffer->BindMTLBuffer(deviceContext), dstDesc,
1753 0, BufferDescriptor(),
1754 0, BufferDescriptor(),
1755 numPatchCoords,
1756 patchCoords->BindMTLBuffer(deviceContext),
1757 patchTable->GetFVarPatchArrays(fvarChannel),
1758 patchTable->GetFVarPatchIndexBuffer(fvarChannel),
1759 patchTable->GetFVarPatchParamBuffer(fvarChannel),
1760 deviceContext
1761 );
1762 }
1763
1811 template <typename SRC_BUFFER, typename DST_BUFFER,
1812 typename PATCHCOORD_BUFFER, typename PATCH_TABLE>
1814 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
1815 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
1816 DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
1817 DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
1818 int numPatchCoords,
1819 PATCHCOORD_BUFFER *patchCoords,
1820 PATCH_TABLE *patchTable,
1821 int fvarChannel,
1822 MTLComputeEvaluator const *instance,
1823 MTLContext* deviceContext) {
1824
1825 if (instance) {
1826 return instance->EvalPatchesFaceVarying(
1827 srcBuffer, srcDesc,
1828 dstBuffer, dstDesc,
1829 duBuffer, duDesc,
1830 dvBuffer, dvDesc,
1831 numPatchCoords, patchCoords,
1832 patchTable,
1833 fvarChannel,
1834 deviceContext);
1835 } else {
1836 // Create an instance on demand (slow)
1837 instance = Create(srcDesc, dstDesc,
1838 duDesc, dvDesc,
1839 deviceContext);
1840 if (instance) {
1841 bool r = instance->EvalPatchesFaceVarying(
1842 srcBuffer, srcDesc,
1843 dstBuffer, dstDesc,
1844 duBuffer, duDesc,
1845 dvBuffer, dvDesc,
1846 numPatchCoords, patchCoords,
1847 patchTable,
1848 fvarChannel,
1849 deviceContext);
1850 delete instance;
1851 return r;
1852 }
1853 return false;
1854 }
1855 }
1856
1898 template <typename SRC_BUFFER, typename DST_BUFFER,
1899 typename PATCHCOORD_BUFFER, typename PATCH_TABLE>
1901 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
1902 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
1903 DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
1904 DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
1905 int numPatchCoords,
1906 PATCHCOORD_BUFFER *patchCoords,
1907 PATCH_TABLE *patchTable,
1908 int fvarChannel,
1909 MTLContext* deviceContext) const {
1910
1911 return EvalPatches(srcBuffer->BindMTLBuffer(deviceContext), srcDesc,
1912 dstBuffer->BindMTLBuffer(deviceContext), dstDesc,
1913 duBuffer->BindMTLBuffer(deviceContext), duDesc,
1914 dvBuffer->BindMTLBuffer(deviceContext), dvDesc,
1915 numPatchCoords,
1916 patchCoords->BindMTLBuffer(deviceContext),
1917 patchTable->GetFVarPatchArrays(fvarChannel),
1918 patchTable->GetFVarPatchIndexBuffer(fvarChannel),
1919 patchTable->GetFVarPatchParamBuffer(fvarChannel),
1920 deviceContext
1921 );
1922 }
1923
1989 template <typename SRC_BUFFER, typename DST_BUFFER,
1990 typename PATCHCOORD_BUFFER, typename PATCH_TABLE>
1992 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
1993 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
1994 DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
1995 DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
1996 DST_BUFFER *duuBuffer, BufferDescriptor const &duuDesc,
1997 DST_BUFFER *duvBuffer, BufferDescriptor const &duvDesc,
1998 DST_BUFFER *dvvBuffer, BufferDescriptor const &dvvDesc,
1999 int numPatchCoords,
2000 PATCHCOORD_BUFFER *patchCoords,
2001 PATCH_TABLE *patchTable,
2002 int fvarChannel,
2003 MTLComputeEvaluator const *instance,
2004 MTLContext* deviceContext) {
2005
2006 if (instance) {
2007 return instance->EvalPatchesFaceVarying(
2008 srcBuffer, srcDesc,
2009 dstBuffer, dstDesc,
2010 duBuffer, duDesc,
2011 dvBuffer, dvDesc,
2012 duuBuffer, duuDesc,
2013 duvBuffer, duvDesc,
2014 dvvBuffer, dvvDesc,
2015 numPatchCoords, patchCoords,
2016 patchTable,
2017 fvarChannel,
2018 deviceContext);
2019 } else {
2020 // Create an instance on demand (slow)
2021 instance = Create(srcDesc, dstDesc,
2022 duDesc, dvDesc,
2023 duuDesc, duvDesc, dvvDesc,
2024 deviceContext);
2025 if (instance) {
2026 bool r = instance->EvalPatchesFaceVarying(
2027 srcBuffer, srcDesc,
2028 dstBuffer, dstDesc,
2029 duBuffer, duDesc,
2030 dvBuffer, dvDesc,
2031 duuBuffer, duuDesc,
2032 duvBuffer, duvDesc,
2033 dvvBuffer, dvvDesc,
2034 numPatchCoords, patchCoords,
2035 patchTable,
2036 fvarChannel,
2037 deviceContext);
2038 delete instance;
2039 return r;
2040 }
2041 return false;
2042 }
2043 }
2044
2104 template <typename SRC_BUFFER, typename DST_BUFFER,
2105 typename PATCHCOORD_BUFFER, typename PATCH_TABLE>
2107 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
2108 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
2109 DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
2110 DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
2111 DST_BUFFER *duuBuffer, BufferDescriptor const &duuDesc,
2112 DST_BUFFER *duvBuffer, BufferDescriptor const &duvDesc,
2113 DST_BUFFER *dvvBuffer, BufferDescriptor const &dvvDesc,
2114 int numPatchCoords,
2115 PATCHCOORD_BUFFER *patchCoords,
2116 PATCH_TABLE *patchTable,
2117 int fvarChannel,
2118 MTLContext* deviceContext) const {
2119
2120 return EvalPatches(srcBuffer->BindMTLBuffer(deviceContext), srcDesc,
2121 dstBuffer->BindMTLBuffer(deviceContext), dstDesc,
2122 duBuffer->BindMTLBuffer(deviceContext), duDesc,
2123 dvBuffer->BindMTLBuffer(deviceContext), dvDesc,
2124 duuBuffer->BindMTLBuffer(deviceContext), duuDesc,
2125 duvBuffer->BindMTLBuffer(deviceContext), duvDesc,
2126 dvvBuffer->BindMTLBuffer(deviceContext), dvvDesc,
2127 numPatchCoords,
2128 patchCoords->BindMTLBuffer(deviceContext),
2129 patchTable->GetFVarPatchArrays(fvarChannel),
2130 patchTable->GetFVarPatchIndexBuffer(fvarChannel),
2131 patchTable->GetFVarPatchParamBuffer(fvarChannel),
2132 fvarChannel,
2133 deviceContext
2134 );
2135 }
2136
2138 bool Compile(BufferDescriptor const &srcDesc,
2139 BufferDescriptor const &dstDesc,
2140 BufferDescriptor const &duDesc,
2141 BufferDescriptor const &dvDesc,
2142 BufferDescriptor const &duuDesc,
2143 BufferDescriptor const &duvDesc,
2144 BufferDescriptor const &dvvDesc,
2145 MTLContext* context);
2146
2148 static void Synchronize(MTLContext* context);
2149
2150 private:
2151
2152 id<MTLLibrary> _computeLibrary;
2153 id<MTLComputePipelineState> _evalStencils;
2154 id<MTLComputePipelineState> _evalPatches;
2155 id<MTLBuffer> _parameterBuffer;
2156
2157 int _workGroupSize;
2158};
2159
2160} //end namespace Osd
2161
2162} //end namespace OPENSUBDIV_VERSION
2163using namespace OPENSUBDIV_VERSION;
2164
2165} //end namespace OpenSubdiv
2166
2167#endif // OPENSUBDIV3_OSD_MTL_COMPUTE_EVALUATOR_H
std::vector< PatchArray > PatchArrayVector
Definition: types.h:132
Stencil table class wrapping the template for compatibility.
Definition: stencilTable.h:273
Limit stencil table class wrapping the template for compatibility.
Definition: stencilTable.h:583
BufferDescriptor is a struct which describes buffer elements in interleaved data buffers....
MTLStencilTable(Far::LimitStencilTable const *stencilTable, MTLContext *context)
MTLStencilTable(Far::StencilTable const *stencilTable, MTLContext *context)
static MTLStencilTable * Create(STENCIL_TABLE *stencilTable, DEVICE_CONTEXT context)
bool EvalStencils(id< MTLBuffer > srcBuffer, BufferDescriptor const &srcDesc, id< MTLBuffer > dstBuffer, BufferDescriptor const &dstDesc, id< MTLBuffer > duBuffer, BufferDescriptor const &duDesc, id< MTLBuffer > dvBuffer, BufferDescriptor const &dvDesc, id< MTLBuffer > duuBuffer, BufferDescriptor const &duuDesc, id< MTLBuffer > duvBuffer, BufferDescriptor const &duvDesc, id< MTLBuffer > dvvBuffer, BufferDescriptor const &dvvDesc, id< MTLBuffer > sizesBuffer, id< MTLBuffer > offsetsBuffer, id< MTLBuffer > indicesBuffer, id< MTLBuffer > weightsBuffer, id< MTLBuffer > duWeightsBuffer, id< MTLBuffer > dvWeightsBuffer, id< MTLBuffer > duuWeightsBuffer, id< MTLBuffer > duvWeightsBuffer, id< MTLBuffer > dvvWeightsBuffer, int start, int end, MTLContext *context) const
Dispatch the MTL compute kernel on GPU asynchronously returns false if the kernel hasn't been compile...
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, MTLComputeEvaluator *instance, MTLContext *context)
Generic limit eval function. This function has a same signature as other device kernels have so that ...
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, MTLComputeEvaluator const *instance, MTLContext *context)
Generic static stencil function. This function has a same signature as other device kernels have so t...
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, MTLComputeEvaluator const *instance, MTLContext *deviceContext)
Generic limit eval function. This function has a same signature as other device kernels have so that ...
static bool EvalPatches(SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc, DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc, int numPatchCoords, PATCHCOORD_BUFFER *patchCoords, PATCH_TABLE *patchTable, MTLComputeEvaluator const *instance, MTLContext *context)
Generic limit eval function. This function has a same signature as other device kernels have so that ...
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, MTLContext *deviceContext) const
Generic limit eval function. This function has a same signature as other device kernels have so that ...
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, MTLComputeEvaluator const *instance, MTLContext *context)
Generic static stencil function. This function has a same signature as other device kernels have so t...
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, MTLContext *deviceContext) const
Generic limit eval function. This function has a same signature as other device kernels have so that ...
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, MTLComputeEvaluator const *instance, MTLContext *deviceContext)
Generic limit eval function. This function has a same signature as other device kernels have so that ...
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, MTLComputeEvaluator const *instance, MTLContext *deviceContext)
Generic limit eval function. This function has a same signature as other device kernels have so that ...
bool EvalStencils(SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc, DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc, STENCIL_TABLE const *stencilTable, MTLContext *context) const
Generic stencil function.
bool EvalPatches(id< MTLBuffer > srcBuffer, BufferDescriptor const &srcDesc, id< MTLBuffer > dstBuffer, BufferDescriptor const &dstDesc, id< MTLBuffer > duBuffer, BufferDescriptor const &duDesc, id< MTLBuffer > dvBuffer, BufferDescriptor const &dvDesc, id< MTLBuffer > duuBuffer, BufferDescriptor const &duuDesc, id< MTLBuffer > duvBuffer, BufferDescriptor const &duvDesc, id< MTLBuffer > dvvBuffer, BufferDescriptor const &dvvDesc, int numPatchCoords, id< MTLBuffer > patchCoordsBuffer, const PatchArrayVector &patchArrays, id< MTLBuffer > patchIndexBuffer, id< MTLBuffer > patchParamsBuffer, MTLContext *context) const
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, MTLContext *deviceContext) const
Generic limit eval function. This function has a same signature as other device kernels have so that ...
static void Synchronize(MTLContext *context)
Wait for the dispatched kernel to finish.
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, MTLContext *context) const
Generic stencil function.
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, MTLComputeEvaluator *instance, MTLContext *context)
Generic limit eval function. This function has a same signature as other device kernels have so that ...
bool EvalPatchesFaceVarying(SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc, DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc, int numPatchCoords, PATCHCOORD_BUFFER *patchCoords, PATCH_TABLE *patchTable, int fvarChannel, MTLContext *deviceContext) const
Generic limit eval function. This function has a same signature as other device kernels have so that ...
static bool EvalPatchesVarying(SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc, DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc, int numPatchCoords, PATCHCOORD_BUFFER *patchCoords, PATCH_TABLE *patchTable, MTLComputeEvaluator const *instance, MTLContext *deviceContext)
Generic limit eval function. This function has a same signature as other device kernels have so that ...
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, MTLContext *context) const
Generic stencil function.
bool EvalStencils(id< MTLBuffer > srcBuffer, BufferDescriptor const &srcDesc, id< MTLBuffer > dstBuffer, BufferDescriptor const &dstDesc, id< MTLBuffer > duBuffer, BufferDescriptor const &duDesc, id< MTLBuffer > dvBuffer, BufferDescriptor const &dvDesc, id< MTLBuffer > sizesBuffer, id< MTLBuffer > offsetsBuffer, id< MTLBuffer > indicesBuffer, id< MTLBuffer > weightsBuffer, id< MTLBuffer > duWeightsBuffer, id< MTLBuffer > dvWeightsBuffer, int start, int end, MTLContext *context) const
Dispatch the MTL compute kernel on GPU asynchronously returns false if the kernel hasn't been compile...
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, MTLComputeEvaluator const *instance, MTLContext *deviceContext)
Generic limit eval function. This function has a same signature as other device kernels have so that ...
bool EvalPatches(SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc, DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc, int numPatchCoords, PATCHCOORD_BUFFER *patchCoords, PATCH_TABLE *patchTable, MTLContext *context) const
Generic limit eval function. This function has a same signature as other device kernels have so that ...
static bool EvalStencils(SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc, DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc, STENCIL_TABLE const *stencilTable, MTLComputeEvaluator const *instance, MTLContext *context)
Generic static stencil function. This function has a same signature as other device kernels have so t...
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, MTLComputeEvaluator const *instance, MTLContext *deviceContext)
Generic limit eval function. This function has a same signature as other device kernels have so that ...
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, MTLContext *context) const
Generic limit eval function with derivatives. This function has a same signature as other device kern...
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, MTLContext *context) const
Generic limit eval function with derivatives. This function has a same signature as other device kern...
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, MTLContext *deviceContext) const
Generic limit eval function. This function has a same signature as other device kernels have so that ...
bool EvalPatchesVarying(SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc, DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc, int numPatchCoords, PATCHCOORD_BUFFER *patchCoords, PATCH_TABLE *patchTable, MTLContext *deviceContext) const
Generic limit eval function. This function has a same signature as other device kernels have so that ...
static MTLComputeEvaluator * Create(BufferDescriptor const &srcDesc, BufferDescriptor const &dstDesc, BufferDescriptor const &duDesc, BufferDescriptor const &dvDesc, MTLContext *context)
static MTLComputeEvaluator * Create(BufferDescriptor const &srcDesc, BufferDescriptor const &dstDesc, BufferDescriptor const &duDesc, BufferDescriptor const &dvDesc, BufferDescriptor const &duuDesc, BufferDescriptor const &duvDesc, BufferDescriptor const &dvvDesc, MTLContext *context)
bool Compile(BufferDescriptor const &srcDesc, BufferDescriptor const &dstDesc, BufferDescriptor const &duDesc, BufferDescriptor const &dvDesc, BufferDescriptor const &duuDesc, BufferDescriptor const &duvDesc, BufferDescriptor const &dvvDesc, MTLContext *context)
Configure compute pipline state. Returns false if it fails to create the pipeline state.
bool EvalPatches(id< MTLBuffer > srcBuffer, BufferDescriptor const &srcDesc, id< MTLBuffer > dstBuffer, BufferDescriptor const &dstDesc, id< MTLBuffer > duBuffer, BufferDescriptor const &duDesc, id< MTLBuffer > dvBuffer, BufferDescriptor const &dvDesc, int numPatchCoords, id< MTLBuffer > patchCoordsBuffer, const PatchArrayVector &patchArrays, id< MTLBuffer > patchIndexBuffer, id< MTLBuffer > patchParamsBuffer, MTLContext *context) const