| OpenSubdiv

Loading...
Searching...
No Matches
mtlComputeEvaluator.h
Go to the documentation of this file.
1//
2// Copyright 2013 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://opensubdiv.org/license.
6//
7
8#ifndef OPENSUBDIV3_OSD_MTL_COMPUTE_EVALUATOR_H
9#define OPENSUBDIV3_OSD_MTL_COMPUTE_EVALUATOR_H
10
11#include "../version.h"
12
13#include "../osd/types.h"
14#include "../osd/bufferDescriptor.h"
15#include "../osd/mtlCommon.h"
16
17@protocol MTLDevice;
18@protocol MTLBuffer;
19@protocol MTLLibrary;
20@protocol MTLComputePipelineState;
21
22 namespace OpenSubdiv {
23 namespace OPENSUBDIV_VERSION {
24
25 namespace Far {
26 class PatchTable;
27 class StencilTable;
28 class LimitStencilTable;
29}
30
31 namespace Osd {
32
33 class MTLStencilTable
34{
35 public:
36 template<typename STENCIL_TABLE, typename DEVICE_CONTEXT>
37 static MTLStencilTable* Create(STENCIL_TABLE* stencilTable,
38 DEVICE_CONTEXT context)
39 {
40 return new MTLStencilTable(stencilTable, context);
41 }
42
43
44 MTLStencilTable(Far::StencilTable const* stencilTable, MTLContext* context);
45 MTLStencilTable(Far::LimitStencilTable const* stencilTable, MTLContext* context);
46 ~MTLStencilTable();
47
48 id<MTLBuffer> GetSizesBuffer() const { return _sizesBuffer; }
49 id<MTLBuffer> GetOffsetsBuffer() const { return _offsetsBuffer; }
50 id<MTLBuffer> GetIndicesBuffer() const { return _indicesBuffer; }
51 id<MTLBuffer> GetWeightsBuffer() const { return _weightsBuffer; }
52 id<MTLBuffer> GetDuWeightsBuffer() const { return _duWeightsBuffer; }
53 id<MTLBuffer> GetDvWeightsBuffer() const { return _dvWeightsBuffer; }
54 id<MTLBuffer> GetDuuWeightsBuffer() const { return _duuWeightsBuffer; }
55 id<MTLBuffer> GetDuvWeightsBuffer() const { return _duvWeightsBuffer; }
56 id<MTLBuffer> GetDvvWeightsBuffer() const { return _dvvWeightsBuffer; }
57
58 int GetNumStencils() const { return _numStencils; }
59
60 private:
61 id<MTLBuffer> _sizesBuffer;
62 id<MTLBuffer> _offsetsBuffer;
63 id<MTLBuffer> _indicesBuffer;
64 id<MTLBuffer> _weightsBuffer;
65 id<MTLBuffer> _duWeightsBuffer;
66 id<MTLBuffer> _dvWeightsBuffer;
67 id<MTLBuffer> _duuWeightsBuffer;
68 id<MTLBuffer> _duvWeightsBuffer;
69 id<MTLBuffer> _dvvWeightsBuffer;
70
71 int _numStencils;
72};
73
74 class MTLComputeEvaluator
75{
76 public:
77 using Instantiatable = bool; // Enable compiled kernel evaluator cache
78
79 static MTLComputeEvaluator * Create(BufferDescriptor const &srcDesc,
80 BufferDescriptor const &dstDesc,
81 BufferDescriptor const &duDesc,
82 BufferDescriptor const &dvDesc,
83 MTLContext* context);
84
85 static MTLComputeEvaluator * Create(BufferDescriptor const &srcDesc,
86 BufferDescriptor const &dstDesc,
87 BufferDescriptor const &duDesc,
88 BufferDescriptor const &dvDesc,
89 BufferDescriptor const &duuDesc,
90 BufferDescriptor const &duvDesc,
91 BufferDescriptor const &dvvDesc,
92 MTLContext* context);
93
94 MTLComputeEvaluator();
95 ~MTLComputeEvaluator();
96
102
131 template <typename SRC_BUFFER, typename DST_BUFFER, typename STENCIL_TABLE>
132 static bool EvalStencils(
133 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
134 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
135 STENCIL_TABLE const *stencilTable,
136 MTLComputeEvaluator const *instance,
137 MTLContext* context)
138 {
139 if (instance) {
140 return instance->EvalStencils(srcBuffer, srcDesc,
141 dstBuffer, dstDesc,
142 stencilTable,
143 context);
144 } else {
145 // Create an instance on demand (slow)
146 instance = Create(srcDesc, dstDesc,
147 BufferDescriptor(),
148 BufferDescriptor(),
149 context);
150 if (instance) {
151 bool r = instance->EvalStencils(srcBuffer, srcDesc,
152 dstBuffer, dstDesc,
153 stencilTable,
154 context);
155 delete instance;
156 return r;
157 }
158 return false;
159 }
160 }
161
202 template <typename SRC_BUFFER, typename DST_BUFFER, typename STENCIL_TABLE>
203 static bool EvalStencils(
204 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
205 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
206 DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
207 DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
208 STENCIL_TABLE const *stencilTable,
209 MTLComputeEvaluator const *instance,
210 MTLContext* context) {
211
212 if (instance) {
213 return instance->EvalStencils(srcBuffer, srcDesc,
214 dstBuffer, dstDesc,
215 duBuffer, duDesc,
216 dvBuffer, dvDesc,
217 stencilTable,
218 context);
219 } else {
220 // Create an instance on demand (slow)
221 instance = Create(srcDesc, dstDesc, duDesc, dvDesc, context);
222 if (instance) {
223 bool r = instance->EvalStencils(srcBuffer, srcDesc,
224 dstBuffer, dstDesc,
225 duBuffer, duDesc,
226 dvBuffer, dvDesc,
227 stencilTable,
228 context);
229 delete instance;
230 return r;
231 }
232 return false;
233 }
234 }
235
294 template <typename SRC_BUFFER, typename DST_BUFFER, typename STENCIL_TABLE>
295 static bool EvalStencils(
296 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
297 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
298 DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
299 DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
300 DST_BUFFER *duuBuffer, BufferDescriptor const &duuDesc,
301 DST_BUFFER *duvBuffer, BufferDescriptor const &duvDesc,
302 DST_BUFFER *dvvBuffer, BufferDescriptor const &dvvDesc,
303 STENCIL_TABLE const *stencilTable,
304 MTLComputeEvaluator const *instance,
305 MTLContext* context) {
306
307 if (instance) {
308 return instance->EvalStencils(srcBuffer, srcDesc,
309 dstBuffer, dstDesc,
310 duBuffer, duDesc,
311 dvBuffer, dvDesc,
312 duuBuffer, duuDesc,
313 duvBuffer, duvDesc,
314 dvvBuffer, dvvDesc,
315 stencilTable,
316 context);
317 } else {
318 // Create an instance on demand (slow)
319 instance = Create(srcDesc, dstDesc, duDesc, dvDesc,
320 duuDesc, duvDesc, dvvDesc, context);
321 if (instance) {
322 bool r = instance->EvalStencils(srcBuffer, srcDesc,
323 dstBuffer, dstDesc,
324 duBuffer, duDesc,
325 dvBuffer, dvDesc,
326 duuBuffer, duuDesc,
327 duvBuffer, duvDesc,
328 dvvBuffer, dvvDesc,
329 stencilTable,
330 context);
331 delete instance;
332 return r;
333 }
334 return false;
335 }
336 }
337
358 template <typename SRC_BUFFER, typename DST_BUFFER, typename STENCIL_TABLE>
359 bool EvalStencils(
360 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
361 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
362 STENCIL_TABLE const *stencilTable,
363 MTLContext* context) const
364 {
365 return EvalStencils(srcBuffer->BindMTLBuffer(context), srcDesc,
366 dstBuffer->BindMTLBuffer(context), dstDesc,
367 0, BufferDescriptor(),
368 0, BufferDescriptor(),
369 stencilTable->GetSizesBuffer(),
370 stencilTable->GetOffsetsBuffer(),
371 stencilTable->GetIndicesBuffer(),
372 stencilTable->GetWeightsBuffer(),
373 0,
374 0,
375 /* start = */ 0,
376 /* end = */ stencilTable->GetNumStencils(),
377 context);
378 }
379
412 template <typename SRC_BUFFER, typename DST_BUFFER, typename STENCIL_TABLE>
413 bool EvalStencils(
414 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
415 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
416 DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
417 DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
418 STENCIL_TABLE const *stencilTable,
419 MTLContext* context) const
420 {
421 return EvalStencils(srcBuffer->BindMTLBuffer(context), srcDesc,
422 dstBuffer->BindMTLBuffer(context), dstDesc,
423 duBuffer->BindMTLBuffer(context), duDesc,
424 dvBuffer->BindMTLBuffer(context), dvDesc,
425 stencilTable->GetSizesBuffer(),
426 stencilTable->GetOffsetsBuffer(),
427 stencilTable->GetIndicesBuffer(),
428 stencilTable->GetWeightsBuffer(),
429 stencilTable->GetDuWeightsBuffer(),
430 stencilTable->GetDvWeightsBuffer(),
431 /* start = */ 0,
432 /* end = */ stencilTable->GetNumStencils(),
433 context);
434 }
435
486 template <typename SRC_BUFFER, typename DST_BUFFER, typename STENCIL_TABLE>
487 bool EvalStencils(
488 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
489 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
490 DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
491 DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
492 DST_BUFFER *duuBuffer, BufferDescriptor const &duuDesc,
493 DST_BUFFER *duvBuffer, BufferDescriptor const &duvDesc,
494 DST_BUFFER *dvvBuffer, BufferDescriptor const &dvvDesc,
495 STENCIL_TABLE const *stencilTable,
496 MTLContext* context) const
497 {
498 return EvalStencils(srcBuffer->BindMTLBuffer(context), srcDesc,
499 dstBuffer->BindMTLBuffer(context), dstDesc,
500 duBuffer->BindMTLBuffer(context), duDesc,
501 dvBuffer->BindMTLBuffer(context), dvDesc,
502 duuBuffer->BindMTLBuffer(context), duuDesc,
503 duvBuffer->BindMTLBuffer(context), duvDesc,
504 dvvBuffer->BindMTLBuffer(context), dvvDesc,
505 stencilTable->GetSizesBuffer(),
506 stencilTable->GetOffsetsBuffer(),
507 stencilTable->GetIndicesBuffer(),
508 stencilTable->GetWeightsBuffer(),
509 stencilTable->GetDuWeightsBuffer(),
510 stencilTable->GetDvWeightsBuffer(),
511 stencilTable->GetDuuWeightsBuffer(),
512 stencilTable->GetDuvWeightsBuffer(),
513 stencilTable->GetDvvWeightsBuffer(),
514 /* start = */ 0,
515 /* end = */ stencilTable->GetNumStencils(),
516 context);
517 }
518
557 bool EvalStencils(id<MTLBuffer> srcBuffer, BufferDescriptor const &srcDesc,
558 id<MTLBuffer> dstBuffer, BufferDescriptor const &dstDesc,
559 id<MTLBuffer> duBuffer, BufferDescriptor const &duDesc,
560 id<MTLBuffer> dvBuffer, BufferDescriptor const &dvDesc,
561 id<MTLBuffer> sizesBuffer,
562 id<MTLBuffer> offsetsBuffer,
563 id<MTLBuffer> indicesBuffer,
564 id<MTLBuffer> weightsBuffer,
565 id<MTLBuffer> duWeightsBuffer,
566 id<MTLBuffer> dvWeightsBuffer,
567 int start,
568 int end,
569 MTLContext* context) const;
570
627 bool EvalStencils(id<MTLBuffer> srcBuffer, BufferDescriptor const &srcDesc,
628 id<MTLBuffer> dstBuffer, BufferDescriptor const &dstDesc,
629 id<MTLBuffer> duBuffer, BufferDescriptor const &duDesc,
630 id<MTLBuffer> dvBuffer, BufferDescriptor const &dvDesc,
631 id<MTLBuffer> duuBuffer, BufferDescriptor const &duuDesc,
632 id<MTLBuffer> duvBuffer, BufferDescriptor const &duvDesc,
633 id<MTLBuffer> dvvBuffer, BufferDescriptor const &dvvDesc,
634 id<MTLBuffer> sizesBuffer,
635 id<MTLBuffer> offsetsBuffer,
636 id<MTLBuffer> indicesBuffer,
637 id<MTLBuffer> weightsBuffer,
638 id<MTLBuffer> duWeightsBuffer,
639 id<MTLBuffer> dvWeightsBuffer,
640 id<MTLBuffer> duuWeightsBuffer,
641 id<MTLBuffer> duvWeightsBuffer,
642 id<MTLBuffer> dvvWeightsBuffer,
643 int start,
644 int end,
645 MTLContext* context) const;
646
652
686 template <typename SRC_BUFFER, typename DST_BUFFER,
687 typename PATCHCOORD_BUFFER, typename PATCH_TABLE>
688 static bool EvalPatches(
689 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
690 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
691 int numPatchCoords,
692 PATCHCOORD_BUFFER *patchCoords,
693 PATCH_TABLE *patchTable,
694 MTLComputeEvaluator const *instance,
695 MTLContext* context) {
696
697 if (instance) {
698 return instance->EvalPatches(srcBuffer, srcDesc,
699 dstBuffer, dstDesc,
700 numPatchCoords, patchCoords,
701 patchTable,
702 context);
703 } else {
704 // Create an instance on demand (slow)
705 instance = Create(srcDesc, dstDesc,
706 BufferDescriptor(),
707 BufferDescriptor(),
708 context);
709 if (instance) {
710 bool r = instance->EvalPatches(srcBuffer, srcDesc,
711 dstBuffer, dstDesc,
712 numPatchCoords, patchCoords,
713 patchTable,
714 context);
715 delete instance;
716 return r;
717 }
718 return false;
719 }
720 }
721
767 template <typename SRC_BUFFER, typename DST_BUFFER,
768 typename PATCHCOORD_BUFFER, typename PATCH_TABLE>
769 static bool EvalPatches(
770 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
771 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
772 DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
773 DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
774 int numPatchCoords,
775 PATCHCOORD_BUFFER *patchCoords,
776 PATCH_TABLE *patchTable,
777 MTLComputeEvaluator* instance,
778 MTLContext* context) {
779
780 if (instance) {
781 return instance->EvalPatches(srcBuffer, srcDesc,
782 dstBuffer, dstDesc,
783 duBuffer, duDesc,
784 dvBuffer, dvDesc,
785 numPatchCoords, patchCoords,
786 patchTable,
787 context);
788 } else {
789 // Create an instance on demand (slow)
790 instance = Create(srcDesc, dstDesc,
791 duDesc, dvDesc, context);
792 if (instance) {
793 bool r = instance->EvalPatches(srcBuffer, srcDesc,
794 dstBuffer, dstDesc,
795 duBuffer, duDesc,
796 dvBuffer, dvDesc,
797 numPatchCoords, patchCoords,
798 patchTable,
799 context);
800 delete instance;
801 return r;
802 }
803 return false;
804 }
805 }
806
870 template <typename SRC_BUFFER, typename DST_BUFFER,
871 typename PATCHCOORD_BUFFER, typename PATCH_TABLE>
872 static bool EvalPatches(
873 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
874 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
875 DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
876 DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
877 DST_BUFFER *duuBuffer, BufferDescriptor const &duuDesc,
878 DST_BUFFER *duvBuffer, BufferDescriptor const &duvDesc,
879 DST_BUFFER *dvvBuffer, BufferDescriptor const &dvvDesc,
880 int numPatchCoords,
881 PATCHCOORD_BUFFER *patchCoords,
882 PATCH_TABLE *patchTable,
883 MTLComputeEvaluator* instance,
884 MTLContext* context) {
885
886 if (instance) {
887 return instance->EvalPatches(srcBuffer, srcDesc,
888 dstBuffer, dstDesc,
889 duBuffer, duDesc,
890 dvBuffer, dvDesc,
891 duuBuffer, duuDesc,
892 duvBuffer, duvDesc,
893 dvvBuffer, dvvDesc,
894 numPatchCoords, patchCoords,
895 patchTable,
896 context);
897 } else {
898 // Create an instance on demand (slow)
899 instance = Create(srcDesc, dstDesc,
900 duDesc, dvDesc,
901 duuDesc, duvDesc, dvvDesc, context);
902 if (instance) {
903 bool r = instance->EvalPatches(srcBuffer, srcDesc,
904 dstBuffer, dstDesc,
905 duBuffer, duDesc,
906 dvBuffer, dvDesc,
907 duuBuffer, duuDesc,
908 duvBuffer, duvDesc,
909 dvvBuffer, dvvDesc,
910 numPatchCoords, patchCoords,
911 patchTable,
912 context);
913 delete instance;
914 return r;
915 }
916 return false;
917 }
918 }
919
947 template <typename SRC_BUFFER, typename DST_BUFFER,
948 typename PATCHCOORD_BUFFER, typename PATCH_TABLE>
949 bool EvalPatches(
950 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
951 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
952 int numPatchCoords,
953 PATCHCOORD_BUFFER *patchCoords,
954 PATCH_TABLE *patchTable,
955 MTLContext* context) const {
956
957 return EvalPatches(srcBuffer->BindMTLBuffer(context), srcDesc,
958 dstBuffer->BindMTLBuffer(context), dstDesc,
959 0, BufferDescriptor(),
960 0, BufferDescriptor(),
961 numPatchCoords,
962 patchCoords->BindMTLBuffer(context),
963 patchTable->GetPatchArrays(),
964 patchTable->GetPatchIndexBuffer(),
965 patchTable->GetPatchParamBuffer(),
966 context);
967 }
968
1006 template <typename SRC_BUFFER, typename DST_BUFFER,
1007 typename PATCHCOORD_BUFFER, typename PATCH_TABLE>
1008 bool EvalPatches(
1009 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
1010 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
1011 DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
1012 DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
1013 int numPatchCoords,
1014 PATCHCOORD_BUFFER *patchCoords,
1015 PATCH_TABLE *patchTable,
1016 MTLContext* context) const {
1017
1018 return EvalPatches(srcBuffer->BindMTLBuffer(context), srcDesc,
1019 dstBuffer->BindMTLBuffer(context), dstDesc,
1020 duBuffer->BindMTLBuffer(context), duDesc,
1021 dvBuffer->BindMTLBuffer(context), dvDesc,
1022 numPatchCoords,
1023 patchCoords->BindMTLBuffer(context),
1024 patchTable->GetPatchArrays(),
1025 patchTable->GetPatchIndexBuffer(),
1026 patchTable->GetPatchParamBuffer(),
1027 context);
1028 }
1029
1085 template <typename SRC_BUFFER, typename DST_BUFFER,
1086 typename PATCHCOORD_BUFFER, typename PATCH_TABLE>
1087 bool EvalPatches(
1088 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
1089 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
1090 DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
1091 DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
1092 DST_BUFFER *duuBuffer, BufferDescriptor const &duuDesc,
1093 DST_BUFFER *duvBuffer, BufferDescriptor const &duvDesc,
1094 DST_BUFFER *dvvBuffer, BufferDescriptor const &dvvDesc,
1095 int numPatchCoords,
1096 PATCHCOORD_BUFFER *patchCoords,
1097 PATCH_TABLE *patchTable,
1098 MTLContext* context) const {
1099
1100 return EvalPatches(srcBuffer->BindMTLBuffer(context), srcDesc,
1101 dstBuffer->BindMTLBuffer(context), dstDesc,
1102 duBuffer->BindMTLBuffer(context), duDesc,
1103 dvBuffer->BindMTLBuffer(context), dvDesc,
1104 duuBuffer->BindMTLBuffer(context), duuDesc,
1105 duvBuffer->BindMTLBuffer(context), duvDesc,
1106 dvvBuffer->BindMTLBuffer(context), dvvDesc,
1107 numPatchCoords,
1108 patchCoords->BindMTLBuffer(context),
1109 patchTable->GetPatchArrays(),
1110 patchTable->GetPatchIndexBuffer(),
1111 patchTable->GetPatchParamBuffer(),
1112 context);
1113 }
1114
1115 bool EvalPatches(id<MTLBuffer> srcBuffer, BufferDescriptor const &srcDesc,
1116 id<MTLBuffer> dstBuffer, BufferDescriptor const &dstDesc,
1117 id<MTLBuffer> duBuffer, BufferDescriptor const &duDesc,
1118 id<MTLBuffer> dvBuffer, BufferDescriptor const &dvDesc,
1119 int numPatchCoords,
1120 id<MTLBuffer> patchCoordsBuffer,
1121 const PatchArrayVector &patchArrays,
1122 id<MTLBuffer> patchIndexBuffer,
1123 id<MTLBuffer> patchParamsBuffer,
1124 MTLContext* context) const;
1125
1126 bool EvalPatches(id<MTLBuffer> srcBuffer, BufferDescriptor const &srcDesc,
1127 id<MTLBuffer> dstBuffer, BufferDescriptor const &dstDesc,
1128 id<MTLBuffer> duBuffer, BufferDescriptor const &duDesc,
1129 id<MTLBuffer> dvBuffer, BufferDescriptor const &dvDesc,
1130 id<MTLBuffer> duuBuffer, BufferDescriptor const &duuDesc,
1131 id<MTLBuffer> duvBuffer, BufferDescriptor const &duvDesc,
1132 id<MTLBuffer> dvvBuffer, BufferDescriptor const &dvvDesc,
1133 int numPatchCoords,
1134 id<MTLBuffer> patchCoordsBuffer,
1135 const PatchArrayVector &patchArrays,
1136 id<MTLBuffer> patchIndexBuffer,
1137 id<MTLBuffer> patchParamsBuffer,
1138 MTLContext* context) const;
1139
1173 template <typename SRC_BUFFER, typename DST_BUFFER,
1174 typename PATCHCOORD_BUFFER, typename PATCH_TABLE>
1175 static bool EvalPatchesVarying(
1176 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
1177 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
1178 int numPatchCoords,
1179 PATCHCOORD_BUFFER *patchCoords,
1180 PATCH_TABLE *patchTable,
1181 MTLComputeEvaluator const *instance,
1182 MTLContext* deviceContext) {
1183
1184 if (instance) {
1185 return instance->EvalPatchesVarying(
1186 srcBuffer, srcDesc,
1187 dstBuffer, dstDesc,
1188 numPatchCoords, patchCoords,
1189 patchTable,
1190 deviceContext);
1191 } else {
1192 // Create an instance on demand (slow)
1193 instance = Create(srcDesc, dstDesc,
1194 BufferDescriptor(),
1195 BufferDescriptor(),
1196 deviceContext);
1197 if (instance) {
1198 bool r = instance->EvalPatchesVarying(
1199 srcBuffer, srcDesc,
1200 dstBuffer, dstDesc,
1201 numPatchCoords, patchCoords,
1202 patchTable,
1203 deviceContext);
1204 delete instance;
1205 return r;
1206 }
1207 return false;
1208 }
1209 }
1210
1238 template <typename SRC_BUFFER, typename DST_BUFFER,
1239 typename PATCHCOORD_BUFFER, typename PATCH_TABLE>
1240 bool EvalPatchesVarying(
1241 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
1242 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
1243 int numPatchCoords,
1244 PATCHCOORD_BUFFER *patchCoords,
1245 PATCH_TABLE *patchTable,
1246 MTLContext* deviceContext) const {
1247
1248 return EvalPatches(srcBuffer->BindMTLBuffer(deviceContext), srcDesc,
1249 dstBuffer->BindMTLBuffer(deviceContext), dstDesc,
1250 0, BufferDescriptor(),
1251 0, BufferDescriptor(),
1252 numPatchCoords,
1253 patchCoords->BindMTLBuffer(deviceContext),
1254 patchTable->GetVaryingPatchArrays(),
1255 patchTable->GetVaryingPatchIndexBuffer(),
1256 patchTable->GetPatchParamBuffer(),
1257 deviceContext
1258 );
1259 }
1260
1306 template <typename SRC_BUFFER, typename DST_BUFFER,
1307 typename PATCHCOORD_BUFFER, typename PATCH_TABLE>
1308 static bool EvalPatchesVarying(
1309 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
1310 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
1311 DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
1312 DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
1313 int numPatchCoords,
1314 PATCHCOORD_BUFFER *patchCoords,
1315 PATCH_TABLE *patchTable,
1316 MTLComputeEvaluator const *instance,
1317 MTLContext* deviceContext) {
1318
1319 if (instance) {
1320 return instance->EvalPatchesVarying(
1321 srcBuffer, srcDesc,
1322 dstBuffer, dstDesc,
1323 duBuffer, duDesc,
1324 dvBuffer, dvDesc,
1325 numPatchCoords, patchCoords,
1326 patchTable,
1327 deviceContext);
1328 } else {
1329 // Create an instance on demand (slow)
1330 instance = Create(srcDesc, dstDesc,
1331 duDesc, dvDesc,
1332 deviceContext);
1333 if (instance) {
1334 bool r = instance->EvalPatchesVarying(
1335 srcBuffer, srcDesc,
1336 dstBuffer, dstDesc,
1337 duBuffer, duDesc,
1338 dvBuffer, dvDesc,
1339 numPatchCoords, patchCoords,
1340 patchTable,
1341 deviceContext);
1342 delete instance;
1343 return r;
1344 }
1345 return false;
1346 }
1347 }
1348
1388 template <typename SRC_BUFFER, typename DST_BUFFER,
1389 typename PATCHCOORD_BUFFER, typename PATCH_TABLE>
1390 bool EvalPatchesVarying(
1391 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
1392 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
1393 DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
1394 DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
1395 int numPatchCoords,
1396 PATCHCOORD_BUFFER *patchCoords,
1397 PATCH_TABLE *patchTable,
1398 MTLContext* deviceContext) const {
1399
1400 return EvalPatches(srcBuffer->BindMTLBuffer(deviceContext), srcDesc,
1401 dstBuffer->BindMTLBuffer(deviceContext), dstDesc,
1402 duBuffer->BindMTLBuffer(deviceContext), duDesc,
1403 dvBuffer->BindMTLBuffer(deviceContext), dvDesc,
1404 numPatchCoords,
1405 patchCoords->BindMTLBuffer(deviceContext),
1406 patchTable->GetVaryingPatchArrays(),
1407 patchTable->GetVaryingPatchIndexBuffer(),
1408 patchTable->GetPatchParamBuffer(),
1409 deviceContext
1410 );
1411 }
1412
1413
1477 template <typename SRC_BUFFER, typename DST_BUFFER,
1478 typename PATCHCOORD_BUFFER, typename PATCH_TABLE>
1479 static bool EvalPatchesVarying(
1480 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
1481 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
1482 DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
1483 DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
1484 DST_BUFFER *duuBuffer, BufferDescriptor const &duuDesc,
1485 DST_BUFFER *duvBuffer, BufferDescriptor const &duvDesc,
1486 DST_BUFFER *dvvBuffer, BufferDescriptor const &dvvDesc,
1487 int numPatchCoords,
1488 PATCHCOORD_BUFFER *patchCoords,
1489 PATCH_TABLE *patchTable,
1490 MTLComputeEvaluator const *instance,
1491 MTLContext* deviceContext) {
1492
1493 if (instance) {
1494 return instance->EvalPatchesVarying(
1495 srcBuffer, srcDesc,
1496 dstBuffer, dstDesc,
1497 duBuffer, duDesc,
1498 dvBuffer, dvDesc,
1499 duuBuffer, duuDesc,
1500 duvBuffer, duvDesc,
1501 dvvBuffer, dvvDesc,
1502 numPatchCoords, patchCoords,
1503 patchTable,
1504 deviceContext);
1505 } else {
1506 // Create an instance on demand (slow)
1507 instance = Create(srcDesc, dstDesc,
1508 duDesc, dvDesc,
1509 duuDesc, duvDesc, dvvDesc,
1510 deviceContext);
1511 if (instance) {
1512 bool r = instance->EvalPatchesVarying(
1513 srcBuffer, srcDesc,
1514 dstBuffer, dstDesc,
1515 duBuffer, duDesc,
1516 dvBuffer, dvDesc,
1517 duuBuffer, duuDesc,
1518 duvBuffer, duvDesc,
1519 dvvBuffer, dvvDesc,
1520 numPatchCoords, patchCoords,
1521 patchTable,
1522 deviceContext);
1523 delete instance;
1524 return r;
1525 }
1526 return false;
1527 }
1528 }
1529
1587 template <typename SRC_BUFFER, typename DST_BUFFER,
1588 typename PATCHCOORD_BUFFER, typename PATCH_TABLE>
1589 bool EvalPatchesVarying(
1590 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
1591 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
1592 DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
1593 DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
1594 DST_BUFFER *duuBuffer, BufferDescriptor const &duuDesc,
1595 DST_BUFFER *duvBuffer, BufferDescriptor const &duvDesc,
1596 DST_BUFFER *dvvBuffer, BufferDescriptor const &dvvDesc,
1597 int numPatchCoords,
1598 PATCHCOORD_BUFFER *patchCoords,
1599 PATCH_TABLE *patchTable,
1600 MTLContext* deviceContext) const {
1601
1602 return EvalPatches(srcBuffer->BindMTLBuffer(deviceContext), srcDesc,
1603 dstBuffer->BindMTLBuffer(deviceContext), dstDesc,
1604 duBuffer->BindMTLBuffer(deviceContext), duDesc,
1605 dvBuffer->BindMTLBuffer(deviceContext), dvDesc,
1606 duuBuffer->BindMTLBuffer(deviceContext), duuDesc,
1607 duvBuffer->BindMTLBuffer(deviceContext), duvDesc,
1608 dvvBuffer->BindMTLBuffer(deviceContext), dvvDesc,
1609 numPatchCoords,
1610 patchCoords->BindMTLBuffer(deviceContext),
1611 patchTable->GetVaryingPatchArrays(),
1612 patchTable->GetVaryingPatchIndexBuffer(),
1613 patchTable->GetPatchParamBuffer(),
1614 deviceContext
1615 );
1616 }
1617
1653 template <typename SRC_BUFFER, typename DST_BUFFER,
1654 typename PATCHCOORD_BUFFER, typename PATCH_TABLE>
1655 static bool EvalPatchesFaceVarying(
1656 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
1657 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
1658 int numPatchCoords,
1659 PATCHCOORD_BUFFER *patchCoords,
1660 PATCH_TABLE *patchTable,
1661 int fvarChannel,
1662 MTLComputeEvaluator const *instance,
1663 MTLContext* deviceContext) {
1664
1665 if (instance) {
1666 return instance->EvalPatchesFaceVarying(
1667 srcBuffer, srcDesc,
1668 dstBuffer, dstDesc,
1669 numPatchCoords, patchCoords,
1670 patchTable,
1671 fvarChannel,
1672 deviceContext);
1673 } else {
1674 // Create an instance on demand (slow)
1675 instance = Create(srcDesc, dstDesc,
1676 BufferDescriptor(),
1677 BufferDescriptor(),
1678 deviceContext);
1679 if (instance) {
1680 bool r = instance->EvalPatchesFaceVarying(
1681 srcBuffer, srcDesc,
1682 dstBuffer, dstDesc,
1683 numPatchCoords, patchCoords,
1684 patchTable,
1685 fvarChannel,
1686 deviceContext);
1687 delete instance;
1688 return r;
1689 }
1690 return false;
1691 }
1692 }
1693
1723 template <typename SRC_BUFFER, typename DST_BUFFER,
1724 typename PATCHCOORD_BUFFER, typename PATCH_TABLE>
1725 bool EvalPatchesFaceVarying(
1726 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
1727 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
1728 int numPatchCoords,
1729 PATCHCOORD_BUFFER *patchCoords,
1730 PATCH_TABLE *patchTable,
1731 int fvarChannel,
1732 MTLContext* deviceContext) const {
1733
1734 return EvalPatches(srcBuffer->BindMTLBuffer(deviceContext), srcDesc,
1735 dstBuffer->BindMTLBuffer(deviceContext), dstDesc,
1736 0, BufferDescriptor(),
1737 0, BufferDescriptor(),
1738 numPatchCoords,
1739 patchCoords->BindMTLBuffer(deviceContext),
1740 patchTable->GetFVarPatchArrays(fvarChannel),
1741 patchTable->GetFVarPatchIndexBuffer(fvarChannel),
1742 patchTable->GetFVarPatchParamBuffer(fvarChannel),
1743 deviceContext
1744 );
1745 }
1746
1794 template <typename SRC_BUFFER, typename DST_BUFFER,
1795 typename PATCHCOORD_BUFFER, typename PATCH_TABLE>
1796 static bool EvalPatchesFaceVarying(
1797 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
1798 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
1799 DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
1800 DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
1801 int numPatchCoords,
1802 PATCHCOORD_BUFFER *patchCoords,
1803 PATCH_TABLE *patchTable,
1804 int fvarChannel,
1805 MTLComputeEvaluator const *instance,
1806 MTLContext* deviceContext) {
1807
1808 if (instance) {
1809 return instance->EvalPatchesFaceVarying(
1810 srcBuffer, srcDesc,
1811 dstBuffer, dstDesc,
1812 duBuffer, duDesc,
1813 dvBuffer, dvDesc,
1814 numPatchCoords, patchCoords,
1815 patchTable,
1816 fvarChannel,
1817 deviceContext);
1818 } else {
1819 // Create an instance on demand (slow)
1820 instance = Create(srcDesc, dstDesc,
1821 duDesc, dvDesc,
1822 deviceContext);
1823 if (instance) {
1824 bool r = instance->EvalPatchesFaceVarying(
1825 srcBuffer, srcDesc,
1826 dstBuffer, dstDesc,
1827 duBuffer, duDesc,
1828 dvBuffer, dvDesc,
1829 numPatchCoords, patchCoords,
1830 patchTable,
1831 fvarChannel,
1832 deviceContext);
1833 delete instance;
1834 return r;
1835 }
1836 return false;
1837 }
1838 }
1839
1881 template <typename SRC_BUFFER, typename DST_BUFFER,
1882 typename PATCHCOORD_BUFFER, typename PATCH_TABLE>
1883 bool EvalPatchesFaceVarying(
1884 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
1885 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
1886 DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
1887 DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
1888 int numPatchCoords,
1889 PATCHCOORD_BUFFER *patchCoords,
1890 PATCH_TABLE *patchTable,
1891 int fvarChannel,
1892 MTLContext* deviceContext) const {
1893
1894 return EvalPatches(srcBuffer->BindMTLBuffer(deviceContext), srcDesc,
1895 dstBuffer->BindMTLBuffer(deviceContext), dstDesc,
1896 duBuffer->BindMTLBuffer(deviceContext), duDesc,
1897 dvBuffer->BindMTLBuffer(deviceContext), dvDesc,
1898 numPatchCoords,
1899 patchCoords->BindMTLBuffer(deviceContext),
1900 patchTable->GetFVarPatchArrays(fvarChannel),
1901 patchTable->GetFVarPatchIndexBuffer(fvarChannel),
1902 patchTable->GetFVarPatchParamBuffer(fvarChannel),
1903 deviceContext
1904 );
1905 }
1906
1972 template <typename SRC_BUFFER, typename DST_BUFFER,
1973 typename PATCHCOORD_BUFFER, typename PATCH_TABLE>
1974 static bool EvalPatchesFaceVarying(
1975 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
1976 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
1977 DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
1978 DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
1979 DST_BUFFER *duuBuffer, BufferDescriptor const &duuDesc,
1980 DST_BUFFER *duvBuffer, BufferDescriptor const &duvDesc,
1981 DST_BUFFER *dvvBuffer, BufferDescriptor const &dvvDesc,
1982 int numPatchCoords,
1983 PATCHCOORD_BUFFER *patchCoords,
1984 PATCH_TABLE *patchTable,
1985 int fvarChannel,
1986 MTLComputeEvaluator const *instance,
1987 MTLContext* deviceContext) {
1988
1989 if (instance) {
1990 return instance->EvalPatchesFaceVarying(
1991 srcBuffer, srcDesc,
1992 dstBuffer, dstDesc,
1993 duBuffer, duDesc,
1994 dvBuffer, dvDesc,
1995 duuBuffer, duuDesc,
1996 duvBuffer, duvDesc,
1997 dvvBuffer, dvvDesc,
1998 numPatchCoords, patchCoords,
1999 patchTable,
2000 fvarChannel,
2001 deviceContext);
2002 } else {
2003 // Create an instance on demand (slow)
2004 instance = Create(srcDesc, dstDesc,
2005 duDesc, dvDesc,
2006 duuDesc, duvDesc, dvvDesc,
2007 deviceContext);
2008 if (instance) {
2009 bool r = instance->EvalPatchesFaceVarying(
2010 srcBuffer, srcDesc,
2011 dstBuffer, dstDesc,
2012 duBuffer, duDesc,
2013 dvBuffer, dvDesc,
2014 duuBuffer, duuDesc,
2015 duvBuffer, duvDesc,
2016 dvvBuffer, dvvDesc,
2017 numPatchCoords, patchCoords,
2018 patchTable,
2019 fvarChannel,
2020 deviceContext);
2021 delete instance;
2022 return r;
2023 }
2024 return false;
2025 }
2026 }
2027
2087 template <typename SRC_BUFFER, typename DST_BUFFER,
2088 typename PATCHCOORD_BUFFER, typename PATCH_TABLE>
2089 bool EvalPatchesFaceVarying(
2090 SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc,
2091 DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc,
2092 DST_BUFFER *duBuffer, BufferDescriptor const &duDesc,
2093 DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc,
2094 DST_BUFFER *duuBuffer, BufferDescriptor const &duuDesc,
2095 DST_BUFFER *duvBuffer, BufferDescriptor const &duvDesc,
2096 DST_BUFFER *dvvBuffer, BufferDescriptor const &dvvDesc,
2097 int numPatchCoords,
2098 PATCHCOORD_BUFFER *patchCoords,
2099 PATCH_TABLE *patchTable,
2100 int fvarChannel,
2101 MTLContext* deviceContext) const {
2102
2103 return EvalPatches(srcBuffer->BindMTLBuffer(deviceContext), srcDesc,
2104 dstBuffer->BindMTLBuffer(deviceContext), dstDesc,
2105 duBuffer->BindMTLBuffer(deviceContext), duDesc,
2106 dvBuffer->BindMTLBuffer(deviceContext), dvDesc,
2107 duuBuffer->BindMTLBuffer(deviceContext), duuDesc,
2108 duvBuffer->BindMTLBuffer(deviceContext), duvDesc,
2109 dvvBuffer->BindMTLBuffer(deviceContext), dvvDesc,
2110 numPatchCoords,
2111 patchCoords->BindMTLBuffer(deviceContext),
2112 patchTable->GetFVarPatchArrays(fvarChannel),
2113 patchTable->GetFVarPatchIndexBuffer(fvarChannel),
2114 patchTable->GetFVarPatchParamBuffer(fvarChannel),
2115 fvarChannel,
2116 deviceContext
2117 );
2118 }
2119
2121 bool Compile(BufferDescriptor const &srcDesc,
2122 BufferDescriptor const &dstDesc,
2123 BufferDescriptor const &duDesc,
2124 BufferDescriptor const &dvDesc,
2125 BufferDescriptor const &duuDesc,
2126 BufferDescriptor const &duvDesc,
2127 BufferDescriptor const &dvvDesc,
2128 MTLContext* context);
2129
2131 static void Synchronize(MTLContext* context);
2132
2133 private:
2134
2135 id<MTLLibrary> _computeLibrary;
2136 id<MTLComputePipelineState> _evalStencils;
2137 id<MTLComputePipelineState> _evalPatches;
2138 id<MTLBuffer> _parameterBuffer;
2139
2140 int _workGroupSize;
2141};
2142
2143} //end namespace Osd
2144
2145} //end namespace OPENSUBDIV_VERSION
2146 using namespace OPENSUBDIV_VERSION;
2147
2148} //end namespace OpenSubdiv
2149
2150#endif // OPENSUBDIV3_OSD_MTL_COMPUTE_EVALUATOR_H
mtlCommon.h
bufferDescriptor.h
OpenSubdiv
Definition limits.h:15
OpenSubdiv::OPENSUBDIV_VERSION
Definition limits.h:16
OpenSubdiv::OPENSUBDIV_VERSION::Far
Definition refinerSurfaceFactory.h:19
OpenSubdiv::OPENSUBDIV_VERSION::Osd
Definition bufferDescriptor.h:17
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArrayVector
std::vector< PatchArray > PatchArrayVector
Definition types.h:115
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTable
Container for arrays of parametric patches.
Definition patchTable.h:38
OpenSubdiv::OPENSUBDIV_VERSION::Far::StencilTable
Stencil table class wrapping the template for compatibility.
Definition stencilTable.h:256
OpenSubdiv::OPENSUBDIV_VERSION::Far::LimitStencilTable
Limit stencil table class wrapping the template for compatibility.
Definition stencilTable.h:566
OpenSubdiv::OPENSUBDIV_VERSION::Osd::BufferDescriptor
BufferDescriptor is a struct which describes buffer elements in interleaved data buffers....
Definition bufferDescriptor.h:44
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLContext
Definition mtlCommon.h:23
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLStencilTable::MTLStencilTable
MTLStencilTable(Far::LimitStencilTable const *stencilTable, MTLContext *context)
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLStencilTable::GetDuWeightsBuffer
id< MTLBuffer > GetDuWeightsBuffer() const
Definition mtlComputeEvaluator.h:52
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLStencilTable::~MTLStencilTable
~MTLStencilTable()
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLStencilTable::GetDvvWeightsBuffer
id< MTLBuffer > GetDvvWeightsBuffer() const
Definition mtlComputeEvaluator.h:56
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLStencilTable::MTLStencilTable
MTLStencilTable(Far::StencilTable const *stencilTable, MTLContext *context)
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLStencilTable::GetDuuWeightsBuffer
id< MTLBuffer > GetDuuWeightsBuffer() const
Definition mtlComputeEvaluator.h:54
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLStencilTable::GetDuvWeightsBuffer
id< MTLBuffer > GetDuvWeightsBuffer() const
Definition mtlComputeEvaluator.h:55
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLStencilTable::GetNumStencils
int GetNumStencils() const
Definition mtlComputeEvaluator.h:58
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLStencilTable::GetIndicesBuffer
id< MTLBuffer > GetIndicesBuffer() const
Definition mtlComputeEvaluator.h:50
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLStencilTable::GetSizesBuffer
id< MTLBuffer > GetSizesBuffer() const
Definition mtlComputeEvaluator.h:48
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLStencilTable::GetOffsetsBuffer
id< MTLBuffer > GetOffsetsBuffer() const
Definition mtlComputeEvaluator.h:49
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLStencilTable::GetWeightsBuffer
id< MTLBuffer > GetWeightsBuffer() const
Definition mtlComputeEvaluator.h:51
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLStencilTable::Create
static MTLStencilTable * Create(STENCIL_TABLE *stencilTable, DEVICE_CONTEXT context)
Definition mtlComputeEvaluator.h:37
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLStencilTable::GetDvWeightsBuffer
id< MTLBuffer > GetDvWeightsBuffer() const
Definition mtlComputeEvaluator.h:53
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLComputeEvaluator::EvalStencils
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...
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLComputeEvaluator::EvalPatches
static bool EvalPatches(SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc, DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc, DST_BUFFER *duBuffer, BufferDescriptor const &duDesc, DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc, int numPatchCoords, PATCHCOORD_BUFFER *patchCoords, PATCH_TABLE *patchTable, MTLComputeEvaluator *instance, MTLContext *context)
Generic limit eval function. This function has a same signature as other device kernels have so that ...
Definition mtlComputeEvaluator.h:769
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLComputeEvaluator::EvalStencils
static bool EvalStencils(SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc, DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc, DST_BUFFER *duBuffer, BufferDescriptor const &duDesc, DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc, 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...
Definition mtlComputeEvaluator.h:295
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLComputeEvaluator::EvalPatchesFaceVarying
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 ...
Definition mtlComputeEvaluator.h:1974
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLComputeEvaluator::MTLComputeEvaluator
MTLComputeEvaluator()
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLComputeEvaluator::~MTLComputeEvaluator
~MTLComputeEvaluator()
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLComputeEvaluator::EvalPatches
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 ...
Definition mtlComputeEvaluator.h:688
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLComputeEvaluator::EvalPatchesVarying
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 ...
Definition mtlComputeEvaluator.h:1589
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLComputeEvaluator::EvalStencils
static bool EvalStencils(SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc, DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc, DST_BUFFER *duBuffer, BufferDescriptor const &duDesc, DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc, STENCIL_TABLE const *stencilTable, MTLComputeEvaluator const *instance, MTLContext *context)
Generic static stencil function. This function has a same signature as other device kernels have so t...
Definition mtlComputeEvaluator.h:203
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLComputeEvaluator::EvalPatchesFaceVarying
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 ...
Definition mtlComputeEvaluator.h:1883
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLComputeEvaluator::EvalPatchesFaceVarying
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 ...
Definition mtlComputeEvaluator.h:1655
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLComputeEvaluator::EvalPatchesVarying
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 ...
Definition mtlComputeEvaluator.h:1479
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLComputeEvaluator::EvalStencils
bool EvalStencils(SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc, DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc, STENCIL_TABLE const *stencilTable, MTLContext *context) const
Generic stencil function.
Definition mtlComputeEvaluator.h:359
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLComputeEvaluator::EvalPatches
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
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLComputeEvaluator::EvalPatchesFaceVarying
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 ...
Definition mtlComputeEvaluator.h:2089
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLComputeEvaluator::Synchronize
static void Synchronize(MTLContext *context)
Wait for the dispatched kernel to finish.
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLComputeEvaluator::Instantiatable
bool Instantiatable
Definition mtlComputeEvaluator.h:77
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLComputeEvaluator::EvalStencils
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.
Definition mtlComputeEvaluator.h:413
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLComputeEvaluator::EvalPatches
static bool EvalPatches(SRC_BUFFER *srcBuffer, BufferDescriptor const &srcDesc, DST_BUFFER *dstBuffer, BufferDescriptor const &dstDesc, DST_BUFFER *duBuffer, BufferDescriptor const &duDesc, DST_BUFFER *dvBuffer, BufferDescriptor const &dvDesc, 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 ...
Definition mtlComputeEvaluator.h:872
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLComputeEvaluator::EvalPatchesFaceVarying
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 ...
Definition mtlComputeEvaluator.h:1725
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLComputeEvaluator::EvalPatchesVarying
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 ...
Definition mtlComputeEvaluator.h:1175
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLComputeEvaluator::EvalStencils
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.
Definition mtlComputeEvaluator.h:487
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLComputeEvaluator::EvalStencils
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...
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLComputeEvaluator::EvalPatchesFaceVarying
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 ...
Definition mtlComputeEvaluator.h:1796
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLComputeEvaluator::EvalPatches
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 ...
Definition mtlComputeEvaluator.h:949
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLComputeEvaluator::EvalStencils
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...
Definition mtlComputeEvaluator.h:132
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLComputeEvaluator::EvalPatchesVarying
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 ...
Definition mtlComputeEvaluator.h:1308
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLComputeEvaluator::EvalPatches
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...
Definition mtlComputeEvaluator.h:1087
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLComputeEvaluator::EvalPatches
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...
Definition mtlComputeEvaluator.h:1008
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLComputeEvaluator::EvalPatchesVarying
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 ...
Definition mtlComputeEvaluator.h:1390
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLComputeEvaluator::EvalPatchesVarying
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 ...
Definition mtlComputeEvaluator.h:1240
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLComputeEvaluator::Create
static MTLComputeEvaluator * Create(BufferDescriptor const &srcDesc, BufferDescriptor const &dstDesc, BufferDescriptor const &duDesc, BufferDescriptor const &dvDesc, MTLContext *context)
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLComputeEvaluator::Create
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)
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLComputeEvaluator::Compile
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.
OpenSubdiv::OPENSUBDIV_VERSION::Osd::MTLComputeEvaluator::EvalPatches
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
types.h