-
Notifications
You must be signed in to change notification settings - Fork 72
/
mtlpp.hpp
2721 lines (2273 loc) · 94.6 KB
/
mtlpp.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright 2016-2017 Nikolay Aleksiev. All rights reserved.
* License: https://github.com/naleksiev/mtlpp/blob/master/LICENSE
*/
#pragma once
//////////////////////////////////////
// FILE: defines.hpp
//////////////////////////////////////
/*
* Copyright 2016-2017 Nikolay Aleksiev. All rights reserved.
* License: https://github.com/naleksiev/mtlpp/blob/master/LICENSE
*/
// #pragma once
#include <stdint.h>
#include <assert.h>
#include <functional>
#ifndef __has_feature
# define __has_feature(x) 0
#endif
#ifndef MTLPP_CONFIG_RVALUE_REFERENCES
# define MTLPP_CONFIG_RVALUE_REFERENCES __has_feature(cxx_rvalue_references)
#endif
#ifndef MTLPP_CONFIG_VALIDATE
# define MTLPP_CONFIG_VALIDATE 1
#endif
#ifndef MTLPP_CONFIG_USE_AVAILABILITY
# define MTLPP_CONFIG_USE_AVAILABILITY 0
#endif
#if MTLPP_CONFIG_USE_AVAILABILITY
# if __has_feature(attribute_availability_with_version_underscores) || (__has_feature(attribute_availability_with_message) && __clang__ && __clang_major__ >= 7)
# include <CoreFoundation/CFAvailability.h>
# define MTLPP_AVAILABLE(mac, ios) CF_AVAILABLE(mac, ios)
# define MTLPP_AVAILABLE_MAC(mac) CF_AVAILABLE_MAC(mac)
# define MTLPP_AVAILABLE_IOS(ios) CF_AVAILABLE_IOS(ios)
# define MTLPP_AVAILABLE_TVOS(tvos)
# define MTLPP_DEPRECATED(macIntro, macDep, iosIntro, iosDep) CF_DEPRECATED(macIntro, macDep, iosIntro, iosDep)
# define MTLPP_DEPRECATED_MAC(macIntro, macDep) CF_DEPRECATED_MAC(macIntro, macDep)
# define MTLPP_DEPRECATED_IOS(iosIntro, iosDep) CF_DEPRECATED_IOS(iosIntro, iosDep)
# endif
#endif
#ifndef MTLPP_AVAILABLE
# define MTLPP_AVAILABLE(mac, ios)
# define MTLPP_AVAILABLE_MAC(mac)
# define MTLPP_AVAILABLE_IOS(ios)
# define MTLPP_AVAILABLE_TVOS(tvos)
# define MTLPP_DEPRECATED(macIntro, macDep, iosIntro, iosDep)
# define MTLPP_DEPRECATED_MAC(macIntro, macDep)
# define MTLPP_DEPRECATED_IOS(iosIntro, iosDep)
#endif
#ifndef __DARWIN_ALIAS_STARTING_MAC___MAC_10_11
# define __DARWIN_ALIAS_STARTING_MAC___MAC_10_11(x)
#endif
#ifndef __DARWIN_ALIAS_STARTING_MAC___MAC_10_12
# define __DARWIN_ALIAS_STARTING_MAC___MAC_10_12(x)
#endif
#ifndef __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_8_0
# define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_8_0(x)
#endif
#ifndef __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_9_0
# define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_9_0(x)
#endif
#ifndef __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_10_0
# define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_10_0(x)
#endif
#ifndef __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_10_3
# define __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_10_3(x)
#endif
#define MTLPP_IS_AVAILABLE_MAC(mac) (0 __DARWIN_ALIAS_STARTING_MAC___MAC_##mac( || 1 ))
#define MTLPP_IS_AVAILABLE_IOS(ios) (0 __DARWIN_ALIAS_STARTING_IPHONE___IPHONE_##ios( || 1 ))
#define MTLPP_IS_AVAILABLE(mac, ios) (MTLPP_IS_AVAILABLE_MAC(mac) || MTLPP_IS_AVAILABLE_IOS(ios))
//////////////////////////////////////
// FILE: ns.hpp
//////////////////////////////////////
/*
* Copyright 2016-2017 Nikolay Aleksiev. All rights reserved.
* License: https://github.com/naleksiev/mtlpp/blob/master/LICENSE
*/
// #pragma once
// #include "defines.hpp"
namespace ns
{
struct Handle
{
const void* ptr;
};
class Object
{
public:
inline const void* GetPtr() const { return m_ptr; }
inline operator bool() const { return m_ptr != nullptr; }
protected:
Object();
Object(const Handle& handle);
Object(const Object& rhs);
#if MTLPP_CONFIG_RVALUE_REFERENCES
Object(Object&& rhs);
#endif
virtual ~Object();
Object& operator=(const Object& rhs);
#if MTLPP_CONFIG_RVALUE_REFERENCES
Object& operator=(Object&& rhs);
#endif
inline void Validate() const
{
#if MTLPP_CONFIG_VALIDATE
assert(m_ptr);
#endif
}
const void* m_ptr = nullptr;
};
struct Range
{
inline Range(uint32_t location, uint32_t length) :
Location(location),
Length(length)
{ }
uint32_t Location;
uint32_t Length;
};
class ArrayBase : public Object
{
public:
ArrayBase() { }
ArrayBase(const Handle& handle) : Object(handle) { }
uint32_t GetSize() const;
protected:
void* GetItem(uint32_t index) const;
};
template<typename T>
class Array : public ArrayBase
{
public:
Array() { }
Array(const Handle& handle) : ArrayBase(handle) { }
const T operator[](uint32_t index) const
{
return Handle{ GetItem(index) };
}
T operator[](uint32_t index)
{
return Handle{ GetItem(index) };
}
};
class DictionaryBase : public Object
{
public:
DictionaryBase() { }
DictionaryBase(const Handle& handle) : Object(handle) { }
protected:
};
template<typename KeyT, typename ValueT>
class Dictionary : public DictionaryBase
{
public:
Dictionary() { }
Dictionary(const Handle& handle) : DictionaryBase(handle) { }
};
class String : public Object
{
public:
String() { }
String(const Handle& handle) : Object(handle) { }
String(const char* cstr);
const char* GetCStr() const;
uint32_t GetLength() const;
};
class Error : public Object
{
public:
Error();
Error(const Handle& handle) : Object(handle) { }
String GetDomain() const;
uint32_t GetCode() const;
//@property (readonly, copy) NSDictionary *userInfo;
String GetLocalizedDescription() const;
String GetLocalizedFailureReason() const;
String GetLocalizedRecoverySuggestion() const;
String GetLocalizedRecoveryOptions() const;
//@property (nullable, readonly, strong) id recoveryAttempter;
String GetHelpAnchor() const;
};
}
//////////////////////////////////////
// FILE: command_encoder.hpp
//////////////////////////////////////
/*
* Copyright 2016-2017 Nikolay Aleksiev. All rights reserved.
* License: https://github.com/naleksiev/mtlpp/blob/master/LICENSE
*/
// #pragma once
// #include "defines.hpp"
// #include "ns.hpp"
namespace mtlpp
{
class Device;
class CommandEncoder : public ns::Object
{
public:
CommandEncoder() { }
CommandEncoder(const ns::Handle& handle) : ns::Object(handle) { }
Device GetDevice() const;
ns::String GetLabel() const;
void SetLabel(const ns::String& label);
void EndEncoding();
void InsertDebugSignpost(const ns::String& string);
void PushDebugGroup(const ns::String& string);
void PopDebugGroup();
}
MTLPP_AVAILABLE(10_11, 8_0);
}
//////////////////////////////////////
// FILE: pixel_format.hpp
//////////////////////////////////////
/*
* Copyright 2016-2017 Nikolay Aleksiev. All rights reserved.
* License: https://github.com/naleksiev/mtlpp/blob/master/LICENSE
*/
// #pragma once
// #include "defines.hpp"
namespace mtlpp
{
enum class PixelFormat
{
Invalid = 0,
A8Unorm = 1,
R8Unorm = 10,
R8Unorm_sRGB MTLPP_AVAILABLE_IOS(8_0) = 11,
R8Snorm = 12,
R8Uint = 13,
R8Sint = 14,
R16Unorm = 20,
R16Snorm = 22,
R16Uint = 23,
R16Sint = 24,
R16Float = 25,
RG8Unorm = 30,
RG8Unorm_sRGB MTLPP_AVAILABLE_IOS(8_0) = 31,
RG8Snorm = 32,
RG8Uint = 33,
RG8Sint = 34,
B5G6R5Unorm MTLPP_AVAILABLE_IOS(8_0) = 40,
A1BGR5Unorm MTLPP_AVAILABLE_IOS(8_0) = 41,
ABGR4Unorm MTLPP_AVAILABLE_IOS(8_0) = 42,
BGR5A1Unorm MTLPP_AVAILABLE_IOS(8_0) = 43,
R32Uint = 53,
R32Sint = 54,
R32Float = 55,
RG16Unorm = 60,
RG16Snorm = 62,
RG16Uint = 63,
RG16Sint = 64,
RG16Float = 65,
RGBA8Unorm = 70,
RGBA8Unorm_sRGB = 71,
RGBA8Snorm = 72,
RGBA8Uint = 73,
RGBA8Sint = 74,
BGRA8Unorm = 80,
BGRA8Unorm_sRGB = 81,
RGB10A2Unorm = 90,
RGB10A2Uint = 91,
RG11B10Float = 92,
RGB9E5Float = 93,
BGR10_XR MTLPP_AVAILABLE_IOS(10_0) = 554,
BGR10_XR_sRGB MTLPP_AVAILABLE_IOS(10_0) = 555,
RG32Uint = 103,
RG32Sint = 104,
RG32Float = 105,
RGBA16Unorm = 110,
RGBA16Snorm = 112,
RGBA16Uint = 113,
RGBA16Sint = 114,
RGBA16Float = 115,
BGRA10_XR MTLPP_AVAILABLE_IOS(10_0) = 552,
BGRA10_XR_sRGB MTLPP_AVAILABLE_IOS(10_0) = 553,
RGBA32Uint = 123,
RGBA32Sint = 124,
RGBA32Float = 125,
BC1_RGBA MTLPP_AVAILABLE_MAC(10_11) = 130,
BC1_RGBA_sRGB MTLPP_AVAILABLE_MAC(10_11) = 131,
BC2_RGBA MTLPP_AVAILABLE_MAC(10_11) = 132,
BC2_RGBA_sRGB MTLPP_AVAILABLE_MAC(10_11) = 133,
BC3_RGBA MTLPP_AVAILABLE_MAC(10_11) = 134,
BC3_RGBA_sRGB MTLPP_AVAILABLE_MAC(10_11) = 135,
BC4_RUnorm MTLPP_AVAILABLE_MAC(10_11) = 140,
BC4_RSnorm MTLPP_AVAILABLE_MAC(10_11) = 141,
BC5_RGUnorm MTLPP_AVAILABLE_MAC(10_11) = 142,
BC5_RGSnorm MTLPP_AVAILABLE_MAC(10_11) = 143,
BC6H_RGBFloat MTLPP_AVAILABLE_MAC(10_11) = 150,
BC6H_RGBUfloat MTLPP_AVAILABLE_MAC(10_11) = 151,
BC7_RGBAUnorm MTLPP_AVAILABLE_MAC(10_11) = 152,
BC7_RGBAUnorm_sRGB MTLPP_AVAILABLE_MAC(10_11) = 153,
PVRTC_RGB_2BPP MTLPP_AVAILABLE_IOS(8_0) = 160,
PVRTC_RGB_2BPP_sRGB MTLPP_AVAILABLE_IOS(8_0) = 161,
PVRTC_RGB_4BPP MTLPP_AVAILABLE_IOS(8_0) = 162,
PVRTC_RGB_4BPP_sRGB MTLPP_AVAILABLE_IOS(8_0) = 163,
PVRTC_RGBA_2BPP MTLPP_AVAILABLE_IOS(8_0) = 164,
PVRTC_RGBA_2BPP_sRGB MTLPP_AVAILABLE_IOS(8_0) = 165,
PVRTC_RGBA_4BPP MTLPP_AVAILABLE_IOS(8_0) = 166,
PVRTC_RGBA_4BPP_sRGB MTLPP_AVAILABLE_IOS(8_0) = 167,
EAC_R11Unorm MTLPP_AVAILABLE_IOS(8_0) = 170,
EAC_R11Snorm MTLPP_AVAILABLE_IOS(8_0) = 172,
EAC_RG11Unorm MTLPP_AVAILABLE_IOS(8_0) = 174,
EAC_RG11Snorm MTLPP_AVAILABLE_IOS(8_0) = 176,
EAC_RGBA8 MTLPP_AVAILABLE_IOS(8_0) = 178,
EAC_RGBA8_sRGB MTLPP_AVAILABLE_IOS(8_0) = 179,
ETC2_RGB8 MTLPP_AVAILABLE_IOS(8_0) = 180,
ETC2_RGB8_sRGB MTLPP_AVAILABLE_IOS(8_0) = 181,
ETC2_RGB8A1 MTLPP_AVAILABLE_IOS(8_0) = 182,
ETC2_RGB8A1_sRGB MTLPP_AVAILABLE_IOS(8_0) = 183,
ASTC_4x4_sRGB MTLPP_AVAILABLE_IOS(8_0) = 186,
ASTC_5x4_sRGB MTLPP_AVAILABLE_IOS(8_0) = 187,
ASTC_5x5_sRGB MTLPP_AVAILABLE_IOS(8_0) = 188,
ASTC_6x5_sRGB MTLPP_AVAILABLE_IOS(8_0) = 189,
ASTC_6x6_sRGB MTLPP_AVAILABLE_IOS(8_0) = 190,
ASTC_8x5_sRGB MTLPP_AVAILABLE_IOS(8_0) = 192,
ASTC_8x6_sRGB MTLPP_AVAILABLE_IOS(8_0) = 193,
ASTC_8x8_sRGB MTLPP_AVAILABLE_IOS(8_0) = 194,
ASTC_10x5_sRGB MTLPP_AVAILABLE_IOS(8_0) = 195,
ASTC_10x6_sRGB MTLPP_AVAILABLE_IOS(8_0) = 196,
ASTC_10x8_sRGB MTLPP_AVAILABLE_IOS(8_0) = 197,
ASTC_10x10_sRGB MTLPP_AVAILABLE_IOS(8_0) = 198,
ASTC_12x10_sRGB MTLPP_AVAILABLE_IOS(8_0) = 199,
ASTC_12x12_sRGB MTLPP_AVAILABLE_IOS(8_0) = 200,
ASTC_4x4_LDR MTLPP_AVAILABLE_IOS(8_0) = 204,
ASTC_5x4_LDR MTLPP_AVAILABLE_IOS(8_0) = 205,
ASTC_5x5_LDR MTLPP_AVAILABLE_IOS(8_0) = 206,
ASTC_6x5_LDR MTLPP_AVAILABLE_IOS(8_0) = 207,
ASTC_6x6_LDR MTLPP_AVAILABLE_IOS(8_0) = 208,
ASTC_8x5_LDR MTLPP_AVAILABLE_IOS(8_0) = 210,
ASTC_8x6_LDR MTLPP_AVAILABLE_IOS(8_0) = 211,
ASTC_8x8_LDR MTLPP_AVAILABLE_IOS(8_0) = 212,
ASTC_10x5_LDR MTLPP_AVAILABLE_IOS(8_0) = 213,
ASTC_10x6_LDR MTLPP_AVAILABLE_IOS(8_0) = 214,
ASTC_10x8_LDR MTLPP_AVAILABLE_IOS(8_0) = 215,
ASTC_10x10_LDR MTLPP_AVAILABLE_IOS(8_0) = 216,
ASTC_12x10_LDR MTLPP_AVAILABLE_IOS(8_0) = 217,
ASTC_12x12_LDR MTLPP_AVAILABLE_IOS(8_0) = 218,
GBGR422 = 240,
BGRG422 = 241,
Depth16Unorm MTLPP_AVAILABLE_MAC(10_12) = 250,
Depth32Float = 252,
Stencil8 = 253,
Depth24Unorm_Stencil8 MTLPP_AVAILABLE_MAC(10_11) = 255,
Depth32Float_Stencil8 MTLPP_AVAILABLE(10_11, 9_0) = 260,
X32_Stencil8 MTLPP_AVAILABLE(10_12, 10_0) = 261,
X24_Stencil8 MTLPP_AVAILABLE_MAC(10_12) = 262,
}
MTLPP_AVAILABLE(10_11, 8_0);
}
//////////////////////////////////////
// FILE: resource.hpp
//////////////////////////////////////
/*
* Copyright 2016-2017 Nikolay Aleksiev. All rights reserved.
* License: https://github.com/naleksiev/mtlpp/blob/master/LICENSE
*/
// #pragma once
// #include "defines.hpp"
// #include "ns.hpp"
namespace mtlpp
{
class Heap;
static const uint32_t ResourceCpuCacheModeShift = 0;
static const uint32_t ResourceStorageModeShift = 4;
static const uint32_t ResourceHazardTrackingModeShift = 8;
enum class PurgeableState
{
KeepCurrent = 1,
NonVolatile = 2,
Volatile = 3,
Empty = 4,
}
MTLPP_AVAILABLE(10_11, 8_0);
enum class CpuCacheMode
{
DefaultCache = 0,
WriteCombined = 1,
}
MTLPP_AVAILABLE(10_11, 8_0);
enum class StorageMode
{
Shared = 0,
Managed MTLPP_AVAILABLE(10_11, NA) = 1,
Private = 2,
Memoryless MTLPP_AVAILABLE(NA, 10_0) = 3,
}
MTLPP_AVAILABLE(10_11, 9_0);
enum class ResourceOptions
{
CpuCacheModeDefaultCache = uint32_t(CpuCacheMode::DefaultCache) << ResourceCpuCacheModeShift,
CpuCacheModeWriteCombined = uint32_t(CpuCacheMode::WriteCombined) << ResourceCpuCacheModeShift,
StorageModeShared MTLPP_AVAILABLE(10_11, 9_0) = uint32_t(StorageMode::Shared) << ResourceStorageModeShift,
StorageModeManaged MTLPP_AVAILABLE(10_11, NA) = uint32_t(StorageMode::Managed) << ResourceStorageModeShift,
StorageModePrivate MTLPP_AVAILABLE(10_11, 9_0) = uint32_t(StorageMode::Private) << ResourceStorageModeShift,
StorageModeMemoryless MTLPP_AVAILABLE(NA, 10_0) = uint32_t(StorageMode::Memoryless) << ResourceStorageModeShift,
HazardTrackingModeUntracked MTLPP_AVAILABLE(NA, 10_0) = 0x1 << ResourceHazardTrackingModeShift,
OptionCpuCacheModeDefault = CpuCacheModeDefaultCache,
OptionCpuCacheModeWriteCombined = CpuCacheModeWriteCombined,
}
MTLPP_AVAILABLE(10_11, 8_0);
class Resource : public ns::Object
{
public:
Resource() { }
Resource(const ns::Handle& handle) : ns::Object(handle) { }
ns::String GetLabel() const;
CpuCacheMode GetCpuCacheMode() const;
StorageMode GetStorageMode() const MTLPP_AVAILABLE(10_11, 9_0);
Heap GetHeap() const MTLPP_AVAILABLE(NA, 10_0);
bool IsAliasable() const MTLPP_AVAILABLE(NA, 10_0);
void SetLabel(const ns::String& label);
PurgeableState SetPurgeableState(PurgeableState state);
void MakeAliasable() const MTLPP_AVAILABLE(NA, 10_0);
}
MTLPP_AVAILABLE(10_11, 8_0);
}
//////////////////////////////////////
// FILE: buffer.hpp
//////////////////////////////////////
/*
* Copyright 2016-2017 Nikolay Aleksiev. All rights reserved.
* License: https://github.com/naleksiev/mtlpp/blob/master/LICENSE
*/
// #pragma once
// #include "defines.hpp"
// #include "pixel_format.hpp"
// #include "resource.hpp"
namespace mtlpp
{
class Texture;
class TextureDescriptor;
class Buffer : public Resource
{
public:
Buffer() { }
Buffer(const ns::Handle& handle) : Resource(handle) { }
uint32_t GetLength() const;
void* GetContents();
void DidModify(const ns::Range& range) MTLPP_AVAILABLE_MAC(10_11);
Texture NewTexture(const TextureDescriptor& descriptor, uint32_t offset, uint32_t bytesPerRow) MTLPP_AVAILABLE_IOS(8_0);
void AddDebugMarker(const ns::String& marker, const ns::Range& range) MTLPP_AVAILABLE(10_12, 10_0);
void RemoveAllDebugMarkers() MTLPP_AVAILABLE(10_12, 10_0);
}
MTLPP_AVAILABLE(10_11, 8_0);
}
//////////////////////////////////////
// FILE: types.hpp
//////////////////////////////////////
/*
* Copyright 2016-2017 Nikolay Aleksiev. All rights reserved.
* License: https://github.com/naleksiev/mtlpp/blob/master/LICENSE
*/
// #pragma once
// #include "defines.hpp"
namespace mtlpp
{
struct Origin
{
inline Origin(uint32_t x, uint32_t y, uint32_t z) :
X(x),
Y(y),
Z(z)
{ }
uint32_t X;
uint32_t Y;
uint32_t Z;
};
struct Size
{
inline Size(uint32_t width, uint32_t height, uint32_t depth) :
Width(width),
Height(height),
Depth(depth)
{ }
uint32_t Width;
uint32_t Height;
uint32_t Depth;
};
struct Region
{
inline Region(uint32_t x, uint32_t width) :
Origin(x, 0, 0),
Size(width, 1, 1)
{ }
inline Region(uint32_t x, uint32_t y, uint32_t width, uint32_t height) :
Origin(x, y, 0),
Size(width, height, 1)
{ }
inline Region(uint32_t x, uint32_t y, uint32_t z, uint32_t width, uint32_t height, uint32_t depth) :
Origin(x, y, z),
Size(width, height, depth)
{ }
Origin Origin;
Size Size;
};
}
//////////////////////////////////////
// FILE: texture.hpp
//////////////////////////////////////
/*
* Copyright 2016-2017 Nikolay Aleksiev. All rights reserved.
* License: https://github.com/naleksiev/mtlpp/blob/master/LICENSE
*/
// #pragma once
// #include "defines.hpp"
// #include "resource.hpp"
// #include "buffer.hpp"
// #include "types.hpp"
namespace mtlpp
{
enum class TextureType
{
Texture1D = 0,
Texture1DArray = 1,
Texture2D = 2,
Texture2DArray = 3,
Texture2DMultisample = 4,
TextureCube = 5,
TextureCubeArray MTLPP_AVAILABLE_MAC(10_11) = 6,
Texture3D = 7,
}
MTLPP_AVAILABLE(10_11, 8_0);
enum class TextureUsage
{
Unknown = 0x0000,
ShaderRead = 0x0001,
ShaderWrite = 0x0002,
RenderTarget = 0x0004,
PixelFormatView = 0x0010,
}
MTLPP_AVAILABLE(10_11, 9_0);
class TextureDescriptor : public ns::Object
{
public:
TextureDescriptor();
TextureDescriptor(const ns::Handle& handle) : ns::Object(handle) { }
static TextureDescriptor Texture2DDescriptor(PixelFormat pixelFormat, uint32_t width, uint32_t height, bool mipmapped);
static TextureDescriptor TextureCubeDescriptor(PixelFormat pixelFormat, uint32_t size, bool mipmapped);
TextureType GetTextureType() const;
PixelFormat GetPixelFormat() const;
uint32_t GetWidth() const;
uint32_t GetHeight() const;
uint32_t GetDepth() const;
uint32_t GetMipmapLevelCount() const;
uint32_t GetSampleCount() const;
uint32_t GetArrayLength() const;
ResourceOptions GetResourceOptions() const;
CpuCacheMode GetCpuCacheMode() const MTLPP_AVAILABLE(10_11, 9_0);
StorageMode GetStorageMode() const MTLPP_AVAILABLE(10_11, 9_0);
TextureUsage GetUsage() const MTLPP_AVAILABLE(10_11, 9_0);
void SetTextureType(TextureType textureType);
void SetPixelFormat(PixelFormat pixelFormat);
void SetWidth(uint32_t width);
void SetHeight(uint32_t height);
void SetDepth(uint32_t depth);
void SetMipmapLevelCount(uint32_t mipmapLevelCount);
void SetSampleCount(uint32_t sampleCount);
void SetArrayLength(uint32_t arrayLength);
void SetResourceOptions(ResourceOptions resourceOptions);
void SetCpuCacheMode(CpuCacheMode cpuCacheMode) MTLPP_AVAILABLE(10_11, 9_0);
void SetStorageMode(StorageMode storageMode) MTLPP_AVAILABLE(10_11, 9_0);
void SetUsage(TextureUsage usage) MTLPP_AVAILABLE(10_11, 9_0);
}
MTLPP_AVAILABLE(10_11, 8_0);
class Texture : public Resource
{
public:
Texture() { }
Texture(const ns::Handle& handle) : Resource(handle) { }
Resource GetRootResource() const MTLPP_DEPRECATED(10_11, 10_12, 8_0, 10_0);
Texture GetParentTexture() const MTLPP_AVAILABLE(10_11, 9_0);
uint32_t GetParentRelativeLevel() const MTLPP_AVAILABLE(10_11, 9_0);
uint32_t GetParentRelativeSlice() const MTLPP_AVAILABLE(10_11, 9_0);
Buffer GetBuffer() const MTLPP_AVAILABLE(10_12, 9_0);
uint32_t GetBufferOffset() const MTLPP_AVAILABLE(10_12, 9_0);
uint32_t GetBufferBytesPerRow() const MTLPP_AVAILABLE(10_12, 9_0);
//IOSurfaceRef GetIOSurface() const;
uint32_t GetIOSurfacePlane() const MTLPP_AVAILABLE_MAC(10_11);
TextureType GetTextureType() const;
PixelFormat GetPixelFormat() const;
uint32_t GetWidth() const;
uint32_t GetHeight() const;
uint32_t GetDepth() const;
uint32_t GetMipmapLevelCount() const;
uint32_t GetSampleCount() const;
uint32_t GetArrayLength() const;
TextureUsage GetUsage() const;
bool IsFrameBufferOnly() const;
void GetBytes(void* pixelBytes, uint32_t bytesPerRow, uint32_t bytesPerImage, const Region& fromRegion, uint32_t mipmapLevel, uint32_t slice);
void Replace(const Region& region, uint32_t mipmapLevel, uint32_t slice, void* pixelBytes, uint32_t bytesPerRow, uint32_t bytesPerImage);
void GetBytes(void* pixelBytes, uint32_t bytesPerRow, const Region& fromRegion, uint32_t mipmapLevel);
void Replace(const Region& region, uint32_t mipmapLevel, void* pixelBytes, uint32_t bytesPerRow);
Texture NewTextureView(PixelFormat pixelFormat);
Texture NewTextureView(PixelFormat pixelFormat, TextureType textureType, const ns::Range& mipmapLevelRange, const ns::Range& sliceRange);
}
MTLPP_AVAILABLE(10_11, 8_0);
}
//////////////////////////////////////
// FILE: argument.hpp
//////////////////////////////////////
/*
* Copyright 2016-2017 Nikolay Aleksiev. All rights reserved.
* License: https://github.com/naleksiev/mtlpp/blob/master/LICENSE
*/
// #pragma once
// #include "defines.hpp"
// #include "texture.hpp"
namespace mtlpp
{
class StructType;
class ArrayType;
enum class DataType
{
None = 0,
Struct = 1,
Array = 2,
Float = 3,
Float2 = 4,
Float3 = 5,
Float4 = 6,
Float2x2 = 7,
Float2x3 = 8,
Float2x4 = 9,
Float3x2 = 10,
Float3x3 = 11,
Float3x4 = 12,
Float4x2 = 13,
Float4x3 = 14,
Float4x4 = 15,
Half = 16,
Half2 = 17,
Half3 = 18,
Half4 = 19,
Half2x2 = 20,
Half2x3 = 21,
Half2x4 = 22,
Half3x2 = 23,
Half3x3 = 24,
Half3x4 = 25,
Half4x2 = 26,
Half4x3 = 27,
Half4x4 = 28,
Int = 29,
Int2 = 30,
Int3 = 31,
Int4 = 32,
UInt = 33,
UInt2 = 34,
UInt3 = 35,
UInt4 = 36,
Short = 37,
Short2 = 38,
Short3 = 39,
Short4 = 40,
UShort = 41,
UShort2 = 42,
UShort3 = 43,
UShort4 = 44,
Char = 45,
Char2 = 46,
Char3 = 47,
Char4 = 48,
UChar = 49,
UChar2 = 50,
UChar3 = 51,
UChar4 = 52,
Bool = 53,
Bool2 = 54,
Bool3 = 55,
Bool4 = 56,
}
MTLPP_AVAILABLE(10_11, 8_0);
enum class ArgumentType
{
Buffer = 0,
ThreadgroupMemory = 1,
Texture = 2,
Sampler = 3,
}
MTLPP_AVAILABLE(10_11, 8_0);
enum class ArgumentAccess
{
ReadOnly = 0,
ReadWrite = 1,
WriteOnly = 2,
}
MTLPP_AVAILABLE(10_11, 8_0);
class StructMember : public ns::Object
{
public:
StructMember();
StructMember(const ns::Handle& handle) : ns::Object(handle) { }
ns::String GetName() const;
uint32_t GetOffset() const;
DataType GetDataType() const;
StructType GetStructType() const;
ArrayType GetArrayType() const;
}
MTLPP_AVAILABLE(10_11, 8_0);
class StructType : public ns::Object
{
public:
StructType();
StructType(const ns::Handle& handle) : ns::Object(handle) { }
const ns::Array<StructMember> GetMembers() const;
StructMember GetMember(const ns::String& name) const;
}
MTLPP_AVAILABLE(10_11, 8_0);
class ArrayType : public ns::Object
{
public:
ArrayType();
ArrayType(const ns::Handle& handle) : ns::Object(handle) { }
uint32_t GetArrayLength() const;
DataType GetElementType() const;
uint32_t GetStride() const;
StructType GetElementStructType() const;
ArrayType GetElementArrayType() const;
}
MTLPP_AVAILABLE(10_11, 8_0);
class Argument : public ns::Object
{
public:
Argument();
Argument(const ns::Handle& handle) : ns::Object(handle) { }
ns::String GetName() const;
ArgumentType GetType() const;
ArgumentAccess GetAccess() const;
uint32_t GetIndex() const;
bool IsActive() const;
uint32_t GetBufferAlignment() const;
uint32_t GetBufferDataSize() const;
DataType GetBufferDataType() const;
StructType GetBufferStructType() const;
uint32_t GetThreadgroupMemoryAlignment() const;
uint32_t GetThreadgroupMemoryDataSize() const;
TextureType GetTextureType() const;
DataType GetTextureDataType() const;
bool IsDepthTexture() const MTLPP_AVAILABLE(10_12, 10_0);
}
MTLPP_AVAILABLE(10_11, 8_0);
}
//////////////////////////////////////
// FILE: library.hpp
//////////////////////////////////////
/*
* Copyright 2016-2017 Nikolay Aleksiev. All rights reserved.
* License: https://github.com/naleksiev/mtlpp/blob/master/LICENSE
*/
// #pragma once
// #include "defines.hpp"
// #include "ns.hpp"
// #include "argument.hpp"
namespace mtlpp
{
class Device;
class FunctionConstantValues;
enum class PatchType
{
None = 0,
Triangle = 1,
Quad = 2,
}
MTLPP_AVAILABLE(10_12, 10_0);
class VertexAttribute : public ns::Object
{
public:
VertexAttribute();
VertexAttribute(const ns::Handle& handle) : ns::Object(handle) { }
ns::String GetName() const;
uint32_t GetAttributeIndex() const;
DataType GetAttributeType() const MTLPP_AVAILABLE(10_11, 8_3);
bool IsActive() const;
bool IsPatchData() const MTLPP_AVAILABLE(10_12, 10_0);
bool IsPatchControlPointData() const MTLPP_AVAILABLE(10_12, 10_0);
}
MTLPP_AVAILABLE(10_11, 8_0);
class Attribute : public ns::Object
{
public:
Attribute();
Attribute(const ns::Handle& handle) : ns::Object(handle) { }
ns::String GetName() const;
uint32_t GetAttributeIndex() const;
DataType GetAttributeType() const MTLPP_AVAILABLE(10_11, 8_3);
bool IsActive() const;
bool IsPatchData() const MTLPP_AVAILABLE(10_12, 10_0);
bool IsPatchControlPointData() const MTLPP_AVAILABLE(10_12, 10_0);
}
MTLPP_AVAILABLE(10_12, 10_0);
enum class FunctionType
{
TypeVertex = 1,
TypeFragment = 2,
TypeKernel = 3,
}
MTLPP_AVAILABLE(10_11, 8_0);
class FunctionConstant : public ns::Object
{
public:
FunctionConstant();
FunctionConstant(const ns::Handle& handle) : ns::Object(handle) { }
ns::String GetName() const;
DataType GetType() const;
uint32_t GetIndex() const;
bool IsRequired() const;
}
MTLPP_AVAILABLE(10_12, 10_0);
class Function : public ns::Object
{
public:
Function() { }
Function(const ns::Handle& handle) : ns::Object(handle) { }
ns::String GetLabel() const MTLPP_AVAILABLE(10_12, 10_0);
Device GetDevice() const;
FunctionType GetFunctionType() const;
PatchType GetPatchType() const MTLPP_AVAILABLE(10_12, 10_0);