yum-mirror/VkFFT

git clone https://git.yummers.dev/yum-mirror/VkFFT

Tolmachev DmitriiMetal support in VkFFTba7001c

master
17.7 KiB655 linesraw
1//-------------------------------------------------------------------------------------------------------------------------------------------------------------
2//
3// Metal/MTLArgument.hpp
4//
5// Copyright 2020-2021 Apple Inc.
6//
7// Licensed under the Apache License, Version 2.0 (the "License");
8// you may not use this file except in compliance with the License.
9// You may obtain a copy of the License at
10//
11//     http://www.apache.org/licenses/LICENSE-2.0
12//
13// Unless required by applicable law or agreed to in writing, software
14// distributed under the License is distributed on an "AS IS" BASIS,
15// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16// See the License for the specific language governing permissions and
17// limitations under the License.
18//
19//-------------------------------------------------------------------------------------------------------------------------------------------------------------
20
21#pragma once
22
23#include "MTLDefines.hpp"
24#include "MTLHeaderBridge.hpp"
25#include "MTLPrivate.hpp"
26
27#include <Foundation/Foundation.hpp>
28
29#include "MTLArgument.hpp"
30#include "MTLTexture.hpp"
31
32namespace MTL
33{
34_MTL_ENUM(NS::UInteger, DataType) {
35    DataTypeNone = 0,
36    DataTypeStruct = 1,
37    DataTypeArray = 2,
38    DataTypeFloat = 3,
39    DataTypeFloat2 = 4,
40    DataTypeFloat3 = 5,
41    DataTypeFloat4 = 6,
42    DataTypeFloat2x2 = 7,
43    DataTypeFloat2x3 = 8,
44    DataTypeFloat2x4 = 9,
45    DataTypeFloat3x2 = 10,
46    DataTypeFloat3x3 = 11,
47    DataTypeFloat3x4 = 12,
48    DataTypeFloat4x2 = 13,
49    DataTypeFloat4x3 = 14,
50    DataTypeFloat4x4 = 15,
51    DataTypeHalf = 16,
52    DataTypeHalf2 = 17,
53    DataTypeHalf3 = 18,
54    DataTypeHalf4 = 19,
55    DataTypeHalf2x2 = 20,
56    DataTypeHalf2x3 = 21,
57    DataTypeHalf2x4 = 22,
58    DataTypeHalf3x2 = 23,
59    DataTypeHalf3x3 = 24,
60    DataTypeHalf3x4 = 25,
61    DataTypeHalf4x2 = 26,
62    DataTypeHalf4x3 = 27,
63    DataTypeHalf4x4 = 28,
64    DataTypeInt = 29,
65    DataTypeInt2 = 30,
66    DataTypeInt3 = 31,
67    DataTypeInt4 = 32,
68    DataTypeUInt = 33,
69    DataTypeUInt2 = 34,
70    DataTypeUInt3 = 35,
71    DataTypeUInt4 = 36,
72    DataTypeShort = 37,
73    DataTypeShort2 = 38,
74    DataTypeShort3 = 39,
75    DataTypeShort4 = 40,
76    DataTypeUShort = 41,
77    DataTypeUShort2 = 42,
78    DataTypeUShort3 = 43,
79    DataTypeUShort4 = 44,
80    DataTypeChar = 45,
81    DataTypeChar2 = 46,
82    DataTypeChar3 = 47,
83    DataTypeChar4 = 48,
84    DataTypeUChar = 49,
85    DataTypeUChar2 = 50,
86    DataTypeUChar3 = 51,
87    DataTypeUChar4 = 52,
88    DataTypeBool = 53,
89    DataTypeBool2 = 54,
90    DataTypeBool3 = 55,
91    DataTypeBool4 = 56,
92    DataTypeTexture = 58,
93    DataTypeSampler = 59,
94    DataTypePointer = 60,
95    DataTypeR8Unorm = 62,
96    DataTypeR8Snorm = 63,
97    DataTypeR16Unorm = 64,
98    DataTypeR16Snorm = 65,
99    DataTypeRG8Unorm = 66,
100    DataTypeRG8Snorm = 67,
101    DataTypeRG16Unorm = 68,
102    DataTypeRG16Snorm = 69,
103    DataTypeRGBA8Unorm = 70,
104    DataTypeRGBA8Unorm_sRGB = 71,
105    DataTypeRGBA8Snorm = 72,
106    DataTypeRGBA16Unorm = 73,
107    DataTypeRGBA16Snorm = 74,
108    DataTypeRGB10A2Unorm = 75,
109    DataTypeRG11B10Float = 76,
110    DataTypeRGB9E5Float = 77,
111    DataTypeRenderPipeline = 78,
112    DataTypeComputePipeline = 79,
113    DataTypeIndirectCommandBuffer = 80,
114    DataTypeLong = 81,
115    DataTypeLong2 = 82,
116    DataTypeLong3 = 83,
117    DataTypeLong4 = 84,
118    DataTypeULong = 85,
119    DataTypeULong2 = 86,
120    DataTypeULong3 = 87,
121    DataTypeULong4 = 88,
122    DataTypeVisibleFunctionTable = 115,
123    DataTypeIntersectionFunctionTable = 116,
124    DataTypePrimitiveAccelerationStructure = 117,
125    DataTypeInstanceAccelerationStructure = 118,
126};
127
128_MTL_ENUM(NS::UInteger, ArgumentType) {
129    ArgumentTypeBuffer = 0,
130    ArgumentTypeThreadgroupMemory = 1,
131    ArgumentTypeTexture = 2,
132    ArgumentTypeSampler = 3,
133    ArgumentTypeImageblockData = 16,
134    ArgumentTypeImageblock = 17,
135    ArgumentTypeVisibleFunctionTable = 24,
136    ArgumentTypePrimitiveAccelerationStructure = 25,
137    ArgumentTypeInstanceAccelerationStructure = 26,
138    ArgumentTypeIntersectionFunctionTable = 27,
139};
140
141_MTL_ENUM(NS::UInteger, ArgumentAccess) {
142    ArgumentAccessReadOnly = 0,
143    ArgumentAccessReadWrite = 1,
144    ArgumentAccessWriteOnly = 2,
145};
146
147class Type : public NS::Referencing<Type>
148{
149public:
150    static class Type* alloc();
151
152    class Type*        init();
153
154    MTL::DataType      dataType() const;
155};
156
157class StructMember : public NS::Referencing<StructMember>
158{
159public:
160    static class StructMember*  alloc();
161
162    class StructMember*         init();
163
164    NS::String*                 name() const;
165
166    NS::UInteger                offset() const;
167
168    MTL::DataType               dataType() const;
169
170    class StructType*           structType();
171
172    class ArrayType*            arrayType();
173
174    class TextureReferenceType* textureReferenceType();
175
176    class PointerType*          pointerType();
177
178    NS::UInteger                argumentIndex() const;
179};
180
181class StructType : public NS::Referencing<StructType, Type>
182{
183public:
184    static class StructType* alloc();
185
186    class StructType*        init();
187
188    NS::Array*               members() const;
189
190    class StructMember*      memberByName(const NS::String* name);
191};
192
193class ArrayType : public NS::Referencing<ArrayType, Type>
194{
195public:
196    static class ArrayType*     alloc();
197
198    class ArrayType*            init();
199
200    MTL::DataType               elementType() const;
201
202    NS::UInteger                arrayLength() const;
203
204    NS::UInteger                stride() const;
205
206    NS::UInteger                argumentIndexStride() const;
207
208    class StructType*           elementStructType();
209
210    class ArrayType*            elementArrayType();
211
212    class TextureReferenceType* elementTextureReferenceType();
213
214    class PointerType*          elementPointerType();
215};
216
217class PointerType : public NS::Referencing<PointerType, Type>
218{
219public:
220    static class PointerType* alloc();
221
222    class PointerType*        init();
223
224    MTL::DataType             elementType() const;
225
226    MTL::ArgumentAccess       access() const;
227
228    NS::UInteger              alignment() const;
229
230    NS::UInteger              dataSize() const;
231
232    bool                      elementIsArgumentBuffer() const;
233
234    class StructType*         elementStructType();
235
236    class ArrayType*          elementArrayType();
237};
238
239class TextureReferenceType : public NS::Referencing<TextureReferenceType, Type>
240{
241public:
242    static class TextureReferenceType* alloc();
243
244    class TextureReferenceType*        init();
245
246    MTL::DataType                      textureDataType() const;
247
248    MTL::TextureType                   textureType() const;
249
250    MTL::ArgumentAccess                access() const;
251
252    bool                               isDepthTexture() const;
253};
254
255class Argument : public NS::Referencing<Argument>
256{
257public:
258    static class Argument* alloc();
259
260    class Argument*        init();
261
262    NS::String*            name() const;
263
264    MTL::ArgumentType      type() const;
265
266    MTL::ArgumentAccess    access() const;
267
268    NS::UInteger           index() const;
269
270    bool                   active() const;
271
272    NS::UInteger           bufferAlignment() const;
273
274    NS::UInteger           bufferDataSize() const;
275
276    MTL::DataType          bufferDataType() const;
277
278    class StructType*      bufferStructType() const;
279
280    class PointerType*     bufferPointerType() const;
281
282    NS::UInteger           threadgroupMemoryAlignment() const;
283
284    NS::UInteger           threadgroupMemoryDataSize() const;
285
286    MTL::TextureType       textureType() const;
287
288    MTL::DataType          textureDataType() const;
289
290    bool                   isDepthTexture() const;
291
292    NS::UInteger           arrayLength() const;
293};
294
295}
296
297// static method: alloc
298_MTL_INLINE MTL::Type* MTL::Type::alloc()
299{
300    return NS::Object::alloc<MTL::Type>(_MTL_PRIVATE_CLS(MTLType));
301}
302
303// method: init
304_MTL_INLINE MTL::Type* MTL::Type::init()
305{
306    return NS::Object::init<MTL::Type>();
307}
308
309// property: dataType
310_MTL_INLINE MTL::DataType MTL::Type::dataType() const
311{
312    return Object::sendMessage<MTL::DataType>(this, _MTL_PRIVATE_SEL(dataType));
313}
314
315// static method: alloc
316_MTL_INLINE MTL::StructMember* MTL::StructMember::alloc()
317{
318    return NS::Object::alloc<MTL::StructMember>(_MTL_PRIVATE_CLS(MTLStructMember));
319}
320
321// method: init
322_MTL_INLINE MTL::StructMember* MTL::StructMember::init()
323{
324    return NS::Object::init<MTL::StructMember>();
325}
326
327// property: name
328_MTL_INLINE NS::String* MTL::StructMember::name() const
329{
330    return Object::sendMessage<NS::String*>(this, _MTL_PRIVATE_SEL(name));
331}
332
333// property: offset
334_MTL_INLINE NS::UInteger MTL::StructMember::offset() const
335{
336    return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(offset));
337}
338
339// property: dataType
340_MTL_INLINE MTL::DataType MTL::StructMember::dataType() const
341{
342    return Object::sendMessage<MTL::DataType>(this, _MTL_PRIVATE_SEL(dataType));
343}
344
345// method: structType
346_MTL_INLINE MTL::StructType* MTL::StructMember::structType()
347{
348    return Object::sendMessage<MTL::StructType*>(this, _MTL_PRIVATE_SEL(structType));
349}
350
351// method: arrayType
352_MTL_INLINE MTL::ArrayType* MTL::StructMember::arrayType()
353{
354    return Object::sendMessage<MTL::ArrayType*>(this, _MTL_PRIVATE_SEL(arrayType));
355}
356
357// method: textureReferenceType
358_MTL_INLINE MTL::TextureReferenceType* MTL::StructMember::textureReferenceType()
359{
360    return Object::sendMessage<MTL::TextureReferenceType*>(this, _MTL_PRIVATE_SEL(textureReferenceType));
361}
362
363// method: pointerType
364_MTL_INLINE MTL::PointerType* MTL::StructMember::pointerType()
365{
366    return Object::sendMessage<MTL::PointerType*>(this, _MTL_PRIVATE_SEL(pointerType));
367}
368
369// property: argumentIndex
370_MTL_INLINE NS::UInteger MTL::StructMember::argumentIndex() const
371{
372    return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(argumentIndex));
373}
374
375// static method: alloc
376_MTL_INLINE MTL::StructType* MTL::StructType::alloc()
377{
378    return NS::Object::alloc<MTL::StructType>(_MTL_PRIVATE_CLS(MTLStructType));
379}
380
381// method: init
382_MTL_INLINE MTL::StructType* MTL::StructType::init()
383{
384    return NS::Object::init<MTL::StructType>();
385}
386
387// property: members
388_MTL_INLINE NS::Array* MTL::StructType::members() const
389{
390    return Object::sendMessage<NS::Array*>(this, _MTL_PRIVATE_SEL(members));
391}
392
393// method: memberByName:
394_MTL_INLINE MTL::StructMember* MTL::StructType::memberByName(const NS::String* name)
395{
396    return Object::sendMessage<MTL::StructMember*>(this, _MTL_PRIVATE_SEL(memberByName_), name);
397}
398
399// static method: alloc
400_MTL_INLINE MTL::ArrayType* MTL::ArrayType::alloc()
401{
402    return NS::Object::alloc<MTL::ArrayType>(_MTL_PRIVATE_CLS(MTLArrayType));
403}
404
405// method: init
406_MTL_INLINE MTL::ArrayType* MTL::ArrayType::init()
407{
408    return NS::Object::init<MTL::ArrayType>();
409}
410
411// property: elementType
412_MTL_INLINE MTL::DataType MTL::ArrayType::elementType() const
413{
414    return Object::sendMessage<MTL::DataType>(this, _MTL_PRIVATE_SEL(elementType));
415}
416
417// property: arrayLength
418_MTL_INLINE NS::UInteger MTL::ArrayType::arrayLength() const
419{
420    return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(arrayLength));
421}
422
423// property: stride
424_MTL_INLINE NS::UInteger MTL::ArrayType::stride() const
425{
426    return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(stride));
427}
428
429// property: argumentIndexStride
430_MTL_INLINE NS::UInteger MTL::ArrayType::argumentIndexStride() const
431{
432    return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(argumentIndexStride));
433}
434
435// method: elementStructType
436_MTL_INLINE MTL::StructType* MTL::ArrayType::elementStructType()
437{
438    return Object::sendMessage<MTL::StructType*>(this, _MTL_PRIVATE_SEL(elementStructType));
439}
440
441// method: elementArrayType
442_MTL_INLINE MTL::ArrayType* MTL::ArrayType::elementArrayType()
443{
444    return Object::sendMessage<MTL::ArrayType*>(this, _MTL_PRIVATE_SEL(elementArrayType));
445}
446
447// method: elementTextureReferenceType
448_MTL_INLINE MTL::TextureReferenceType* MTL::ArrayType::elementTextureReferenceType()
449{
450    return Object::sendMessage<MTL::TextureReferenceType*>(this, _MTL_PRIVATE_SEL(elementTextureReferenceType));
451}
452
453// method: elementPointerType
454_MTL_INLINE MTL::PointerType* MTL::ArrayType::elementPointerType()
455{
456    return Object::sendMessage<MTL::PointerType*>(this, _MTL_PRIVATE_SEL(elementPointerType));
457}
458
459// static method: alloc
460_MTL_INLINE MTL::PointerType* MTL::PointerType::alloc()
461{
462    return NS::Object::alloc<MTL::PointerType>(_MTL_PRIVATE_CLS(MTLPointerType));
463}
464
465// method: init
466_MTL_INLINE MTL::PointerType* MTL::PointerType::init()
467{
468    return NS::Object::init<MTL::PointerType>();
469}
470
471// property: elementType
472_MTL_INLINE MTL::DataType MTL::PointerType::elementType() const
473{
474    return Object::sendMessage<MTL::DataType>(this, _MTL_PRIVATE_SEL(elementType));
475}
476
477// property: access
478_MTL_INLINE MTL::ArgumentAccess MTL::PointerType::access() const
479{
480    return Object::sendMessage<MTL::ArgumentAccess>(this, _MTL_PRIVATE_SEL(access));
481}
482
483// property: alignment
484_MTL_INLINE NS::UInteger MTL::PointerType::alignment() const
485{
486    return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(alignment));
487}
488
489// property: dataSize
490_MTL_INLINE NS::UInteger MTL::PointerType::dataSize() const
491{
492    return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(dataSize));
493}
494
495// property: elementIsArgumentBuffer
496_MTL_INLINE bool MTL::PointerType::elementIsArgumentBuffer() const
497{
498    return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(elementIsArgumentBuffer));
499}
500
501// method: elementStructType
502_MTL_INLINE MTL::StructType* MTL::PointerType::elementStructType()
503{
504    return Object::sendMessage<MTL::StructType*>(this, _MTL_PRIVATE_SEL(elementStructType));
505}
506
507// method: elementArrayType
508_MTL_INLINE MTL::ArrayType* MTL::PointerType::elementArrayType()
509{
510    return Object::sendMessage<MTL::ArrayType*>(this, _MTL_PRIVATE_SEL(elementArrayType));
511}
512
513// static method: alloc
514_MTL_INLINE MTL::TextureReferenceType* MTL::TextureReferenceType::alloc()
515{
516    return NS::Object::alloc<MTL::TextureReferenceType>(_MTL_PRIVATE_CLS(MTLTextureReferenceType));
517}
518
519// method: init
520_MTL_INLINE MTL::TextureReferenceType* MTL::TextureReferenceType::init()
521{
522    return NS::Object::init<MTL::TextureReferenceType>();
523}
524
525// property: textureDataType
526_MTL_INLINE MTL::DataType MTL::TextureReferenceType::textureDataType() const
527{
528    return Object::sendMessage<MTL::DataType>(this, _MTL_PRIVATE_SEL(textureDataType));
529}
530
531// property: textureType
532_MTL_INLINE MTL::TextureType MTL::TextureReferenceType::textureType() const
533{
534    return Object::sendMessage<MTL::TextureType>(this, _MTL_PRIVATE_SEL(textureType));
535}
536
537// property: access
538_MTL_INLINE MTL::ArgumentAccess MTL::TextureReferenceType::access() const
539{
540    return Object::sendMessage<MTL::ArgumentAccess>(this, _MTL_PRIVATE_SEL(access));
541}
542
543// property: isDepthTexture
544_MTL_INLINE bool MTL::TextureReferenceType::isDepthTexture() const
545{
546    return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(isDepthTexture));
547}
548
549// static method: alloc
550_MTL_INLINE MTL::Argument* MTL::Argument::alloc()
551{
552    return NS::Object::alloc<MTL::Argument>(_MTL_PRIVATE_CLS(MTLArgument));
553}
554
555// method: init
556_MTL_INLINE MTL::Argument* MTL::Argument::init()
557{
558    return NS::Object::init<MTL::Argument>();
559}
560
561// property: name
562_MTL_INLINE NS::String* MTL::Argument::name() const
563{
564    return Object::sendMessage<NS::String*>(this, _MTL_PRIVATE_SEL(name));
565}
566
567// property: type
568_MTL_INLINE MTL::ArgumentType MTL::Argument::type() const
569{
570    return Object::sendMessage<MTL::ArgumentType>(this, _MTL_PRIVATE_SEL(type));
571}
572
573// property: access
574_MTL_INLINE MTL::ArgumentAccess MTL::Argument::access() const
575{
576    return Object::sendMessage<MTL::ArgumentAccess>(this, _MTL_PRIVATE_SEL(access));
577}
578
579// property: index
580_MTL_INLINE NS::UInteger MTL::Argument::index() const
581{
582    return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(index));
583}
584
585// property: active
586_MTL_INLINE bool MTL::Argument::active() const
587{
588    return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(isActive));
589}
590
591// property: bufferAlignment
592_MTL_INLINE NS::UInteger MTL::Argument::bufferAlignment() const
593{
594    return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(bufferAlignment));
595}
596
597// property: bufferDataSize
598_MTL_INLINE NS::UInteger MTL::Argument::bufferDataSize() const
599{
600    return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(bufferDataSize));
601}
602
603// property: bufferDataType
604_MTL_INLINE MTL::DataType MTL::Argument::bufferDataType() const
605{
606    return Object::sendMessage<MTL::DataType>(this, _MTL_PRIVATE_SEL(bufferDataType));
607}
608
609// property: bufferStructType
610_MTL_INLINE MTL::StructType* MTL::Argument::bufferStructType() const
611{
612    return Object::sendMessage<MTL::StructType*>(this, _MTL_PRIVATE_SEL(bufferStructType));
613}
614
615// property: bufferPointerType
616_MTL_INLINE MTL::PointerType* MTL::Argument::bufferPointerType() const
617{
618    return Object::sendMessage<MTL::PointerType*>(this, _MTL_PRIVATE_SEL(bufferPointerType));
619}
620
621// property: threadgroupMemoryAlignment
622_MTL_INLINE NS::UInteger MTL::Argument::threadgroupMemoryAlignment() const
623{
624    return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(threadgroupMemoryAlignment));
625}
626
627// property: threadgroupMemoryDataSize
628_MTL_INLINE NS::UInteger MTL::Argument::threadgroupMemoryDataSize() const
629{
630    return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(threadgroupMemoryDataSize));
631}
632
633// property: textureType
634_MTL_INLINE MTL::TextureType MTL::Argument::textureType() const
635{
636    return Object::sendMessage<MTL::TextureType>(this, _MTL_PRIVATE_SEL(textureType));
637}
638
639// property: textureDataType
640_MTL_INLINE MTL::DataType MTL::Argument::textureDataType() const
641{
642    return Object::sendMessage<MTL::DataType>(this, _MTL_PRIVATE_SEL(textureDataType));
643}
644
645// property: isDepthTexture
646_MTL_INLINE bool MTL::Argument::isDepthTexture() const
647{
648    return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(isDepthTexture));
649}
650
651// property: arrayLength
652_MTL_INLINE NS::UInteger MTL::Argument::arrayLength() const
653{
654    return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(arrayLength));
655}