reach-vb HF staff commited on
Commit
c125e70
1 Parent(s): c4764a2

98964e89c425f708e709046a261696e8068d60301d796ec7f8d23890f0535d89

Browse files
Files changed (50) hide show
  1. lib/python3.11/site-packages/mlx/include/metal_cpp/Metal/MTLPixelFormat.hpp +173 -0
  2. lib/python3.11/site-packages/mlx/include/metal_cpp/Metal/MTLPrivate.hpp +156 -0
  3. lib/python3.11/site-packages/mlx/include/metal_cpp/Metal/MTLRasterizationRate.hpp +386 -0
  4. lib/python3.11/site-packages/mlx/include/metal_cpp/Metal/MTLRenderCommandEncoder.hpp +1177 -0
  5. lib/python3.11/site-packages/mlx/include/metal_cpp/Metal/MTLRenderPass.hpp +786 -0
  6. lib/python3.11/site-packages/mlx/include/metal_cpp/Metal/MTLRenderPipeline.hpp +1640 -0
  7. lib/python3.11/site-packages/mlx/include/metal_cpp/Metal/MTLResource.hpp +178 -0
  8. lib/python3.11/site-packages/mlx/include/metal_cpp/Metal/MTLResourceStateCommandEncoder.hpp +103 -0
  9. lib/python3.11/site-packages/mlx/include/metal_cpp/Metal/MTLResourceStatePass.hpp +165 -0
  10. lib/python3.11/site-packages/mlx/include/metal_cpp/Metal/MTLSampler.hpp +319 -0
  11. lib/python3.11/site-packages/mlx/include/metal_cpp/Metal/MTLStageInputOutputDescriptor.hpp +383 -0
  12. lib/python3.11/site-packages/mlx/include/metal_cpp/Metal/MTLTexture.hpp +685 -0
  13. lib/python3.11/site-packages/mlx/include/metal_cpp/Metal/MTLTypes.hpp +168 -0
  14. lib/python3.11/site-packages/mlx/include/metal_cpp/Metal/MTLVersion.hpp +32 -0
  15. lib/python3.11/site-packages/mlx/include/metal_cpp/Metal/MTLVertexDescriptor.hpp +349 -0
  16. lib/python3.11/site-packages/mlx/include/metal_cpp/Metal/MTLVisibleFunctionTable.hpp +104 -0
  17. lib/python3.11/site-packages/mlx/include/metal_cpp/Metal/Metal.hpp +84 -0
  18. lib/python3.11/site-packages/mlx/include/metal_cpp/MetalFX/MTLFXDefines.hpp +41 -0
  19. lib/python3.11/site-packages/mlx/include/metal_cpp/MetalFX/MTLFXPrivate.hpp +281 -0
  20. lib/python3.11/site-packages/mlx/include/metal_cpp/MetalFX/MTLFXSpatialScaler.hpp +372 -0
  21. lib/python3.11/site-packages/mlx/include/metal_cpp/MetalFX/MTLFXTemporalScaler.hpp +660 -0
  22. lib/python3.11/site-packages/mlx/include/metal_cpp/MetalFX/MetalFX.hpp +28 -0
  23. lib/python3.11/site-packages/mlx/include/metal_cpp/QuartzCore/CADefines.hpp +41 -0
  24. lib/python3.11/site-packages/mlx/include/metal_cpp/QuartzCore/CAMetalDrawable.hpp +57 -0
  25. lib/python3.11/site-packages/mlx/include/metal_cpp/QuartzCore/CAMetalLayer.hpp +131 -0
  26. lib/python3.11/site-packages/mlx/include/metal_cpp/QuartzCore/CAPrivate.hpp +132 -0
  27. lib/python3.11/site-packages/mlx/include/metal_cpp/QuartzCore/QuartzCore.hpp +28 -0
  28. lib/python3.11/site-packages/mlx/include/metal_cpp/README.md +311 -0
  29. lib/python3.11/site-packages/mlx/include/metal_cpp/SingleHeader/MakeSingleHeader.py +271 -0
  30. lib/python3.11/site-packages/mlx/include/metal_cpp/SingleHeader/__pycache__/MakeSingleHeader.cpython-311.pyc +0 -0
  31. lib/python3.11/site-packages/mlx/include/mlx/3rdparty/pocketfft.h +0 -0
  32. lib/python3.11/site-packages/mlx/include/mlx/allocator.h +66 -0
  33. lib/python3.11/site-packages/mlx/include/mlx/array.h +438 -0
  34. lib/python3.11/site-packages/mlx/include/mlx/backend/accelerate/utils.h +28 -0
  35. lib/python3.11/site-packages/mlx/include/mlx/backend/common/arange.h +74 -0
  36. lib/python3.11/site-packages/mlx/include/mlx/backend/common/binary.h +556 -0
  37. lib/python3.11/site-packages/mlx/include/mlx/backend/common/copy.h +29 -0
  38. lib/python3.11/site-packages/mlx/include/mlx/backend/common/erf.h +11 -0
  39. lib/python3.11/site-packages/mlx/include/mlx/backend/common/reduce.h +366 -0
  40. lib/python3.11/site-packages/mlx/include/mlx/backend/common/threefry.h +21 -0
  41. lib/python3.11/site-packages/mlx/include/mlx/backend/common/unary.h +160 -0
  42. lib/python3.11/site-packages/mlx/include/mlx/backend/common/utils.h +31 -0
  43. lib/python3.11/site-packages/mlx/include/mlx/backend/metal/allocator.h +74 -0
  44. lib/python3.11/site-packages/mlx/include/mlx/backend/metal/copy.h +18 -0
  45. lib/python3.11/site-packages/mlx/include/mlx/backend/metal/device.h +81 -0
  46. lib/python3.11/site-packages/mlx/include/mlx/backend/metal/kernels/atomic.h +322 -0
  47. lib/python3.11/site-packages/mlx/include/mlx/backend/metal/kernels/bf16.h +317 -0
  48. lib/python3.11/site-packages/mlx/include/mlx/backend/metal/kernels/bf16_math.h +394 -0
  49. lib/python3.11/site-packages/mlx/include/mlx/backend/metal/kernels/complex.h +125 -0
  50. lib/python3.11/site-packages/mlx/include/mlx/backend/metal/kernels/conv_params.h +19 -0
lib/python3.11/site-packages/mlx/include/metal_cpp/Metal/MTLPixelFormat.hpp ADDED
@@ -0,0 +1,173 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
2
+ //
3
+ // Metal/MTLPixelFormat.hpp
4
+ //
5
+ // Copyright 2020-2023 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
+ namespace MTL
30
+ {
31
+ _MTL_ENUM(NS::UInteger, PixelFormat) {
32
+ PixelFormatInvalid = 0,
33
+ PixelFormatA8Unorm = 1,
34
+ PixelFormatR8Unorm = 10,
35
+ PixelFormatR8Unorm_sRGB = 11,
36
+ PixelFormatR8Snorm = 12,
37
+ PixelFormatR8Uint = 13,
38
+ PixelFormatR8Sint = 14,
39
+ PixelFormatR16Unorm = 20,
40
+ PixelFormatR16Snorm = 22,
41
+ PixelFormatR16Uint = 23,
42
+ PixelFormatR16Sint = 24,
43
+ PixelFormatR16Float = 25,
44
+ PixelFormatRG8Unorm = 30,
45
+ PixelFormatRG8Unorm_sRGB = 31,
46
+ PixelFormatRG8Snorm = 32,
47
+ PixelFormatRG8Uint = 33,
48
+ PixelFormatRG8Sint = 34,
49
+ PixelFormatB5G6R5Unorm = 40,
50
+ PixelFormatA1BGR5Unorm = 41,
51
+ PixelFormatABGR4Unorm = 42,
52
+ PixelFormatBGR5A1Unorm = 43,
53
+ PixelFormatR32Uint = 53,
54
+ PixelFormatR32Sint = 54,
55
+ PixelFormatR32Float = 55,
56
+ PixelFormatRG16Unorm = 60,
57
+ PixelFormatRG16Snorm = 62,
58
+ PixelFormatRG16Uint = 63,
59
+ PixelFormatRG16Sint = 64,
60
+ PixelFormatRG16Float = 65,
61
+ PixelFormatRGBA8Unorm = 70,
62
+ PixelFormatRGBA8Unorm_sRGB = 71,
63
+ PixelFormatRGBA8Snorm = 72,
64
+ PixelFormatRGBA8Uint = 73,
65
+ PixelFormatRGBA8Sint = 74,
66
+ PixelFormatBGRA8Unorm = 80,
67
+ PixelFormatBGRA8Unorm_sRGB = 81,
68
+ PixelFormatRGB10A2Unorm = 90,
69
+ PixelFormatRGB10A2Uint = 91,
70
+ PixelFormatRG11B10Float = 92,
71
+ PixelFormatRGB9E5Float = 93,
72
+ PixelFormatBGR10A2Unorm = 94,
73
+ PixelFormatRG32Uint = 103,
74
+ PixelFormatRG32Sint = 104,
75
+ PixelFormatRG32Float = 105,
76
+ PixelFormatRGBA16Unorm = 110,
77
+ PixelFormatRGBA16Snorm = 112,
78
+ PixelFormatRGBA16Uint = 113,
79
+ PixelFormatRGBA16Sint = 114,
80
+ PixelFormatRGBA16Float = 115,
81
+ PixelFormatRGBA32Uint = 123,
82
+ PixelFormatRGBA32Sint = 124,
83
+ PixelFormatRGBA32Float = 125,
84
+ PixelFormatBC1_RGBA = 130,
85
+ PixelFormatBC1_RGBA_sRGB = 131,
86
+ PixelFormatBC2_RGBA = 132,
87
+ PixelFormatBC2_RGBA_sRGB = 133,
88
+ PixelFormatBC3_RGBA = 134,
89
+ PixelFormatBC3_RGBA_sRGB = 135,
90
+ PixelFormatBC4_RUnorm = 140,
91
+ PixelFormatBC4_RSnorm = 141,
92
+ PixelFormatBC5_RGUnorm = 142,
93
+ PixelFormatBC5_RGSnorm = 143,
94
+ PixelFormatBC6H_RGBFloat = 150,
95
+ PixelFormatBC6H_RGBUfloat = 151,
96
+ PixelFormatBC7_RGBAUnorm = 152,
97
+ PixelFormatBC7_RGBAUnorm_sRGB = 153,
98
+ PixelFormatPVRTC_RGB_2BPP = 160,
99
+ PixelFormatPVRTC_RGB_2BPP_sRGB = 161,
100
+ PixelFormatPVRTC_RGB_4BPP = 162,
101
+ PixelFormatPVRTC_RGB_4BPP_sRGB = 163,
102
+ PixelFormatPVRTC_RGBA_2BPP = 164,
103
+ PixelFormatPVRTC_RGBA_2BPP_sRGB = 165,
104
+ PixelFormatPVRTC_RGBA_4BPP = 166,
105
+ PixelFormatPVRTC_RGBA_4BPP_sRGB = 167,
106
+ PixelFormatEAC_R11Unorm = 170,
107
+ PixelFormatEAC_R11Snorm = 172,
108
+ PixelFormatEAC_RG11Unorm = 174,
109
+ PixelFormatEAC_RG11Snorm = 176,
110
+ PixelFormatEAC_RGBA8 = 178,
111
+ PixelFormatEAC_RGBA8_sRGB = 179,
112
+ PixelFormatETC2_RGB8 = 180,
113
+ PixelFormatETC2_RGB8_sRGB = 181,
114
+ PixelFormatETC2_RGB8A1 = 182,
115
+ PixelFormatETC2_RGB8A1_sRGB = 183,
116
+ PixelFormatASTC_4x4_sRGB = 186,
117
+ PixelFormatASTC_5x4_sRGB = 187,
118
+ PixelFormatASTC_5x5_sRGB = 188,
119
+ PixelFormatASTC_6x5_sRGB = 189,
120
+ PixelFormatASTC_6x6_sRGB = 190,
121
+ PixelFormatASTC_8x5_sRGB = 192,
122
+ PixelFormatASTC_8x6_sRGB = 193,
123
+ PixelFormatASTC_8x8_sRGB = 194,
124
+ PixelFormatASTC_10x5_sRGB = 195,
125
+ PixelFormatASTC_10x6_sRGB = 196,
126
+ PixelFormatASTC_10x8_sRGB = 197,
127
+ PixelFormatASTC_10x10_sRGB = 198,
128
+ PixelFormatASTC_12x10_sRGB = 199,
129
+ PixelFormatASTC_12x12_sRGB = 200,
130
+ PixelFormatASTC_4x4_LDR = 204,
131
+ PixelFormatASTC_5x4_LDR = 205,
132
+ PixelFormatASTC_5x5_LDR = 206,
133
+ PixelFormatASTC_6x5_LDR = 207,
134
+ PixelFormatASTC_6x6_LDR = 208,
135
+ PixelFormatASTC_8x5_LDR = 210,
136
+ PixelFormatASTC_8x6_LDR = 211,
137
+ PixelFormatASTC_8x8_LDR = 212,
138
+ PixelFormatASTC_10x5_LDR = 213,
139
+ PixelFormatASTC_10x6_LDR = 214,
140
+ PixelFormatASTC_10x8_LDR = 215,
141
+ PixelFormatASTC_10x10_LDR = 216,
142
+ PixelFormatASTC_12x10_LDR = 217,
143
+ PixelFormatASTC_12x12_LDR = 218,
144
+ PixelFormatASTC_4x4_HDR = 222,
145
+ PixelFormatASTC_5x4_HDR = 223,
146
+ PixelFormatASTC_5x5_HDR = 224,
147
+ PixelFormatASTC_6x5_HDR = 225,
148
+ PixelFormatASTC_6x6_HDR = 226,
149
+ PixelFormatASTC_8x5_HDR = 228,
150
+ PixelFormatASTC_8x6_HDR = 229,
151
+ PixelFormatASTC_8x8_HDR = 230,
152
+ PixelFormatASTC_10x5_HDR = 231,
153
+ PixelFormatASTC_10x6_HDR = 232,
154
+ PixelFormatASTC_10x8_HDR = 233,
155
+ PixelFormatASTC_10x10_HDR = 234,
156
+ PixelFormatASTC_12x10_HDR = 235,
157
+ PixelFormatASTC_12x12_HDR = 236,
158
+ PixelFormatGBGR422 = 240,
159
+ PixelFormatBGRG422 = 241,
160
+ PixelFormatDepth16Unorm = 250,
161
+ PixelFormatDepth32Float = 252,
162
+ PixelFormatStencil8 = 253,
163
+ PixelFormatDepth24Unorm_Stencil8 = 255,
164
+ PixelFormatDepth32Float_Stencil8 = 260,
165
+ PixelFormatX32_Stencil8 = 261,
166
+ PixelFormatX24_Stencil8 = 262,
167
+ PixelFormatBGRA10_XR = 552,
168
+ PixelFormatBGRA10_XR_sRGB = 553,
169
+ PixelFormatBGR10_XR = 554,
170
+ PixelFormatBGR10_XR_sRGB = 555,
171
+ };
172
+
173
+ }
lib/python3.11/site-packages/mlx/include/metal_cpp/Metal/MTLPrivate.hpp ADDED
@@ -0,0 +1,156 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
2
+ //
3
+ // Metal/MTLPrivate.hpp
4
+ //
5
+ // Copyright 2020-2023 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
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
24
+
25
+ #include "MTLDefines.hpp"
26
+
27
+ #include <objc/runtime.h>
28
+
29
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
30
+
31
+ #define _MTL_PRIVATE_CLS(symbol) (Private::Class::s_k##symbol)
32
+ #define _MTL_PRIVATE_SEL(accessor) (Private::Selector::s_k##accessor)
33
+
34
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
35
+
36
+ #if defined(MTL_PRIVATE_IMPLEMENTATION)
37
+
38
+ #ifdef METALCPP_SYMBOL_VISIBILITY_HIDDEN
39
+ #define _MTL_PRIVATE_VISIBILITY __attribute__((visibility("hidden")))
40
+ #else
41
+ #define _MTL_PRIVATE_VISIBILITY __attribute__((visibility("default")))
42
+ #endif // METALCPP_SYMBOL_VISIBILITY_HIDDEN
43
+
44
+ #define _MTL_PRIVATE_IMPORT __attribute__((weak_import))
45
+
46
+ #ifdef __OBJC__
47
+ #define _MTL_PRIVATE_OBJC_LOOKUP_CLASS(symbol) ((__bridge void*)objc_lookUpClass(#symbol))
48
+ #define _MTL_PRIVATE_OBJC_GET_PROTOCOL(symbol) ((__bridge void*)objc_getProtocol(#symbol))
49
+ #else
50
+ #define _MTL_PRIVATE_OBJC_LOOKUP_CLASS(symbol) objc_lookUpClass(#symbol)
51
+ #define _MTL_PRIVATE_OBJC_GET_PROTOCOL(symbol) objc_getProtocol(#symbol)
52
+ #endif // __OBJC__
53
+
54
+ #define _MTL_PRIVATE_DEF_CLS(symbol) void* s_k##symbol _MTL_PRIVATE_VISIBILITY = _MTL_PRIVATE_OBJC_LOOKUP_CLASS(symbol)
55
+ #define _MTL_PRIVATE_DEF_PRO(symbol) void* s_k##symbol _MTL_PRIVATE_VISIBILITY = _MTL_PRIVATE_OBJC_GET_PROTOCOL(symbol)
56
+ #define _MTL_PRIVATE_DEF_SEL(accessor, symbol) SEL s_k##accessor _MTL_PRIVATE_VISIBILITY = sel_registerName(symbol)
57
+
58
+ #include <dlfcn.h>
59
+ #define MTL_DEF_FUNC( name, signature ) \
60
+ using Fn##name = signature; \
61
+ Fn##name name = reinterpret_cast< Fn##name >( dlsym( RTLD_DEFAULT, #name ) )
62
+
63
+ namespace MTL::Private
64
+ {
65
+ template <typename _Type>
66
+ inline _Type const LoadSymbol(const char* pSymbol)
67
+ {
68
+ const _Type* pAddress = static_cast<_Type*>(dlsym(RTLD_DEFAULT, pSymbol));
69
+
70
+ return pAddress ? *pAddress : nullptr;
71
+ }
72
+ } // MTL::Private
73
+
74
+ #if defined(__MAC_10_16) || defined(__MAC_11_0) || defined(__MAC_12_0) || defined(__MAC_13_0) || defined(__MAC_14_0) || defined(__IPHONE_14_0) || defined(__IPHONE_15_0) || defined(__IPHONE_16_0) || defined(__IPHONE_17_0) || defined(__TVOS_14_0) || defined(__TVOS_15_0) || defined(__TVOS_16_0) || defined(__TVOS_17_0)
75
+
76
+ #define _MTL_PRIVATE_DEF_STR(type, symbol) \
77
+ _MTL_EXTERN type const MTL##symbol _MTL_PRIVATE_IMPORT; \
78
+ type const MTL::symbol = (nullptr != &MTL##symbol) ? MTL##symbol : nullptr
79
+
80
+ #define _MTL_PRIVATE_DEF_CONST(type, symbol) \
81
+ _MTL_EXTERN type const MTL##symbol _MTL_PRIVATE_IMPORT; \
82
+ type const MTL::symbol = (nullptr != &MTL##symbol) ? MTL##symbol : nullptr
83
+
84
+ #define _MTL_PRIVATE_DEF_WEAK_CONST(type, symbol) \
85
+ _MTL_EXTERN type const MTL##symbol; \
86
+ type const MTL::symbol = Private::LoadSymbol<type>("MTL" #symbol)
87
+
88
+ #else
89
+
90
+ #define _MTL_PRIVATE_DEF_STR(type, symbol) \
91
+ _MTL_EXTERN type const MTL##symbol; \
92
+ type const MTL::symbol = Private::LoadSymbol<type>("MTL" #symbol)
93
+
94
+ #define _MTL_PRIVATE_DEF_CONST(type, symbol) \
95
+ _MTL_EXTERN type const MTL##symbol; \
96
+ type const MTL::symbol = Private::LoadSymbol<type>("MTL" #symbol)
97
+
98
+ #define _MTL_PRIVATE_DEF_WEAK_CONST(type, symbol) _MTL_PRIVATE_DEF_CONST(type, symbol)
99
+
100
+ #endif // defined(__MAC_10_16) || defined(__MAC_11_0) || defined(__MAC_12_0) || defined(__MAC_13_0) || defined(__MAC_14_0) || defined(__IPHONE_14_0) || defined(__IPHONE_15_0) || defined(__IPHONE_16_0) || defined(__IPHONE_17_0) || defined(__TVOS_14_0) || defined(__TVOS_15_0) || defined(__TVOS_16_0) || defined(__TVOS_17_0)
101
+
102
+ #else
103
+
104
+ #define _MTL_PRIVATE_DEF_CLS(symbol) extern void* s_k##symbol
105
+ #define _MTL_PRIVATE_DEF_PRO(symbol) extern void* s_k##symbol
106
+ #define _MTL_PRIVATE_DEF_SEL(accessor, symbol) extern SEL s_k##accessor
107
+ #define _MTL_PRIVATE_DEF_STR(type, symbol) extern type const MTL::symbol
108
+ #define _MTL_PRIVATE_DEF_CONST(type, symbol) extern type const MTL::symbol
109
+ #define _MTL_PRIVATE_DEF_WEAK_CONST(type, symbol) extern type const MTL::symbol
110
+
111
+ #endif // MTL_PRIVATE_IMPLEMENTATION
112
+
113
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
114
+
115
+ namespace MTL
116
+ {
117
+ namespace Private
118
+ {
119
+ namespace Class
120
+ {
121
+
122
+ } // Class
123
+ } // Private
124
+ } // MTL
125
+
126
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
127
+
128
+ namespace MTL
129
+ {
130
+ namespace Private
131
+ {
132
+ namespace Protocol
133
+ {
134
+
135
+ } // Protocol
136
+ } // Private
137
+ } // MTL
138
+
139
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
140
+
141
+ namespace MTL
142
+ {
143
+ namespace Private
144
+ {
145
+ namespace Selector
146
+ {
147
+
148
+ _MTL_PRIVATE_DEF_SEL(beginScope,
149
+ "beginScope");
150
+ _MTL_PRIVATE_DEF_SEL(endScope,
151
+ "endScope");
152
+ } // Class
153
+ } // Private
154
+ } // MTL
155
+
156
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
lib/python3.11/site-packages/mlx/include/metal_cpp/Metal/MTLRasterizationRate.hpp ADDED
@@ -0,0 +1,386 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
2
+ //
3
+ // Metal/MTLRasterizationRate.hpp
4
+ //
5
+ // Copyright 2020-2023 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 "MTLDevice.hpp"
30
+ #include "MTLTypes.hpp"
31
+
32
+ namespace MTL
33
+ {
34
+ class RasterizationRateSampleArray : public NS::Referencing<RasterizationRateSampleArray>
35
+ {
36
+ public:
37
+ static class RasterizationRateSampleArray* alloc();
38
+
39
+ class RasterizationRateSampleArray* init();
40
+
41
+ NS::Number* object(NS::UInteger index);
42
+
43
+ void setObject(const NS::Number* value, NS::UInteger index);
44
+ };
45
+
46
+ class RasterizationRateLayerDescriptor : public NS::Copying<RasterizationRateLayerDescriptor>
47
+ {
48
+ public:
49
+ static class RasterizationRateLayerDescriptor* alloc();
50
+
51
+ MTL::RasterizationRateLayerDescriptor* init();
52
+
53
+ MTL::RasterizationRateLayerDescriptor* init(MTL::Size sampleCount);
54
+
55
+ MTL::RasterizationRateLayerDescriptor* init(MTL::Size sampleCount, const float* horizontal, const float* vertical);
56
+
57
+ MTL::Size sampleCount() const;
58
+
59
+ MTL::Size maxSampleCount() const;
60
+
61
+ float* horizontalSampleStorage() const;
62
+
63
+ float* verticalSampleStorage() const;
64
+
65
+ class RasterizationRateSampleArray* horizontal() const;
66
+
67
+ class RasterizationRateSampleArray* vertical() const;
68
+
69
+ void setSampleCount(MTL::Size sampleCount);
70
+ };
71
+
72
+ class RasterizationRateLayerArray : public NS::Referencing<RasterizationRateLayerArray>
73
+ {
74
+ public:
75
+ static class RasterizationRateLayerArray* alloc();
76
+
77
+ class RasterizationRateLayerArray* init();
78
+
79
+ class RasterizationRateLayerDescriptor* object(NS::UInteger layerIndex);
80
+
81
+ void setObject(const class RasterizationRateLayerDescriptor* layer, NS::UInteger layerIndex);
82
+ };
83
+
84
+ class RasterizationRateMapDescriptor : public NS::Copying<RasterizationRateMapDescriptor>
85
+ {
86
+ public:
87
+ static class RasterizationRateMapDescriptor* alloc();
88
+
89
+ class RasterizationRateMapDescriptor* init();
90
+
91
+ static class RasterizationRateMapDescriptor* rasterizationRateMapDescriptor(MTL::Size screenSize);
92
+
93
+ static class RasterizationRateMapDescriptor* rasterizationRateMapDescriptor(MTL::Size screenSize, const class RasterizationRateLayerDescriptor* layer);
94
+
95
+ static class RasterizationRateMapDescriptor* rasterizationRateMapDescriptor(MTL::Size screenSize, NS::UInteger layerCount, const class RasterizationRateLayerDescriptor* const* layers);
96
+
97
+ class RasterizationRateLayerDescriptor* layer(NS::UInteger layerIndex);
98
+
99
+ void setLayer(const class RasterizationRateLayerDescriptor* layer, NS::UInteger layerIndex);
100
+
101
+ class RasterizationRateLayerArray* layers() const;
102
+
103
+ MTL::Size screenSize() const;
104
+ void setScreenSize(MTL::Size screenSize);
105
+
106
+ NS::String* label() const;
107
+ void setLabel(const NS::String* label);
108
+
109
+ NS::UInteger layerCount() const;
110
+ };
111
+
112
+ class RasterizationRateMap : public NS::Referencing<RasterizationRateMap>
113
+ {
114
+ public:
115
+ class Device* device() const;
116
+
117
+ NS::String* label() const;
118
+
119
+ MTL::Size screenSize() const;
120
+
121
+ MTL::Size physicalGranularity() const;
122
+
123
+ NS::UInteger layerCount() const;
124
+
125
+ MTL::SizeAndAlign parameterBufferSizeAndAlign() const;
126
+
127
+ void copyParameterDataToBuffer(const class Buffer* buffer, NS::UInteger offset);
128
+
129
+ MTL::Size physicalSize(NS::UInteger layerIndex);
130
+
131
+ MTL::Coordinate2D mapScreenToPhysicalCoordinates(MTL::Coordinate2D screenCoordinates, NS::UInteger layerIndex);
132
+
133
+ MTL::Coordinate2D mapPhysicalToScreenCoordinates(MTL::Coordinate2D physicalCoordinates, NS::UInteger layerIndex);
134
+ };
135
+
136
+ }
137
+
138
+ // static method: alloc
139
+ _MTL_INLINE MTL::RasterizationRateSampleArray* MTL::RasterizationRateSampleArray::alloc()
140
+ {
141
+ return NS::Object::alloc<MTL::RasterizationRateSampleArray>(_MTL_PRIVATE_CLS(MTLRasterizationRateSampleArray));
142
+ }
143
+
144
+ // method: init
145
+ _MTL_INLINE MTL::RasterizationRateSampleArray* MTL::RasterizationRateSampleArray::init()
146
+ {
147
+ return NS::Object::init<MTL::RasterizationRateSampleArray>();
148
+ }
149
+
150
+ // method: objectAtIndexedSubscript:
151
+ _MTL_INLINE NS::Number* MTL::RasterizationRateSampleArray::object(NS::UInteger index)
152
+ {
153
+ return Object::sendMessage<NS::Number*>(this, _MTL_PRIVATE_SEL(objectAtIndexedSubscript_), index);
154
+ }
155
+
156
+ // method: setObject:atIndexedSubscript:
157
+ _MTL_INLINE void MTL::RasterizationRateSampleArray::setObject(const NS::Number* value, NS::UInteger index)
158
+ {
159
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setObject_atIndexedSubscript_), value, index);
160
+ }
161
+
162
+ // static method: alloc
163
+ _MTL_INLINE MTL::RasterizationRateLayerDescriptor* MTL::RasterizationRateLayerDescriptor::alloc()
164
+ {
165
+ return NS::Object::alloc<MTL::RasterizationRateLayerDescriptor>(_MTL_PRIVATE_CLS(MTLRasterizationRateLayerDescriptor));
166
+ }
167
+
168
+ // method: init
169
+ _MTL_INLINE MTL::RasterizationRateLayerDescriptor* MTL::RasterizationRateLayerDescriptor::init()
170
+ {
171
+ return NS::Object::init<MTL::RasterizationRateLayerDescriptor>();
172
+ }
173
+
174
+ // method: initWithSampleCount:
175
+ _MTL_INLINE MTL::RasterizationRateLayerDescriptor* MTL::RasterizationRateLayerDescriptor::init(MTL::Size sampleCount)
176
+ {
177
+ return Object::sendMessage<MTL::RasterizationRateLayerDescriptor*>(this, _MTL_PRIVATE_SEL(initWithSampleCount_), sampleCount);
178
+ }
179
+
180
+ // method: initWithSampleCount:horizontal:vertical:
181
+ _MTL_INLINE MTL::RasterizationRateLayerDescriptor* MTL::RasterizationRateLayerDescriptor::init(MTL::Size sampleCount, const float* horizontal, const float* vertical)
182
+ {
183
+ return Object::sendMessage<MTL::RasterizationRateLayerDescriptor*>(this, _MTL_PRIVATE_SEL(initWithSampleCount_horizontal_vertical_), sampleCount, horizontal, vertical);
184
+ }
185
+
186
+ // property: sampleCount
187
+ _MTL_INLINE MTL::Size MTL::RasterizationRateLayerDescriptor::sampleCount() const
188
+ {
189
+ return Object::sendMessage<MTL::Size>(this, _MTL_PRIVATE_SEL(sampleCount));
190
+ }
191
+
192
+ // property: maxSampleCount
193
+ _MTL_INLINE MTL::Size MTL::RasterizationRateLayerDescriptor::maxSampleCount() const
194
+ {
195
+ return Object::sendMessage<MTL::Size>(this, _MTL_PRIVATE_SEL(maxSampleCount));
196
+ }
197
+
198
+ // property: horizontalSampleStorage
199
+ _MTL_INLINE float* MTL::RasterizationRateLayerDescriptor::horizontalSampleStorage() const
200
+ {
201
+ return Object::sendMessage<float*>(this, _MTL_PRIVATE_SEL(horizontalSampleStorage));
202
+ }
203
+
204
+ // property: verticalSampleStorage
205
+ _MTL_INLINE float* MTL::RasterizationRateLayerDescriptor::verticalSampleStorage() const
206
+ {
207
+ return Object::sendMessage<float*>(this, _MTL_PRIVATE_SEL(verticalSampleStorage));
208
+ }
209
+
210
+ // property: horizontal
211
+ _MTL_INLINE MTL::RasterizationRateSampleArray* MTL::RasterizationRateLayerDescriptor::horizontal() const
212
+ {
213
+ return Object::sendMessage<MTL::RasterizationRateSampleArray*>(this, _MTL_PRIVATE_SEL(horizontal));
214
+ }
215
+
216
+ // property: vertical
217
+ _MTL_INLINE MTL::RasterizationRateSampleArray* MTL::RasterizationRateLayerDescriptor::vertical() const
218
+ {
219
+ return Object::sendMessage<MTL::RasterizationRateSampleArray*>(this, _MTL_PRIVATE_SEL(vertical));
220
+ }
221
+
222
+ // method: setSampleCount:
223
+ _MTL_INLINE void MTL::RasterizationRateLayerDescriptor::setSampleCount(MTL::Size sampleCount)
224
+ {
225
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setSampleCount_), sampleCount);
226
+ }
227
+
228
+ // static method: alloc
229
+ _MTL_INLINE MTL::RasterizationRateLayerArray* MTL::RasterizationRateLayerArray::alloc()
230
+ {
231
+ return NS::Object::alloc<MTL::RasterizationRateLayerArray>(_MTL_PRIVATE_CLS(MTLRasterizationRateLayerArray));
232
+ }
233
+
234
+ // method: init
235
+ _MTL_INLINE MTL::RasterizationRateLayerArray* MTL::RasterizationRateLayerArray::init()
236
+ {
237
+ return NS::Object::init<MTL::RasterizationRateLayerArray>();
238
+ }
239
+
240
+ // method: objectAtIndexedSubscript:
241
+ _MTL_INLINE MTL::RasterizationRateLayerDescriptor* MTL::RasterizationRateLayerArray::object(NS::UInteger layerIndex)
242
+ {
243
+ return Object::sendMessage<MTL::RasterizationRateLayerDescriptor*>(this, _MTL_PRIVATE_SEL(objectAtIndexedSubscript_), layerIndex);
244
+ }
245
+
246
+ // method: setObject:atIndexedSubscript:
247
+ _MTL_INLINE void MTL::RasterizationRateLayerArray::setObject(const MTL::RasterizationRateLayerDescriptor* layer, NS::UInteger layerIndex)
248
+ {
249
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setObject_atIndexedSubscript_), layer, layerIndex);
250
+ }
251
+
252
+ // static method: alloc
253
+ _MTL_INLINE MTL::RasterizationRateMapDescriptor* MTL::RasterizationRateMapDescriptor::alloc()
254
+ {
255
+ return NS::Object::alloc<MTL::RasterizationRateMapDescriptor>(_MTL_PRIVATE_CLS(MTLRasterizationRateMapDescriptor));
256
+ }
257
+
258
+ // method: init
259
+ _MTL_INLINE MTL::RasterizationRateMapDescriptor* MTL::RasterizationRateMapDescriptor::init()
260
+ {
261
+ return NS::Object::init<MTL::RasterizationRateMapDescriptor>();
262
+ }
263
+
264
+ // static method: rasterizationRateMapDescriptorWithScreenSize:
265
+ _MTL_INLINE MTL::RasterizationRateMapDescriptor* MTL::RasterizationRateMapDescriptor::rasterizationRateMapDescriptor(MTL::Size screenSize)
266
+ {
267
+ return Object::sendMessage<MTL::RasterizationRateMapDescriptor*>(_MTL_PRIVATE_CLS(MTLRasterizationRateMapDescriptor), _MTL_PRIVATE_SEL(rasterizationRateMapDescriptorWithScreenSize_), screenSize);
268
+ }
269
+
270
+ // static method: rasterizationRateMapDescriptorWithScreenSize:layer:
271
+ _MTL_INLINE MTL::RasterizationRateMapDescriptor* MTL::RasterizationRateMapDescriptor::rasterizationRateMapDescriptor(MTL::Size screenSize, const MTL::RasterizationRateLayerDescriptor* layer)
272
+ {
273
+ return Object::sendMessage<MTL::RasterizationRateMapDescriptor*>(_MTL_PRIVATE_CLS(MTLRasterizationRateMapDescriptor), _MTL_PRIVATE_SEL(rasterizationRateMapDescriptorWithScreenSize_layer_), screenSize, layer);
274
+ }
275
+
276
+ // static method: rasterizationRateMapDescriptorWithScreenSize:layerCount:layers:
277
+ _MTL_INLINE MTL::RasterizationRateMapDescriptor* MTL::RasterizationRateMapDescriptor::rasterizationRateMapDescriptor(MTL::Size screenSize, NS::UInteger layerCount, const MTL::RasterizationRateLayerDescriptor* const* layers)
278
+ {
279
+ return Object::sendMessage<MTL::RasterizationRateMapDescriptor*>(_MTL_PRIVATE_CLS(MTLRasterizationRateMapDescriptor), _MTL_PRIVATE_SEL(rasterizationRateMapDescriptorWithScreenSize_layerCount_layers_), screenSize, layerCount, layers);
280
+ }
281
+
282
+ // method: layerAtIndex:
283
+ _MTL_INLINE MTL::RasterizationRateLayerDescriptor* MTL::RasterizationRateMapDescriptor::layer(NS::UInteger layerIndex)
284
+ {
285
+ return Object::sendMessage<MTL::RasterizationRateLayerDescriptor*>(this, _MTL_PRIVATE_SEL(layerAtIndex_), layerIndex);
286
+ }
287
+
288
+ // method: setLayer:atIndex:
289
+ _MTL_INLINE void MTL::RasterizationRateMapDescriptor::setLayer(const MTL::RasterizationRateLayerDescriptor* layer, NS::UInteger layerIndex)
290
+ {
291
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setLayer_atIndex_), layer, layerIndex);
292
+ }
293
+
294
+ // property: layers
295
+ _MTL_INLINE MTL::RasterizationRateLayerArray* MTL::RasterizationRateMapDescriptor::layers() const
296
+ {
297
+ return Object::sendMessage<MTL::RasterizationRateLayerArray*>(this, _MTL_PRIVATE_SEL(layers));
298
+ }
299
+
300
+ // property: screenSize
301
+ _MTL_INLINE MTL::Size MTL::RasterizationRateMapDescriptor::screenSize() const
302
+ {
303
+ return Object::sendMessage<MTL::Size>(this, _MTL_PRIVATE_SEL(screenSize));
304
+ }
305
+
306
+ _MTL_INLINE void MTL::RasterizationRateMapDescriptor::setScreenSize(MTL::Size screenSize)
307
+ {
308
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setScreenSize_), screenSize);
309
+ }
310
+
311
+ // property: label
312
+ _MTL_INLINE NS::String* MTL::RasterizationRateMapDescriptor::label() const
313
+ {
314
+ return Object::sendMessage<NS::String*>(this, _MTL_PRIVATE_SEL(label));
315
+ }
316
+
317
+ _MTL_INLINE void MTL::RasterizationRateMapDescriptor::setLabel(const NS::String* label)
318
+ {
319
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setLabel_), label);
320
+ }
321
+
322
+ // property: layerCount
323
+ _MTL_INLINE NS::UInteger MTL::RasterizationRateMapDescriptor::layerCount() const
324
+ {
325
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(layerCount));
326
+ }
327
+
328
+ // property: device
329
+ _MTL_INLINE MTL::Device* MTL::RasterizationRateMap::device() const
330
+ {
331
+ return Object::sendMessage<MTL::Device*>(this, _MTL_PRIVATE_SEL(device));
332
+ }
333
+
334
+ // property: label
335
+ _MTL_INLINE NS::String* MTL::RasterizationRateMap::label() const
336
+ {
337
+ return Object::sendMessage<NS::String*>(this, _MTL_PRIVATE_SEL(label));
338
+ }
339
+
340
+ // property: screenSize
341
+ _MTL_INLINE MTL::Size MTL::RasterizationRateMap::screenSize() const
342
+ {
343
+ return Object::sendMessage<MTL::Size>(this, _MTL_PRIVATE_SEL(screenSize));
344
+ }
345
+
346
+ // property: physicalGranularity
347
+ _MTL_INLINE MTL::Size MTL::RasterizationRateMap::physicalGranularity() const
348
+ {
349
+ return Object::sendMessage<MTL::Size>(this, _MTL_PRIVATE_SEL(physicalGranularity));
350
+ }
351
+
352
+ // property: layerCount
353
+ _MTL_INLINE NS::UInteger MTL::RasterizationRateMap::layerCount() const
354
+ {
355
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(layerCount));
356
+ }
357
+
358
+ // property: parameterBufferSizeAndAlign
359
+ _MTL_INLINE MTL::SizeAndAlign MTL::RasterizationRateMap::parameterBufferSizeAndAlign() const
360
+ {
361
+ return Object::sendMessage<MTL::SizeAndAlign>(this, _MTL_PRIVATE_SEL(parameterBufferSizeAndAlign));
362
+ }
363
+
364
+ // method: copyParameterDataToBuffer:offset:
365
+ _MTL_INLINE void MTL::RasterizationRateMap::copyParameterDataToBuffer(const MTL::Buffer* buffer, NS::UInteger offset)
366
+ {
367
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(copyParameterDataToBuffer_offset_), buffer, offset);
368
+ }
369
+
370
+ // method: physicalSizeForLayer:
371
+ _MTL_INLINE MTL::Size MTL::RasterizationRateMap::physicalSize(NS::UInteger layerIndex)
372
+ {
373
+ return Object::sendMessage<MTL::Size>(this, _MTL_PRIVATE_SEL(physicalSizeForLayer_), layerIndex);
374
+ }
375
+
376
+ // method: mapScreenToPhysicalCoordinates:forLayer:
377
+ _MTL_INLINE MTL::Coordinate2D MTL::RasterizationRateMap::mapScreenToPhysicalCoordinates(MTL::Coordinate2D screenCoordinates, NS::UInteger layerIndex)
378
+ {
379
+ return Object::sendMessage<MTL::Coordinate2D>(this, _MTL_PRIVATE_SEL(mapScreenToPhysicalCoordinates_forLayer_), screenCoordinates, layerIndex);
380
+ }
381
+
382
+ // method: mapPhysicalToScreenCoordinates:forLayer:
383
+ _MTL_INLINE MTL::Coordinate2D MTL::RasterizationRateMap::mapPhysicalToScreenCoordinates(MTL::Coordinate2D physicalCoordinates, NS::UInteger layerIndex)
384
+ {
385
+ return Object::sendMessage<MTL::Coordinate2D>(this, _MTL_PRIVATE_SEL(mapPhysicalToScreenCoordinates_forLayer_), physicalCoordinates, layerIndex);
386
+ }
lib/python3.11/site-packages/mlx/include/metal_cpp/Metal/MTLRenderCommandEncoder.hpp ADDED
@@ -0,0 +1,1177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
2
+ //
3
+ // Metal/MTLRenderCommandEncoder.hpp
4
+ //
5
+ // Copyright 2020-2023 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 "MTLCommandEncoder.hpp"
30
+ #include "MTLRenderCommandEncoder.hpp"
31
+ #include "MTLRenderPass.hpp"
32
+ #include "MTLStageInputOutputDescriptor.hpp"
33
+ #include "MTLTypes.hpp"
34
+
35
+ namespace MTL
36
+ {
37
+ _MTL_ENUM(NS::UInteger, PrimitiveType) {
38
+ PrimitiveTypePoint = 0,
39
+ PrimitiveTypeLine = 1,
40
+ PrimitiveTypeLineStrip = 2,
41
+ PrimitiveTypeTriangle = 3,
42
+ PrimitiveTypeTriangleStrip = 4,
43
+ };
44
+
45
+ _MTL_ENUM(NS::UInteger, VisibilityResultMode) {
46
+ VisibilityResultModeDisabled = 0,
47
+ VisibilityResultModeBoolean = 1,
48
+ VisibilityResultModeCounting = 2,
49
+ };
50
+
51
+ struct ScissorRect
52
+ {
53
+ NS::UInteger x;
54
+ NS::UInteger y;
55
+ NS::UInteger width;
56
+ NS::UInteger height;
57
+ } _MTL_PACKED;
58
+
59
+ struct Viewport
60
+ {
61
+ double originX;
62
+ double originY;
63
+ double width;
64
+ double height;
65
+ double znear;
66
+ double zfar;
67
+ } _MTL_PACKED;
68
+
69
+ _MTL_ENUM(NS::UInteger, CullMode) {
70
+ CullModeNone = 0,
71
+ CullModeFront = 1,
72
+ CullModeBack = 2,
73
+ };
74
+
75
+ _MTL_ENUM(NS::UInteger, Winding) {
76
+ WindingClockwise = 0,
77
+ WindingCounterClockwise = 1,
78
+ };
79
+
80
+ _MTL_ENUM(NS::UInteger, DepthClipMode) {
81
+ DepthClipModeClip = 0,
82
+ DepthClipModeClamp = 1,
83
+ };
84
+
85
+ _MTL_ENUM(NS::UInteger, TriangleFillMode) {
86
+ TriangleFillModeFill = 0,
87
+ TriangleFillModeLines = 1,
88
+ };
89
+
90
+ struct DrawPrimitivesIndirectArguments
91
+ {
92
+ uint32_t vertexCount;
93
+ uint32_t instanceCount;
94
+ uint32_t vertexStart;
95
+ uint32_t baseInstance;
96
+ } _MTL_PACKED;
97
+
98
+ struct DrawIndexedPrimitivesIndirectArguments
99
+ {
100
+ uint32_t indexCount;
101
+ uint32_t instanceCount;
102
+ uint32_t indexStart;
103
+ int32_t baseVertex;
104
+ uint32_t baseInstance;
105
+ } _MTL_PACKED;
106
+
107
+ struct VertexAmplificationViewMapping
108
+ {
109
+ uint32_t viewportArrayIndexOffset;
110
+ uint32_t renderTargetArrayIndexOffset;
111
+ } _MTL_PACKED;
112
+
113
+ struct DrawPatchIndirectArguments
114
+ {
115
+ uint32_t patchCount;
116
+ uint32_t instanceCount;
117
+ uint32_t patchStart;
118
+ uint32_t baseInstance;
119
+ } _MTL_PACKED;
120
+
121
+ struct QuadTessellationFactorsHalf
122
+ {
123
+ uint16_t edgeTessellationFactor[4];
124
+ uint16_t insideTessellationFactor[2];
125
+ } _MTL_PACKED;
126
+
127
+ struct TriangleTessellationFactorsHalf
128
+ {
129
+ uint16_t edgeTessellationFactor[3];
130
+ uint16_t insideTessellationFactor;
131
+ } _MTL_PACKED;
132
+
133
+ _MTL_OPTIONS(NS::UInteger, RenderStages) {
134
+ RenderStageVertex = 1,
135
+ RenderStageFragment = 2,
136
+ RenderStageTile = 4,
137
+ RenderStageObject = 8,
138
+ RenderStageMesh = 16,
139
+ };
140
+
141
+ class RenderCommandEncoder : public NS::Referencing<RenderCommandEncoder, CommandEncoder>
142
+ {
143
+ public:
144
+ void setRenderPipelineState(const class RenderPipelineState* pipelineState);
145
+
146
+ void setVertexBytes(const void* bytes, NS::UInteger length, NS::UInteger index);
147
+
148
+ void setVertexBuffer(const class Buffer* buffer, NS::UInteger offset, NS::UInteger index);
149
+
150
+ void setVertexBufferOffset(NS::UInteger offset, NS::UInteger index);
151
+
152
+ void setVertexBuffers(const class Buffer* const buffers[], const NS::UInteger offsets[], NS::Range range);
153
+
154
+ void setVertexBuffer(const class Buffer* buffer, NS::UInteger offset, NS::UInteger stride, NS::UInteger index);
155
+
156
+ void setVertexBuffers(const class Buffer* const buffers[], const NS::UInteger* offsets, const NS::UInteger* strides, NS::Range range);
157
+
158
+ void setVertexBufferOffset(NS::UInteger offset, NS::UInteger stride, NS::UInteger index);
159
+
160
+ void setVertexBytes(const void* bytes, NS::UInteger length, NS::UInteger stride, NS::UInteger index);
161
+
162
+ void setVertexTexture(const class Texture* texture, NS::UInteger index);
163
+
164
+ void setVertexTextures(const class Texture* const textures[], NS::Range range);
165
+
166
+ void setVertexSamplerState(const class SamplerState* sampler, NS::UInteger index);
167
+
168
+ void setVertexSamplerStates(const class SamplerState* const samplers[], NS::Range range);
169
+
170
+ void setVertexSamplerState(const class SamplerState* sampler, float lodMinClamp, float lodMaxClamp, NS::UInteger index);
171
+
172
+ void setVertexSamplerStates(const class SamplerState* const samplers[], const float lodMinClamps[], const float lodMaxClamps[], NS::Range range);
173
+
174
+ void setVertexVisibleFunctionTable(const class VisibleFunctionTable* functionTable, NS::UInteger bufferIndex);
175
+
176
+ void setVertexVisibleFunctionTables(const class VisibleFunctionTable* const functionTables[], NS::Range range);
177
+
178
+ void setVertexIntersectionFunctionTable(const class IntersectionFunctionTable* intersectionFunctionTable, NS::UInteger bufferIndex);
179
+
180
+ void setVertexIntersectionFunctionTables(const class IntersectionFunctionTable* const intersectionFunctionTables[], NS::Range range);
181
+
182
+ void setVertexAccelerationStructure(const class AccelerationStructure* accelerationStructure, NS::UInteger bufferIndex);
183
+
184
+ void setViewport(MTL::Viewport viewport);
185
+
186
+ void setViewports(const MTL::Viewport* viewports, NS::UInteger count);
187
+
188
+ void setFrontFacingWinding(MTL::Winding frontFacingWinding);
189
+
190
+ void setVertexAmplificationCount(NS::UInteger count, const MTL::VertexAmplificationViewMapping* viewMappings);
191
+
192
+ void setCullMode(MTL::CullMode cullMode);
193
+
194
+ void setDepthClipMode(MTL::DepthClipMode depthClipMode);
195
+
196
+ void setDepthBias(float depthBias, float slopeScale, float clamp);
197
+
198
+ void setScissorRect(MTL::ScissorRect rect);
199
+
200
+ void setScissorRects(const MTL::ScissorRect* scissorRects, NS::UInteger count);
201
+
202
+ void setTriangleFillMode(MTL::TriangleFillMode fillMode);
203
+
204
+ void setFragmentBytes(const void* bytes, NS::UInteger length, NS::UInteger index);
205
+
206
+ void setFragmentBuffer(const class Buffer* buffer, NS::UInteger offset, NS::UInteger index);
207
+
208
+ void setFragmentBufferOffset(NS::UInteger offset, NS::UInteger index);
209
+
210
+ void setFragmentBuffers(const class Buffer* const buffers[], const NS::UInteger offsets[], NS::Range range);
211
+
212
+ void setFragmentTexture(const class Texture* texture, NS::UInteger index);
213
+
214
+ void setFragmentTextures(const class Texture* const textures[], NS::Range range);
215
+
216
+ void setFragmentSamplerState(const class SamplerState* sampler, NS::UInteger index);
217
+
218
+ void setFragmentSamplerStates(const class SamplerState* const samplers[], NS::Range range);
219
+
220
+ void setFragmentSamplerState(const class SamplerState* sampler, float lodMinClamp, float lodMaxClamp, NS::UInteger index);
221
+
222
+ void setFragmentSamplerStates(const class SamplerState* const samplers[], const float lodMinClamps[], const float lodMaxClamps[], NS::Range range);
223
+
224
+ void setFragmentVisibleFunctionTable(const class VisibleFunctionTable* functionTable, NS::UInteger bufferIndex);
225
+
226
+ void setFragmentVisibleFunctionTables(const class VisibleFunctionTable* const functionTables[], NS::Range range);
227
+
228
+ void setFragmentIntersectionFunctionTable(const class IntersectionFunctionTable* intersectionFunctionTable, NS::UInteger bufferIndex);
229
+
230
+ void setFragmentIntersectionFunctionTables(const class IntersectionFunctionTable* const intersectionFunctionTables[], NS::Range range);
231
+
232
+ void setFragmentAccelerationStructure(const class AccelerationStructure* accelerationStructure, NS::UInteger bufferIndex);
233
+
234
+ void setBlendColor(float red, float green, float blue, float alpha);
235
+
236
+ void setDepthStencilState(const class DepthStencilState* depthStencilState);
237
+
238
+ void setStencilReferenceValue(uint32_t referenceValue);
239
+
240
+ void setStencilReferenceValues(uint32_t frontReferenceValue, uint32_t backReferenceValue);
241
+
242
+ void setVisibilityResultMode(MTL::VisibilityResultMode mode, NS::UInteger offset);
243
+
244
+ void setColorStoreAction(MTL::StoreAction storeAction, NS::UInteger colorAttachmentIndex);
245
+
246
+ void setDepthStoreAction(MTL::StoreAction storeAction);
247
+
248
+ void setStencilStoreAction(MTL::StoreAction storeAction);
249
+
250
+ void setColorStoreActionOptions(MTL::StoreActionOptions storeActionOptions, NS::UInteger colorAttachmentIndex);
251
+
252
+ void setDepthStoreActionOptions(MTL::StoreActionOptions storeActionOptions);
253
+
254
+ void setStencilStoreActionOptions(MTL::StoreActionOptions storeActionOptions);
255
+
256
+ void setObjectBytes(const void* bytes, NS::UInteger length, NS::UInteger index);
257
+
258
+ void setObjectBuffer(const class Buffer* buffer, NS::UInteger offset, NS::UInteger index);
259
+
260
+ void setObjectBufferOffset(NS::UInteger offset, NS::UInteger index);
261
+
262
+ void setObjectBuffers(const class Buffer* const buffers[], const NS::UInteger* offsets, NS::Range range);
263
+
264
+ void setObjectTexture(const class Texture* texture, NS::UInteger index);
265
+
266
+ void setObjectTextures(const class Texture* const textures[], NS::Range range);
267
+
268
+ void setObjectSamplerState(const class SamplerState* sampler, NS::UInteger index);
269
+
270
+ void setObjectSamplerStates(const class SamplerState* const samplers[], NS::Range range);
271
+
272
+ void setObjectSamplerState(const class SamplerState* sampler, float lodMinClamp, float lodMaxClamp, NS::UInteger index);
273
+
274
+ void setObjectSamplerStates(const class SamplerState* const samplers[], const float* lodMinClamps, const float* lodMaxClamps, NS::Range range);
275
+
276
+ void setObjectThreadgroupMemoryLength(NS::UInteger length, NS::UInteger index);
277
+
278
+ void setMeshBytes(const void* bytes, NS::UInteger length, NS::UInteger index);
279
+
280
+ void setMeshBuffer(const class Buffer* buffer, NS::UInteger offset, NS::UInteger index);
281
+
282
+ void setMeshBufferOffset(NS::UInteger offset, NS::UInteger index);
283
+
284
+ void setMeshBuffers(const class Buffer* const buffers[], const NS::UInteger* offsets, NS::Range range);
285
+
286
+ void setMeshTexture(const class Texture* texture, NS::UInteger index);
287
+
288
+ void setMeshTextures(const class Texture* const textures[], NS::Range range);
289
+
290
+ void setMeshSamplerState(const class SamplerState* sampler, NS::UInteger index);
291
+
292
+ void setMeshSamplerStates(const class SamplerState* const samplers[], NS::Range range);
293
+
294
+ void setMeshSamplerState(const class SamplerState* sampler, float lodMinClamp, float lodMaxClamp, NS::UInteger index);
295
+
296
+ void setMeshSamplerStates(const class SamplerState* const samplers[], const float* lodMinClamps, const float* lodMaxClamps, NS::Range range);
297
+
298
+ void drawMeshThreadgroups(MTL::Size threadgroupsPerGrid, MTL::Size threadsPerObjectThreadgroup, MTL::Size threadsPerMeshThreadgroup);
299
+
300
+ void drawMeshThreads(MTL::Size threadsPerGrid, MTL::Size threadsPerObjectThreadgroup, MTL::Size threadsPerMeshThreadgroup);
301
+
302
+ void drawMeshThreadgroups(const class Buffer* indirectBuffer, NS::UInteger indirectBufferOffset, MTL::Size threadsPerObjectThreadgroup, MTL::Size threadsPerMeshThreadgroup);
303
+
304
+ void drawPrimitives(MTL::PrimitiveType primitiveType, NS::UInteger vertexStart, NS::UInteger vertexCount, NS::UInteger instanceCount);
305
+
306
+ void drawPrimitives(MTL::PrimitiveType primitiveType, NS::UInteger vertexStart, NS::UInteger vertexCount);
307
+
308
+ void drawIndexedPrimitives(MTL::PrimitiveType primitiveType, NS::UInteger indexCount, MTL::IndexType indexType, const class Buffer* indexBuffer, NS::UInteger indexBufferOffset, NS::UInteger instanceCount);
309
+
310
+ void drawIndexedPrimitives(MTL::PrimitiveType primitiveType, NS::UInteger indexCount, MTL::IndexType indexType, const class Buffer* indexBuffer, NS::UInteger indexBufferOffset);
311
+
312
+ void drawPrimitives(MTL::PrimitiveType primitiveType, NS::UInteger vertexStart, NS::UInteger vertexCount, NS::UInteger instanceCount, NS::UInteger baseInstance);
313
+
314
+ void drawIndexedPrimitives(MTL::PrimitiveType primitiveType, NS::UInteger indexCount, MTL::IndexType indexType, const class Buffer* indexBuffer, NS::UInteger indexBufferOffset, NS::UInteger instanceCount, NS::Integer baseVertex, NS::UInteger baseInstance);
315
+
316
+ void drawPrimitives(MTL::PrimitiveType primitiveType, const class Buffer* indirectBuffer, NS::UInteger indirectBufferOffset);
317
+
318
+ void drawIndexedPrimitives(MTL::PrimitiveType primitiveType, MTL::IndexType indexType, const class Buffer* indexBuffer, NS::UInteger indexBufferOffset, const class Buffer* indirectBuffer, NS::UInteger indirectBufferOffset);
319
+
320
+ void textureBarrier();
321
+
322
+ void updateFence(const class Fence* fence, MTL::RenderStages stages);
323
+
324
+ void waitForFence(const class Fence* fence, MTL::RenderStages stages);
325
+
326
+ void setTessellationFactorBuffer(const class Buffer* buffer, NS::UInteger offset, NS::UInteger instanceStride);
327
+
328
+ void setTessellationFactorScale(float scale);
329
+
330
+ void drawPatches(NS::UInteger numberOfPatchControlPoints, NS::UInteger patchStart, NS::UInteger patchCount, const class Buffer* patchIndexBuffer, NS::UInteger patchIndexBufferOffset, NS::UInteger instanceCount, NS::UInteger baseInstance);
331
+
332
+ void drawPatches(NS::UInteger numberOfPatchControlPoints, const class Buffer* patchIndexBuffer, NS::UInteger patchIndexBufferOffset, const class Buffer* indirectBuffer, NS::UInteger indirectBufferOffset);
333
+
334
+ void drawIndexedPatches(NS::UInteger numberOfPatchControlPoints, NS::UInteger patchStart, NS::UInteger patchCount, const class Buffer* patchIndexBuffer, NS::UInteger patchIndexBufferOffset, const class Buffer* controlPointIndexBuffer, NS::UInteger controlPointIndexBufferOffset, NS::UInteger instanceCount, NS::UInteger baseInstance);
335
+
336
+ void drawIndexedPatches(NS::UInteger numberOfPatchControlPoints, const class Buffer* patchIndexBuffer, NS::UInteger patchIndexBufferOffset, const class Buffer* controlPointIndexBuffer, NS::UInteger controlPointIndexBufferOffset, const class Buffer* indirectBuffer, NS::UInteger indirectBufferOffset);
337
+
338
+ NS::UInteger tileWidth() const;
339
+
340
+ NS::UInteger tileHeight() const;
341
+
342
+ void setTileBytes(const void* bytes, NS::UInteger length, NS::UInteger index);
343
+
344
+ void setTileBuffer(const class Buffer* buffer, NS::UInteger offset, NS::UInteger index);
345
+
346
+ void setTileBufferOffset(NS::UInteger offset, NS::UInteger index);
347
+
348
+ void setTileBuffers(const class Buffer* const buffers[], const NS::UInteger* offsets, NS::Range range);
349
+
350
+ void setTileTexture(const class Texture* texture, NS::UInteger index);
351
+
352
+ void setTileTextures(const class Texture* const textures[], NS::Range range);
353
+
354
+ void setTileSamplerState(const class SamplerState* sampler, NS::UInteger index);
355
+
356
+ void setTileSamplerStates(const class SamplerState* const samplers[], NS::Range range);
357
+
358
+ void setTileSamplerState(const class SamplerState* sampler, float lodMinClamp, float lodMaxClamp, NS::UInteger index);
359
+
360
+ void setTileSamplerStates(const class SamplerState* const samplers[], const float lodMinClamps[], const float lodMaxClamps[], NS::Range range);
361
+
362
+ void setTileVisibleFunctionTable(const class VisibleFunctionTable* functionTable, NS::UInteger bufferIndex);
363
+
364
+ void setTileVisibleFunctionTables(const class VisibleFunctionTable* const functionTables[], NS::Range range);
365
+
366
+ void setTileIntersectionFunctionTable(const class IntersectionFunctionTable* intersectionFunctionTable, NS::UInteger bufferIndex);
367
+
368
+ void setTileIntersectionFunctionTables(const class IntersectionFunctionTable* const intersectionFunctionTables[], NS::Range range);
369
+
370
+ void setTileAccelerationStructure(const class AccelerationStructure* accelerationStructure, NS::UInteger bufferIndex);
371
+
372
+ void dispatchThreadsPerTile(MTL::Size threadsPerTile);
373
+
374
+ void setThreadgroupMemoryLength(NS::UInteger length, NS::UInteger offset, NS::UInteger index);
375
+
376
+ void useResource(const class Resource* resource, MTL::ResourceUsage usage);
377
+
378
+ void useResources(const class Resource* const resources[], NS::UInteger count, MTL::ResourceUsage usage);
379
+
380
+ void useResource(const class Resource* resource, MTL::ResourceUsage usage, MTL::RenderStages stages);
381
+
382
+ void useResources(const class Resource* const resources[], NS::UInteger count, MTL::ResourceUsage usage, MTL::RenderStages stages);
383
+
384
+ void useHeap(const class Heap* heap);
385
+
386
+ void useHeaps(const class Heap* const heaps[], NS::UInteger count);
387
+
388
+ void useHeap(const class Heap* heap, MTL::RenderStages stages);
389
+
390
+ void useHeaps(const class Heap* const heaps[], NS::UInteger count, MTL::RenderStages stages);
391
+
392
+ void executeCommandsInBuffer(const class IndirectCommandBuffer* indirectCommandBuffer, NS::Range executionRange);
393
+
394
+ void executeCommandsInBuffer(const class IndirectCommandBuffer* indirectCommandbuffer, const class Buffer* indirectRangeBuffer, NS::UInteger indirectBufferOffset);
395
+
396
+ void memoryBarrier(MTL::BarrierScope scope, MTL::RenderStages after, MTL::RenderStages before);
397
+
398
+ void memoryBarrier(const class Resource* const resources[], NS::UInteger count, MTL::RenderStages after, MTL::RenderStages before);
399
+
400
+ void sampleCountersInBuffer(const class CounterSampleBuffer* sampleBuffer, NS::UInteger sampleIndex, bool barrier);
401
+ };
402
+
403
+ }
404
+
405
+ // method: setRenderPipelineState:
406
+ _MTL_INLINE void MTL::RenderCommandEncoder::setRenderPipelineState(const MTL::RenderPipelineState* pipelineState)
407
+ {
408
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setRenderPipelineState_), pipelineState);
409
+ }
410
+
411
+ // method: setVertexBytes:length:atIndex:
412
+ _MTL_INLINE void MTL::RenderCommandEncoder::setVertexBytes(const void* bytes, NS::UInteger length, NS::UInteger index)
413
+ {
414
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setVertexBytes_length_atIndex_), bytes, length, index);
415
+ }
416
+
417
+ // method: setVertexBuffer:offset:atIndex:
418
+ _MTL_INLINE void MTL::RenderCommandEncoder::setVertexBuffer(const MTL::Buffer* buffer, NS::UInteger offset, NS::UInteger index)
419
+ {
420
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setVertexBuffer_offset_atIndex_), buffer, offset, index);
421
+ }
422
+
423
+ // method: setVertexBufferOffset:atIndex:
424
+ _MTL_INLINE void MTL::RenderCommandEncoder::setVertexBufferOffset(NS::UInteger offset, NS::UInteger index)
425
+ {
426
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setVertexBufferOffset_atIndex_), offset, index);
427
+ }
428
+
429
+ // method: setVertexBuffers:offsets:withRange:
430
+ _MTL_INLINE void MTL::RenderCommandEncoder::setVertexBuffers(const MTL::Buffer* const buffers[], const NS::UInteger offsets[], NS::Range range)
431
+ {
432
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setVertexBuffers_offsets_withRange_), buffers, offsets, range);
433
+ }
434
+
435
+ // method: setVertexBuffer:offset:attributeStride:atIndex:
436
+ _MTL_INLINE void MTL::RenderCommandEncoder::setVertexBuffer(const MTL::Buffer* buffer, NS::UInteger offset, NS::UInteger stride, NS::UInteger index)
437
+ {
438
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setVertexBuffer_offset_attributeStride_atIndex_), buffer, offset, stride, index);
439
+ }
440
+
441
+ // method: setVertexBuffers:offsets:attributeStrides:withRange:
442
+ _MTL_INLINE void MTL::RenderCommandEncoder::setVertexBuffers(const MTL::Buffer* const buffers[], const NS::UInteger* offsets, const NS::UInteger* strides, NS::Range range)
443
+ {
444
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setVertexBuffers_offsets_attributeStrides_withRange_), buffers, offsets, strides, range);
445
+ }
446
+
447
+ // method: setVertexBufferOffset:attributeStride:atIndex:
448
+ _MTL_INLINE void MTL::RenderCommandEncoder::setVertexBufferOffset(NS::UInteger offset, NS::UInteger stride, NS::UInteger index)
449
+ {
450
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setVertexBufferOffset_attributeStride_atIndex_), offset, stride, index);
451
+ }
452
+
453
+ // method: setVertexBytes:length:attributeStride:atIndex:
454
+ _MTL_INLINE void MTL::RenderCommandEncoder::setVertexBytes(const void* bytes, NS::UInteger length, NS::UInteger stride, NS::UInteger index)
455
+ {
456
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setVertexBytes_length_attributeStride_atIndex_), bytes, length, stride, index);
457
+ }
458
+
459
+ // method: setVertexTexture:atIndex:
460
+ _MTL_INLINE void MTL::RenderCommandEncoder::setVertexTexture(const MTL::Texture* texture, NS::UInteger index)
461
+ {
462
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setVertexTexture_atIndex_), texture, index);
463
+ }
464
+
465
+ // method: setVertexTextures:withRange:
466
+ _MTL_INLINE void MTL::RenderCommandEncoder::setVertexTextures(const MTL::Texture* const textures[], NS::Range range)
467
+ {
468
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setVertexTextures_withRange_), textures, range);
469
+ }
470
+
471
+ // method: setVertexSamplerState:atIndex:
472
+ _MTL_INLINE void MTL::RenderCommandEncoder::setVertexSamplerState(const MTL::SamplerState* sampler, NS::UInteger index)
473
+ {
474
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setVertexSamplerState_atIndex_), sampler, index);
475
+ }
476
+
477
+ // method: setVertexSamplerStates:withRange:
478
+ _MTL_INLINE void MTL::RenderCommandEncoder::setVertexSamplerStates(const MTL::SamplerState* const samplers[], NS::Range range)
479
+ {
480
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setVertexSamplerStates_withRange_), samplers, range);
481
+ }
482
+
483
+ // method: setVertexSamplerState:lodMinClamp:lodMaxClamp:atIndex:
484
+ _MTL_INLINE void MTL::RenderCommandEncoder::setVertexSamplerState(const MTL::SamplerState* sampler, float lodMinClamp, float lodMaxClamp, NS::UInteger index)
485
+ {
486
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setVertexSamplerState_lodMinClamp_lodMaxClamp_atIndex_), sampler, lodMinClamp, lodMaxClamp, index);
487
+ }
488
+
489
+ // method: setVertexSamplerStates:lodMinClamps:lodMaxClamps:withRange:
490
+ _MTL_INLINE void MTL::RenderCommandEncoder::setVertexSamplerStates(const MTL::SamplerState* const samplers[], const float lodMinClamps[], const float lodMaxClamps[], NS::Range range)
491
+ {
492
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setVertexSamplerStates_lodMinClamps_lodMaxClamps_withRange_), samplers, lodMinClamps, lodMaxClamps, range);
493
+ }
494
+
495
+ // method: setVertexVisibleFunctionTable:atBufferIndex:
496
+ _MTL_INLINE void MTL::RenderCommandEncoder::setVertexVisibleFunctionTable(const MTL::VisibleFunctionTable* functionTable, NS::UInteger bufferIndex)
497
+ {
498
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setVertexVisibleFunctionTable_atBufferIndex_), functionTable, bufferIndex);
499
+ }
500
+
501
+ // method: setVertexVisibleFunctionTables:withBufferRange:
502
+ _MTL_INLINE void MTL::RenderCommandEncoder::setVertexVisibleFunctionTables(const MTL::VisibleFunctionTable* const functionTables[], NS::Range range)
503
+ {
504
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setVertexVisibleFunctionTables_withBufferRange_), functionTables, range);
505
+ }
506
+
507
+ // method: setVertexIntersectionFunctionTable:atBufferIndex:
508
+ _MTL_INLINE void MTL::RenderCommandEncoder::setVertexIntersectionFunctionTable(const MTL::IntersectionFunctionTable* intersectionFunctionTable, NS::UInteger bufferIndex)
509
+ {
510
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setVertexIntersectionFunctionTable_atBufferIndex_), intersectionFunctionTable, bufferIndex);
511
+ }
512
+
513
+ // method: setVertexIntersectionFunctionTables:withBufferRange:
514
+ _MTL_INLINE void MTL::RenderCommandEncoder::setVertexIntersectionFunctionTables(const MTL::IntersectionFunctionTable* const intersectionFunctionTables[], NS::Range range)
515
+ {
516
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setVertexIntersectionFunctionTables_withBufferRange_), intersectionFunctionTables, range);
517
+ }
518
+
519
+ // method: setVertexAccelerationStructure:atBufferIndex:
520
+ _MTL_INLINE void MTL::RenderCommandEncoder::setVertexAccelerationStructure(const MTL::AccelerationStructure* accelerationStructure, NS::UInteger bufferIndex)
521
+ {
522
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setVertexAccelerationStructure_atBufferIndex_), accelerationStructure, bufferIndex);
523
+ }
524
+
525
+ // method: setViewport:
526
+ _MTL_INLINE void MTL::RenderCommandEncoder::setViewport(MTL::Viewport viewport)
527
+ {
528
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setViewport_), viewport);
529
+ }
530
+
531
+ // method: setViewports:count:
532
+ _MTL_INLINE void MTL::RenderCommandEncoder::setViewports(const MTL::Viewport* viewports, NS::UInteger count)
533
+ {
534
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setViewports_count_), viewports, count);
535
+ }
536
+
537
+ // method: setFrontFacingWinding:
538
+ _MTL_INLINE void MTL::RenderCommandEncoder::setFrontFacingWinding(MTL::Winding frontFacingWinding)
539
+ {
540
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setFrontFacingWinding_), frontFacingWinding);
541
+ }
542
+
543
+ // method: setVertexAmplificationCount:viewMappings:
544
+ _MTL_INLINE void MTL::RenderCommandEncoder::setVertexAmplificationCount(NS::UInteger count, const MTL::VertexAmplificationViewMapping* viewMappings)
545
+ {
546
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setVertexAmplificationCount_viewMappings_), count, viewMappings);
547
+ }
548
+
549
+ // method: setCullMode:
550
+ _MTL_INLINE void MTL::RenderCommandEncoder::setCullMode(MTL::CullMode cullMode)
551
+ {
552
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setCullMode_), cullMode);
553
+ }
554
+
555
+ // method: setDepthClipMode:
556
+ _MTL_INLINE void MTL::RenderCommandEncoder::setDepthClipMode(MTL::DepthClipMode depthClipMode)
557
+ {
558
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setDepthClipMode_), depthClipMode);
559
+ }
560
+
561
+ // method: setDepthBias:slopeScale:clamp:
562
+ _MTL_INLINE void MTL::RenderCommandEncoder::setDepthBias(float depthBias, float slopeScale, float clamp)
563
+ {
564
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setDepthBias_slopeScale_clamp_), depthBias, slopeScale, clamp);
565
+ }
566
+
567
+ // method: setScissorRect:
568
+ _MTL_INLINE void MTL::RenderCommandEncoder::setScissorRect(MTL::ScissorRect rect)
569
+ {
570
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setScissorRect_), rect);
571
+ }
572
+
573
+ // method: setScissorRects:count:
574
+ _MTL_INLINE void MTL::RenderCommandEncoder::setScissorRects(const MTL::ScissorRect* scissorRects, NS::UInteger count)
575
+ {
576
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setScissorRects_count_), scissorRects, count);
577
+ }
578
+
579
+ // method: setTriangleFillMode:
580
+ _MTL_INLINE void MTL::RenderCommandEncoder::setTriangleFillMode(MTL::TriangleFillMode fillMode)
581
+ {
582
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setTriangleFillMode_), fillMode);
583
+ }
584
+
585
+ // method: setFragmentBytes:length:atIndex:
586
+ _MTL_INLINE void MTL::RenderCommandEncoder::setFragmentBytes(const void* bytes, NS::UInteger length, NS::UInteger index)
587
+ {
588
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setFragmentBytes_length_atIndex_), bytes, length, index);
589
+ }
590
+
591
+ // method: setFragmentBuffer:offset:atIndex:
592
+ _MTL_INLINE void MTL::RenderCommandEncoder::setFragmentBuffer(const MTL::Buffer* buffer, NS::UInteger offset, NS::UInteger index)
593
+ {
594
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setFragmentBuffer_offset_atIndex_), buffer, offset, index);
595
+ }
596
+
597
+ // method: setFragmentBufferOffset:atIndex:
598
+ _MTL_INLINE void MTL::RenderCommandEncoder::setFragmentBufferOffset(NS::UInteger offset, NS::UInteger index)
599
+ {
600
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setFragmentBufferOffset_atIndex_), offset, index);
601
+ }
602
+
603
+ // method: setFragmentBuffers:offsets:withRange:
604
+ _MTL_INLINE void MTL::RenderCommandEncoder::setFragmentBuffers(const MTL::Buffer* const buffers[], const NS::UInteger offsets[], NS::Range range)
605
+ {
606
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setFragmentBuffers_offsets_withRange_), buffers, offsets, range);
607
+ }
608
+
609
+ // method: setFragmentTexture:atIndex:
610
+ _MTL_INLINE void MTL::RenderCommandEncoder::setFragmentTexture(const MTL::Texture* texture, NS::UInteger index)
611
+ {
612
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setFragmentTexture_atIndex_), texture, index);
613
+ }
614
+
615
+ // method: setFragmentTextures:withRange:
616
+ _MTL_INLINE void MTL::RenderCommandEncoder::setFragmentTextures(const MTL::Texture* const textures[], NS::Range range)
617
+ {
618
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setFragmentTextures_withRange_), textures, range);
619
+ }
620
+
621
+ // method: setFragmentSamplerState:atIndex:
622
+ _MTL_INLINE void MTL::RenderCommandEncoder::setFragmentSamplerState(const MTL::SamplerState* sampler, NS::UInteger index)
623
+ {
624
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setFragmentSamplerState_atIndex_), sampler, index);
625
+ }
626
+
627
+ // method: setFragmentSamplerStates:withRange:
628
+ _MTL_INLINE void MTL::RenderCommandEncoder::setFragmentSamplerStates(const MTL::SamplerState* const samplers[], NS::Range range)
629
+ {
630
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setFragmentSamplerStates_withRange_), samplers, range);
631
+ }
632
+
633
+ // method: setFragmentSamplerState:lodMinClamp:lodMaxClamp:atIndex:
634
+ _MTL_INLINE void MTL::RenderCommandEncoder::setFragmentSamplerState(const MTL::SamplerState* sampler, float lodMinClamp, float lodMaxClamp, NS::UInteger index)
635
+ {
636
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setFragmentSamplerState_lodMinClamp_lodMaxClamp_atIndex_), sampler, lodMinClamp, lodMaxClamp, index);
637
+ }
638
+
639
+ // method: setFragmentSamplerStates:lodMinClamps:lodMaxClamps:withRange:
640
+ _MTL_INLINE void MTL::RenderCommandEncoder::setFragmentSamplerStates(const MTL::SamplerState* const samplers[], const float lodMinClamps[], const float lodMaxClamps[], NS::Range range)
641
+ {
642
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setFragmentSamplerStates_lodMinClamps_lodMaxClamps_withRange_), samplers, lodMinClamps, lodMaxClamps, range);
643
+ }
644
+
645
+ // method: setFragmentVisibleFunctionTable:atBufferIndex:
646
+ _MTL_INLINE void MTL::RenderCommandEncoder::setFragmentVisibleFunctionTable(const MTL::VisibleFunctionTable* functionTable, NS::UInteger bufferIndex)
647
+ {
648
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setFragmentVisibleFunctionTable_atBufferIndex_), functionTable, bufferIndex);
649
+ }
650
+
651
+ // method: setFragmentVisibleFunctionTables:withBufferRange:
652
+ _MTL_INLINE void MTL::RenderCommandEncoder::setFragmentVisibleFunctionTables(const MTL::VisibleFunctionTable* const functionTables[], NS::Range range)
653
+ {
654
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setFragmentVisibleFunctionTables_withBufferRange_), functionTables, range);
655
+ }
656
+
657
+ // method: setFragmentIntersectionFunctionTable:atBufferIndex:
658
+ _MTL_INLINE void MTL::RenderCommandEncoder::setFragmentIntersectionFunctionTable(const MTL::IntersectionFunctionTable* intersectionFunctionTable, NS::UInteger bufferIndex)
659
+ {
660
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setFragmentIntersectionFunctionTable_atBufferIndex_), intersectionFunctionTable, bufferIndex);
661
+ }
662
+
663
+ // method: setFragmentIntersectionFunctionTables:withBufferRange:
664
+ _MTL_INLINE void MTL::RenderCommandEncoder::setFragmentIntersectionFunctionTables(const MTL::IntersectionFunctionTable* const intersectionFunctionTables[], NS::Range range)
665
+ {
666
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setFragmentIntersectionFunctionTables_withBufferRange_), intersectionFunctionTables, range);
667
+ }
668
+
669
+ // method: setFragmentAccelerationStructure:atBufferIndex:
670
+ _MTL_INLINE void MTL::RenderCommandEncoder::setFragmentAccelerationStructure(const MTL::AccelerationStructure* accelerationStructure, NS::UInteger bufferIndex)
671
+ {
672
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setFragmentAccelerationStructure_atBufferIndex_), accelerationStructure, bufferIndex);
673
+ }
674
+
675
+ // method: setBlendColorRed:green:blue:alpha:
676
+ _MTL_INLINE void MTL::RenderCommandEncoder::setBlendColor(float red, float green, float blue, float alpha)
677
+ {
678
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setBlendColorRed_green_blue_alpha_), red, green, blue, alpha);
679
+ }
680
+
681
+ // method: setDepthStencilState:
682
+ _MTL_INLINE void MTL::RenderCommandEncoder::setDepthStencilState(const MTL::DepthStencilState* depthStencilState)
683
+ {
684
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setDepthStencilState_), depthStencilState);
685
+ }
686
+
687
+ // method: setStencilReferenceValue:
688
+ _MTL_INLINE void MTL::RenderCommandEncoder::setStencilReferenceValue(uint32_t referenceValue)
689
+ {
690
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setStencilReferenceValue_), referenceValue);
691
+ }
692
+
693
+ // method: setStencilFrontReferenceValue:backReferenceValue:
694
+ _MTL_INLINE void MTL::RenderCommandEncoder::setStencilReferenceValues(uint32_t frontReferenceValue, uint32_t backReferenceValue)
695
+ {
696
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setStencilFrontReferenceValue_backReferenceValue_), frontReferenceValue, backReferenceValue);
697
+ }
698
+
699
+ // method: setVisibilityResultMode:offset:
700
+ _MTL_INLINE void MTL::RenderCommandEncoder::setVisibilityResultMode(MTL::VisibilityResultMode mode, NS::UInteger offset)
701
+ {
702
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setVisibilityResultMode_offset_), mode, offset);
703
+ }
704
+
705
+ // method: setColorStoreAction:atIndex:
706
+ _MTL_INLINE void MTL::RenderCommandEncoder::setColorStoreAction(MTL::StoreAction storeAction, NS::UInteger colorAttachmentIndex)
707
+ {
708
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setColorStoreAction_atIndex_), storeAction, colorAttachmentIndex);
709
+ }
710
+
711
+ // method: setDepthStoreAction:
712
+ _MTL_INLINE void MTL::RenderCommandEncoder::setDepthStoreAction(MTL::StoreAction storeAction)
713
+ {
714
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setDepthStoreAction_), storeAction);
715
+ }
716
+
717
+ // method: setStencilStoreAction:
718
+ _MTL_INLINE void MTL::RenderCommandEncoder::setStencilStoreAction(MTL::StoreAction storeAction)
719
+ {
720
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setStencilStoreAction_), storeAction);
721
+ }
722
+
723
+ // method: setColorStoreActionOptions:atIndex:
724
+ _MTL_INLINE void MTL::RenderCommandEncoder::setColorStoreActionOptions(MTL::StoreActionOptions storeActionOptions, NS::UInteger colorAttachmentIndex)
725
+ {
726
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setColorStoreActionOptions_atIndex_), storeActionOptions, colorAttachmentIndex);
727
+ }
728
+
729
+ // method: setDepthStoreActionOptions:
730
+ _MTL_INLINE void MTL::RenderCommandEncoder::setDepthStoreActionOptions(MTL::StoreActionOptions storeActionOptions)
731
+ {
732
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setDepthStoreActionOptions_), storeActionOptions);
733
+ }
734
+
735
+ // method: setStencilStoreActionOptions:
736
+ _MTL_INLINE void MTL::RenderCommandEncoder::setStencilStoreActionOptions(MTL::StoreActionOptions storeActionOptions)
737
+ {
738
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setStencilStoreActionOptions_), storeActionOptions);
739
+ }
740
+
741
+ // method: setObjectBytes:length:atIndex:
742
+ _MTL_INLINE void MTL::RenderCommandEncoder::setObjectBytes(const void* bytes, NS::UInteger length, NS::UInteger index)
743
+ {
744
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setObjectBytes_length_atIndex_), bytes, length, index);
745
+ }
746
+
747
+ // method: setObjectBuffer:offset:atIndex:
748
+ _MTL_INLINE void MTL::RenderCommandEncoder::setObjectBuffer(const MTL::Buffer* buffer, NS::UInteger offset, NS::UInteger index)
749
+ {
750
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setObjectBuffer_offset_atIndex_), buffer, offset, index);
751
+ }
752
+
753
+ // method: setObjectBufferOffset:atIndex:
754
+ _MTL_INLINE void MTL::RenderCommandEncoder::setObjectBufferOffset(NS::UInteger offset, NS::UInteger index)
755
+ {
756
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setObjectBufferOffset_atIndex_), offset, index);
757
+ }
758
+
759
+ // method: setObjectBuffers:offsets:withRange:
760
+ _MTL_INLINE void MTL::RenderCommandEncoder::setObjectBuffers(const MTL::Buffer* const buffers[], const NS::UInteger* offsets, NS::Range range)
761
+ {
762
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setObjectBuffers_offsets_withRange_), buffers, offsets, range);
763
+ }
764
+
765
+ // method: setObjectTexture:atIndex:
766
+ _MTL_INLINE void MTL::RenderCommandEncoder::setObjectTexture(const MTL::Texture* texture, NS::UInteger index)
767
+ {
768
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setObjectTexture_atIndex_), texture, index);
769
+ }
770
+
771
+ // method: setObjectTextures:withRange:
772
+ _MTL_INLINE void MTL::RenderCommandEncoder::setObjectTextures(const MTL::Texture* const textures[], NS::Range range)
773
+ {
774
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setObjectTextures_withRange_), textures, range);
775
+ }
776
+
777
+ // method: setObjectSamplerState:atIndex:
778
+ _MTL_INLINE void MTL::RenderCommandEncoder::setObjectSamplerState(const MTL::SamplerState* sampler, NS::UInteger index)
779
+ {
780
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setObjectSamplerState_atIndex_), sampler, index);
781
+ }
782
+
783
+ // method: setObjectSamplerStates:withRange:
784
+ _MTL_INLINE void MTL::RenderCommandEncoder::setObjectSamplerStates(const MTL::SamplerState* const samplers[], NS::Range range)
785
+ {
786
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setObjectSamplerStates_withRange_), samplers, range);
787
+ }
788
+
789
+ // method: setObjectSamplerState:lodMinClamp:lodMaxClamp:atIndex:
790
+ _MTL_INLINE void MTL::RenderCommandEncoder::setObjectSamplerState(const MTL::SamplerState* sampler, float lodMinClamp, float lodMaxClamp, NS::UInteger index)
791
+ {
792
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setObjectSamplerState_lodMinClamp_lodMaxClamp_atIndex_), sampler, lodMinClamp, lodMaxClamp, index);
793
+ }
794
+
795
+ // method: setObjectSamplerStates:lodMinClamps:lodMaxClamps:withRange:
796
+ _MTL_INLINE void MTL::RenderCommandEncoder::setObjectSamplerStates(const MTL::SamplerState* const samplers[], const float* lodMinClamps, const float* lodMaxClamps, NS::Range range)
797
+ {
798
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setObjectSamplerStates_lodMinClamps_lodMaxClamps_withRange_), samplers, lodMinClamps, lodMaxClamps, range);
799
+ }
800
+
801
+ // method: setObjectThreadgroupMemoryLength:atIndex:
802
+ _MTL_INLINE void MTL::RenderCommandEncoder::setObjectThreadgroupMemoryLength(NS::UInteger length, NS::UInteger index)
803
+ {
804
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setObjectThreadgroupMemoryLength_atIndex_), length, index);
805
+ }
806
+
807
+ // method: setMeshBytes:length:atIndex:
808
+ _MTL_INLINE void MTL::RenderCommandEncoder::setMeshBytes(const void* bytes, NS::UInteger length, NS::UInteger index)
809
+ {
810
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setMeshBytes_length_atIndex_), bytes, length, index);
811
+ }
812
+
813
+ // method: setMeshBuffer:offset:atIndex:
814
+ _MTL_INLINE void MTL::RenderCommandEncoder::setMeshBuffer(const MTL::Buffer* buffer, NS::UInteger offset, NS::UInteger index)
815
+ {
816
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setMeshBuffer_offset_atIndex_), buffer, offset, index);
817
+ }
818
+
819
+ // method: setMeshBufferOffset:atIndex:
820
+ _MTL_INLINE void MTL::RenderCommandEncoder::setMeshBufferOffset(NS::UInteger offset, NS::UInteger index)
821
+ {
822
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setMeshBufferOffset_atIndex_), offset, index);
823
+ }
824
+
825
+ // method: setMeshBuffers:offsets:withRange:
826
+ _MTL_INLINE void MTL::RenderCommandEncoder::setMeshBuffers(const MTL::Buffer* const buffers[], const NS::UInteger* offsets, NS::Range range)
827
+ {
828
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setMeshBuffers_offsets_withRange_), buffers, offsets, range);
829
+ }
830
+
831
+ // method: setMeshTexture:atIndex:
832
+ _MTL_INLINE void MTL::RenderCommandEncoder::setMeshTexture(const MTL::Texture* texture, NS::UInteger index)
833
+ {
834
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setMeshTexture_atIndex_), texture, index);
835
+ }
836
+
837
+ // method: setMeshTextures:withRange:
838
+ _MTL_INLINE void MTL::RenderCommandEncoder::setMeshTextures(const MTL::Texture* const textures[], NS::Range range)
839
+ {
840
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setMeshTextures_withRange_), textures, range);
841
+ }
842
+
843
+ // method: setMeshSamplerState:atIndex:
844
+ _MTL_INLINE void MTL::RenderCommandEncoder::setMeshSamplerState(const MTL::SamplerState* sampler, NS::UInteger index)
845
+ {
846
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setMeshSamplerState_atIndex_), sampler, index);
847
+ }
848
+
849
+ // method: setMeshSamplerStates:withRange:
850
+ _MTL_INLINE void MTL::RenderCommandEncoder::setMeshSamplerStates(const MTL::SamplerState* const samplers[], NS::Range range)
851
+ {
852
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setMeshSamplerStates_withRange_), samplers, range);
853
+ }
854
+
855
+ // method: setMeshSamplerState:lodMinClamp:lodMaxClamp:atIndex:
856
+ _MTL_INLINE void MTL::RenderCommandEncoder::setMeshSamplerState(const MTL::SamplerState* sampler, float lodMinClamp, float lodMaxClamp, NS::UInteger index)
857
+ {
858
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setMeshSamplerState_lodMinClamp_lodMaxClamp_atIndex_), sampler, lodMinClamp, lodMaxClamp, index);
859
+ }
860
+
861
+ // method: setMeshSamplerStates:lodMinClamps:lodMaxClamps:withRange:
862
+ _MTL_INLINE void MTL::RenderCommandEncoder::setMeshSamplerStates(const MTL::SamplerState* const samplers[], const float* lodMinClamps, const float* lodMaxClamps, NS::Range range)
863
+ {
864
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setMeshSamplerStates_lodMinClamps_lodMaxClamps_withRange_), samplers, lodMinClamps, lodMaxClamps, range);
865
+ }
866
+
867
+ // method: drawMeshThreadgroups:threadsPerObjectThreadgroup:threadsPerMeshThreadgroup:
868
+ _MTL_INLINE void MTL::RenderCommandEncoder::drawMeshThreadgroups(MTL::Size threadgroupsPerGrid, MTL::Size threadsPerObjectThreadgroup, MTL::Size threadsPerMeshThreadgroup)
869
+ {
870
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(drawMeshThreadgroups_threadsPerObjectThreadgroup_threadsPerMeshThreadgroup_), threadgroupsPerGrid, threadsPerObjectThreadgroup, threadsPerMeshThreadgroup);
871
+ }
872
+
873
+ // method: drawMeshThreads:threadsPerObjectThreadgroup:threadsPerMeshThreadgroup:
874
+ _MTL_INLINE void MTL::RenderCommandEncoder::drawMeshThreads(MTL::Size threadsPerGrid, MTL::Size threadsPerObjectThreadgroup, MTL::Size threadsPerMeshThreadgroup)
875
+ {
876
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(drawMeshThreads_threadsPerObjectThreadgroup_threadsPerMeshThreadgroup_), threadsPerGrid, threadsPerObjectThreadgroup, threadsPerMeshThreadgroup);
877
+ }
878
+
879
+ // method: drawMeshThreadgroupsWithIndirectBuffer:indirectBufferOffset:threadsPerObjectThreadgroup:threadsPerMeshThreadgroup:
880
+ _MTL_INLINE void MTL::RenderCommandEncoder::drawMeshThreadgroups(const MTL::Buffer* indirectBuffer, NS::UInteger indirectBufferOffset, MTL::Size threadsPerObjectThreadgroup, MTL::Size threadsPerMeshThreadgroup)
881
+ {
882
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(drawMeshThreadgroupsWithIndirectBuffer_indirectBufferOffset_threadsPerObjectThreadgroup_threadsPerMeshThreadgroup_), indirectBuffer, indirectBufferOffset, threadsPerObjectThreadgroup, threadsPerMeshThreadgroup);
883
+ }
884
+
885
+ // method: drawPrimitives:vertexStart:vertexCount:instanceCount:
886
+ _MTL_INLINE void MTL::RenderCommandEncoder::drawPrimitives(MTL::PrimitiveType primitiveType, NS::UInteger vertexStart, NS::UInteger vertexCount, NS::UInteger instanceCount)
887
+ {
888
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(drawPrimitives_vertexStart_vertexCount_instanceCount_), primitiveType, vertexStart, vertexCount, instanceCount);
889
+ }
890
+
891
+ // method: drawPrimitives:vertexStart:vertexCount:
892
+ _MTL_INLINE void MTL::RenderCommandEncoder::drawPrimitives(MTL::PrimitiveType primitiveType, NS::UInteger vertexStart, NS::UInteger vertexCount)
893
+ {
894
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(drawPrimitives_vertexStart_vertexCount_), primitiveType, vertexStart, vertexCount);
895
+ }
896
+
897
+ // method: drawIndexedPrimitives:indexCount:indexType:indexBuffer:indexBufferOffset:instanceCount:
898
+ _MTL_INLINE void MTL::RenderCommandEncoder::drawIndexedPrimitives(MTL::PrimitiveType primitiveType, NS::UInteger indexCount, MTL::IndexType indexType, const MTL::Buffer* indexBuffer, NS::UInteger indexBufferOffset, NS::UInteger instanceCount)
899
+ {
900
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(drawIndexedPrimitives_indexCount_indexType_indexBuffer_indexBufferOffset_instanceCount_), primitiveType, indexCount, indexType, indexBuffer, indexBufferOffset, instanceCount);
901
+ }
902
+
903
+ // method: drawIndexedPrimitives:indexCount:indexType:indexBuffer:indexBufferOffset:
904
+ _MTL_INLINE void MTL::RenderCommandEncoder::drawIndexedPrimitives(MTL::PrimitiveType primitiveType, NS::UInteger indexCount, MTL::IndexType indexType, const MTL::Buffer* indexBuffer, NS::UInteger indexBufferOffset)
905
+ {
906
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(drawIndexedPrimitives_indexCount_indexType_indexBuffer_indexBufferOffset_), primitiveType, indexCount, indexType, indexBuffer, indexBufferOffset);
907
+ }
908
+
909
+ // method: drawPrimitives:vertexStart:vertexCount:instanceCount:baseInstance:
910
+ _MTL_INLINE void MTL::RenderCommandEncoder::drawPrimitives(MTL::PrimitiveType primitiveType, NS::UInteger vertexStart, NS::UInteger vertexCount, NS::UInteger instanceCount, NS::UInteger baseInstance)
911
+ {
912
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(drawPrimitives_vertexStart_vertexCount_instanceCount_baseInstance_), primitiveType, vertexStart, vertexCount, instanceCount, baseInstance);
913
+ }
914
+
915
+ // method: drawIndexedPrimitives:indexCount:indexType:indexBuffer:indexBufferOffset:instanceCount:baseVertex:baseInstance:
916
+ _MTL_INLINE void MTL::RenderCommandEncoder::drawIndexedPrimitives(MTL::PrimitiveType primitiveType, NS::UInteger indexCount, MTL::IndexType indexType, const MTL::Buffer* indexBuffer, NS::UInteger indexBufferOffset, NS::UInteger instanceCount, NS::Integer baseVertex, NS::UInteger baseInstance)
917
+ {
918
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(drawIndexedPrimitives_indexCount_indexType_indexBuffer_indexBufferOffset_instanceCount_baseVertex_baseInstance_), primitiveType, indexCount, indexType, indexBuffer, indexBufferOffset, instanceCount, baseVertex, baseInstance);
919
+ }
920
+
921
+ // method: drawPrimitives:indirectBuffer:indirectBufferOffset:
922
+ _MTL_INLINE void MTL::RenderCommandEncoder::drawPrimitives(MTL::PrimitiveType primitiveType, const MTL::Buffer* indirectBuffer, NS::UInteger indirectBufferOffset)
923
+ {
924
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(drawPrimitives_indirectBuffer_indirectBufferOffset_), primitiveType, indirectBuffer, indirectBufferOffset);
925
+ }
926
+
927
+ // method: drawIndexedPrimitives:indexType:indexBuffer:indexBufferOffset:indirectBuffer:indirectBufferOffset:
928
+ _MTL_INLINE void MTL::RenderCommandEncoder::drawIndexedPrimitives(MTL::PrimitiveType primitiveType, MTL::IndexType indexType, const MTL::Buffer* indexBuffer, NS::UInteger indexBufferOffset, const MTL::Buffer* indirectBuffer, NS::UInteger indirectBufferOffset)
929
+ {
930
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(drawIndexedPrimitives_indexType_indexBuffer_indexBufferOffset_indirectBuffer_indirectBufferOffset_), primitiveType, indexType, indexBuffer, indexBufferOffset, indirectBuffer, indirectBufferOffset);
931
+ }
932
+
933
+ // method: textureBarrier
934
+ _MTL_INLINE void MTL::RenderCommandEncoder::textureBarrier()
935
+ {
936
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(textureBarrier));
937
+ }
938
+
939
+ // method: updateFence:afterStages:
940
+ _MTL_INLINE void MTL::RenderCommandEncoder::updateFence(const MTL::Fence* fence, MTL::RenderStages stages)
941
+ {
942
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(updateFence_afterStages_), fence, stages);
943
+ }
944
+
945
+ // method: waitForFence:beforeStages:
946
+ _MTL_INLINE void MTL::RenderCommandEncoder::waitForFence(const MTL::Fence* fence, MTL::RenderStages stages)
947
+ {
948
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(waitForFence_beforeStages_), fence, stages);
949
+ }
950
+
951
+ // method: setTessellationFactorBuffer:offset:instanceStride:
952
+ _MTL_INLINE void MTL::RenderCommandEncoder::setTessellationFactorBuffer(const MTL::Buffer* buffer, NS::UInteger offset, NS::UInteger instanceStride)
953
+ {
954
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setTessellationFactorBuffer_offset_instanceStride_), buffer, offset, instanceStride);
955
+ }
956
+
957
+ // method: setTessellationFactorScale:
958
+ _MTL_INLINE void MTL::RenderCommandEncoder::setTessellationFactorScale(float scale)
959
+ {
960
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setTessellationFactorScale_), scale);
961
+ }
962
+
963
+ // method: drawPatches:patchStart:patchCount:patchIndexBuffer:patchIndexBufferOffset:instanceCount:baseInstance:
964
+ _MTL_INLINE void MTL::RenderCommandEncoder::drawPatches(NS::UInteger numberOfPatchControlPoints, NS::UInteger patchStart, NS::UInteger patchCount, const MTL::Buffer* patchIndexBuffer, NS::UInteger patchIndexBufferOffset, NS::UInteger instanceCount, NS::UInteger baseInstance)
965
+ {
966
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(drawPatches_patchStart_patchCount_patchIndexBuffer_patchIndexBufferOffset_instanceCount_baseInstance_), numberOfPatchControlPoints, patchStart, patchCount, patchIndexBuffer, patchIndexBufferOffset, instanceCount, baseInstance);
967
+ }
968
+
969
+ // method: drawPatches:patchIndexBuffer:patchIndexBufferOffset:indirectBuffer:indirectBufferOffset:
970
+ _MTL_INLINE void MTL::RenderCommandEncoder::drawPatches(NS::UInteger numberOfPatchControlPoints, const MTL::Buffer* patchIndexBuffer, NS::UInteger patchIndexBufferOffset, const MTL::Buffer* indirectBuffer, NS::UInteger indirectBufferOffset)
971
+ {
972
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(drawPatches_patchIndexBuffer_patchIndexBufferOffset_indirectBuffer_indirectBufferOffset_), numberOfPatchControlPoints, patchIndexBuffer, patchIndexBufferOffset, indirectBuffer, indirectBufferOffset);
973
+ }
974
+
975
+ // method: drawIndexedPatches:patchStart:patchCount:patchIndexBuffer:patchIndexBufferOffset:controlPointIndexBuffer:controlPointIndexBufferOffset:instanceCount:baseInstance:
976
+ _MTL_INLINE void MTL::RenderCommandEncoder::drawIndexedPatches(NS::UInteger numberOfPatchControlPoints, NS::UInteger patchStart, NS::UInteger patchCount, const MTL::Buffer* patchIndexBuffer, NS::UInteger patchIndexBufferOffset, const MTL::Buffer* controlPointIndexBuffer, NS::UInteger controlPointIndexBufferOffset, NS::UInteger instanceCount, NS::UInteger baseInstance)
977
+ {
978
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(drawIndexedPatches_patchStart_patchCount_patchIndexBuffer_patchIndexBufferOffset_controlPointIndexBuffer_controlPointIndexBufferOffset_instanceCount_baseInstance_), numberOfPatchControlPoints, patchStart, patchCount, patchIndexBuffer, patchIndexBufferOffset, controlPointIndexBuffer, controlPointIndexBufferOffset, instanceCount, baseInstance);
979
+ }
980
+
981
+ // method: drawIndexedPatches:patchIndexBuffer:patchIndexBufferOffset:controlPointIndexBuffer:controlPointIndexBufferOffset:indirectBuffer:indirectBufferOffset:
982
+ _MTL_INLINE void MTL::RenderCommandEncoder::drawIndexedPatches(NS::UInteger numberOfPatchControlPoints, const MTL::Buffer* patchIndexBuffer, NS::UInteger patchIndexBufferOffset, const MTL::Buffer* controlPointIndexBuffer, NS::UInteger controlPointIndexBufferOffset, const MTL::Buffer* indirectBuffer, NS::UInteger indirectBufferOffset)
983
+ {
984
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(drawIndexedPatches_patchIndexBuffer_patchIndexBufferOffset_controlPointIndexBuffer_controlPointIndexBufferOffset_indirectBuffer_indirectBufferOffset_), numberOfPatchControlPoints, patchIndexBuffer, patchIndexBufferOffset, controlPointIndexBuffer, controlPointIndexBufferOffset, indirectBuffer, indirectBufferOffset);
985
+ }
986
+
987
+ // property: tileWidth
988
+ _MTL_INLINE NS::UInteger MTL::RenderCommandEncoder::tileWidth() const
989
+ {
990
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(tileWidth));
991
+ }
992
+
993
+ // property: tileHeight
994
+ _MTL_INLINE NS::UInteger MTL::RenderCommandEncoder::tileHeight() const
995
+ {
996
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(tileHeight));
997
+ }
998
+
999
+ // method: setTileBytes:length:atIndex:
1000
+ _MTL_INLINE void MTL::RenderCommandEncoder::setTileBytes(const void* bytes, NS::UInteger length, NS::UInteger index)
1001
+ {
1002
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setTileBytes_length_atIndex_), bytes, length, index);
1003
+ }
1004
+
1005
+ // method: setTileBuffer:offset:atIndex:
1006
+ _MTL_INLINE void MTL::RenderCommandEncoder::setTileBuffer(const MTL::Buffer* buffer, NS::UInteger offset, NS::UInteger index)
1007
+ {
1008
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setTileBuffer_offset_atIndex_), buffer, offset, index);
1009
+ }
1010
+
1011
+ // method: setTileBufferOffset:atIndex:
1012
+ _MTL_INLINE void MTL::RenderCommandEncoder::setTileBufferOffset(NS::UInteger offset, NS::UInteger index)
1013
+ {
1014
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setTileBufferOffset_atIndex_), offset, index);
1015
+ }
1016
+
1017
+ // method: setTileBuffers:offsets:withRange:
1018
+ _MTL_INLINE void MTL::RenderCommandEncoder::setTileBuffers(const MTL::Buffer* const buffers[], const NS::UInteger* offsets, NS::Range range)
1019
+ {
1020
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setTileBuffers_offsets_withRange_), buffers, offsets, range);
1021
+ }
1022
+
1023
+ // method: setTileTexture:atIndex:
1024
+ _MTL_INLINE void MTL::RenderCommandEncoder::setTileTexture(const MTL::Texture* texture, NS::UInteger index)
1025
+ {
1026
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setTileTexture_atIndex_), texture, index);
1027
+ }
1028
+
1029
+ // method: setTileTextures:withRange:
1030
+ _MTL_INLINE void MTL::RenderCommandEncoder::setTileTextures(const MTL::Texture* const textures[], NS::Range range)
1031
+ {
1032
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setTileTextures_withRange_), textures, range);
1033
+ }
1034
+
1035
+ // method: setTileSamplerState:atIndex:
1036
+ _MTL_INLINE void MTL::RenderCommandEncoder::setTileSamplerState(const MTL::SamplerState* sampler, NS::UInteger index)
1037
+ {
1038
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setTileSamplerState_atIndex_), sampler, index);
1039
+ }
1040
+
1041
+ // method: setTileSamplerStates:withRange:
1042
+ _MTL_INLINE void MTL::RenderCommandEncoder::setTileSamplerStates(const MTL::SamplerState* const samplers[], NS::Range range)
1043
+ {
1044
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setTileSamplerStates_withRange_), samplers, range);
1045
+ }
1046
+
1047
+ // method: setTileSamplerState:lodMinClamp:lodMaxClamp:atIndex:
1048
+ _MTL_INLINE void MTL::RenderCommandEncoder::setTileSamplerState(const MTL::SamplerState* sampler, float lodMinClamp, float lodMaxClamp, NS::UInteger index)
1049
+ {
1050
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setTileSamplerState_lodMinClamp_lodMaxClamp_atIndex_), sampler, lodMinClamp, lodMaxClamp, index);
1051
+ }
1052
+
1053
+ // method: setTileSamplerStates:lodMinClamps:lodMaxClamps:withRange:
1054
+ _MTL_INLINE void MTL::RenderCommandEncoder::setTileSamplerStates(const MTL::SamplerState* const samplers[], const float lodMinClamps[], const float lodMaxClamps[], NS::Range range)
1055
+ {
1056
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setTileSamplerStates_lodMinClamps_lodMaxClamps_withRange_), samplers, lodMinClamps, lodMaxClamps, range);
1057
+ }
1058
+
1059
+ // method: setTileVisibleFunctionTable:atBufferIndex:
1060
+ _MTL_INLINE void MTL::RenderCommandEncoder::setTileVisibleFunctionTable(const MTL::VisibleFunctionTable* functionTable, NS::UInteger bufferIndex)
1061
+ {
1062
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setTileVisibleFunctionTable_atBufferIndex_), functionTable, bufferIndex);
1063
+ }
1064
+
1065
+ // method: setTileVisibleFunctionTables:withBufferRange:
1066
+ _MTL_INLINE void MTL::RenderCommandEncoder::setTileVisibleFunctionTables(const MTL::VisibleFunctionTable* const functionTables[], NS::Range range)
1067
+ {
1068
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setTileVisibleFunctionTables_withBufferRange_), functionTables, range);
1069
+ }
1070
+
1071
+ // method: setTileIntersectionFunctionTable:atBufferIndex:
1072
+ _MTL_INLINE void MTL::RenderCommandEncoder::setTileIntersectionFunctionTable(const MTL::IntersectionFunctionTable* intersectionFunctionTable, NS::UInteger bufferIndex)
1073
+ {
1074
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setTileIntersectionFunctionTable_atBufferIndex_), intersectionFunctionTable, bufferIndex);
1075
+ }
1076
+
1077
+ // method: setTileIntersectionFunctionTables:withBufferRange:
1078
+ _MTL_INLINE void MTL::RenderCommandEncoder::setTileIntersectionFunctionTables(const MTL::IntersectionFunctionTable* const intersectionFunctionTables[], NS::Range range)
1079
+ {
1080
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setTileIntersectionFunctionTables_withBufferRange_), intersectionFunctionTables, range);
1081
+ }
1082
+
1083
+ // method: setTileAccelerationStructure:atBufferIndex:
1084
+ _MTL_INLINE void MTL::RenderCommandEncoder::setTileAccelerationStructure(const MTL::AccelerationStructure* accelerationStructure, NS::UInteger bufferIndex)
1085
+ {
1086
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setTileAccelerationStructure_atBufferIndex_), accelerationStructure, bufferIndex);
1087
+ }
1088
+
1089
+ // method: dispatchThreadsPerTile:
1090
+ _MTL_INLINE void MTL::RenderCommandEncoder::dispatchThreadsPerTile(MTL::Size threadsPerTile)
1091
+ {
1092
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(dispatchThreadsPerTile_), threadsPerTile);
1093
+ }
1094
+
1095
+ // method: setThreadgroupMemoryLength:offset:atIndex:
1096
+ _MTL_INLINE void MTL::RenderCommandEncoder::setThreadgroupMemoryLength(NS::UInteger length, NS::UInteger offset, NS::UInteger index)
1097
+ {
1098
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setThreadgroupMemoryLength_offset_atIndex_), length, offset, index);
1099
+ }
1100
+
1101
+ // method: useResource:usage:
1102
+ _MTL_INLINE void MTL::RenderCommandEncoder::useResource(const MTL::Resource* resource, MTL::ResourceUsage usage)
1103
+ {
1104
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(useResource_usage_), resource, usage);
1105
+ }
1106
+
1107
+ // method: useResources:count:usage:
1108
+ _MTL_INLINE void MTL::RenderCommandEncoder::useResources(const MTL::Resource* const resources[], NS::UInteger count, MTL::ResourceUsage usage)
1109
+ {
1110
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(useResources_count_usage_), resources, count, usage);
1111
+ }
1112
+
1113
+ // method: useResource:usage:stages:
1114
+ _MTL_INLINE void MTL::RenderCommandEncoder::useResource(const MTL::Resource* resource, MTL::ResourceUsage usage, MTL::RenderStages stages)
1115
+ {
1116
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(useResource_usage_stages_), resource, usage, stages);
1117
+ }
1118
+
1119
+ // method: useResources:count:usage:stages:
1120
+ _MTL_INLINE void MTL::RenderCommandEncoder::useResources(const MTL::Resource* const resources[], NS::UInteger count, MTL::ResourceUsage usage, MTL::RenderStages stages)
1121
+ {
1122
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(useResources_count_usage_stages_), resources, count, usage, stages);
1123
+ }
1124
+
1125
+ // method: useHeap:
1126
+ _MTL_INLINE void MTL::RenderCommandEncoder::useHeap(const MTL::Heap* heap)
1127
+ {
1128
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(useHeap_), heap);
1129
+ }
1130
+
1131
+ // method: useHeaps:count:
1132
+ _MTL_INLINE void MTL::RenderCommandEncoder::useHeaps(const MTL::Heap* const heaps[], NS::UInteger count)
1133
+ {
1134
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(useHeaps_count_), heaps, count);
1135
+ }
1136
+
1137
+ // method: useHeap:stages:
1138
+ _MTL_INLINE void MTL::RenderCommandEncoder::useHeap(const MTL::Heap* heap, MTL::RenderStages stages)
1139
+ {
1140
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(useHeap_stages_), heap, stages);
1141
+ }
1142
+
1143
+ // method: useHeaps:count:stages:
1144
+ _MTL_INLINE void MTL::RenderCommandEncoder::useHeaps(const MTL::Heap* const heaps[], NS::UInteger count, MTL::RenderStages stages)
1145
+ {
1146
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(useHeaps_count_stages_), heaps, count, stages);
1147
+ }
1148
+
1149
+ // method: executeCommandsInBuffer:withRange:
1150
+ _MTL_INLINE void MTL::RenderCommandEncoder::executeCommandsInBuffer(const MTL::IndirectCommandBuffer* indirectCommandBuffer, NS::Range executionRange)
1151
+ {
1152
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(executeCommandsInBuffer_withRange_), indirectCommandBuffer, executionRange);
1153
+ }
1154
+
1155
+ // method: executeCommandsInBuffer:indirectBuffer:indirectBufferOffset:
1156
+ _MTL_INLINE void MTL::RenderCommandEncoder::executeCommandsInBuffer(const MTL::IndirectCommandBuffer* indirectCommandbuffer, const MTL::Buffer* indirectRangeBuffer, NS::UInteger indirectBufferOffset)
1157
+ {
1158
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(executeCommandsInBuffer_indirectBuffer_indirectBufferOffset_), indirectCommandbuffer, indirectRangeBuffer, indirectBufferOffset);
1159
+ }
1160
+
1161
+ // method: memoryBarrierWithScope:afterStages:beforeStages:
1162
+ _MTL_INLINE void MTL::RenderCommandEncoder::memoryBarrier(MTL::BarrierScope scope, MTL::RenderStages after, MTL::RenderStages before)
1163
+ {
1164
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(memoryBarrierWithScope_afterStages_beforeStages_), scope, after, before);
1165
+ }
1166
+
1167
+ // method: memoryBarrierWithResources:count:afterStages:beforeStages:
1168
+ _MTL_INLINE void MTL::RenderCommandEncoder::memoryBarrier(const MTL::Resource* const resources[], NS::UInteger count, MTL::RenderStages after, MTL::RenderStages before)
1169
+ {
1170
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(memoryBarrierWithResources_count_afterStages_beforeStages_), resources, count, after, before);
1171
+ }
1172
+
1173
+ // method: sampleCountersInBuffer:atSampleIndex:withBarrier:
1174
+ _MTL_INLINE void MTL::RenderCommandEncoder::sampleCountersInBuffer(const MTL::CounterSampleBuffer* sampleBuffer, NS::UInteger sampleIndex, bool barrier)
1175
+ {
1176
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(sampleCountersInBuffer_atSampleIndex_withBarrier_), sampleBuffer, sampleIndex, barrier);
1177
+ }
lib/python3.11/site-packages/mlx/include/metal_cpp/Metal/MTLRenderPass.hpp ADDED
@@ -0,0 +1,786 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
2
+ //
3
+ // Metal/MTLRenderPass.hpp
4
+ //
5
+ // Copyright 2020-2023 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 "MTLRenderPass.hpp"
30
+
31
+ namespace MTL
32
+ {
33
+ struct ClearColor
34
+ {
35
+ static ClearColor Make(double red, double green, double blue, double alpha);
36
+
37
+ ClearColor() = default;
38
+
39
+ ClearColor(double red, double green, double blue, double alpha);
40
+
41
+ double red;
42
+ double green;
43
+ double blue;
44
+ double alpha;
45
+ } _MTL_PACKED;
46
+
47
+ _MTL_ENUM(NS::UInteger, LoadAction) {
48
+ LoadActionDontCare = 0,
49
+ LoadActionLoad = 1,
50
+ LoadActionClear = 2,
51
+ };
52
+
53
+ _MTL_ENUM(NS::UInteger, StoreAction) {
54
+ StoreActionDontCare = 0,
55
+ StoreActionStore = 1,
56
+ StoreActionMultisampleResolve = 2,
57
+ StoreActionStoreAndMultisampleResolve = 3,
58
+ StoreActionUnknown = 4,
59
+ StoreActionCustomSampleDepthStore = 5,
60
+ };
61
+
62
+ _MTL_OPTIONS(NS::UInteger, StoreActionOptions) {
63
+ StoreActionOptionNone = 0,
64
+ StoreActionOptionValidMask = 1,
65
+ StoreActionOptionCustomSamplePositions = 1,
66
+ };
67
+
68
+ class RenderPassAttachmentDescriptor : public NS::Copying<RenderPassAttachmentDescriptor>
69
+ {
70
+ public:
71
+ static class RenderPassAttachmentDescriptor* alloc();
72
+
73
+ class RenderPassAttachmentDescriptor* init();
74
+
75
+ class Texture* texture() const;
76
+ void setTexture(const class Texture* texture);
77
+
78
+ NS::UInteger level() const;
79
+ void setLevel(NS::UInteger level);
80
+
81
+ NS::UInteger slice() const;
82
+ void setSlice(NS::UInteger slice);
83
+
84
+ NS::UInteger depthPlane() const;
85
+ void setDepthPlane(NS::UInteger depthPlane);
86
+
87
+ class Texture* resolveTexture() const;
88
+ void setResolveTexture(const class Texture* resolveTexture);
89
+
90
+ NS::UInteger resolveLevel() const;
91
+ void setResolveLevel(NS::UInteger resolveLevel);
92
+
93
+ NS::UInteger resolveSlice() const;
94
+ void setResolveSlice(NS::UInteger resolveSlice);
95
+
96
+ NS::UInteger resolveDepthPlane() const;
97
+ void setResolveDepthPlane(NS::UInteger resolveDepthPlane);
98
+
99
+ MTL::LoadAction loadAction() const;
100
+ void setLoadAction(MTL::LoadAction loadAction);
101
+
102
+ MTL::StoreAction storeAction() const;
103
+ void setStoreAction(MTL::StoreAction storeAction);
104
+
105
+ MTL::StoreActionOptions storeActionOptions() const;
106
+ void setStoreActionOptions(MTL::StoreActionOptions storeActionOptions);
107
+ };
108
+
109
+ class RenderPassColorAttachmentDescriptor : public NS::Copying<RenderPassColorAttachmentDescriptor, MTL::RenderPassAttachmentDescriptor>
110
+ {
111
+ public:
112
+ static class RenderPassColorAttachmentDescriptor* alloc();
113
+
114
+ class RenderPassColorAttachmentDescriptor* init();
115
+
116
+ MTL::ClearColor clearColor() const;
117
+ void setClearColor(MTL::ClearColor clearColor);
118
+ };
119
+
120
+ _MTL_ENUM(NS::UInteger, MultisampleDepthResolveFilter) {
121
+ MultisampleDepthResolveFilterSample0 = 0,
122
+ MultisampleDepthResolveFilterMin = 1,
123
+ MultisampleDepthResolveFilterMax = 2,
124
+ };
125
+
126
+ class RenderPassDepthAttachmentDescriptor : public NS::Copying<RenderPassDepthAttachmentDescriptor, MTL::RenderPassAttachmentDescriptor>
127
+ {
128
+ public:
129
+ static class RenderPassDepthAttachmentDescriptor* alloc();
130
+
131
+ class RenderPassDepthAttachmentDescriptor* init();
132
+
133
+ double clearDepth() const;
134
+ void setClearDepth(double clearDepth);
135
+
136
+ MTL::MultisampleDepthResolveFilter depthResolveFilter() const;
137
+ void setDepthResolveFilter(MTL::MultisampleDepthResolveFilter depthResolveFilter);
138
+ };
139
+
140
+ _MTL_ENUM(NS::UInteger, MultisampleStencilResolveFilter) {
141
+ MultisampleStencilResolveFilterSample0 = 0,
142
+ MultisampleStencilResolveFilterDepthResolvedSample = 1,
143
+ };
144
+
145
+ class RenderPassStencilAttachmentDescriptor : public NS::Copying<RenderPassStencilAttachmentDescriptor, MTL::RenderPassAttachmentDescriptor>
146
+ {
147
+ public:
148
+ static class RenderPassStencilAttachmentDescriptor* alloc();
149
+
150
+ class RenderPassStencilAttachmentDescriptor* init();
151
+
152
+ uint32_t clearStencil() const;
153
+ void setClearStencil(uint32_t clearStencil);
154
+
155
+ MTL::MultisampleStencilResolveFilter stencilResolveFilter() const;
156
+ void setStencilResolveFilter(MTL::MultisampleStencilResolveFilter stencilResolveFilter);
157
+ };
158
+
159
+ class RenderPassColorAttachmentDescriptorArray : public NS::Referencing<RenderPassColorAttachmentDescriptorArray>
160
+ {
161
+ public:
162
+ static class RenderPassColorAttachmentDescriptorArray* alloc();
163
+
164
+ class RenderPassColorAttachmentDescriptorArray* init();
165
+
166
+ class RenderPassColorAttachmentDescriptor* object(NS::UInteger attachmentIndex);
167
+
168
+ void setObject(const class RenderPassColorAttachmentDescriptor* attachment, NS::UInteger attachmentIndex);
169
+ };
170
+
171
+ class RenderPassSampleBufferAttachmentDescriptor : public NS::Copying<RenderPassSampleBufferAttachmentDescriptor>
172
+ {
173
+ public:
174
+ static class RenderPassSampleBufferAttachmentDescriptor* alloc();
175
+
176
+ class RenderPassSampleBufferAttachmentDescriptor* init();
177
+
178
+ class CounterSampleBuffer* sampleBuffer() const;
179
+ void setSampleBuffer(const class CounterSampleBuffer* sampleBuffer);
180
+
181
+ NS::UInteger startOfVertexSampleIndex() const;
182
+ void setStartOfVertexSampleIndex(NS::UInteger startOfVertexSampleIndex);
183
+
184
+ NS::UInteger endOfVertexSampleIndex() const;
185
+ void setEndOfVertexSampleIndex(NS::UInteger endOfVertexSampleIndex);
186
+
187
+ NS::UInteger startOfFragmentSampleIndex() const;
188
+ void setStartOfFragmentSampleIndex(NS::UInteger startOfFragmentSampleIndex);
189
+
190
+ NS::UInteger endOfFragmentSampleIndex() const;
191
+ void setEndOfFragmentSampleIndex(NS::UInteger endOfFragmentSampleIndex);
192
+ };
193
+
194
+ class RenderPassSampleBufferAttachmentDescriptorArray : public NS::Referencing<RenderPassSampleBufferAttachmentDescriptorArray>
195
+ {
196
+ public:
197
+ static class RenderPassSampleBufferAttachmentDescriptorArray* alloc();
198
+
199
+ class RenderPassSampleBufferAttachmentDescriptorArray* init();
200
+
201
+ class RenderPassSampleBufferAttachmentDescriptor* object(NS::UInteger attachmentIndex);
202
+
203
+ void setObject(const class RenderPassSampleBufferAttachmentDescriptor* attachment, NS::UInteger attachmentIndex);
204
+ };
205
+
206
+ class RenderPassDescriptor : public NS::Copying<RenderPassDescriptor>
207
+ {
208
+ public:
209
+ static class RenderPassDescriptor* alloc();
210
+
211
+ class RenderPassDescriptor* init();
212
+
213
+ static class RenderPassDescriptor* renderPassDescriptor();
214
+
215
+ class RenderPassColorAttachmentDescriptorArray* colorAttachments() const;
216
+
217
+ class RenderPassDepthAttachmentDescriptor* depthAttachment() const;
218
+ void setDepthAttachment(const class RenderPassDepthAttachmentDescriptor* depthAttachment);
219
+
220
+ class RenderPassStencilAttachmentDescriptor* stencilAttachment() const;
221
+ void setStencilAttachment(const class RenderPassStencilAttachmentDescriptor* stencilAttachment);
222
+
223
+ class Buffer* visibilityResultBuffer() const;
224
+ void setVisibilityResultBuffer(const class Buffer* visibilityResultBuffer);
225
+
226
+ NS::UInteger renderTargetArrayLength() const;
227
+ void setRenderTargetArrayLength(NS::UInteger renderTargetArrayLength);
228
+
229
+ NS::UInteger imageblockSampleLength() const;
230
+ void setImageblockSampleLength(NS::UInteger imageblockSampleLength);
231
+
232
+ NS::UInteger threadgroupMemoryLength() const;
233
+ void setThreadgroupMemoryLength(NS::UInteger threadgroupMemoryLength);
234
+
235
+ NS::UInteger tileWidth() const;
236
+ void setTileWidth(NS::UInteger tileWidth);
237
+
238
+ NS::UInteger tileHeight() const;
239
+ void setTileHeight(NS::UInteger tileHeight);
240
+
241
+ NS::UInteger defaultRasterSampleCount() const;
242
+ void setDefaultRasterSampleCount(NS::UInteger defaultRasterSampleCount);
243
+
244
+ NS::UInteger renderTargetWidth() const;
245
+ void setRenderTargetWidth(NS::UInteger renderTargetWidth);
246
+
247
+ NS::UInteger renderTargetHeight() const;
248
+ void setRenderTargetHeight(NS::UInteger renderTargetHeight);
249
+
250
+ void setSamplePositions(const MTL::SamplePosition* positions, NS::UInteger count);
251
+
252
+ NS::UInteger getSamplePositions(MTL::SamplePosition* positions, NS::UInteger count);
253
+
254
+ class RasterizationRateMap* rasterizationRateMap() const;
255
+ void setRasterizationRateMap(const class RasterizationRateMap* rasterizationRateMap);
256
+
257
+ class RenderPassSampleBufferAttachmentDescriptorArray* sampleBufferAttachments() const;
258
+ };
259
+
260
+ }
261
+
262
+ _MTL_INLINE MTL::ClearColor MTL::ClearColor::Make(double red, double green, double blue, double alpha)
263
+ {
264
+ return ClearColor(red, green, blue, alpha);
265
+ }
266
+
267
+ _MTL_INLINE MTL::ClearColor::ClearColor(double _red, double _green, double _blue, double _alpha)
268
+ : red(_red)
269
+ , green(_green)
270
+ , blue(_blue)
271
+ , alpha(_alpha)
272
+ {
273
+ }
274
+
275
+ // static method: alloc
276
+ _MTL_INLINE MTL::RenderPassAttachmentDescriptor* MTL::RenderPassAttachmentDescriptor::alloc()
277
+ {
278
+ return NS::Object::alloc<MTL::RenderPassAttachmentDescriptor>(_MTL_PRIVATE_CLS(MTLRenderPassAttachmentDescriptor));
279
+ }
280
+
281
+ // method: init
282
+ _MTL_INLINE MTL::RenderPassAttachmentDescriptor* MTL::RenderPassAttachmentDescriptor::init()
283
+ {
284
+ return NS::Object::init<MTL::RenderPassAttachmentDescriptor>();
285
+ }
286
+
287
+ // property: texture
288
+ _MTL_INLINE MTL::Texture* MTL::RenderPassAttachmentDescriptor::texture() const
289
+ {
290
+ return Object::sendMessage<MTL::Texture*>(this, _MTL_PRIVATE_SEL(texture));
291
+ }
292
+
293
+ _MTL_INLINE void MTL::RenderPassAttachmentDescriptor::setTexture(const MTL::Texture* texture)
294
+ {
295
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setTexture_), texture);
296
+ }
297
+
298
+ // property: level
299
+ _MTL_INLINE NS::UInteger MTL::RenderPassAttachmentDescriptor::level() const
300
+ {
301
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(level));
302
+ }
303
+
304
+ _MTL_INLINE void MTL::RenderPassAttachmentDescriptor::setLevel(NS::UInteger level)
305
+ {
306
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setLevel_), level);
307
+ }
308
+
309
+ // property: slice
310
+ _MTL_INLINE NS::UInteger MTL::RenderPassAttachmentDescriptor::slice() const
311
+ {
312
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(slice));
313
+ }
314
+
315
+ _MTL_INLINE void MTL::RenderPassAttachmentDescriptor::setSlice(NS::UInteger slice)
316
+ {
317
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setSlice_), slice);
318
+ }
319
+
320
+ // property: depthPlane
321
+ _MTL_INLINE NS::UInteger MTL::RenderPassAttachmentDescriptor::depthPlane() const
322
+ {
323
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(depthPlane));
324
+ }
325
+
326
+ _MTL_INLINE void MTL::RenderPassAttachmentDescriptor::setDepthPlane(NS::UInteger depthPlane)
327
+ {
328
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setDepthPlane_), depthPlane);
329
+ }
330
+
331
+ // property: resolveTexture
332
+ _MTL_INLINE MTL::Texture* MTL::RenderPassAttachmentDescriptor::resolveTexture() const
333
+ {
334
+ return Object::sendMessage<MTL::Texture*>(this, _MTL_PRIVATE_SEL(resolveTexture));
335
+ }
336
+
337
+ _MTL_INLINE void MTL::RenderPassAttachmentDescriptor::setResolveTexture(const MTL::Texture* resolveTexture)
338
+ {
339
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setResolveTexture_), resolveTexture);
340
+ }
341
+
342
+ // property: resolveLevel
343
+ _MTL_INLINE NS::UInteger MTL::RenderPassAttachmentDescriptor::resolveLevel() const
344
+ {
345
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(resolveLevel));
346
+ }
347
+
348
+ _MTL_INLINE void MTL::RenderPassAttachmentDescriptor::setResolveLevel(NS::UInteger resolveLevel)
349
+ {
350
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setResolveLevel_), resolveLevel);
351
+ }
352
+
353
+ // property: resolveSlice
354
+ _MTL_INLINE NS::UInteger MTL::RenderPassAttachmentDescriptor::resolveSlice() const
355
+ {
356
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(resolveSlice));
357
+ }
358
+
359
+ _MTL_INLINE void MTL::RenderPassAttachmentDescriptor::setResolveSlice(NS::UInteger resolveSlice)
360
+ {
361
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setResolveSlice_), resolveSlice);
362
+ }
363
+
364
+ // property: resolveDepthPlane
365
+ _MTL_INLINE NS::UInteger MTL::RenderPassAttachmentDescriptor::resolveDepthPlane() const
366
+ {
367
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(resolveDepthPlane));
368
+ }
369
+
370
+ _MTL_INLINE void MTL::RenderPassAttachmentDescriptor::setResolveDepthPlane(NS::UInteger resolveDepthPlane)
371
+ {
372
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setResolveDepthPlane_), resolveDepthPlane);
373
+ }
374
+
375
+ // property: loadAction
376
+ _MTL_INLINE MTL::LoadAction MTL::RenderPassAttachmentDescriptor::loadAction() const
377
+ {
378
+ return Object::sendMessage<MTL::LoadAction>(this, _MTL_PRIVATE_SEL(loadAction));
379
+ }
380
+
381
+ _MTL_INLINE void MTL::RenderPassAttachmentDescriptor::setLoadAction(MTL::LoadAction loadAction)
382
+ {
383
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setLoadAction_), loadAction);
384
+ }
385
+
386
+ // property: storeAction
387
+ _MTL_INLINE MTL::StoreAction MTL::RenderPassAttachmentDescriptor::storeAction() const
388
+ {
389
+ return Object::sendMessage<MTL::StoreAction>(this, _MTL_PRIVATE_SEL(storeAction));
390
+ }
391
+
392
+ _MTL_INLINE void MTL::RenderPassAttachmentDescriptor::setStoreAction(MTL::StoreAction storeAction)
393
+ {
394
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setStoreAction_), storeAction);
395
+ }
396
+
397
+ // property: storeActionOptions
398
+ _MTL_INLINE MTL::StoreActionOptions MTL::RenderPassAttachmentDescriptor::storeActionOptions() const
399
+ {
400
+ return Object::sendMessage<MTL::StoreActionOptions>(this, _MTL_PRIVATE_SEL(storeActionOptions));
401
+ }
402
+
403
+ _MTL_INLINE void MTL::RenderPassAttachmentDescriptor::setStoreActionOptions(MTL::StoreActionOptions storeActionOptions)
404
+ {
405
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setStoreActionOptions_), storeActionOptions);
406
+ }
407
+
408
+ // static method: alloc
409
+ _MTL_INLINE MTL::RenderPassColorAttachmentDescriptor* MTL::RenderPassColorAttachmentDescriptor::alloc()
410
+ {
411
+ return NS::Object::alloc<MTL::RenderPassColorAttachmentDescriptor>(_MTL_PRIVATE_CLS(MTLRenderPassColorAttachmentDescriptor));
412
+ }
413
+
414
+ // method: init
415
+ _MTL_INLINE MTL::RenderPassColorAttachmentDescriptor* MTL::RenderPassColorAttachmentDescriptor::init()
416
+ {
417
+ return NS::Object::init<MTL::RenderPassColorAttachmentDescriptor>();
418
+ }
419
+
420
+ // property: clearColor
421
+ _MTL_INLINE MTL::ClearColor MTL::RenderPassColorAttachmentDescriptor::clearColor() const
422
+ {
423
+ return Object::sendMessage<MTL::ClearColor>(this, _MTL_PRIVATE_SEL(clearColor));
424
+ }
425
+
426
+ _MTL_INLINE void MTL::RenderPassColorAttachmentDescriptor::setClearColor(MTL::ClearColor clearColor)
427
+ {
428
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setClearColor_), clearColor);
429
+ }
430
+
431
+ // static method: alloc
432
+ _MTL_INLINE MTL::RenderPassDepthAttachmentDescriptor* MTL::RenderPassDepthAttachmentDescriptor::alloc()
433
+ {
434
+ return NS::Object::alloc<MTL::RenderPassDepthAttachmentDescriptor>(_MTL_PRIVATE_CLS(MTLRenderPassDepthAttachmentDescriptor));
435
+ }
436
+
437
+ // method: init
438
+ _MTL_INLINE MTL::RenderPassDepthAttachmentDescriptor* MTL::RenderPassDepthAttachmentDescriptor::init()
439
+ {
440
+ return NS::Object::init<MTL::RenderPassDepthAttachmentDescriptor>();
441
+ }
442
+
443
+ // property: clearDepth
444
+ _MTL_INLINE double MTL::RenderPassDepthAttachmentDescriptor::clearDepth() const
445
+ {
446
+ return Object::sendMessage<double>(this, _MTL_PRIVATE_SEL(clearDepth));
447
+ }
448
+
449
+ _MTL_INLINE void MTL::RenderPassDepthAttachmentDescriptor::setClearDepth(double clearDepth)
450
+ {
451
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setClearDepth_), clearDepth);
452
+ }
453
+
454
+ // property: depthResolveFilter
455
+ _MTL_INLINE MTL::MultisampleDepthResolveFilter MTL::RenderPassDepthAttachmentDescriptor::depthResolveFilter() const
456
+ {
457
+ return Object::sendMessage<MTL::MultisampleDepthResolveFilter>(this, _MTL_PRIVATE_SEL(depthResolveFilter));
458
+ }
459
+
460
+ _MTL_INLINE void MTL::RenderPassDepthAttachmentDescriptor::setDepthResolveFilter(MTL::MultisampleDepthResolveFilter depthResolveFilter)
461
+ {
462
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setDepthResolveFilter_), depthResolveFilter);
463
+ }
464
+
465
+ // static method: alloc
466
+ _MTL_INLINE MTL::RenderPassStencilAttachmentDescriptor* MTL::RenderPassStencilAttachmentDescriptor::alloc()
467
+ {
468
+ return NS::Object::alloc<MTL::RenderPassStencilAttachmentDescriptor>(_MTL_PRIVATE_CLS(MTLRenderPassStencilAttachmentDescriptor));
469
+ }
470
+
471
+ // method: init
472
+ _MTL_INLINE MTL::RenderPassStencilAttachmentDescriptor* MTL::RenderPassStencilAttachmentDescriptor::init()
473
+ {
474
+ return NS::Object::init<MTL::RenderPassStencilAttachmentDescriptor>();
475
+ }
476
+
477
+ // property: clearStencil
478
+ _MTL_INLINE uint32_t MTL::RenderPassStencilAttachmentDescriptor::clearStencil() const
479
+ {
480
+ return Object::sendMessage<uint32_t>(this, _MTL_PRIVATE_SEL(clearStencil));
481
+ }
482
+
483
+ _MTL_INLINE void MTL::RenderPassStencilAttachmentDescriptor::setClearStencil(uint32_t clearStencil)
484
+ {
485
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setClearStencil_), clearStencil);
486
+ }
487
+
488
+ // property: stencilResolveFilter
489
+ _MTL_INLINE MTL::MultisampleStencilResolveFilter MTL::RenderPassStencilAttachmentDescriptor::stencilResolveFilter() const
490
+ {
491
+ return Object::sendMessage<MTL::MultisampleStencilResolveFilter>(this, _MTL_PRIVATE_SEL(stencilResolveFilter));
492
+ }
493
+
494
+ _MTL_INLINE void MTL::RenderPassStencilAttachmentDescriptor::setStencilResolveFilter(MTL::MultisampleStencilResolveFilter stencilResolveFilter)
495
+ {
496
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setStencilResolveFilter_), stencilResolveFilter);
497
+ }
498
+
499
+ // static method: alloc
500
+ _MTL_INLINE MTL::RenderPassColorAttachmentDescriptorArray* MTL::RenderPassColorAttachmentDescriptorArray::alloc()
501
+ {
502
+ return NS::Object::alloc<MTL::RenderPassColorAttachmentDescriptorArray>(_MTL_PRIVATE_CLS(MTLRenderPassColorAttachmentDescriptorArray));
503
+ }
504
+
505
+ // method: init
506
+ _MTL_INLINE MTL::RenderPassColorAttachmentDescriptorArray* MTL::RenderPassColorAttachmentDescriptorArray::init()
507
+ {
508
+ return NS::Object::init<MTL::RenderPassColorAttachmentDescriptorArray>();
509
+ }
510
+
511
+ // method: objectAtIndexedSubscript:
512
+ _MTL_INLINE MTL::RenderPassColorAttachmentDescriptor* MTL::RenderPassColorAttachmentDescriptorArray::object(NS::UInteger attachmentIndex)
513
+ {
514
+ return Object::sendMessage<MTL::RenderPassColorAttachmentDescriptor*>(this, _MTL_PRIVATE_SEL(objectAtIndexedSubscript_), attachmentIndex);
515
+ }
516
+
517
+ // method: setObject:atIndexedSubscript:
518
+ _MTL_INLINE void MTL::RenderPassColorAttachmentDescriptorArray::setObject(const MTL::RenderPassColorAttachmentDescriptor* attachment, NS::UInteger attachmentIndex)
519
+ {
520
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setObject_atIndexedSubscript_), attachment, attachmentIndex);
521
+ }
522
+
523
+ // static method: alloc
524
+ _MTL_INLINE MTL::RenderPassSampleBufferAttachmentDescriptor* MTL::RenderPassSampleBufferAttachmentDescriptor::alloc()
525
+ {
526
+ return NS::Object::alloc<MTL::RenderPassSampleBufferAttachmentDescriptor>(_MTL_PRIVATE_CLS(MTLRenderPassSampleBufferAttachmentDescriptor));
527
+ }
528
+
529
+ // method: init
530
+ _MTL_INLINE MTL::RenderPassSampleBufferAttachmentDescriptor* MTL::RenderPassSampleBufferAttachmentDescriptor::init()
531
+ {
532
+ return NS::Object::init<MTL::RenderPassSampleBufferAttachmentDescriptor>();
533
+ }
534
+
535
+ // property: sampleBuffer
536
+ _MTL_INLINE MTL::CounterSampleBuffer* MTL::RenderPassSampleBufferAttachmentDescriptor::sampleBuffer() const
537
+ {
538
+ return Object::sendMessage<MTL::CounterSampleBuffer*>(this, _MTL_PRIVATE_SEL(sampleBuffer));
539
+ }
540
+
541
+ _MTL_INLINE void MTL::RenderPassSampleBufferAttachmentDescriptor::setSampleBuffer(const MTL::CounterSampleBuffer* sampleBuffer)
542
+ {
543
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setSampleBuffer_), sampleBuffer);
544
+ }
545
+
546
+ // property: startOfVertexSampleIndex
547
+ _MTL_INLINE NS::UInteger MTL::RenderPassSampleBufferAttachmentDescriptor::startOfVertexSampleIndex() const
548
+ {
549
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(startOfVertexSampleIndex));
550
+ }
551
+
552
+ _MTL_INLINE void MTL::RenderPassSampleBufferAttachmentDescriptor::setStartOfVertexSampleIndex(NS::UInteger startOfVertexSampleIndex)
553
+ {
554
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setStartOfVertexSampleIndex_), startOfVertexSampleIndex);
555
+ }
556
+
557
+ // property: endOfVertexSampleIndex
558
+ _MTL_INLINE NS::UInteger MTL::RenderPassSampleBufferAttachmentDescriptor::endOfVertexSampleIndex() const
559
+ {
560
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(endOfVertexSampleIndex));
561
+ }
562
+
563
+ _MTL_INLINE void MTL::RenderPassSampleBufferAttachmentDescriptor::setEndOfVertexSampleIndex(NS::UInteger endOfVertexSampleIndex)
564
+ {
565
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setEndOfVertexSampleIndex_), endOfVertexSampleIndex);
566
+ }
567
+
568
+ // property: startOfFragmentSampleIndex
569
+ _MTL_INLINE NS::UInteger MTL::RenderPassSampleBufferAttachmentDescriptor::startOfFragmentSampleIndex() const
570
+ {
571
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(startOfFragmentSampleIndex));
572
+ }
573
+
574
+ _MTL_INLINE void MTL::RenderPassSampleBufferAttachmentDescriptor::setStartOfFragmentSampleIndex(NS::UInteger startOfFragmentSampleIndex)
575
+ {
576
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setStartOfFragmentSampleIndex_), startOfFragmentSampleIndex);
577
+ }
578
+
579
+ // property: endOfFragmentSampleIndex
580
+ _MTL_INLINE NS::UInteger MTL::RenderPassSampleBufferAttachmentDescriptor::endOfFragmentSampleIndex() const
581
+ {
582
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(endOfFragmentSampleIndex));
583
+ }
584
+
585
+ _MTL_INLINE void MTL::RenderPassSampleBufferAttachmentDescriptor::setEndOfFragmentSampleIndex(NS::UInteger endOfFragmentSampleIndex)
586
+ {
587
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setEndOfFragmentSampleIndex_), endOfFragmentSampleIndex);
588
+ }
589
+
590
+ // static method: alloc
591
+ _MTL_INLINE MTL::RenderPassSampleBufferAttachmentDescriptorArray* MTL::RenderPassSampleBufferAttachmentDescriptorArray::alloc()
592
+ {
593
+ return NS::Object::alloc<MTL::RenderPassSampleBufferAttachmentDescriptorArray>(_MTL_PRIVATE_CLS(MTLRenderPassSampleBufferAttachmentDescriptorArray));
594
+ }
595
+
596
+ // method: init
597
+ _MTL_INLINE MTL::RenderPassSampleBufferAttachmentDescriptorArray* MTL::RenderPassSampleBufferAttachmentDescriptorArray::init()
598
+ {
599
+ return NS::Object::init<MTL::RenderPassSampleBufferAttachmentDescriptorArray>();
600
+ }
601
+
602
+ // method: objectAtIndexedSubscript:
603
+ _MTL_INLINE MTL::RenderPassSampleBufferAttachmentDescriptor* MTL::RenderPassSampleBufferAttachmentDescriptorArray::object(NS::UInteger attachmentIndex)
604
+ {
605
+ return Object::sendMessage<MTL::RenderPassSampleBufferAttachmentDescriptor*>(this, _MTL_PRIVATE_SEL(objectAtIndexedSubscript_), attachmentIndex);
606
+ }
607
+
608
+ // method: setObject:atIndexedSubscript:
609
+ _MTL_INLINE void MTL::RenderPassSampleBufferAttachmentDescriptorArray::setObject(const MTL::RenderPassSampleBufferAttachmentDescriptor* attachment, NS::UInteger attachmentIndex)
610
+ {
611
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setObject_atIndexedSubscript_), attachment, attachmentIndex);
612
+ }
613
+
614
+ // static method: alloc
615
+ _MTL_INLINE MTL::RenderPassDescriptor* MTL::RenderPassDescriptor::alloc()
616
+ {
617
+ return NS::Object::alloc<MTL::RenderPassDescriptor>(_MTL_PRIVATE_CLS(MTLRenderPassDescriptor));
618
+ }
619
+
620
+ // method: init
621
+ _MTL_INLINE MTL::RenderPassDescriptor* MTL::RenderPassDescriptor::init()
622
+ {
623
+ return NS::Object::init<MTL::RenderPassDescriptor>();
624
+ }
625
+
626
+ // static method: renderPassDescriptor
627
+ _MTL_INLINE MTL::RenderPassDescriptor* MTL::RenderPassDescriptor::renderPassDescriptor()
628
+ {
629
+ return Object::sendMessage<MTL::RenderPassDescriptor*>(_MTL_PRIVATE_CLS(MTLRenderPassDescriptor), _MTL_PRIVATE_SEL(renderPassDescriptor));
630
+ }
631
+
632
+ // property: colorAttachments
633
+ _MTL_INLINE MTL::RenderPassColorAttachmentDescriptorArray* MTL::RenderPassDescriptor::colorAttachments() const
634
+ {
635
+ return Object::sendMessage<MTL::RenderPassColorAttachmentDescriptorArray*>(this, _MTL_PRIVATE_SEL(colorAttachments));
636
+ }
637
+
638
+ // property: depthAttachment
639
+ _MTL_INLINE MTL::RenderPassDepthAttachmentDescriptor* MTL::RenderPassDescriptor::depthAttachment() const
640
+ {
641
+ return Object::sendMessage<MTL::RenderPassDepthAttachmentDescriptor*>(this, _MTL_PRIVATE_SEL(depthAttachment));
642
+ }
643
+
644
+ _MTL_INLINE void MTL::RenderPassDescriptor::setDepthAttachment(const MTL::RenderPassDepthAttachmentDescriptor* depthAttachment)
645
+ {
646
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setDepthAttachment_), depthAttachment);
647
+ }
648
+
649
+ // property: stencilAttachment
650
+ _MTL_INLINE MTL::RenderPassStencilAttachmentDescriptor* MTL::RenderPassDescriptor::stencilAttachment() const
651
+ {
652
+ return Object::sendMessage<MTL::RenderPassStencilAttachmentDescriptor*>(this, _MTL_PRIVATE_SEL(stencilAttachment));
653
+ }
654
+
655
+ _MTL_INLINE void MTL::RenderPassDescriptor::setStencilAttachment(const MTL::RenderPassStencilAttachmentDescriptor* stencilAttachment)
656
+ {
657
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setStencilAttachment_), stencilAttachment);
658
+ }
659
+
660
+ // property: visibilityResultBuffer
661
+ _MTL_INLINE MTL::Buffer* MTL::RenderPassDescriptor::visibilityResultBuffer() const
662
+ {
663
+ return Object::sendMessage<MTL::Buffer*>(this, _MTL_PRIVATE_SEL(visibilityResultBuffer));
664
+ }
665
+
666
+ _MTL_INLINE void MTL::RenderPassDescriptor::setVisibilityResultBuffer(const MTL::Buffer* visibilityResultBuffer)
667
+ {
668
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setVisibilityResultBuffer_), visibilityResultBuffer);
669
+ }
670
+
671
+ // property: renderTargetArrayLength
672
+ _MTL_INLINE NS::UInteger MTL::RenderPassDescriptor::renderTargetArrayLength() const
673
+ {
674
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(renderTargetArrayLength));
675
+ }
676
+
677
+ _MTL_INLINE void MTL::RenderPassDescriptor::setRenderTargetArrayLength(NS::UInteger renderTargetArrayLength)
678
+ {
679
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setRenderTargetArrayLength_), renderTargetArrayLength);
680
+ }
681
+
682
+ // property: imageblockSampleLength
683
+ _MTL_INLINE NS::UInteger MTL::RenderPassDescriptor::imageblockSampleLength() const
684
+ {
685
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(imageblockSampleLength));
686
+ }
687
+
688
+ _MTL_INLINE void MTL::RenderPassDescriptor::setImageblockSampleLength(NS::UInteger imageblockSampleLength)
689
+ {
690
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setImageblockSampleLength_), imageblockSampleLength);
691
+ }
692
+
693
+ // property: threadgroupMemoryLength
694
+ _MTL_INLINE NS::UInteger MTL::RenderPassDescriptor::threadgroupMemoryLength() const
695
+ {
696
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(threadgroupMemoryLength));
697
+ }
698
+
699
+ _MTL_INLINE void MTL::RenderPassDescriptor::setThreadgroupMemoryLength(NS::UInteger threadgroupMemoryLength)
700
+ {
701
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setThreadgroupMemoryLength_), threadgroupMemoryLength);
702
+ }
703
+
704
+ // property: tileWidth
705
+ _MTL_INLINE NS::UInteger MTL::RenderPassDescriptor::tileWidth() const
706
+ {
707
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(tileWidth));
708
+ }
709
+
710
+ _MTL_INLINE void MTL::RenderPassDescriptor::setTileWidth(NS::UInteger tileWidth)
711
+ {
712
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setTileWidth_), tileWidth);
713
+ }
714
+
715
+ // property: tileHeight
716
+ _MTL_INLINE NS::UInteger MTL::RenderPassDescriptor::tileHeight() const
717
+ {
718
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(tileHeight));
719
+ }
720
+
721
+ _MTL_INLINE void MTL::RenderPassDescriptor::setTileHeight(NS::UInteger tileHeight)
722
+ {
723
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setTileHeight_), tileHeight);
724
+ }
725
+
726
+ // property: defaultRasterSampleCount
727
+ _MTL_INLINE NS::UInteger MTL::RenderPassDescriptor::defaultRasterSampleCount() const
728
+ {
729
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(defaultRasterSampleCount));
730
+ }
731
+
732
+ _MTL_INLINE void MTL::RenderPassDescriptor::setDefaultRasterSampleCount(NS::UInteger defaultRasterSampleCount)
733
+ {
734
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setDefaultRasterSampleCount_), defaultRasterSampleCount);
735
+ }
736
+
737
+ // property: renderTargetWidth
738
+ _MTL_INLINE NS::UInteger MTL::RenderPassDescriptor::renderTargetWidth() const
739
+ {
740
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(renderTargetWidth));
741
+ }
742
+
743
+ _MTL_INLINE void MTL::RenderPassDescriptor::setRenderTargetWidth(NS::UInteger renderTargetWidth)
744
+ {
745
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setRenderTargetWidth_), renderTargetWidth);
746
+ }
747
+
748
+ // property: renderTargetHeight
749
+ _MTL_INLINE NS::UInteger MTL::RenderPassDescriptor::renderTargetHeight() const
750
+ {
751
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(renderTargetHeight));
752
+ }
753
+
754
+ _MTL_INLINE void MTL::RenderPassDescriptor::setRenderTargetHeight(NS::UInteger renderTargetHeight)
755
+ {
756
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setRenderTargetHeight_), renderTargetHeight);
757
+ }
758
+
759
+ // method: setSamplePositions:count:
760
+ _MTL_INLINE void MTL::RenderPassDescriptor::setSamplePositions(const MTL::SamplePosition* positions, NS::UInteger count)
761
+ {
762
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setSamplePositions_count_), positions, count);
763
+ }
764
+
765
+ // method: getSamplePositions:count:
766
+ _MTL_INLINE NS::UInteger MTL::RenderPassDescriptor::getSamplePositions(MTL::SamplePosition* positions, NS::UInteger count)
767
+ {
768
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(getSamplePositions_count_), positions, count);
769
+ }
770
+
771
+ // property: rasterizationRateMap
772
+ _MTL_INLINE MTL::RasterizationRateMap* MTL::RenderPassDescriptor::rasterizationRateMap() const
773
+ {
774
+ return Object::sendMessage<MTL::RasterizationRateMap*>(this, _MTL_PRIVATE_SEL(rasterizationRateMap));
775
+ }
776
+
777
+ _MTL_INLINE void MTL::RenderPassDescriptor::setRasterizationRateMap(const MTL::RasterizationRateMap* rasterizationRateMap)
778
+ {
779
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setRasterizationRateMap_), rasterizationRateMap);
780
+ }
781
+
782
+ // property: sampleBufferAttachments
783
+ _MTL_INLINE MTL::RenderPassSampleBufferAttachmentDescriptorArray* MTL::RenderPassDescriptor::sampleBufferAttachments() const
784
+ {
785
+ return Object::sendMessage<MTL::RenderPassSampleBufferAttachmentDescriptorArray*>(this, _MTL_PRIVATE_SEL(sampleBufferAttachments));
786
+ }
lib/python3.11/site-packages/mlx/include/metal_cpp/Metal/MTLRenderPipeline.hpp ADDED
@@ -0,0 +1,1640 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
2
+ //
3
+ // Metal/MTLRenderPipeline.hpp
4
+ //
5
+ // Copyright 2020-2023 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 "MTLPixelFormat.hpp"
30
+ #include "MTLRenderCommandEncoder.hpp"
31
+ #include "MTLRenderPipeline.hpp"
32
+ #include "MTLTypes.hpp"
33
+
34
+ namespace MTL
35
+ {
36
+ _MTL_ENUM(NS::UInteger, BlendFactor) {
37
+ BlendFactorZero = 0,
38
+ BlendFactorOne = 1,
39
+ BlendFactorSourceColor = 2,
40
+ BlendFactorOneMinusSourceColor = 3,
41
+ BlendFactorSourceAlpha = 4,
42
+ BlendFactorOneMinusSourceAlpha = 5,
43
+ BlendFactorDestinationColor = 6,
44
+ BlendFactorOneMinusDestinationColor = 7,
45
+ BlendFactorDestinationAlpha = 8,
46
+ BlendFactorOneMinusDestinationAlpha = 9,
47
+ BlendFactorSourceAlphaSaturated = 10,
48
+ BlendFactorBlendColor = 11,
49
+ BlendFactorOneMinusBlendColor = 12,
50
+ BlendFactorBlendAlpha = 13,
51
+ BlendFactorOneMinusBlendAlpha = 14,
52
+ BlendFactorSource1Color = 15,
53
+ BlendFactorOneMinusSource1Color = 16,
54
+ BlendFactorSource1Alpha = 17,
55
+ BlendFactorOneMinusSource1Alpha = 18,
56
+ };
57
+
58
+ _MTL_ENUM(NS::UInteger, BlendOperation) {
59
+ BlendOperationAdd = 0,
60
+ BlendOperationSubtract = 1,
61
+ BlendOperationReverseSubtract = 2,
62
+ BlendOperationMin = 3,
63
+ BlendOperationMax = 4,
64
+ };
65
+
66
+ _MTL_OPTIONS(NS::UInteger, ColorWriteMask) {
67
+ ColorWriteMaskNone = 0,
68
+ ColorWriteMaskAlpha = 1,
69
+ ColorWriteMaskBlue = 2,
70
+ ColorWriteMaskGreen = 4,
71
+ ColorWriteMaskRed = 8,
72
+ ColorWriteMaskAll = 15,
73
+ };
74
+
75
+ _MTL_ENUM(NS::UInteger, PrimitiveTopologyClass) {
76
+ PrimitiveTopologyClassUnspecified = 0,
77
+ PrimitiveTopologyClassPoint = 1,
78
+ PrimitiveTopologyClassLine = 2,
79
+ PrimitiveTopologyClassTriangle = 3,
80
+ };
81
+
82
+ _MTL_ENUM(NS::UInteger, TessellationPartitionMode) {
83
+ TessellationPartitionModePow2 = 0,
84
+ TessellationPartitionModeInteger = 1,
85
+ TessellationPartitionModeFractionalOdd = 2,
86
+ TessellationPartitionModeFractionalEven = 3,
87
+ };
88
+
89
+ _MTL_ENUM(NS::UInteger, TessellationFactorStepFunction) {
90
+ TessellationFactorStepFunctionConstant = 0,
91
+ TessellationFactorStepFunctionPerPatch = 1,
92
+ TessellationFactorStepFunctionPerInstance = 2,
93
+ TessellationFactorStepFunctionPerPatchAndPerInstance = 3,
94
+ };
95
+
96
+ _MTL_ENUM(NS::UInteger, TessellationFactorFormat) {
97
+ TessellationFactorFormatHalf = 0,
98
+ };
99
+
100
+ _MTL_ENUM(NS::UInteger, TessellationControlPointIndexType) {
101
+ TessellationControlPointIndexTypeNone = 0,
102
+ TessellationControlPointIndexTypeUInt16 = 1,
103
+ TessellationControlPointIndexTypeUInt32 = 2,
104
+ };
105
+
106
+ class RenderPipelineColorAttachmentDescriptor : public NS::Copying<RenderPipelineColorAttachmentDescriptor>
107
+ {
108
+ public:
109
+ static class RenderPipelineColorAttachmentDescriptor* alloc();
110
+
111
+ class RenderPipelineColorAttachmentDescriptor* init();
112
+
113
+ MTL::PixelFormat pixelFormat() const;
114
+ void setPixelFormat(MTL::PixelFormat pixelFormat);
115
+
116
+ bool blendingEnabled() const;
117
+ void setBlendingEnabled(bool blendingEnabled);
118
+
119
+ MTL::BlendFactor sourceRGBBlendFactor() const;
120
+ void setSourceRGBBlendFactor(MTL::BlendFactor sourceRGBBlendFactor);
121
+
122
+ MTL::BlendFactor destinationRGBBlendFactor() const;
123
+ void setDestinationRGBBlendFactor(MTL::BlendFactor destinationRGBBlendFactor);
124
+
125
+ MTL::BlendOperation rgbBlendOperation() const;
126
+ void setRgbBlendOperation(MTL::BlendOperation rgbBlendOperation);
127
+
128
+ MTL::BlendFactor sourceAlphaBlendFactor() const;
129
+ void setSourceAlphaBlendFactor(MTL::BlendFactor sourceAlphaBlendFactor);
130
+
131
+ MTL::BlendFactor destinationAlphaBlendFactor() const;
132
+ void setDestinationAlphaBlendFactor(MTL::BlendFactor destinationAlphaBlendFactor);
133
+
134
+ MTL::BlendOperation alphaBlendOperation() const;
135
+ void setAlphaBlendOperation(MTL::BlendOperation alphaBlendOperation);
136
+
137
+ MTL::ColorWriteMask writeMask() const;
138
+ void setWriteMask(MTL::ColorWriteMask writeMask);
139
+ };
140
+
141
+ class RenderPipelineReflection : public NS::Referencing<RenderPipelineReflection>
142
+ {
143
+ public:
144
+ static class RenderPipelineReflection* alloc();
145
+
146
+ class RenderPipelineReflection* init();
147
+
148
+ NS::Array* vertexBindings() const;
149
+
150
+ NS::Array* fragmentBindings() const;
151
+
152
+ NS::Array* tileBindings() const;
153
+
154
+ NS::Array* objectBindings() const;
155
+
156
+ NS::Array* meshBindings() const;
157
+
158
+ NS::Array* vertexArguments() const;
159
+
160
+ NS::Array* fragmentArguments() const;
161
+
162
+ NS::Array* tileArguments() const;
163
+ };
164
+
165
+ class RenderPipelineDescriptor : public NS::Copying<RenderPipelineDescriptor>
166
+ {
167
+ public:
168
+ static class RenderPipelineDescriptor* alloc();
169
+
170
+ class RenderPipelineDescriptor* init();
171
+
172
+ NS::String* label() const;
173
+ void setLabel(const NS::String* label);
174
+
175
+ class Function* vertexFunction() const;
176
+ void setVertexFunction(const class Function* vertexFunction);
177
+
178
+ class Function* fragmentFunction() const;
179
+ void setFragmentFunction(const class Function* fragmentFunction);
180
+
181
+ class VertexDescriptor* vertexDescriptor() const;
182
+ void setVertexDescriptor(const class VertexDescriptor* vertexDescriptor);
183
+
184
+ NS::UInteger sampleCount() const;
185
+ void setSampleCount(NS::UInteger sampleCount);
186
+
187
+ NS::UInteger rasterSampleCount() const;
188
+ void setRasterSampleCount(NS::UInteger rasterSampleCount);
189
+
190
+ bool alphaToCoverageEnabled() const;
191
+ void setAlphaToCoverageEnabled(bool alphaToCoverageEnabled);
192
+
193
+ bool alphaToOneEnabled() const;
194
+ void setAlphaToOneEnabled(bool alphaToOneEnabled);
195
+
196
+ bool rasterizationEnabled() const;
197
+ void setRasterizationEnabled(bool rasterizationEnabled);
198
+
199
+ NS::UInteger maxVertexAmplificationCount() const;
200
+ void setMaxVertexAmplificationCount(NS::UInteger maxVertexAmplificationCount);
201
+
202
+ class RenderPipelineColorAttachmentDescriptorArray* colorAttachments() const;
203
+
204
+ MTL::PixelFormat depthAttachmentPixelFormat() const;
205
+ void setDepthAttachmentPixelFormat(MTL::PixelFormat depthAttachmentPixelFormat);
206
+
207
+ MTL::PixelFormat stencilAttachmentPixelFormat() const;
208
+ void setStencilAttachmentPixelFormat(MTL::PixelFormat stencilAttachmentPixelFormat);
209
+
210
+ MTL::PrimitiveTopologyClass inputPrimitiveTopology() const;
211
+ void setInputPrimitiveTopology(MTL::PrimitiveTopologyClass inputPrimitiveTopology);
212
+
213
+ MTL::TessellationPartitionMode tessellationPartitionMode() const;
214
+ void setTessellationPartitionMode(MTL::TessellationPartitionMode tessellationPartitionMode);
215
+
216
+ NS::UInteger maxTessellationFactor() const;
217
+ void setMaxTessellationFactor(NS::UInteger maxTessellationFactor);
218
+
219
+ bool tessellationFactorScaleEnabled() const;
220
+ void setTessellationFactorScaleEnabled(bool tessellationFactorScaleEnabled);
221
+
222
+ MTL::TessellationFactorFormat tessellationFactorFormat() const;
223
+ void setTessellationFactorFormat(MTL::TessellationFactorFormat tessellationFactorFormat);
224
+
225
+ MTL::TessellationControlPointIndexType tessellationControlPointIndexType() const;
226
+ void setTessellationControlPointIndexType(MTL::TessellationControlPointIndexType tessellationControlPointIndexType);
227
+
228
+ MTL::TessellationFactorStepFunction tessellationFactorStepFunction() const;
229
+ void setTessellationFactorStepFunction(MTL::TessellationFactorStepFunction tessellationFactorStepFunction);
230
+
231
+ MTL::Winding tessellationOutputWindingOrder() const;
232
+ void setTessellationOutputWindingOrder(MTL::Winding tessellationOutputWindingOrder);
233
+
234
+ class PipelineBufferDescriptorArray* vertexBuffers() const;
235
+
236
+ class PipelineBufferDescriptorArray* fragmentBuffers() const;
237
+
238
+ bool supportIndirectCommandBuffers() const;
239
+ void setSupportIndirectCommandBuffers(bool supportIndirectCommandBuffers);
240
+
241
+ NS::Array* binaryArchives() const;
242
+ void setBinaryArchives(const NS::Array* binaryArchives);
243
+
244
+ NS::Array* vertexPreloadedLibraries() const;
245
+ void setVertexPreloadedLibraries(const NS::Array* vertexPreloadedLibraries);
246
+
247
+ NS::Array* fragmentPreloadedLibraries() const;
248
+ void setFragmentPreloadedLibraries(const NS::Array* fragmentPreloadedLibraries);
249
+
250
+ class LinkedFunctions* vertexLinkedFunctions() const;
251
+ void setVertexLinkedFunctions(const class LinkedFunctions* vertexLinkedFunctions);
252
+
253
+ class LinkedFunctions* fragmentLinkedFunctions() const;
254
+ void setFragmentLinkedFunctions(const class LinkedFunctions* fragmentLinkedFunctions);
255
+
256
+ bool supportAddingVertexBinaryFunctions() const;
257
+ void setSupportAddingVertexBinaryFunctions(bool supportAddingVertexBinaryFunctions);
258
+
259
+ bool supportAddingFragmentBinaryFunctions() const;
260
+ void setSupportAddingFragmentBinaryFunctions(bool supportAddingFragmentBinaryFunctions);
261
+
262
+ NS::UInteger maxVertexCallStackDepth() const;
263
+ void setMaxVertexCallStackDepth(NS::UInteger maxVertexCallStackDepth);
264
+
265
+ NS::UInteger maxFragmentCallStackDepth() const;
266
+ void setMaxFragmentCallStackDepth(NS::UInteger maxFragmentCallStackDepth);
267
+
268
+ void reset();
269
+ };
270
+
271
+ class RenderPipelineFunctionsDescriptor : public NS::Copying<RenderPipelineFunctionsDescriptor>
272
+ {
273
+ public:
274
+ static class RenderPipelineFunctionsDescriptor* alloc();
275
+
276
+ class RenderPipelineFunctionsDescriptor* init();
277
+
278
+ NS::Array* vertexAdditionalBinaryFunctions() const;
279
+ void setVertexAdditionalBinaryFunctions(const NS::Array* vertexAdditionalBinaryFunctions);
280
+
281
+ NS::Array* fragmentAdditionalBinaryFunctions() const;
282
+ void setFragmentAdditionalBinaryFunctions(const NS::Array* fragmentAdditionalBinaryFunctions);
283
+
284
+ NS::Array* tileAdditionalBinaryFunctions() const;
285
+ void setTileAdditionalBinaryFunctions(const NS::Array* tileAdditionalBinaryFunctions);
286
+ };
287
+
288
+ class RenderPipelineState : public NS::Referencing<RenderPipelineState>
289
+ {
290
+ public:
291
+ NS::String* label() const;
292
+
293
+ class Device* device() const;
294
+
295
+ NS::UInteger maxTotalThreadsPerThreadgroup() const;
296
+
297
+ bool threadgroupSizeMatchesTileSize() const;
298
+
299
+ NS::UInteger imageblockSampleLength() const;
300
+
301
+ NS::UInteger imageblockMemoryLength(MTL::Size imageblockDimensions);
302
+
303
+ bool supportIndirectCommandBuffers() const;
304
+
305
+ NS::UInteger maxTotalThreadsPerObjectThreadgroup() const;
306
+
307
+ NS::UInteger maxTotalThreadsPerMeshThreadgroup() const;
308
+
309
+ NS::UInteger objectThreadExecutionWidth() const;
310
+
311
+ NS::UInteger meshThreadExecutionWidth() const;
312
+
313
+ NS::UInteger maxTotalThreadgroupsPerMeshGrid() const;
314
+
315
+ MTL::ResourceID gpuResourceID() const;
316
+
317
+ class FunctionHandle* functionHandle(const class Function* function, MTL::RenderStages stage);
318
+
319
+ class VisibleFunctionTable* newVisibleFunctionTable(const class VisibleFunctionTableDescriptor* descriptor, MTL::RenderStages stage);
320
+
321
+ class IntersectionFunctionTable* newIntersectionFunctionTable(const class IntersectionFunctionTableDescriptor* descriptor, MTL::RenderStages stage);
322
+
323
+ class RenderPipelineState* newRenderPipelineState(const class RenderPipelineFunctionsDescriptor* additionalBinaryFunctions, NS::Error** error);
324
+ };
325
+
326
+ class RenderPipelineColorAttachmentDescriptorArray : public NS::Referencing<RenderPipelineColorAttachmentDescriptorArray>
327
+ {
328
+ public:
329
+ static class RenderPipelineColorAttachmentDescriptorArray* alloc();
330
+
331
+ class RenderPipelineColorAttachmentDescriptorArray* init();
332
+
333
+ class RenderPipelineColorAttachmentDescriptor* object(NS::UInteger attachmentIndex);
334
+
335
+ void setObject(const class RenderPipelineColorAttachmentDescriptor* attachment, NS::UInteger attachmentIndex);
336
+ };
337
+
338
+ class TileRenderPipelineColorAttachmentDescriptor : public NS::Copying<TileRenderPipelineColorAttachmentDescriptor>
339
+ {
340
+ public:
341
+ static class TileRenderPipelineColorAttachmentDescriptor* alloc();
342
+
343
+ class TileRenderPipelineColorAttachmentDescriptor* init();
344
+
345
+ MTL::PixelFormat pixelFormat() const;
346
+ void setPixelFormat(MTL::PixelFormat pixelFormat);
347
+ };
348
+
349
+ class TileRenderPipelineColorAttachmentDescriptorArray : public NS::Referencing<TileRenderPipelineColorAttachmentDescriptorArray>
350
+ {
351
+ public:
352
+ static class TileRenderPipelineColorAttachmentDescriptorArray* alloc();
353
+
354
+ class TileRenderPipelineColorAttachmentDescriptorArray* init();
355
+
356
+ class TileRenderPipelineColorAttachmentDescriptor* object(NS::UInteger attachmentIndex);
357
+
358
+ void setObject(const class TileRenderPipelineColorAttachmentDescriptor* attachment, NS::UInteger attachmentIndex);
359
+ };
360
+
361
+ class TileRenderPipelineDescriptor : public NS::Copying<TileRenderPipelineDescriptor>
362
+ {
363
+ public:
364
+ static class TileRenderPipelineDescriptor* alloc();
365
+
366
+ class TileRenderPipelineDescriptor* init();
367
+
368
+ NS::String* label() const;
369
+ void setLabel(const NS::String* label);
370
+
371
+ class Function* tileFunction() const;
372
+ void setTileFunction(const class Function* tileFunction);
373
+
374
+ NS::UInteger rasterSampleCount() const;
375
+ void setRasterSampleCount(NS::UInteger rasterSampleCount);
376
+
377
+ class TileRenderPipelineColorAttachmentDescriptorArray* colorAttachments() const;
378
+
379
+ bool threadgroupSizeMatchesTileSize() const;
380
+ void setThreadgroupSizeMatchesTileSize(bool threadgroupSizeMatchesTileSize);
381
+
382
+ class PipelineBufferDescriptorArray* tileBuffers() const;
383
+
384
+ NS::UInteger maxTotalThreadsPerThreadgroup() const;
385
+ void setMaxTotalThreadsPerThreadgroup(NS::UInteger maxTotalThreadsPerThreadgroup);
386
+
387
+ NS::Array* binaryArchives() const;
388
+ void setBinaryArchives(const NS::Array* binaryArchives);
389
+
390
+ NS::Array* preloadedLibraries() const;
391
+ void setPreloadedLibraries(const NS::Array* preloadedLibraries);
392
+
393
+ class LinkedFunctions* linkedFunctions() const;
394
+ void setLinkedFunctions(const class LinkedFunctions* linkedFunctions);
395
+
396
+ bool supportAddingBinaryFunctions() const;
397
+ void setSupportAddingBinaryFunctions(bool supportAddingBinaryFunctions);
398
+
399
+ NS::UInteger maxCallStackDepth() const;
400
+ void setMaxCallStackDepth(NS::UInteger maxCallStackDepth);
401
+
402
+ void reset();
403
+ };
404
+
405
+ class MeshRenderPipelineDescriptor : public NS::Copying<MeshRenderPipelineDescriptor>
406
+ {
407
+ public:
408
+ static class MeshRenderPipelineDescriptor* alloc();
409
+
410
+ class MeshRenderPipelineDescriptor* init();
411
+
412
+ NS::String* label() const;
413
+ void setLabel(const NS::String* label);
414
+
415
+ class Function* objectFunction() const;
416
+ void setObjectFunction(const class Function* objectFunction);
417
+
418
+ class Function* meshFunction() const;
419
+ void setMeshFunction(const class Function* meshFunction);
420
+
421
+ class Function* fragmentFunction() const;
422
+ void setFragmentFunction(const class Function* fragmentFunction);
423
+
424
+ NS::UInteger maxTotalThreadsPerObjectThreadgroup() const;
425
+ void setMaxTotalThreadsPerObjectThreadgroup(NS::UInteger maxTotalThreadsPerObjectThreadgroup);
426
+
427
+ NS::UInteger maxTotalThreadsPerMeshThreadgroup() const;
428
+ void setMaxTotalThreadsPerMeshThreadgroup(NS::UInteger maxTotalThreadsPerMeshThreadgroup);
429
+
430
+ bool objectThreadgroupSizeIsMultipleOfThreadExecutionWidth() const;
431
+ void setObjectThreadgroupSizeIsMultipleOfThreadExecutionWidth(bool objectThreadgroupSizeIsMultipleOfThreadExecutionWidth);
432
+
433
+ bool meshThreadgroupSizeIsMultipleOfThreadExecutionWidth() const;
434
+ void setMeshThreadgroupSizeIsMultipleOfThreadExecutionWidth(bool meshThreadgroupSizeIsMultipleOfThreadExecutionWidth);
435
+
436
+ NS::UInteger payloadMemoryLength() const;
437
+ void setPayloadMemoryLength(NS::UInteger payloadMemoryLength);
438
+
439
+ NS::UInteger maxTotalThreadgroupsPerMeshGrid() const;
440
+ void setMaxTotalThreadgroupsPerMeshGrid(NS::UInteger maxTotalThreadgroupsPerMeshGrid);
441
+
442
+ class PipelineBufferDescriptorArray* objectBuffers() const;
443
+
444
+ class PipelineBufferDescriptorArray* meshBuffers() const;
445
+
446
+ class PipelineBufferDescriptorArray* fragmentBuffers() const;
447
+
448
+ NS::UInteger rasterSampleCount() const;
449
+ void setRasterSampleCount(NS::UInteger rasterSampleCount);
450
+
451
+ bool alphaToCoverageEnabled() const;
452
+ void setAlphaToCoverageEnabled(bool alphaToCoverageEnabled);
453
+
454
+ bool alphaToOneEnabled() const;
455
+ void setAlphaToOneEnabled(bool alphaToOneEnabled);
456
+
457
+ bool rasterizationEnabled() const;
458
+ void setRasterizationEnabled(bool rasterizationEnabled);
459
+
460
+ NS::UInteger maxVertexAmplificationCount() const;
461
+ void setMaxVertexAmplificationCount(NS::UInteger maxVertexAmplificationCount);
462
+
463
+ class RenderPipelineColorAttachmentDescriptorArray* colorAttachments() const;
464
+
465
+ MTL::PixelFormat depthAttachmentPixelFormat() const;
466
+ void setDepthAttachmentPixelFormat(MTL::PixelFormat depthAttachmentPixelFormat);
467
+
468
+ MTL::PixelFormat stencilAttachmentPixelFormat() const;
469
+ void setStencilAttachmentPixelFormat(MTL::PixelFormat stencilAttachmentPixelFormat);
470
+
471
+ class LinkedFunctions* objectLinkedFunctions() const;
472
+ void setObjectLinkedFunctions(const class LinkedFunctions* objectLinkedFunctions);
473
+
474
+ class LinkedFunctions* meshLinkedFunctions() const;
475
+ void setMeshLinkedFunctions(const class LinkedFunctions* meshLinkedFunctions);
476
+
477
+ class LinkedFunctions* fragmentLinkedFunctions() const;
478
+ void setFragmentLinkedFunctions(const class LinkedFunctions* fragmentLinkedFunctions);
479
+
480
+ void reset();
481
+ };
482
+
483
+ }
484
+
485
+ // static method: alloc
486
+ _MTL_INLINE MTL::RenderPipelineColorAttachmentDescriptor* MTL::RenderPipelineColorAttachmentDescriptor::alloc()
487
+ {
488
+ return NS::Object::alloc<MTL::RenderPipelineColorAttachmentDescriptor>(_MTL_PRIVATE_CLS(MTLRenderPipelineColorAttachmentDescriptor));
489
+ }
490
+
491
+ // method: init
492
+ _MTL_INLINE MTL::RenderPipelineColorAttachmentDescriptor* MTL::RenderPipelineColorAttachmentDescriptor::init()
493
+ {
494
+ return NS::Object::init<MTL::RenderPipelineColorAttachmentDescriptor>();
495
+ }
496
+
497
+ // property: pixelFormat
498
+ _MTL_INLINE MTL::PixelFormat MTL::RenderPipelineColorAttachmentDescriptor::pixelFormat() const
499
+ {
500
+ return Object::sendMessage<MTL::PixelFormat>(this, _MTL_PRIVATE_SEL(pixelFormat));
501
+ }
502
+
503
+ _MTL_INLINE void MTL::RenderPipelineColorAttachmentDescriptor::setPixelFormat(MTL::PixelFormat pixelFormat)
504
+ {
505
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setPixelFormat_), pixelFormat);
506
+ }
507
+
508
+ // property: blendingEnabled
509
+ _MTL_INLINE bool MTL::RenderPipelineColorAttachmentDescriptor::blendingEnabled() const
510
+ {
511
+ return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(isBlendingEnabled));
512
+ }
513
+
514
+ _MTL_INLINE void MTL::RenderPipelineColorAttachmentDescriptor::setBlendingEnabled(bool blendingEnabled)
515
+ {
516
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setBlendingEnabled_), blendingEnabled);
517
+ }
518
+
519
+ // property: sourceRGBBlendFactor
520
+ _MTL_INLINE MTL::BlendFactor MTL::RenderPipelineColorAttachmentDescriptor::sourceRGBBlendFactor() const
521
+ {
522
+ return Object::sendMessage<MTL::BlendFactor>(this, _MTL_PRIVATE_SEL(sourceRGBBlendFactor));
523
+ }
524
+
525
+ _MTL_INLINE void MTL::RenderPipelineColorAttachmentDescriptor::setSourceRGBBlendFactor(MTL::BlendFactor sourceRGBBlendFactor)
526
+ {
527
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setSourceRGBBlendFactor_), sourceRGBBlendFactor);
528
+ }
529
+
530
+ // property: destinationRGBBlendFactor
531
+ _MTL_INLINE MTL::BlendFactor MTL::RenderPipelineColorAttachmentDescriptor::destinationRGBBlendFactor() const
532
+ {
533
+ return Object::sendMessage<MTL::BlendFactor>(this, _MTL_PRIVATE_SEL(destinationRGBBlendFactor));
534
+ }
535
+
536
+ _MTL_INLINE void MTL::RenderPipelineColorAttachmentDescriptor::setDestinationRGBBlendFactor(MTL::BlendFactor destinationRGBBlendFactor)
537
+ {
538
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setDestinationRGBBlendFactor_), destinationRGBBlendFactor);
539
+ }
540
+
541
+ // property: rgbBlendOperation
542
+ _MTL_INLINE MTL::BlendOperation MTL::RenderPipelineColorAttachmentDescriptor::rgbBlendOperation() const
543
+ {
544
+ return Object::sendMessage<MTL::BlendOperation>(this, _MTL_PRIVATE_SEL(rgbBlendOperation));
545
+ }
546
+
547
+ _MTL_INLINE void MTL::RenderPipelineColorAttachmentDescriptor::setRgbBlendOperation(MTL::BlendOperation rgbBlendOperation)
548
+ {
549
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setRgbBlendOperation_), rgbBlendOperation);
550
+ }
551
+
552
+ // property: sourceAlphaBlendFactor
553
+ _MTL_INLINE MTL::BlendFactor MTL::RenderPipelineColorAttachmentDescriptor::sourceAlphaBlendFactor() const
554
+ {
555
+ return Object::sendMessage<MTL::BlendFactor>(this, _MTL_PRIVATE_SEL(sourceAlphaBlendFactor));
556
+ }
557
+
558
+ _MTL_INLINE void MTL::RenderPipelineColorAttachmentDescriptor::setSourceAlphaBlendFactor(MTL::BlendFactor sourceAlphaBlendFactor)
559
+ {
560
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setSourceAlphaBlendFactor_), sourceAlphaBlendFactor);
561
+ }
562
+
563
+ // property: destinationAlphaBlendFactor
564
+ _MTL_INLINE MTL::BlendFactor MTL::RenderPipelineColorAttachmentDescriptor::destinationAlphaBlendFactor() const
565
+ {
566
+ return Object::sendMessage<MTL::BlendFactor>(this, _MTL_PRIVATE_SEL(destinationAlphaBlendFactor));
567
+ }
568
+
569
+ _MTL_INLINE void MTL::RenderPipelineColorAttachmentDescriptor::setDestinationAlphaBlendFactor(MTL::BlendFactor destinationAlphaBlendFactor)
570
+ {
571
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setDestinationAlphaBlendFactor_), destinationAlphaBlendFactor);
572
+ }
573
+
574
+ // property: alphaBlendOperation
575
+ _MTL_INLINE MTL::BlendOperation MTL::RenderPipelineColorAttachmentDescriptor::alphaBlendOperation() const
576
+ {
577
+ return Object::sendMessage<MTL::BlendOperation>(this, _MTL_PRIVATE_SEL(alphaBlendOperation));
578
+ }
579
+
580
+ _MTL_INLINE void MTL::RenderPipelineColorAttachmentDescriptor::setAlphaBlendOperation(MTL::BlendOperation alphaBlendOperation)
581
+ {
582
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setAlphaBlendOperation_), alphaBlendOperation);
583
+ }
584
+
585
+ // property: writeMask
586
+ _MTL_INLINE MTL::ColorWriteMask MTL::RenderPipelineColorAttachmentDescriptor::writeMask() const
587
+ {
588
+ return Object::sendMessage<MTL::ColorWriteMask>(this, _MTL_PRIVATE_SEL(writeMask));
589
+ }
590
+
591
+ _MTL_INLINE void MTL::RenderPipelineColorAttachmentDescriptor::setWriteMask(MTL::ColorWriteMask writeMask)
592
+ {
593
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setWriteMask_), writeMask);
594
+ }
595
+
596
+ // static method: alloc
597
+ _MTL_INLINE MTL::RenderPipelineReflection* MTL::RenderPipelineReflection::alloc()
598
+ {
599
+ return NS::Object::alloc<MTL::RenderPipelineReflection>(_MTL_PRIVATE_CLS(MTLRenderPipelineReflection));
600
+ }
601
+
602
+ // method: init
603
+ _MTL_INLINE MTL::RenderPipelineReflection* MTL::RenderPipelineReflection::init()
604
+ {
605
+ return NS::Object::init<MTL::RenderPipelineReflection>();
606
+ }
607
+
608
+ // property: vertexBindings
609
+ _MTL_INLINE NS::Array* MTL::RenderPipelineReflection::vertexBindings() const
610
+ {
611
+ return Object::sendMessage<NS::Array*>(this, _MTL_PRIVATE_SEL(vertexBindings));
612
+ }
613
+
614
+ // property: fragmentBindings
615
+ _MTL_INLINE NS::Array* MTL::RenderPipelineReflection::fragmentBindings() const
616
+ {
617
+ return Object::sendMessage<NS::Array*>(this, _MTL_PRIVATE_SEL(fragmentBindings));
618
+ }
619
+
620
+ // property: tileBindings
621
+ _MTL_INLINE NS::Array* MTL::RenderPipelineReflection::tileBindings() const
622
+ {
623
+ return Object::sendMessage<NS::Array*>(this, _MTL_PRIVATE_SEL(tileBindings));
624
+ }
625
+
626
+ // property: objectBindings
627
+ _MTL_INLINE NS::Array* MTL::RenderPipelineReflection::objectBindings() const
628
+ {
629
+ return Object::sendMessage<NS::Array*>(this, _MTL_PRIVATE_SEL(objectBindings));
630
+ }
631
+
632
+ // property: meshBindings
633
+ _MTL_INLINE NS::Array* MTL::RenderPipelineReflection::meshBindings() const
634
+ {
635
+ return Object::sendMessage<NS::Array*>(this, _MTL_PRIVATE_SEL(meshBindings));
636
+ }
637
+
638
+ // property: vertexArguments
639
+ _MTL_INLINE NS::Array* MTL::RenderPipelineReflection::vertexArguments() const
640
+ {
641
+ return Object::sendMessage<NS::Array*>(this, _MTL_PRIVATE_SEL(vertexArguments));
642
+ }
643
+
644
+ // property: fragmentArguments
645
+ _MTL_INLINE NS::Array* MTL::RenderPipelineReflection::fragmentArguments() const
646
+ {
647
+ return Object::sendMessage<NS::Array*>(this, _MTL_PRIVATE_SEL(fragmentArguments));
648
+ }
649
+
650
+ // property: tileArguments
651
+ _MTL_INLINE NS::Array* MTL::RenderPipelineReflection::tileArguments() const
652
+ {
653
+ return Object::sendMessage<NS::Array*>(this, _MTL_PRIVATE_SEL(tileArguments));
654
+ }
655
+
656
+ // static method: alloc
657
+ _MTL_INLINE MTL::RenderPipelineDescriptor* MTL::RenderPipelineDescriptor::alloc()
658
+ {
659
+ return NS::Object::alloc<MTL::RenderPipelineDescriptor>(_MTL_PRIVATE_CLS(MTLRenderPipelineDescriptor));
660
+ }
661
+
662
+ // method: init
663
+ _MTL_INLINE MTL::RenderPipelineDescriptor* MTL::RenderPipelineDescriptor::init()
664
+ {
665
+ return NS::Object::init<MTL::RenderPipelineDescriptor>();
666
+ }
667
+
668
+ // property: label
669
+ _MTL_INLINE NS::String* MTL::RenderPipelineDescriptor::label() const
670
+ {
671
+ return Object::sendMessage<NS::String*>(this, _MTL_PRIVATE_SEL(label));
672
+ }
673
+
674
+ _MTL_INLINE void MTL::RenderPipelineDescriptor::setLabel(const NS::String* label)
675
+ {
676
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setLabel_), label);
677
+ }
678
+
679
+ // property: vertexFunction
680
+ _MTL_INLINE MTL::Function* MTL::RenderPipelineDescriptor::vertexFunction() const
681
+ {
682
+ return Object::sendMessage<MTL::Function*>(this, _MTL_PRIVATE_SEL(vertexFunction));
683
+ }
684
+
685
+ _MTL_INLINE void MTL::RenderPipelineDescriptor::setVertexFunction(const MTL::Function* vertexFunction)
686
+ {
687
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setVertexFunction_), vertexFunction);
688
+ }
689
+
690
+ // property: fragmentFunction
691
+ _MTL_INLINE MTL::Function* MTL::RenderPipelineDescriptor::fragmentFunction() const
692
+ {
693
+ return Object::sendMessage<MTL::Function*>(this, _MTL_PRIVATE_SEL(fragmentFunction));
694
+ }
695
+
696
+ _MTL_INLINE void MTL::RenderPipelineDescriptor::setFragmentFunction(const MTL::Function* fragmentFunction)
697
+ {
698
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setFragmentFunction_), fragmentFunction);
699
+ }
700
+
701
+ // property: vertexDescriptor
702
+ _MTL_INLINE MTL::VertexDescriptor* MTL::RenderPipelineDescriptor::vertexDescriptor() const
703
+ {
704
+ return Object::sendMessage<MTL::VertexDescriptor*>(this, _MTL_PRIVATE_SEL(vertexDescriptor));
705
+ }
706
+
707
+ _MTL_INLINE void MTL::RenderPipelineDescriptor::setVertexDescriptor(const MTL::VertexDescriptor* vertexDescriptor)
708
+ {
709
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setVertexDescriptor_), vertexDescriptor);
710
+ }
711
+
712
+ // property: sampleCount
713
+ _MTL_INLINE NS::UInteger MTL::RenderPipelineDescriptor::sampleCount() const
714
+ {
715
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(sampleCount));
716
+ }
717
+
718
+ _MTL_INLINE void MTL::RenderPipelineDescriptor::setSampleCount(NS::UInteger sampleCount)
719
+ {
720
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setSampleCount_), sampleCount);
721
+ }
722
+
723
+ // property: rasterSampleCount
724
+ _MTL_INLINE NS::UInteger MTL::RenderPipelineDescriptor::rasterSampleCount() const
725
+ {
726
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(rasterSampleCount));
727
+ }
728
+
729
+ _MTL_INLINE void MTL::RenderPipelineDescriptor::setRasterSampleCount(NS::UInteger rasterSampleCount)
730
+ {
731
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setRasterSampleCount_), rasterSampleCount);
732
+ }
733
+
734
+ // property: alphaToCoverageEnabled
735
+ _MTL_INLINE bool MTL::RenderPipelineDescriptor::alphaToCoverageEnabled() const
736
+ {
737
+ return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(isAlphaToCoverageEnabled));
738
+ }
739
+
740
+ _MTL_INLINE void MTL::RenderPipelineDescriptor::setAlphaToCoverageEnabled(bool alphaToCoverageEnabled)
741
+ {
742
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setAlphaToCoverageEnabled_), alphaToCoverageEnabled);
743
+ }
744
+
745
+ // property: alphaToOneEnabled
746
+ _MTL_INLINE bool MTL::RenderPipelineDescriptor::alphaToOneEnabled() const
747
+ {
748
+ return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(isAlphaToOneEnabled));
749
+ }
750
+
751
+ _MTL_INLINE void MTL::RenderPipelineDescriptor::setAlphaToOneEnabled(bool alphaToOneEnabled)
752
+ {
753
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setAlphaToOneEnabled_), alphaToOneEnabled);
754
+ }
755
+
756
+ // property: rasterizationEnabled
757
+ _MTL_INLINE bool MTL::RenderPipelineDescriptor::rasterizationEnabled() const
758
+ {
759
+ return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(isRasterizationEnabled));
760
+ }
761
+
762
+ _MTL_INLINE void MTL::RenderPipelineDescriptor::setRasterizationEnabled(bool rasterizationEnabled)
763
+ {
764
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setRasterizationEnabled_), rasterizationEnabled);
765
+ }
766
+
767
+ // property: maxVertexAmplificationCount
768
+ _MTL_INLINE NS::UInteger MTL::RenderPipelineDescriptor::maxVertexAmplificationCount() const
769
+ {
770
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(maxVertexAmplificationCount));
771
+ }
772
+
773
+ _MTL_INLINE void MTL::RenderPipelineDescriptor::setMaxVertexAmplificationCount(NS::UInteger maxVertexAmplificationCount)
774
+ {
775
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setMaxVertexAmplificationCount_), maxVertexAmplificationCount);
776
+ }
777
+
778
+ // property: colorAttachments
779
+ _MTL_INLINE MTL::RenderPipelineColorAttachmentDescriptorArray* MTL::RenderPipelineDescriptor::colorAttachments() const
780
+ {
781
+ return Object::sendMessage<MTL::RenderPipelineColorAttachmentDescriptorArray*>(this, _MTL_PRIVATE_SEL(colorAttachments));
782
+ }
783
+
784
+ // property: depthAttachmentPixelFormat
785
+ _MTL_INLINE MTL::PixelFormat MTL::RenderPipelineDescriptor::depthAttachmentPixelFormat() const
786
+ {
787
+ return Object::sendMessage<MTL::PixelFormat>(this, _MTL_PRIVATE_SEL(depthAttachmentPixelFormat));
788
+ }
789
+
790
+ _MTL_INLINE void MTL::RenderPipelineDescriptor::setDepthAttachmentPixelFormat(MTL::PixelFormat depthAttachmentPixelFormat)
791
+ {
792
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setDepthAttachmentPixelFormat_), depthAttachmentPixelFormat);
793
+ }
794
+
795
+ // property: stencilAttachmentPixelFormat
796
+ _MTL_INLINE MTL::PixelFormat MTL::RenderPipelineDescriptor::stencilAttachmentPixelFormat() const
797
+ {
798
+ return Object::sendMessage<MTL::PixelFormat>(this, _MTL_PRIVATE_SEL(stencilAttachmentPixelFormat));
799
+ }
800
+
801
+ _MTL_INLINE void MTL::RenderPipelineDescriptor::setStencilAttachmentPixelFormat(MTL::PixelFormat stencilAttachmentPixelFormat)
802
+ {
803
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setStencilAttachmentPixelFormat_), stencilAttachmentPixelFormat);
804
+ }
805
+
806
+ // property: inputPrimitiveTopology
807
+ _MTL_INLINE MTL::PrimitiveTopologyClass MTL::RenderPipelineDescriptor::inputPrimitiveTopology() const
808
+ {
809
+ return Object::sendMessage<MTL::PrimitiveTopologyClass>(this, _MTL_PRIVATE_SEL(inputPrimitiveTopology));
810
+ }
811
+
812
+ _MTL_INLINE void MTL::RenderPipelineDescriptor::setInputPrimitiveTopology(MTL::PrimitiveTopologyClass inputPrimitiveTopology)
813
+ {
814
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setInputPrimitiveTopology_), inputPrimitiveTopology);
815
+ }
816
+
817
+ // property: tessellationPartitionMode
818
+ _MTL_INLINE MTL::TessellationPartitionMode MTL::RenderPipelineDescriptor::tessellationPartitionMode() const
819
+ {
820
+ return Object::sendMessage<MTL::TessellationPartitionMode>(this, _MTL_PRIVATE_SEL(tessellationPartitionMode));
821
+ }
822
+
823
+ _MTL_INLINE void MTL::RenderPipelineDescriptor::setTessellationPartitionMode(MTL::TessellationPartitionMode tessellationPartitionMode)
824
+ {
825
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setTessellationPartitionMode_), tessellationPartitionMode);
826
+ }
827
+
828
+ // property: maxTessellationFactor
829
+ _MTL_INLINE NS::UInteger MTL::RenderPipelineDescriptor::maxTessellationFactor() const
830
+ {
831
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(maxTessellationFactor));
832
+ }
833
+
834
+ _MTL_INLINE void MTL::RenderPipelineDescriptor::setMaxTessellationFactor(NS::UInteger maxTessellationFactor)
835
+ {
836
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setMaxTessellationFactor_), maxTessellationFactor);
837
+ }
838
+
839
+ // property: tessellationFactorScaleEnabled
840
+ _MTL_INLINE bool MTL::RenderPipelineDescriptor::tessellationFactorScaleEnabled() const
841
+ {
842
+ return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(isTessellationFactorScaleEnabled));
843
+ }
844
+
845
+ _MTL_INLINE void MTL::RenderPipelineDescriptor::setTessellationFactorScaleEnabled(bool tessellationFactorScaleEnabled)
846
+ {
847
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setTessellationFactorScaleEnabled_), tessellationFactorScaleEnabled);
848
+ }
849
+
850
+ // property: tessellationFactorFormat
851
+ _MTL_INLINE MTL::TessellationFactorFormat MTL::RenderPipelineDescriptor::tessellationFactorFormat() const
852
+ {
853
+ return Object::sendMessage<MTL::TessellationFactorFormat>(this, _MTL_PRIVATE_SEL(tessellationFactorFormat));
854
+ }
855
+
856
+ _MTL_INLINE void MTL::RenderPipelineDescriptor::setTessellationFactorFormat(MTL::TessellationFactorFormat tessellationFactorFormat)
857
+ {
858
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setTessellationFactorFormat_), tessellationFactorFormat);
859
+ }
860
+
861
+ // property: tessellationControlPointIndexType
862
+ _MTL_INLINE MTL::TessellationControlPointIndexType MTL::RenderPipelineDescriptor::tessellationControlPointIndexType() const
863
+ {
864
+ return Object::sendMessage<MTL::TessellationControlPointIndexType>(this, _MTL_PRIVATE_SEL(tessellationControlPointIndexType));
865
+ }
866
+
867
+ _MTL_INLINE void MTL::RenderPipelineDescriptor::setTessellationControlPointIndexType(MTL::TessellationControlPointIndexType tessellationControlPointIndexType)
868
+ {
869
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setTessellationControlPointIndexType_), tessellationControlPointIndexType);
870
+ }
871
+
872
+ // property: tessellationFactorStepFunction
873
+ _MTL_INLINE MTL::TessellationFactorStepFunction MTL::RenderPipelineDescriptor::tessellationFactorStepFunction() const
874
+ {
875
+ return Object::sendMessage<MTL::TessellationFactorStepFunction>(this, _MTL_PRIVATE_SEL(tessellationFactorStepFunction));
876
+ }
877
+
878
+ _MTL_INLINE void MTL::RenderPipelineDescriptor::setTessellationFactorStepFunction(MTL::TessellationFactorStepFunction tessellationFactorStepFunction)
879
+ {
880
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setTessellationFactorStepFunction_), tessellationFactorStepFunction);
881
+ }
882
+
883
+ // property: tessellationOutputWindingOrder
884
+ _MTL_INLINE MTL::Winding MTL::RenderPipelineDescriptor::tessellationOutputWindingOrder() const
885
+ {
886
+ return Object::sendMessage<MTL::Winding>(this, _MTL_PRIVATE_SEL(tessellationOutputWindingOrder));
887
+ }
888
+
889
+ _MTL_INLINE void MTL::RenderPipelineDescriptor::setTessellationOutputWindingOrder(MTL::Winding tessellationOutputWindingOrder)
890
+ {
891
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setTessellationOutputWindingOrder_), tessellationOutputWindingOrder);
892
+ }
893
+
894
+ // property: vertexBuffers
895
+ _MTL_INLINE MTL::PipelineBufferDescriptorArray* MTL::RenderPipelineDescriptor::vertexBuffers() const
896
+ {
897
+ return Object::sendMessage<MTL::PipelineBufferDescriptorArray*>(this, _MTL_PRIVATE_SEL(vertexBuffers));
898
+ }
899
+
900
+ // property: fragmentBuffers
901
+ _MTL_INLINE MTL::PipelineBufferDescriptorArray* MTL::RenderPipelineDescriptor::fragmentBuffers() const
902
+ {
903
+ return Object::sendMessage<MTL::PipelineBufferDescriptorArray*>(this, _MTL_PRIVATE_SEL(fragmentBuffers));
904
+ }
905
+
906
+ // property: supportIndirectCommandBuffers
907
+ _MTL_INLINE bool MTL::RenderPipelineDescriptor::supportIndirectCommandBuffers() const
908
+ {
909
+ return Object::sendMessageSafe<bool>(this, _MTL_PRIVATE_SEL(supportIndirectCommandBuffers));
910
+ }
911
+
912
+ _MTL_INLINE void MTL::RenderPipelineDescriptor::setSupportIndirectCommandBuffers(bool supportIndirectCommandBuffers)
913
+ {
914
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setSupportIndirectCommandBuffers_), supportIndirectCommandBuffers);
915
+ }
916
+
917
+ // property: binaryArchives
918
+ _MTL_INLINE NS::Array* MTL::RenderPipelineDescriptor::binaryArchives() const
919
+ {
920
+ return Object::sendMessage<NS::Array*>(this, _MTL_PRIVATE_SEL(binaryArchives));
921
+ }
922
+
923
+ _MTL_INLINE void MTL::RenderPipelineDescriptor::setBinaryArchives(const NS::Array* binaryArchives)
924
+ {
925
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setBinaryArchives_), binaryArchives);
926
+ }
927
+
928
+ // property: vertexPreloadedLibraries
929
+ _MTL_INLINE NS::Array* MTL::RenderPipelineDescriptor::vertexPreloadedLibraries() const
930
+ {
931
+ return Object::sendMessage<NS::Array*>(this, _MTL_PRIVATE_SEL(vertexPreloadedLibraries));
932
+ }
933
+
934
+ _MTL_INLINE void MTL::RenderPipelineDescriptor::setVertexPreloadedLibraries(const NS::Array* vertexPreloadedLibraries)
935
+ {
936
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setVertexPreloadedLibraries_), vertexPreloadedLibraries);
937
+ }
938
+
939
+ // property: fragmentPreloadedLibraries
940
+ _MTL_INLINE NS::Array* MTL::RenderPipelineDescriptor::fragmentPreloadedLibraries() const
941
+ {
942
+ return Object::sendMessage<NS::Array*>(this, _MTL_PRIVATE_SEL(fragmentPreloadedLibraries));
943
+ }
944
+
945
+ _MTL_INLINE void MTL::RenderPipelineDescriptor::setFragmentPreloadedLibraries(const NS::Array* fragmentPreloadedLibraries)
946
+ {
947
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setFragmentPreloadedLibraries_), fragmentPreloadedLibraries);
948
+ }
949
+
950
+ // property: vertexLinkedFunctions
951
+ _MTL_INLINE MTL::LinkedFunctions* MTL::RenderPipelineDescriptor::vertexLinkedFunctions() const
952
+ {
953
+ return Object::sendMessage<MTL::LinkedFunctions*>(this, _MTL_PRIVATE_SEL(vertexLinkedFunctions));
954
+ }
955
+
956
+ _MTL_INLINE void MTL::RenderPipelineDescriptor::setVertexLinkedFunctions(const MTL::LinkedFunctions* vertexLinkedFunctions)
957
+ {
958
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setVertexLinkedFunctions_), vertexLinkedFunctions);
959
+ }
960
+
961
+ // property: fragmentLinkedFunctions
962
+ _MTL_INLINE MTL::LinkedFunctions* MTL::RenderPipelineDescriptor::fragmentLinkedFunctions() const
963
+ {
964
+ return Object::sendMessage<MTL::LinkedFunctions*>(this, _MTL_PRIVATE_SEL(fragmentLinkedFunctions));
965
+ }
966
+
967
+ _MTL_INLINE void MTL::RenderPipelineDescriptor::setFragmentLinkedFunctions(const MTL::LinkedFunctions* fragmentLinkedFunctions)
968
+ {
969
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setFragmentLinkedFunctions_), fragmentLinkedFunctions);
970
+ }
971
+
972
+ // property: supportAddingVertexBinaryFunctions
973
+ _MTL_INLINE bool MTL::RenderPipelineDescriptor::supportAddingVertexBinaryFunctions() const
974
+ {
975
+ return Object::sendMessageSafe<bool>(this, _MTL_PRIVATE_SEL(supportAddingVertexBinaryFunctions));
976
+ }
977
+
978
+ _MTL_INLINE void MTL::RenderPipelineDescriptor::setSupportAddingVertexBinaryFunctions(bool supportAddingVertexBinaryFunctions)
979
+ {
980
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setSupportAddingVertexBinaryFunctions_), supportAddingVertexBinaryFunctions);
981
+ }
982
+
983
+ // property: supportAddingFragmentBinaryFunctions
984
+ _MTL_INLINE bool MTL::RenderPipelineDescriptor::supportAddingFragmentBinaryFunctions() const
985
+ {
986
+ return Object::sendMessageSafe<bool>(this, _MTL_PRIVATE_SEL(supportAddingFragmentBinaryFunctions));
987
+ }
988
+
989
+ _MTL_INLINE void MTL::RenderPipelineDescriptor::setSupportAddingFragmentBinaryFunctions(bool supportAddingFragmentBinaryFunctions)
990
+ {
991
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setSupportAddingFragmentBinaryFunctions_), supportAddingFragmentBinaryFunctions);
992
+ }
993
+
994
+ // property: maxVertexCallStackDepth
995
+ _MTL_INLINE NS::UInteger MTL::RenderPipelineDescriptor::maxVertexCallStackDepth() const
996
+ {
997
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(maxVertexCallStackDepth));
998
+ }
999
+
1000
+ _MTL_INLINE void MTL::RenderPipelineDescriptor::setMaxVertexCallStackDepth(NS::UInteger maxVertexCallStackDepth)
1001
+ {
1002
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setMaxVertexCallStackDepth_), maxVertexCallStackDepth);
1003
+ }
1004
+
1005
+ // property: maxFragmentCallStackDepth
1006
+ _MTL_INLINE NS::UInteger MTL::RenderPipelineDescriptor::maxFragmentCallStackDepth() const
1007
+ {
1008
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(maxFragmentCallStackDepth));
1009
+ }
1010
+
1011
+ _MTL_INLINE void MTL::RenderPipelineDescriptor::setMaxFragmentCallStackDepth(NS::UInteger maxFragmentCallStackDepth)
1012
+ {
1013
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setMaxFragmentCallStackDepth_), maxFragmentCallStackDepth);
1014
+ }
1015
+
1016
+ // method: reset
1017
+ _MTL_INLINE void MTL::RenderPipelineDescriptor::reset()
1018
+ {
1019
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(reset));
1020
+ }
1021
+
1022
+ // static method: alloc
1023
+ _MTL_INLINE MTL::RenderPipelineFunctionsDescriptor* MTL::RenderPipelineFunctionsDescriptor::alloc()
1024
+ {
1025
+ return NS::Object::alloc<MTL::RenderPipelineFunctionsDescriptor>(_MTL_PRIVATE_CLS(MTLRenderPipelineFunctionsDescriptor));
1026
+ }
1027
+
1028
+ // method: init
1029
+ _MTL_INLINE MTL::RenderPipelineFunctionsDescriptor* MTL::RenderPipelineFunctionsDescriptor::init()
1030
+ {
1031
+ return NS::Object::init<MTL::RenderPipelineFunctionsDescriptor>();
1032
+ }
1033
+
1034
+ // property: vertexAdditionalBinaryFunctions
1035
+ _MTL_INLINE NS::Array* MTL::RenderPipelineFunctionsDescriptor::vertexAdditionalBinaryFunctions() const
1036
+ {
1037
+ return Object::sendMessage<NS::Array*>(this, _MTL_PRIVATE_SEL(vertexAdditionalBinaryFunctions));
1038
+ }
1039
+
1040
+ _MTL_INLINE void MTL::RenderPipelineFunctionsDescriptor::setVertexAdditionalBinaryFunctions(const NS::Array* vertexAdditionalBinaryFunctions)
1041
+ {
1042
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setVertexAdditionalBinaryFunctions_), vertexAdditionalBinaryFunctions);
1043
+ }
1044
+
1045
+ // property: fragmentAdditionalBinaryFunctions
1046
+ _MTL_INLINE NS::Array* MTL::RenderPipelineFunctionsDescriptor::fragmentAdditionalBinaryFunctions() const
1047
+ {
1048
+ return Object::sendMessage<NS::Array*>(this, _MTL_PRIVATE_SEL(fragmentAdditionalBinaryFunctions));
1049
+ }
1050
+
1051
+ _MTL_INLINE void MTL::RenderPipelineFunctionsDescriptor::setFragmentAdditionalBinaryFunctions(const NS::Array* fragmentAdditionalBinaryFunctions)
1052
+ {
1053
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setFragmentAdditionalBinaryFunctions_), fragmentAdditionalBinaryFunctions);
1054
+ }
1055
+
1056
+ // property: tileAdditionalBinaryFunctions
1057
+ _MTL_INLINE NS::Array* MTL::RenderPipelineFunctionsDescriptor::tileAdditionalBinaryFunctions() const
1058
+ {
1059
+ return Object::sendMessage<NS::Array*>(this, _MTL_PRIVATE_SEL(tileAdditionalBinaryFunctions));
1060
+ }
1061
+
1062
+ _MTL_INLINE void MTL::RenderPipelineFunctionsDescriptor::setTileAdditionalBinaryFunctions(const NS::Array* tileAdditionalBinaryFunctions)
1063
+ {
1064
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setTileAdditionalBinaryFunctions_), tileAdditionalBinaryFunctions);
1065
+ }
1066
+
1067
+ // property: label
1068
+ _MTL_INLINE NS::String* MTL::RenderPipelineState::label() const
1069
+ {
1070
+ return Object::sendMessage<NS::String*>(this, _MTL_PRIVATE_SEL(label));
1071
+ }
1072
+
1073
+ // property: device
1074
+ _MTL_INLINE MTL::Device* MTL::RenderPipelineState::device() const
1075
+ {
1076
+ return Object::sendMessage<MTL::Device*>(this, _MTL_PRIVATE_SEL(device));
1077
+ }
1078
+
1079
+ // property: maxTotalThreadsPerThreadgroup
1080
+ _MTL_INLINE NS::UInteger MTL::RenderPipelineState::maxTotalThreadsPerThreadgroup() const
1081
+ {
1082
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(maxTotalThreadsPerThreadgroup));
1083
+ }
1084
+
1085
+ // property: threadgroupSizeMatchesTileSize
1086
+ _MTL_INLINE bool MTL::RenderPipelineState::threadgroupSizeMatchesTileSize() const
1087
+ {
1088
+ return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(threadgroupSizeMatchesTileSize));
1089
+ }
1090
+
1091
+ // property: imageblockSampleLength
1092
+ _MTL_INLINE NS::UInteger MTL::RenderPipelineState::imageblockSampleLength() const
1093
+ {
1094
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(imageblockSampleLength));
1095
+ }
1096
+
1097
+ // method: imageblockMemoryLengthForDimensions:
1098
+ _MTL_INLINE NS::UInteger MTL::RenderPipelineState::imageblockMemoryLength(MTL::Size imageblockDimensions)
1099
+ {
1100
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(imageblockMemoryLengthForDimensions_), imageblockDimensions);
1101
+ }
1102
+
1103
+ // property: supportIndirectCommandBuffers
1104
+ _MTL_INLINE bool MTL::RenderPipelineState::supportIndirectCommandBuffers() const
1105
+ {
1106
+ return Object::sendMessageSafe<bool>(this, _MTL_PRIVATE_SEL(supportIndirectCommandBuffers));
1107
+ }
1108
+
1109
+ // property: maxTotalThreadsPerObjectThreadgroup
1110
+ _MTL_INLINE NS::UInteger MTL::RenderPipelineState::maxTotalThreadsPerObjectThreadgroup() const
1111
+ {
1112
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(maxTotalThreadsPerObjectThreadgroup));
1113
+ }
1114
+
1115
+ // property: maxTotalThreadsPerMeshThreadgroup
1116
+ _MTL_INLINE NS::UInteger MTL::RenderPipelineState::maxTotalThreadsPerMeshThreadgroup() const
1117
+ {
1118
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(maxTotalThreadsPerMeshThreadgroup));
1119
+ }
1120
+
1121
+ // property: objectThreadExecutionWidth
1122
+ _MTL_INLINE NS::UInteger MTL::RenderPipelineState::objectThreadExecutionWidth() const
1123
+ {
1124
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(objectThreadExecutionWidth));
1125
+ }
1126
+
1127
+ // property: meshThreadExecutionWidth
1128
+ _MTL_INLINE NS::UInteger MTL::RenderPipelineState::meshThreadExecutionWidth() const
1129
+ {
1130
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(meshThreadExecutionWidth));
1131
+ }
1132
+
1133
+ // property: maxTotalThreadgroupsPerMeshGrid
1134
+ _MTL_INLINE NS::UInteger MTL::RenderPipelineState::maxTotalThreadgroupsPerMeshGrid() const
1135
+ {
1136
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(maxTotalThreadgroupsPerMeshGrid));
1137
+ }
1138
+
1139
+ // property: gpuResourceID
1140
+ _MTL_INLINE MTL::ResourceID MTL::RenderPipelineState::gpuResourceID() const
1141
+ {
1142
+ return Object::sendMessage<MTL::ResourceID>(this, _MTL_PRIVATE_SEL(gpuResourceID));
1143
+ }
1144
+
1145
+ // method: functionHandleWithFunction:stage:
1146
+ _MTL_INLINE MTL::FunctionHandle* MTL::RenderPipelineState::functionHandle(const MTL::Function* function, MTL::RenderStages stage)
1147
+ {
1148
+ return Object::sendMessage<MTL::FunctionHandle*>(this, _MTL_PRIVATE_SEL(functionHandleWithFunction_stage_), function, stage);
1149
+ }
1150
+
1151
+ // method: newVisibleFunctionTableWithDescriptor:stage:
1152
+ _MTL_INLINE MTL::VisibleFunctionTable* MTL::RenderPipelineState::newVisibleFunctionTable(const MTL::VisibleFunctionTableDescriptor* descriptor, MTL::RenderStages stage)
1153
+ {
1154
+ return Object::sendMessage<MTL::VisibleFunctionTable*>(this, _MTL_PRIVATE_SEL(newVisibleFunctionTableWithDescriptor_stage_), descriptor, stage);
1155
+ }
1156
+
1157
+ // method: newIntersectionFunctionTableWithDescriptor:stage:
1158
+ _MTL_INLINE MTL::IntersectionFunctionTable* MTL::RenderPipelineState::newIntersectionFunctionTable(const MTL::IntersectionFunctionTableDescriptor* descriptor, MTL::RenderStages stage)
1159
+ {
1160
+ return Object::sendMessage<MTL::IntersectionFunctionTable*>(this, _MTL_PRIVATE_SEL(newIntersectionFunctionTableWithDescriptor_stage_), descriptor, stage);
1161
+ }
1162
+
1163
+ // method: newRenderPipelineStateWithAdditionalBinaryFunctions:error:
1164
+ _MTL_INLINE MTL::RenderPipelineState* MTL::RenderPipelineState::newRenderPipelineState(const MTL::RenderPipelineFunctionsDescriptor* additionalBinaryFunctions, NS::Error** error)
1165
+ {
1166
+ return Object::sendMessage<MTL::RenderPipelineState*>(this, _MTL_PRIVATE_SEL(newRenderPipelineStateWithAdditionalBinaryFunctions_error_), additionalBinaryFunctions, error);
1167
+ }
1168
+
1169
+ // static method: alloc
1170
+ _MTL_INLINE MTL::RenderPipelineColorAttachmentDescriptorArray* MTL::RenderPipelineColorAttachmentDescriptorArray::alloc()
1171
+ {
1172
+ return NS::Object::alloc<MTL::RenderPipelineColorAttachmentDescriptorArray>(_MTL_PRIVATE_CLS(MTLRenderPipelineColorAttachmentDescriptorArray));
1173
+ }
1174
+
1175
+ // method: init
1176
+ _MTL_INLINE MTL::RenderPipelineColorAttachmentDescriptorArray* MTL::RenderPipelineColorAttachmentDescriptorArray::init()
1177
+ {
1178
+ return NS::Object::init<MTL::RenderPipelineColorAttachmentDescriptorArray>();
1179
+ }
1180
+
1181
+ // method: objectAtIndexedSubscript:
1182
+ _MTL_INLINE MTL::RenderPipelineColorAttachmentDescriptor* MTL::RenderPipelineColorAttachmentDescriptorArray::object(NS::UInteger attachmentIndex)
1183
+ {
1184
+ return Object::sendMessage<MTL::RenderPipelineColorAttachmentDescriptor*>(this, _MTL_PRIVATE_SEL(objectAtIndexedSubscript_), attachmentIndex);
1185
+ }
1186
+
1187
+ // method: setObject:atIndexedSubscript:
1188
+ _MTL_INLINE void MTL::RenderPipelineColorAttachmentDescriptorArray::setObject(const MTL::RenderPipelineColorAttachmentDescriptor* attachment, NS::UInteger attachmentIndex)
1189
+ {
1190
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setObject_atIndexedSubscript_), attachment, attachmentIndex);
1191
+ }
1192
+
1193
+ // static method: alloc
1194
+ _MTL_INLINE MTL::TileRenderPipelineColorAttachmentDescriptor* MTL::TileRenderPipelineColorAttachmentDescriptor::alloc()
1195
+ {
1196
+ return NS::Object::alloc<MTL::TileRenderPipelineColorAttachmentDescriptor>(_MTL_PRIVATE_CLS(MTLTileRenderPipelineColorAttachmentDescriptor));
1197
+ }
1198
+
1199
+ // method: init
1200
+ _MTL_INLINE MTL::TileRenderPipelineColorAttachmentDescriptor* MTL::TileRenderPipelineColorAttachmentDescriptor::init()
1201
+ {
1202
+ return NS::Object::init<MTL::TileRenderPipelineColorAttachmentDescriptor>();
1203
+ }
1204
+
1205
+ // property: pixelFormat
1206
+ _MTL_INLINE MTL::PixelFormat MTL::TileRenderPipelineColorAttachmentDescriptor::pixelFormat() const
1207
+ {
1208
+ return Object::sendMessage<MTL::PixelFormat>(this, _MTL_PRIVATE_SEL(pixelFormat));
1209
+ }
1210
+
1211
+ _MTL_INLINE void MTL::TileRenderPipelineColorAttachmentDescriptor::setPixelFormat(MTL::PixelFormat pixelFormat)
1212
+ {
1213
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setPixelFormat_), pixelFormat);
1214
+ }
1215
+
1216
+ // static method: alloc
1217
+ _MTL_INLINE MTL::TileRenderPipelineColorAttachmentDescriptorArray* MTL::TileRenderPipelineColorAttachmentDescriptorArray::alloc()
1218
+ {
1219
+ return NS::Object::alloc<MTL::TileRenderPipelineColorAttachmentDescriptorArray>(_MTL_PRIVATE_CLS(MTLTileRenderPipelineColorAttachmentDescriptorArray));
1220
+ }
1221
+
1222
+ // method: init
1223
+ _MTL_INLINE MTL::TileRenderPipelineColorAttachmentDescriptorArray* MTL::TileRenderPipelineColorAttachmentDescriptorArray::init()
1224
+ {
1225
+ return NS::Object::init<MTL::TileRenderPipelineColorAttachmentDescriptorArray>();
1226
+ }
1227
+
1228
+ // method: objectAtIndexedSubscript:
1229
+ _MTL_INLINE MTL::TileRenderPipelineColorAttachmentDescriptor* MTL::TileRenderPipelineColorAttachmentDescriptorArray::object(NS::UInteger attachmentIndex)
1230
+ {
1231
+ return Object::sendMessage<MTL::TileRenderPipelineColorAttachmentDescriptor*>(this, _MTL_PRIVATE_SEL(objectAtIndexedSubscript_), attachmentIndex);
1232
+ }
1233
+
1234
+ // method: setObject:atIndexedSubscript:
1235
+ _MTL_INLINE void MTL::TileRenderPipelineColorAttachmentDescriptorArray::setObject(const MTL::TileRenderPipelineColorAttachmentDescriptor* attachment, NS::UInteger attachmentIndex)
1236
+ {
1237
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setObject_atIndexedSubscript_), attachment, attachmentIndex);
1238
+ }
1239
+
1240
+ // static method: alloc
1241
+ _MTL_INLINE MTL::TileRenderPipelineDescriptor* MTL::TileRenderPipelineDescriptor::alloc()
1242
+ {
1243
+ return NS::Object::alloc<MTL::TileRenderPipelineDescriptor>(_MTL_PRIVATE_CLS(MTLTileRenderPipelineDescriptor));
1244
+ }
1245
+
1246
+ // method: init
1247
+ _MTL_INLINE MTL::TileRenderPipelineDescriptor* MTL::TileRenderPipelineDescriptor::init()
1248
+ {
1249
+ return NS::Object::init<MTL::TileRenderPipelineDescriptor>();
1250
+ }
1251
+
1252
+ // property: label
1253
+ _MTL_INLINE NS::String* MTL::TileRenderPipelineDescriptor::label() const
1254
+ {
1255
+ return Object::sendMessage<NS::String*>(this, _MTL_PRIVATE_SEL(label));
1256
+ }
1257
+
1258
+ _MTL_INLINE void MTL::TileRenderPipelineDescriptor::setLabel(const NS::String* label)
1259
+ {
1260
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setLabel_), label);
1261
+ }
1262
+
1263
+ // property: tileFunction
1264
+ _MTL_INLINE MTL::Function* MTL::TileRenderPipelineDescriptor::tileFunction() const
1265
+ {
1266
+ return Object::sendMessage<MTL::Function*>(this, _MTL_PRIVATE_SEL(tileFunction));
1267
+ }
1268
+
1269
+ _MTL_INLINE void MTL::TileRenderPipelineDescriptor::setTileFunction(const MTL::Function* tileFunction)
1270
+ {
1271
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setTileFunction_), tileFunction);
1272
+ }
1273
+
1274
+ // property: rasterSampleCount
1275
+ _MTL_INLINE NS::UInteger MTL::TileRenderPipelineDescriptor::rasterSampleCount() const
1276
+ {
1277
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(rasterSampleCount));
1278
+ }
1279
+
1280
+ _MTL_INLINE void MTL::TileRenderPipelineDescriptor::setRasterSampleCount(NS::UInteger rasterSampleCount)
1281
+ {
1282
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setRasterSampleCount_), rasterSampleCount);
1283
+ }
1284
+
1285
+ // property: colorAttachments
1286
+ _MTL_INLINE MTL::TileRenderPipelineColorAttachmentDescriptorArray* MTL::TileRenderPipelineDescriptor::colorAttachments() const
1287
+ {
1288
+ return Object::sendMessage<MTL::TileRenderPipelineColorAttachmentDescriptorArray*>(this, _MTL_PRIVATE_SEL(colorAttachments));
1289
+ }
1290
+
1291
+ // property: threadgroupSizeMatchesTileSize
1292
+ _MTL_INLINE bool MTL::TileRenderPipelineDescriptor::threadgroupSizeMatchesTileSize() const
1293
+ {
1294
+ return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(threadgroupSizeMatchesTileSize));
1295
+ }
1296
+
1297
+ _MTL_INLINE void MTL::TileRenderPipelineDescriptor::setThreadgroupSizeMatchesTileSize(bool threadgroupSizeMatchesTileSize)
1298
+ {
1299
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setThreadgroupSizeMatchesTileSize_), threadgroupSizeMatchesTileSize);
1300
+ }
1301
+
1302
+ // property: tileBuffers
1303
+ _MTL_INLINE MTL::PipelineBufferDescriptorArray* MTL::TileRenderPipelineDescriptor::tileBuffers() const
1304
+ {
1305
+ return Object::sendMessage<MTL::PipelineBufferDescriptorArray*>(this, _MTL_PRIVATE_SEL(tileBuffers));
1306
+ }
1307
+
1308
+ // property: maxTotalThreadsPerThreadgroup
1309
+ _MTL_INLINE NS::UInteger MTL::TileRenderPipelineDescriptor::maxTotalThreadsPerThreadgroup() const
1310
+ {
1311
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(maxTotalThreadsPerThreadgroup));
1312
+ }
1313
+
1314
+ _MTL_INLINE void MTL::TileRenderPipelineDescriptor::setMaxTotalThreadsPerThreadgroup(NS::UInteger maxTotalThreadsPerThreadgroup)
1315
+ {
1316
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setMaxTotalThreadsPerThreadgroup_), maxTotalThreadsPerThreadgroup);
1317
+ }
1318
+
1319
+ // property: binaryArchives
1320
+ _MTL_INLINE NS::Array* MTL::TileRenderPipelineDescriptor::binaryArchives() const
1321
+ {
1322
+ return Object::sendMessage<NS::Array*>(this, _MTL_PRIVATE_SEL(binaryArchives));
1323
+ }
1324
+
1325
+ _MTL_INLINE void MTL::TileRenderPipelineDescriptor::setBinaryArchives(const NS::Array* binaryArchives)
1326
+ {
1327
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setBinaryArchives_), binaryArchives);
1328
+ }
1329
+
1330
+ // property: preloadedLibraries
1331
+ _MTL_INLINE NS::Array* MTL::TileRenderPipelineDescriptor::preloadedLibraries() const
1332
+ {
1333
+ return Object::sendMessage<NS::Array*>(this, _MTL_PRIVATE_SEL(preloadedLibraries));
1334
+ }
1335
+
1336
+ _MTL_INLINE void MTL::TileRenderPipelineDescriptor::setPreloadedLibraries(const NS::Array* preloadedLibraries)
1337
+ {
1338
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setPreloadedLibraries_), preloadedLibraries);
1339
+ }
1340
+
1341
+ // property: linkedFunctions
1342
+ _MTL_INLINE MTL::LinkedFunctions* MTL::TileRenderPipelineDescriptor::linkedFunctions() const
1343
+ {
1344
+ return Object::sendMessage<MTL::LinkedFunctions*>(this, _MTL_PRIVATE_SEL(linkedFunctions));
1345
+ }
1346
+
1347
+ _MTL_INLINE void MTL::TileRenderPipelineDescriptor::setLinkedFunctions(const MTL::LinkedFunctions* linkedFunctions)
1348
+ {
1349
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setLinkedFunctions_), linkedFunctions);
1350
+ }
1351
+
1352
+ // property: supportAddingBinaryFunctions
1353
+ _MTL_INLINE bool MTL::TileRenderPipelineDescriptor::supportAddingBinaryFunctions() const
1354
+ {
1355
+ return Object::sendMessageSafe<bool>(this, _MTL_PRIVATE_SEL(supportAddingBinaryFunctions));
1356
+ }
1357
+
1358
+ _MTL_INLINE void MTL::TileRenderPipelineDescriptor::setSupportAddingBinaryFunctions(bool supportAddingBinaryFunctions)
1359
+ {
1360
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setSupportAddingBinaryFunctions_), supportAddingBinaryFunctions);
1361
+ }
1362
+
1363
+ // property: maxCallStackDepth
1364
+ _MTL_INLINE NS::UInteger MTL::TileRenderPipelineDescriptor::maxCallStackDepth() const
1365
+ {
1366
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(maxCallStackDepth));
1367
+ }
1368
+
1369
+ _MTL_INLINE void MTL::TileRenderPipelineDescriptor::setMaxCallStackDepth(NS::UInteger maxCallStackDepth)
1370
+ {
1371
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setMaxCallStackDepth_), maxCallStackDepth);
1372
+ }
1373
+
1374
+ // method: reset
1375
+ _MTL_INLINE void MTL::TileRenderPipelineDescriptor::reset()
1376
+ {
1377
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(reset));
1378
+ }
1379
+
1380
+ // static method: alloc
1381
+ _MTL_INLINE MTL::MeshRenderPipelineDescriptor* MTL::MeshRenderPipelineDescriptor::alloc()
1382
+ {
1383
+ return NS::Object::alloc<MTL::MeshRenderPipelineDescriptor>(_MTL_PRIVATE_CLS(MTLMeshRenderPipelineDescriptor));
1384
+ }
1385
+
1386
+ // method: init
1387
+ _MTL_INLINE MTL::MeshRenderPipelineDescriptor* MTL::MeshRenderPipelineDescriptor::init()
1388
+ {
1389
+ return NS::Object::init<MTL::MeshRenderPipelineDescriptor>();
1390
+ }
1391
+
1392
+ // property: label
1393
+ _MTL_INLINE NS::String* MTL::MeshRenderPipelineDescriptor::label() const
1394
+ {
1395
+ return Object::sendMessage<NS::String*>(this, _MTL_PRIVATE_SEL(label));
1396
+ }
1397
+
1398
+ _MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setLabel(const NS::String* label)
1399
+ {
1400
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setLabel_), label);
1401
+ }
1402
+
1403
+ // property: objectFunction
1404
+ _MTL_INLINE MTL::Function* MTL::MeshRenderPipelineDescriptor::objectFunction() const
1405
+ {
1406
+ return Object::sendMessage<MTL::Function*>(this, _MTL_PRIVATE_SEL(objectFunction));
1407
+ }
1408
+
1409
+ _MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setObjectFunction(const MTL::Function* objectFunction)
1410
+ {
1411
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setObjectFunction_), objectFunction);
1412
+ }
1413
+
1414
+ // property: meshFunction
1415
+ _MTL_INLINE MTL::Function* MTL::MeshRenderPipelineDescriptor::meshFunction() const
1416
+ {
1417
+ return Object::sendMessage<MTL::Function*>(this, _MTL_PRIVATE_SEL(meshFunction));
1418
+ }
1419
+
1420
+ _MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setMeshFunction(const MTL::Function* meshFunction)
1421
+ {
1422
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setMeshFunction_), meshFunction);
1423
+ }
1424
+
1425
+ // property: fragmentFunction
1426
+ _MTL_INLINE MTL::Function* MTL::MeshRenderPipelineDescriptor::fragmentFunction() const
1427
+ {
1428
+ return Object::sendMessage<MTL::Function*>(this, _MTL_PRIVATE_SEL(fragmentFunction));
1429
+ }
1430
+
1431
+ _MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setFragmentFunction(const MTL::Function* fragmentFunction)
1432
+ {
1433
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setFragmentFunction_), fragmentFunction);
1434
+ }
1435
+
1436
+ // property: maxTotalThreadsPerObjectThreadgroup
1437
+ _MTL_INLINE NS::UInteger MTL::MeshRenderPipelineDescriptor::maxTotalThreadsPerObjectThreadgroup() const
1438
+ {
1439
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(maxTotalThreadsPerObjectThreadgroup));
1440
+ }
1441
+
1442
+ _MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setMaxTotalThreadsPerObjectThreadgroup(NS::UInteger maxTotalThreadsPerObjectThreadgroup)
1443
+ {
1444
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setMaxTotalThreadsPerObjectThreadgroup_), maxTotalThreadsPerObjectThreadgroup);
1445
+ }
1446
+
1447
+ // property: maxTotalThreadsPerMeshThreadgroup
1448
+ _MTL_INLINE NS::UInteger MTL::MeshRenderPipelineDescriptor::maxTotalThreadsPerMeshThreadgroup() const
1449
+ {
1450
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(maxTotalThreadsPerMeshThreadgroup));
1451
+ }
1452
+
1453
+ _MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setMaxTotalThreadsPerMeshThreadgroup(NS::UInteger maxTotalThreadsPerMeshThreadgroup)
1454
+ {
1455
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setMaxTotalThreadsPerMeshThreadgroup_), maxTotalThreadsPerMeshThreadgroup);
1456
+ }
1457
+
1458
+ // property: objectThreadgroupSizeIsMultipleOfThreadExecutionWidth
1459
+ _MTL_INLINE bool MTL::MeshRenderPipelineDescriptor::objectThreadgroupSizeIsMultipleOfThreadExecutionWidth() const
1460
+ {
1461
+ return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(objectThreadgroupSizeIsMultipleOfThreadExecutionWidth));
1462
+ }
1463
+
1464
+ _MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setObjectThreadgroupSizeIsMultipleOfThreadExecutionWidth(bool objectThreadgroupSizeIsMultipleOfThreadExecutionWidth)
1465
+ {
1466
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setObjectThreadgroupSizeIsMultipleOfThreadExecutionWidth_), objectThreadgroupSizeIsMultipleOfThreadExecutionWidth);
1467
+ }
1468
+
1469
+ // property: meshThreadgroupSizeIsMultipleOfThreadExecutionWidth
1470
+ _MTL_INLINE bool MTL::MeshRenderPipelineDescriptor::meshThreadgroupSizeIsMultipleOfThreadExecutionWidth() const
1471
+ {
1472
+ return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(meshThreadgroupSizeIsMultipleOfThreadExecutionWidth));
1473
+ }
1474
+
1475
+ _MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setMeshThreadgroupSizeIsMultipleOfThreadExecutionWidth(bool meshThreadgroupSizeIsMultipleOfThreadExecutionWidth)
1476
+ {
1477
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setMeshThreadgroupSizeIsMultipleOfThreadExecutionWidth_), meshThreadgroupSizeIsMultipleOfThreadExecutionWidth);
1478
+ }
1479
+
1480
+ // property: payloadMemoryLength
1481
+ _MTL_INLINE NS::UInteger MTL::MeshRenderPipelineDescriptor::payloadMemoryLength() const
1482
+ {
1483
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(payloadMemoryLength));
1484
+ }
1485
+
1486
+ _MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setPayloadMemoryLength(NS::UInteger payloadMemoryLength)
1487
+ {
1488
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setPayloadMemoryLength_), payloadMemoryLength);
1489
+ }
1490
+
1491
+ // property: maxTotalThreadgroupsPerMeshGrid
1492
+ _MTL_INLINE NS::UInteger MTL::MeshRenderPipelineDescriptor::maxTotalThreadgroupsPerMeshGrid() const
1493
+ {
1494
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(maxTotalThreadgroupsPerMeshGrid));
1495
+ }
1496
+
1497
+ _MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setMaxTotalThreadgroupsPerMeshGrid(NS::UInteger maxTotalThreadgroupsPerMeshGrid)
1498
+ {
1499
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setMaxTotalThreadgroupsPerMeshGrid_), maxTotalThreadgroupsPerMeshGrid);
1500
+ }
1501
+
1502
+ // property: objectBuffers
1503
+ _MTL_INLINE MTL::PipelineBufferDescriptorArray* MTL::MeshRenderPipelineDescriptor::objectBuffers() const
1504
+ {
1505
+ return Object::sendMessage<MTL::PipelineBufferDescriptorArray*>(this, _MTL_PRIVATE_SEL(objectBuffers));
1506
+ }
1507
+
1508
+ // property: meshBuffers
1509
+ _MTL_INLINE MTL::PipelineBufferDescriptorArray* MTL::MeshRenderPipelineDescriptor::meshBuffers() const
1510
+ {
1511
+ return Object::sendMessage<MTL::PipelineBufferDescriptorArray*>(this, _MTL_PRIVATE_SEL(meshBuffers));
1512
+ }
1513
+
1514
+ // property: fragmentBuffers
1515
+ _MTL_INLINE MTL::PipelineBufferDescriptorArray* MTL::MeshRenderPipelineDescriptor::fragmentBuffers() const
1516
+ {
1517
+ return Object::sendMessage<MTL::PipelineBufferDescriptorArray*>(this, _MTL_PRIVATE_SEL(fragmentBuffers));
1518
+ }
1519
+
1520
+ // property: rasterSampleCount
1521
+ _MTL_INLINE NS::UInteger MTL::MeshRenderPipelineDescriptor::rasterSampleCount() const
1522
+ {
1523
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(rasterSampleCount));
1524
+ }
1525
+
1526
+ _MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setRasterSampleCount(NS::UInteger rasterSampleCount)
1527
+ {
1528
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setRasterSampleCount_), rasterSampleCount);
1529
+ }
1530
+
1531
+ // property: alphaToCoverageEnabled
1532
+ _MTL_INLINE bool MTL::MeshRenderPipelineDescriptor::alphaToCoverageEnabled() const
1533
+ {
1534
+ return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(isAlphaToCoverageEnabled));
1535
+ }
1536
+
1537
+ _MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setAlphaToCoverageEnabled(bool alphaToCoverageEnabled)
1538
+ {
1539
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setAlphaToCoverageEnabled_), alphaToCoverageEnabled);
1540
+ }
1541
+
1542
+ // property: alphaToOneEnabled
1543
+ _MTL_INLINE bool MTL::MeshRenderPipelineDescriptor::alphaToOneEnabled() const
1544
+ {
1545
+ return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(isAlphaToOneEnabled));
1546
+ }
1547
+
1548
+ _MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setAlphaToOneEnabled(bool alphaToOneEnabled)
1549
+ {
1550
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setAlphaToOneEnabled_), alphaToOneEnabled);
1551
+ }
1552
+
1553
+ // property: rasterizationEnabled
1554
+ _MTL_INLINE bool MTL::MeshRenderPipelineDescriptor::rasterizationEnabled() const
1555
+ {
1556
+ return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(isRasterizationEnabled));
1557
+ }
1558
+
1559
+ _MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setRasterizationEnabled(bool rasterizationEnabled)
1560
+ {
1561
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setRasterizationEnabled_), rasterizationEnabled);
1562
+ }
1563
+
1564
+ // property: maxVertexAmplificationCount
1565
+ _MTL_INLINE NS::UInteger MTL::MeshRenderPipelineDescriptor::maxVertexAmplificationCount() const
1566
+ {
1567
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(maxVertexAmplificationCount));
1568
+ }
1569
+
1570
+ _MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setMaxVertexAmplificationCount(NS::UInteger maxVertexAmplificationCount)
1571
+ {
1572
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setMaxVertexAmplificationCount_), maxVertexAmplificationCount);
1573
+ }
1574
+
1575
+ // property: colorAttachments
1576
+ _MTL_INLINE MTL::RenderPipelineColorAttachmentDescriptorArray* MTL::MeshRenderPipelineDescriptor::colorAttachments() const
1577
+ {
1578
+ return Object::sendMessage<MTL::RenderPipelineColorAttachmentDescriptorArray*>(this, _MTL_PRIVATE_SEL(colorAttachments));
1579
+ }
1580
+
1581
+ // property: depthAttachmentPixelFormat
1582
+ _MTL_INLINE MTL::PixelFormat MTL::MeshRenderPipelineDescriptor::depthAttachmentPixelFormat() const
1583
+ {
1584
+ return Object::sendMessage<MTL::PixelFormat>(this, _MTL_PRIVATE_SEL(depthAttachmentPixelFormat));
1585
+ }
1586
+
1587
+ _MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setDepthAttachmentPixelFormat(MTL::PixelFormat depthAttachmentPixelFormat)
1588
+ {
1589
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setDepthAttachmentPixelFormat_), depthAttachmentPixelFormat);
1590
+ }
1591
+
1592
+ // property: stencilAttachmentPixelFormat
1593
+ _MTL_INLINE MTL::PixelFormat MTL::MeshRenderPipelineDescriptor::stencilAttachmentPixelFormat() const
1594
+ {
1595
+ return Object::sendMessage<MTL::PixelFormat>(this, _MTL_PRIVATE_SEL(stencilAttachmentPixelFormat));
1596
+ }
1597
+
1598
+ _MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setStencilAttachmentPixelFormat(MTL::PixelFormat stencilAttachmentPixelFormat)
1599
+ {
1600
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setStencilAttachmentPixelFormat_), stencilAttachmentPixelFormat);
1601
+ }
1602
+
1603
+ // property: objectLinkedFunctions
1604
+ _MTL_INLINE MTL::LinkedFunctions* MTL::MeshRenderPipelineDescriptor::objectLinkedFunctions() const
1605
+ {
1606
+ return Object::sendMessage<MTL::LinkedFunctions*>(this, _MTL_PRIVATE_SEL(objectLinkedFunctions));
1607
+ }
1608
+
1609
+ _MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setObjectLinkedFunctions(const MTL::LinkedFunctions* objectLinkedFunctions)
1610
+ {
1611
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setObjectLinkedFunctions_), objectLinkedFunctions);
1612
+ }
1613
+
1614
+ // property: meshLinkedFunctions
1615
+ _MTL_INLINE MTL::LinkedFunctions* MTL::MeshRenderPipelineDescriptor::meshLinkedFunctions() const
1616
+ {
1617
+ return Object::sendMessage<MTL::LinkedFunctions*>(this, _MTL_PRIVATE_SEL(meshLinkedFunctions));
1618
+ }
1619
+
1620
+ _MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setMeshLinkedFunctions(const MTL::LinkedFunctions* meshLinkedFunctions)
1621
+ {
1622
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setMeshLinkedFunctions_), meshLinkedFunctions);
1623
+ }
1624
+
1625
+ // property: fragmentLinkedFunctions
1626
+ _MTL_INLINE MTL::LinkedFunctions* MTL::MeshRenderPipelineDescriptor::fragmentLinkedFunctions() const
1627
+ {
1628
+ return Object::sendMessage<MTL::LinkedFunctions*>(this, _MTL_PRIVATE_SEL(fragmentLinkedFunctions));
1629
+ }
1630
+
1631
+ _MTL_INLINE void MTL::MeshRenderPipelineDescriptor::setFragmentLinkedFunctions(const MTL::LinkedFunctions* fragmentLinkedFunctions)
1632
+ {
1633
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setFragmentLinkedFunctions_), fragmentLinkedFunctions);
1634
+ }
1635
+
1636
+ // method: reset
1637
+ _MTL_INLINE void MTL::MeshRenderPipelineDescriptor::reset()
1638
+ {
1639
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(reset));
1640
+ }
lib/python3.11/site-packages/mlx/include/metal_cpp/Metal/MTLResource.hpp ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
2
+ //
3
+ // Metal/MTLResource.hpp
4
+ //
5
+ // Copyright 2020-2023 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 "MTLResource.hpp"
30
+
31
+ namespace MTL
32
+ {
33
+ _MTL_ENUM(NS::UInteger, PurgeableState) {
34
+ PurgeableStateKeepCurrent = 1,
35
+ PurgeableStateNonVolatile = 2,
36
+ PurgeableStateVolatile = 3,
37
+ PurgeableStateEmpty = 4,
38
+ };
39
+
40
+ _MTL_ENUM(NS::UInteger, CPUCacheMode) {
41
+ CPUCacheModeDefaultCache = 0,
42
+ CPUCacheModeWriteCombined = 1,
43
+ };
44
+
45
+ _MTL_ENUM(NS::UInteger, StorageMode) {
46
+ StorageModeShared = 0,
47
+ StorageModeManaged = 1,
48
+ StorageModePrivate = 2,
49
+ StorageModeMemoryless = 3,
50
+ };
51
+
52
+ _MTL_ENUM(NS::UInteger, HazardTrackingMode) {
53
+ HazardTrackingModeDefault = 0,
54
+ HazardTrackingModeUntracked = 1,
55
+ HazardTrackingModeTracked = 2,
56
+ };
57
+
58
+ _MTL_OPTIONS(NS::UInteger, ResourceOptions) {
59
+ ResourceStorageModeShared = 0,
60
+ ResourceHazardTrackingModeDefault = 0,
61
+ ResourceCPUCacheModeDefaultCache = 0,
62
+ ResourceOptionCPUCacheModeDefault = 0,
63
+ ResourceCPUCacheModeWriteCombined = 1,
64
+ ResourceOptionCPUCacheModeWriteCombined = 1,
65
+ ResourceStorageModeManaged = 16,
66
+ ResourceStorageModePrivate = 32,
67
+ ResourceStorageModeMemoryless = 48,
68
+ ResourceHazardTrackingModeUntracked = 256,
69
+ ResourceHazardTrackingModeTracked = 512,
70
+ };
71
+
72
+ class Resource : public NS::Referencing<Resource>
73
+ {
74
+ public:
75
+ NS::String* label() const;
76
+ void setLabel(const NS::String* label);
77
+
78
+ class Device* device() const;
79
+
80
+ MTL::CPUCacheMode cpuCacheMode() const;
81
+
82
+ MTL::StorageMode storageMode() const;
83
+
84
+ MTL::HazardTrackingMode hazardTrackingMode() const;
85
+
86
+ MTL::ResourceOptions resourceOptions() const;
87
+
88
+ MTL::PurgeableState setPurgeableState(MTL::PurgeableState state);
89
+
90
+ class Heap* heap() const;
91
+
92
+ NS::UInteger heapOffset() const;
93
+
94
+ NS::UInteger allocatedSize() const;
95
+
96
+ void makeAliasable();
97
+
98
+ bool isAliasable();
99
+ };
100
+
101
+ }
102
+
103
+ // property: label
104
+ _MTL_INLINE NS::String* MTL::Resource::label() const
105
+ {
106
+ return Object::sendMessage<NS::String*>(this, _MTL_PRIVATE_SEL(label));
107
+ }
108
+
109
+ _MTL_INLINE void MTL::Resource::setLabel(const NS::String* label)
110
+ {
111
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setLabel_), label);
112
+ }
113
+
114
+ // property: device
115
+ _MTL_INLINE MTL::Device* MTL::Resource::device() const
116
+ {
117
+ return Object::sendMessage<MTL::Device*>(this, _MTL_PRIVATE_SEL(device));
118
+ }
119
+
120
+ // property: cpuCacheMode
121
+ _MTL_INLINE MTL::CPUCacheMode MTL::Resource::cpuCacheMode() const
122
+ {
123
+ return Object::sendMessage<MTL::CPUCacheMode>(this, _MTL_PRIVATE_SEL(cpuCacheMode));
124
+ }
125
+
126
+ // property: storageMode
127
+ _MTL_INLINE MTL::StorageMode MTL::Resource::storageMode() const
128
+ {
129
+ return Object::sendMessage<MTL::StorageMode>(this, _MTL_PRIVATE_SEL(storageMode));
130
+ }
131
+
132
+ // property: hazardTrackingMode
133
+ _MTL_INLINE MTL::HazardTrackingMode MTL::Resource::hazardTrackingMode() const
134
+ {
135
+ return Object::sendMessage<MTL::HazardTrackingMode>(this, _MTL_PRIVATE_SEL(hazardTrackingMode));
136
+ }
137
+
138
+ // property: resourceOptions
139
+ _MTL_INLINE MTL::ResourceOptions MTL::Resource::resourceOptions() const
140
+ {
141
+ return Object::sendMessage<MTL::ResourceOptions>(this, _MTL_PRIVATE_SEL(resourceOptions));
142
+ }
143
+
144
+ // method: setPurgeableState:
145
+ _MTL_INLINE MTL::PurgeableState MTL::Resource::setPurgeableState(MTL::PurgeableState state)
146
+ {
147
+ return Object::sendMessage<MTL::PurgeableState>(this, _MTL_PRIVATE_SEL(setPurgeableState_), state);
148
+ }
149
+
150
+ // property: heap
151
+ _MTL_INLINE MTL::Heap* MTL::Resource::heap() const
152
+ {
153
+ return Object::sendMessage<MTL::Heap*>(this, _MTL_PRIVATE_SEL(heap));
154
+ }
155
+
156
+ // property: heapOffset
157
+ _MTL_INLINE NS::UInteger MTL::Resource::heapOffset() const
158
+ {
159
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(heapOffset));
160
+ }
161
+
162
+ // property: allocatedSize
163
+ _MTL_INLINE NS::UInteger MTL::Resource::allocatedSize() const
164
+ {
165
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(allocatedSize));
166
+ }
167
+
168
+ // method: makeAliasable
169
+ _MTL_INLINE void MTL::Resource::makeAliasable()
170
+ {
171
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(makeAliasable));
172
+ }
173
+
174
+ // method: isAliasable
175
+ _MTL_INLINE bool MTL::Resource::isAliasable()
176
+ {
177
+ return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(isAliasable));
178
+ }
lib/python3.11/site-packages/mlx/include/metal_cpp/Metal/MTLResourceStateCommandEncoder.hpp ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
2
+ //
3
+ // Metal/MTLResourceStateCommandEncoder.hpp
4
+ //
5
+ // Copyright 2020-2023 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 "MTLCommandEncoder.hpp"
30
+ #include "MTLTypes.hpp"
31
+
32
+ namespace MTL
33
+ {
34
+ _MTL_ENUM(NS::UInteger, SparseTextureMappingMode) {
35
+ SparseTextureMappingModeMap = 0,
36
+ SparseTextureMappingModeUnmap = 1,
37
+ };
38
+
39
+ struct MapIndirectArguments
40
+ {
41
+ uint32_t regionOriginX;
42
+ uint32_t regionOriginY;
43
+ uint32_t regionOriginZ;
44
+ uint32_t regionSizeWidth;
45
+ uint32_t regionSizeHeight;
46
+ uint32_t regionSizeDepth;
47
+ uint32_t mipMapLevel;
48
+ uint32_t sliceId;
49
+ } _MTL_PACKED;
50
+
51
+ class ResourceStateCommandEncoder : public NS::Referencing<ResourceStateCommandEncoder, CommandEncoder>
52
+ {
53
+ public:
54
+ void updateTextureMappings(const class Texture* texture, const MTL::SparseTextureMappingMode mode, const MTL::Region* regions, const NS::UInteger* mipLevels, const NS::UInteger* slices, NS::UInteger numRegions);
55
+
56
+ void updateTextureMapping(const class Texture* texture, const MTL::SparseTextureMappingMode mode, const MTL::Region region, const NS::UInteger mipLevel, const NS::UInteger slice);
57
+
58
+ void updateTextureMapping(const class Texture* texture, const MTL::SparseTextureMappingMode mode, const class Buffer* indirectBuffer, NS::UInteger indirectBufferOffset);
59
+
60
+ void updateFence(const class Fence* fence);
61
+
62
+ void waitForFence(const class Fence* fence);
63
+
64
+ void moveTextureMappingsFromTexture(const class Texture* sourceTexture, NS::UInteger sourceSlice, NS::UInteger sourceLevel, MTL::Origin sourceOrigin, MTL::Size sourceSize, const class Texture* destinationTexture, NS::UInteger destinationSlice, NS::UInteger destinationLevel, MTL::Origin destinationOrigin);
65
+ };
66
+
67
+ }
68
+
69
+ // method: updateTextureMappings:mode:regions:mipLevels:slices:numRegions:
70
+ _MTL_INLINE void MTL::ResourceStateCommandEncoder::updateTextureMappings(const MTL::Texture* texture, const MTL::SparseTextureMappingMode mode, const MTL::Region* regions, const NS::UInteger* mipLevels, const NS::UInteger* slices, NS::UInteger numRegions)
71
+ {
72
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(updateTextureMappings_mode_regions_mipLevels_slices_numRegions_), texture, mode, regions, mipLevels, slices, numRegions);
73
+ }
74
+
75
+ // method: updateTextureMapping:mode:region:mipLevel:slice:
76
+ _MTL_INLINE void MTL::ResourceStateCommandEncoder::updateTextureMapping(const MTL::Texture* texture, const MTL::SparseTextureMappingMode mode, const MTL::Region region, const NS::UInteger mipLevel, const NS::UInteger slice)
77
+ {
78
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(updateTextureMapping_mode_region_mipLevel_slice_), texture, mode, region, mipLevel, slice);
79
+ }
80
+
81
+ // method: updateTextureMapping:mode:indirectBuffer:indirectBufferOffset:
82
+ _MTL_INLINE void MTL::ResourceStateCommandEncoder::updateTextureMapping(const MTL::Texture* texture, const MTL::SparseTextureMappingMode mode, const MTL::Buffer* indirectBuffer, NS::UInteger indirectBufferOffset)
83
+ {
84
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(updateTextureMapping_mode_indirectBuffer_indirectBufferOffset_), texture, mode, indirectBuffer, indirectBufferOffset);
85
+ }
86
+
87
+ // method: updateFence:
88
+ _MTL_INLINE void MTL::ResourceStateCommandEncoder::updateFence(const MTL::Fence* fence)
89
+ {
90
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(updateFence_), fence);
91
+ }
92
+
93
+ // method: waitForFence:
94
+ _MTL_INLINE void MTL::ResourceStateCommandEncoder::waitForFence(const MTL::Fence* fence)
95
+ {
96
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(waitForFence_), fence);
97
+ }
98
+
99
+ // method: moveTextureMappingsFromTexture:sourceSlice:sourceLevel:sourceOrigin:sourceSize:toTexture:destinationSlice:destinationLevel:destinationOrigin:
100
+ _MTL_INLINE void MTL::ResourceStateCommandEncoder::moveTextureMappingsFromTexture(const MTL::Texture* sourceTexture, NS::UInteger sourceSlice, NS::UInteger sourceLevel, MTL::Origin sourceOrigin, MTL::Size sourceSize, const MTL::Texture* destinationTexture, NS::UInteger destinationSlice, NS::UInteger destinationLevel, MTL::Origin destinationOrigin)
101
+ {
102
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(moveTextureMappingsFromTexture_sourceSlice_sourceLevel_sourceOrigin_sourceSize_toTexture_destinationSlice_destinationLevel_destinationOrigin_), sourceTexture, sourceSlice, sourceLevel, sourceOrigin, sourceSize, destinationTexture, destinationSlice, destinationLevel, destinationOrigin);
103
+ }
lib/python3.11/site-packages/mlx/include/metal_cpp/Metal/MTLResourceStatePass.hpp ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
2
+ //
3
+ // Metal/MTLResourceStatePass.hpp
4
+ //
5
+ // Copyright 2020-2023 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
+ namespace MTL
30
+ {
31
+ class ResourceStatePassSampleBufferAttachmentDescriptor : public NS::Copying<ResourceStatePassSampleBufferAttachmentDescriptor>
32
+ {
33
+ public:
34
+ static class ResourceStatePassSampleBufferAttachmentDescriptor* alloc();
35
+
36
+ class ResourceStatePassSampleBufferAttachmentDescriptor* init();
37
+
38
+ class CounterSampleBuffer* sampleBuffer() const;
39
+ void setSampleBuffer(const class CounterSampleBuffer* sampleBuffer);
40
+
41
+ NS::UInteger startOfEncoderSampleIndex() const;
42
+ void setStartOfEncoderSampleIndex(NS::UInteger startOfEncoderSampleIndex);
43
+
44
+ NS::UInteger endOfEncoderSampleIndex() const;
45
+ void setEndOfEncoderSampleIndex(NS::UInteger endOfEncoderSampleIndex);
46
+ };
47
+
48
+ class ResourceStatePassSampleBufferAttachmentDescriptorArray : public NS::Referencing<ResourceStatePassSampleBufferAttachmentDescriptorArray>
49
+ {
50
+ public:
51
+ static class ResourceStatePassSampleBufferAttachmentDescriptorArray* alloc();
52
+
53
+ class ResourceStatePassSampleBufferAttachmentDescriptorArray* init();
54
+
55
+ class ResourceStatePassSampleBufferAttachmentDescriptor* object(NS::UInteger attachmentIndex);
56
+
57
+ void setObject(const class ResourceStatePassSampleBufferAttachmentDescriptor* attachment, NS::UInteger attachmentIndex);
58
+ };
59
+
60
+ class ResourceStatePassDescriptor : public NS::Copying<ResourceStatePassDescriptor>
61
+ {
62
+ public:
63
+ static class ResourceStatePassDescriptor* alloc();
64
+
65
+ class ResourceStatePassDescriptor* init();
66
+
67
+ static class ResourceStatePassDescriptor* resourceStatePassDescriptor();
68
+
69
+ class ResourceStatePassSampleBufferAttachmentDescriptorArray* sampleBufferAttachments() const;
70
+ };
71
+
72
+ }
73
+
74
+ // static method: alloc
75
+ _MTL_INLINE MTL::ResourceStatePassSampleBufferAttachmentDescriptor* MTL::ResourceStatePassSampleBufferAttachmentDescriptor::alloc()
76
+ {
77
+ return NS::Object::alloc<MTL::ResourceStatePassSampleBufferAttachmentDescriptor>(_MTL_PRIVATE_CLS(MTLResourceStatePassSampleBufferAttachmentDescriptor));
78
+ }
79
+
80
+ // method: init
81
+ _MTL_INLINE MTL::ResourceStatePassSampleBufferAttachmentDescriptor* MTL::ResourceStatePassSampleBufferAttachmentDescriptor::init()
82
+ {
83
+ return NS::Object::init<MTL::ResourceStatePassSampleBufferAttachmentDescriptor>();
84
+ }
85
+
86
+ // property: sampleBuffer
87
+ _MTL_INLINE MTL::CounterSampleBuffer* MTL::ResourceStatePassSampleBufferAttachmentDescriptor::sampleBuffer() const
88
+ {
89
+ return Object::sendMessage<MTL::CounterSampleBuffer*>(this, _MTL_PRIVATE_SEL(sampleBuffer));
90
+ }
91
+
92
+ _MTL_INLINE void MTL::ResourceStatePassSampleBufferAttachmentDescriptor::setSampleBuffer(const MTL::CounterSampleBuffer* sampleBuffer)
93
+ {
94
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setSampleBuffer_), sampleBuffer);
95
+ }
96
+
97
+ // property: startOfEncoderSampleIndex
98
+ _MTL_INLINE NS::UInteger MTL::ResourceStatePassSampleBufferAttachmentDescriptor::startOfEncoderSampleIndex() const
99
+ {
100
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(startOfEncoderSampleIndex));
101
+ }
102
+
103
+ _MTL_INLINE void MTL::ResourceStatePassSampleBufferAttachmentDescriptor::setStartOfEncoderSampleIndex(NS::UInteger startOfEncoderSampleIndex)
104
+ {
105
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setStartOfEncoderSampleIndex_), startOfEncoderSampleIndex);
106
+ }
107
+
108
+ // property: endOfEncoderSampleIndex
109
+ _MTL_INLINE NS::UInteger MTL::ResourceStatePassSampleBufferAttachmentDescriptor::endOfEncoderSampleIndex() const
110
+ {
111
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(endOfEncoderSampleIndex));
112
+ }
113
+
114
+ _MTL_INLINE void MTL::ResourceStatePassSampleBufferAttachmentDescriptor::setEndOfEncoderSampleIndex(NS::UInteger endOfEncoderSampleIndex)
115
+ {
116
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setEndOfEncoderSampleIndex_), endOfEncoderSampleIndex);
117
+ }
118
+
119
+ // static method: alloc
120
+ _MTL_INLINE MTL::ResourceStatePassSampleBufferAttachmentDescriptorArray* MTL::ResourceStatePassSampleBufferAttachmentDescriptorArray::alloc()
121
+ {
122
+ return NS::Object::alloc<MTL::ResourceStatePassSampleBufferAttachmentDescriptorArray>(_MTL_PRIVATE_CLS(MTLResourceStatePassSampleBufferAttachmentDescriptorArray));
123
+ }
124
+
125
+ // method: init
126
+ _MTL_INLINE MTL::ResourceStatePassSampleBufferAttachmentDescriptorArray* MTL::ResourceStatePassSampleBufferAttachmentDescriptorArray::init()
127
+ {
128
+ return NS::Object::init<MTL::ResourceStatePassSampleBufferAttachmentDescriptorArray>();
129
+ }
130
+
131
+ // method: objectAtIndexedSubscript:
132
+ _MTL_INLINE MTL::ResourceStatePassSampleBufferAttachmentDescriptor* MTL::ResourceStatePassSampleBufferAttachmentDescriptorArray::object(NS::UInteger attachmentIndex)
133
+ {
134
+ return Object::sendMessage<MTL::ResourceStatePassSampleBufferAttachmentDescriptor*>(this, _MTL_PRIVATE_SEL(objectAtIndexedSubscript_), attachmentIndex);
135
+ }
136
+
137
+ // method: setObject:atIndexedSubscript:
138
+ _MTL_INLINE void MTL::ResourceStatePassSampleBufferAttachmentDescriptorArray::setObject(const MTL::ResourceStatePassSampleBufferAttachmentDescriptor* attachment, NS::UInteger attachmentIndex)
139
+ {
140
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setObject_atIndexedSubscript_), attachment, attachmentIndex);
141
+ }
142
+
143
+ // static method: alloc
144
+ _MTL_INLINE MTL::ResourceStatePassDescriptor* MTL::ResourceStatePassDescriptor::alloc()
145
+ {
146
+ return NS::Object::alloc<MTL::ResourceStatePassDescriptor>(_MTL_PRIVATE_CLS(MTLResourceStatePassDescriptor));
147
+ }
148
+
149
+ // method: init
150
+ _MTL_INLINE MTL::ResourceStatePassDescriptor* MTL::ResourceStatePassDescriptor::init()
151
+ {
152
+ return NS::Object::init<MTL::ResourceStatePassDescriptor>();
153
+ }
154
+
155
+ // static method: resourceStatePassDescriptor
156
+ _MTL_INLINE MTL::ResourceStatePassDescriptor* MTL::ResourceStatePassDescriptor::resourceStatePassDescriptor()
157
+ {
158
+ return Object::sendMessage<MTL::ResourceStatePassDescriptor*>(_MTL_PRIVATE_CLS(MTLResourceStatePassDescriptor), _MTL_PRIVATE_SEL(resourceStatePassDescriptor));
159
+ }
160
+
161
+ // property: sampleBufferAttachments
162
+ _MTL_INLINE MTL::ResourceStatePassSampleBufferAttachmentDescriptorArray* MTL::ResourceStatePassDescriptor::sampleBufferAttachments() const
163
+ {
164
+ return Object::sendMessage<MTL::ResourceStatePassSampleBufferAttachmentDescriptorArray*>(this, _MTL_PRIVATE_SEL(sampleBufferAttachments));
165
+ }
lib/python3.11/site-packages/mlx/include/metal_cpp/Metal/MTLSampler.hpp ADDED
@@ -0,0 +1,319 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
2
+ //
3
+ // Metal/MTLSampler.hpp
4
+ //
5
+ // Copyright 2020-2023 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 "MTLDepthStencil.hpp"
30
+ #include "MTLSampler.hpp"
31
+ #include "MTLTypes.hpp"
32
+
33
+ namespace MTL
34
+ {
35
+ _MTL_ENUM(NS::UInteger, SamplerMinMagFilter) {
36
+ SamplerMinMagFilterNearest = 0,
37
+ SamplerMinMagFilterLinear = 1,
38
+ };
39
+
40
+ _MTL_ENUM(NS::UInteger, SamplerMipFilter) {
41
+ SamplerMipFilterNotMipmapped = 0,
42
+ SamplerMipFilterNearest = 1,
43
+ SamplerMipFilterLinear = 2,
44
+ };
45
+
46
+ _MTL_ENUM(NS::UInteger, SamplerAddressMode) {
47
+ SamplerAddressModeClampToEdge = 0,
48
+ SamplerAddressModeMirrorClampToEdge = 1,
49
+ SamplerAddressModeRepeat = 2,
50
+ SamplerAddressModeMirrorRepeat = 3,
51
+ SamplerAddressModeClampToZero = 4,
52
+ SamplerAddressModeClampToBorderColor = 5,
53
+ };
54
+
55
+ _MTL_ENUM(NS::UInteger, SamplerBorderColor) {
56
+ SamplerBorderColorTransparentBlack = 0,
57
+ SamplerBorderColorOpaqueBlack = 1,
58
+ SamplerBorderColorOpaqueWhite = 2,
59
+ };
60
+
61
+ class SamplerDescriptor : public NS::Copying<SamplerDescriptor>
62
+ {
63
+ public:
64
+ static class SamplerDescriptor* alloc();
65
+
66
+ class SamplerDescriptor* init();
67
+
68
+ MTL::SamplerMinMagFilter minFilter() const;
69
+ void setMinFilter(MTL::SamplerMinMagFilter minFilter);
70
+
71
+ MTL::SamplerMinMagFilter magFilter() const;
72
+ void setMagFilter(MTL::SamplerMinMagFilter magFilter);
73
+
74
+ MTL::SamplerMipFilter mipFilter() const;
75
+ void setMipFilter(MTL::SamplerMipFilter mipFilter);
76
+
77
+ NS::UInteger maxAnisotropy() const;
78
+ void setMaxAnisotropy(NS::UInteger maxAnisotropy);
79
+
80
+ MTL::SamplerAddressMode sAddressMode() const;
81
+ void setSAddressMode(MTL::SamplerAddressMode sAddressMode);
82
+
83
+ MTL::SamplerAddressMode tAddressMode() const;
84
+ void setTAddressMode(MTL::SamplerAddressMode tAddressMode);
85
+
86
+ MTL::SamplerAddressMode rAddressMode() const;
87
+ void setRAddressMode(MTL::SamplerAddressMode rAddressMode);
88
+
89
+ MTL::SamplerBorderColor borderColor() const;
90
+ void setBorderColor(MTL::SamplerBorderColor borderColor);
91
+
92
+ bool normalizedCoordinates() const;
93
+ void setNormalizedCoordinates(bool normalizedCoordinates);
94
+
95
+ float lodMinClamp() const;
96
+ void setLodMinClamp(float lodMinClamp);
97
+
98
+ float lodMaxClamp() const;
99
+ void setLodMaxClamp(float lodMaxClamp);
100
+
101
+ bool lodAverage() const;
102
+ void setLodAverage(bool lodAverage);
103
+
104
+ MTL::CompareFunction compareFunction() const;
105
+ void setCompareFunction(MTL::CompareFunction compareFunction);
106
+
107
+ bool supportArgumentBuffers() const;
108
+ void setSupportArgumentBuffers(bool supportArgumentBuffers);
109
+
110
+ NS::String* label() const;
111
+ void setLabel(const NS::String* label);
112
+ };
113
+
114
+ class SamplerState : public NS::Referencing<SamplerState>
115
+ {
116
+ public:
117
+ NS::String* label() const;
118
+
119
+ class Device* device() const;
120
+
121
+ MTL::ResourceID gpuResourceID() const;
122
+ };
123
+
124
+ }
125
+
126
+ // static method: alloc
127
+ _MTL_INLINE MTL::SamplerDescriptor* MTL::SamplerDescriptor::alloc()
128
+ {
129
+ return NS::Object::alloc<MTL::SamplerDescriptor>(_MTL_PRIVATE_CLS(MTLSamplerDescriptor));
130
+ }
131
+
132
+ // method: init
133
+ _MTL_INLINE MTL::SamplerDescriptor* MTL::SamplerDescriptor::init()
134
+ {
135
+ return NS::Object::init<MTL::SamplerDescriptor>();
136
+ }
137
+
138
+ // property: minFilter
139
+ _MTL_INLINE MTL::SamplerMinMagFilter MTL::SamplerDescriptor::minFilter() const
140
+ {
141
+ return Object::sendMessage<MTL::SamplerMinMagFilter>(this, _MTL_PRIVATE_SEL(minFilter));
142
+ }
143
+
144
+ _MTL_INLINE void MTL::SamplerDescriptor::setMinFilter(MTL::SamplerMinMagFilter minFilter)
145
+ {
146
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setMinFilter_), minFilter);
147
+ }
148
+
149
+ // property: magFilter
150
+ _MTL_INLINE MTL::SamplerMinMagFilter MTL::SamplerDescriptor::magFilter() const
151
+ {
152
+ return Object::sendMessage<MTL::SamplerMinMagFilter>(this, _MTL_PRIVATE_SEL(magFilter));
153
+ }
154
+
155
+ _MTL_INLINE void MTL::SamplerDescriptor::setMagFilter(MTL::SamplerMinMagFilter magFilter)
156
+ {
157
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setMagFilter_), magFilter);
158
+ }
159
+
160
+ // property: mipFilter
161
+ _MTL_INLINE MTL::SamplerMipFilter MTL::SamplerDescriptor::mipFilter() const
162
+ {
163
+ return Object::sendMessage<MTL::SamplerMipFilter>(this, _MTL_PRIVATE_SEL(mipFilter));
164
+ }
165
+
166
+ _MTL_INLINE void MTL::SamplerDescriptor::setMipFilter(MTL::SamplerMipFilter mipFilter)
167
+ {
168
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setMipFilter_), mipFilter);
169
+ }
170
+
171
+ // property: maxAnisotropy
172
+ _MTL_INLINE NS::UInteger MTL::SamplerDescriptor::maxAnisotropy() const
173
+ {
174
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(maxAnisotropy));
175
+ }
176
+
177
+ _MTL_INLINE void MTL::SamplerDescriptor::setMaxAnisotropy(NS::UInteger maxAnisotropy)
178
+ {
179
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setMaxAnisotropy_), maxAnisotropy);
180
+ }
181
+
182
+ // property: sAddressMode
183
+ _MTL_INLINE MTL::SamplerAddressMode MTL::SamplerDescriptor::sAddressMode() const
184
+ {
185
+ return Object::sendMessage<MTL::SamplerAddressMode>(this, _MTL_PRIVATE_SEL(sAddressMode));
186
+ }
187
+
188
+ _MTL_INLINE void MTL::SamplerDescriptor::setSAddressMode(MTL::SamplerAddressMode sAddressMode)
189
+ {
190
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setSAddressMode_), sAddressMode);
191
+ }
192
+
193
+ // property: tAddressMode
194
+ _MTL_INLINE MTL::SamplerAddressMode MTL::SamplerDescriptor::tAddressMode() const
195
+ {
196
+ return Object::sendMessage<MTL::SamplerAddressMode>(this, _MTL_PRIVATE_SEL(tAddressMode));
197
+ }
198
+
199
+ _MTL_INLINE void MTL::SamplerDescriptor::setTAddressMode(MTL::SamplerAddressMode tAddressMode)
200
+ {
201
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setTAddressMode_), tAddressMode);
202
+ }
203
+
204
+ // property: rAddressMode
205
+ _MTL_INLINE MTL::SamplerAddressMode MTL::SamplerDescriptor::rAddressMode() const
206
+ {
207
+ return Object::sendMessage<MTL::SamplerAddressMode>(this, _MTL_PRIVATE_SEL(rAddressMode));
208
+ }
209
+
210
+ _MTL_INLINE void MTL::SamplerDescriptor::setRAddressMode(MTL::SamplerAddressMode rAddressMode)
211
+ {
212
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setRAddressMode_), rAddressMode);
213
+ }
214
+
215
+ // property: borderColor
216
+ _MTL_INLINE MTL::SamplerBorderColor MTL::SamplerDescriptor::borderColor() const
217
+ {
218
+ return Object::sendMessage<MTL::SamplerBorderColor>(this, _MTL_PRIVATE_SEL(borderColor));
219
+ }
220
+
221
+ _MTL_INLINE void MTL::SamplerDescriptor::setBorderColor(MTL::SamplerBorderColor borderColor)
222
+ {
223
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setBorderColor_), borderColor);
224
+ }
225
+
226
+ // property: normalizedCoordinates
227
+ _MTL_INLINE bool MTL::SamplerDescriptor::normalizedCoordinates() const
228
+ {
229
+ return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(normalizedCoordinates));
230
+ }
231
+
232
+ _MTL_INLINE void MTL::SamplerDescriptor::setNormalizedCoordinates(bool normalizedCoordinates)
233
+ {
234
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setNormalizedCoordinates_), normalizedCoordinates);
235
+ }
236
+
237
+ // property: lodMinClamp
238
+ _MTL_INLINE float MTL::SamplerDescriptor::lodMinClamp() const
239
+ {
240
+ return Object::sendMessage<float>(this, _MTL_PRIVATE_SEL(lodMinClamp));
241
+ }
242
+
243
+ _MTL_INLINE void MTL::SamplerDescriptor::setLodMinClamp(float lodMinClamp)
244
+ {
245
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setLodMinClamp_), lodMinClamp);
246
+ }
247
+
248
+ // property: lodMaxClamp
249
+ _MTL_INLINE float MTL::SamplerDescriptor::lodMaxClamp() const
250
+ {
251
+ return Object::sendMessage<float>(this, _MTL_PRIVATE_SEL(lodMaxClamp));
252
+ }
253
+
254
+ _MTL_INLINE void MTL::SamplerDescriptor::setLodMaxClamp(float lodMaxClamp)
255
+ {
256
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setLodMaxClamp_), lodMaxClamp);
257
+ }
258
+
259
+ // property: lodAverage
260
+ _MTL_INLINE bool MTL::SamplerDescriptor::lodAverage() const
261
+ {
262
+ return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(lodAverage));
263
+ }
264
+
265
+ _MTL_INLINE void MTL::SamplerDescriptor::setLodAverage(bool lodAverage)
266
+ {
267
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setLodAverage_), lodAverage);
268
+ }
269
+
270
+ // property: compareFunction
271
+ _MTL_INLINE MTL::CompareFunction MTL::SamplerDescriptor::compareFunction() const
272
+ {
273
+ return Object::sendMessage<MTL::CompareFunction>(this, _MTL_PRIVATE_SEL(compareFunction));
274
+ }
275
+
276
+ _MTL_INLINE void MTL::SamplerDescriptor::setCompareFunction(MTL::CompareFunction compareFunction)
277
+ {
278
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setCompareFunction_), compareFunction);
279
+ }
280
+
281
+ // property: supportArgumentBuffers
282
+ _MTL_INLINE bool MTL::SamplerDescriptor::supportArgumentBuffers() const
283
+ {
284
+ return Object::sendMessageSafe<bool>(this, _MTL_PRIVATE_SEL(supportArgumentBuffers));
285
+ }
286
+
287
+ _MTL_INLINE void MTL::SamplerDescriptor::setSupportArgumentBuffers(bool supportArgumentBuffers)
288
+ {
289
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setSupportArgumentBuffers_), supportArgumentBuffers);
290
+ }
291
+
292
+ // property: label
293
+ _MTL_INLINE NS::String* MTL::SamplerDescriptor::label() const
294
+ {
295
+ return Object::sendMessage<NS::String*>(this, _MTL_PRIVATE_SEL(label));
296
+ }
297
+
298
+ _MTL_INLINE void MTL::SamplerDescriptor::setLabel(const NS::String* label)
299
+ {
300
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setLabel_), label);
301
+ }
302
+
303
+ // property: label
304
+ _MTL_INLINE NS::String* MTL::SamplerState::label() const
305
+ {
306
+ return Object::sendMessage<NS::String*>(this, _MTL_PRIVATE_SEL(label));
307
+ }
308
+
309
+ // property: device
310
+ _MTL_INLINE MTL::Device* MTL::SamplerState::device() const
311
+ {
312
+ return Object::sendMessage<MTL::Device*>(this, _MTL_PRIVATE_SEL(device));
313
+ }
314
+
315
+ // property: gpuResourceID
316
+ _MTL_INLINE MTL::ResourceID MTL::SamplerState::gpuResourceID() const
317
+ {
318
+ return Object::sendMessage<MTL::ResourceID>(this, _MTL_PRIVATE_SEL(gpuResourceID));
319
+ }
lib/python3.11/site-packages/mlx/include/metal_cpp/Metal/MTLStageInputOutputDescriptor.hpp ADDED
@@ -0,0 +1,383 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
2
+ //
3
+ // Metal/MTLStageInputOutputDescriptor.hpp
4
+ //
5
+ // Copyright 2020-2023 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 "MTLStageInputOutputDescriptor.hpp"
30
+
31
+ namespace MTL
32
+ {
33
+ _MTL_ENUM(NS::UInteger, AttributeFormat) {
34
+ AttributeFormatInvalid = 0,
35
+ AttributeFormatUChar2 = 1,
36
+ AttributeFormatUChar3 = 2,
37
+ AttributeFormatUChar4 = 3,
38
+ AttributeFormatChar2 = 4,
39
+ AttributeFormatChar3 = 5,
40
+ AttributeFormatChar4 = 6,
41
+ AttributeFormatUChar2Normalized = 7,
42
+ AttributeFormatUChar3Normalized = 8,
43
+ AttributeFormatUChar4Normalized = 9,
44
+ AttributeFormatChar2Normalized = 10,
45
+ AttributeFormatChar3Normalized = 11,
46
+ AttributeFormatChar4Normalized = 12,
47
+ AttributeFormatUShort2 = 13,
48
+ AttributeFormatUShort3 = 14,
49
+ AttributeFormatUShort4 = 15,
50
+ AttributeFormatShort2 = 16,
51
+ AttributeFormatShort3 = 17,
52
+ AttributeFormatShort4 = 18,
53
+ AttributeFormatUShort2Normalized = 19,
54
+ AttributeFormatUShort3Normalized = 20,
55
+ AttributeFormatUShort4Normalized = 21,
56
+ AttributeFormatShort2Normalized = 22,
57
+ AttributeFormatShort3Normalized = 23,
58
+ AttributeFormatShort4Normalized = 24,
59
+ AttributeFormatHalf2 = 25,
60
+ AttributeFormatHalf3 = 26,
61
+ AttributeFormatHalf4 = 27,
62
+ AttributeFormatFloat = 28,
63
+ AttributeFormatFloat2 = 29,
64
+ AttributeFormatFloat3 = 30,
65
+ AttributeFormatFloat4 = 31,
66
+ AttributeFormatInt = 32,
67
+ AttributeFormatInt2 = 33,
68
+ AttributeFormatInt3 = 34,
69
+ AttributeFormatInt4 = 35,
70
+ AttributeFormatUInt = 36,
71
+ AttributeFormatUInt2 = 37,
72
+ AttributeFormatUInt3 = 38,
73
+ AttributeFormatUInt4 = 39,
74
+ AttributeFormatInt1010102Normalized = 40,
75
+ AttributeFormatUInt1010102Normalized = 41,
76
+ AttributeFormatUChar4Normalized_BGRA = 42,
77
+ AttributeFormatUChar = 45,
78
+ AttributeFormatChar = 46,
79
+ AttributeFormatUCharNormalized = 47,
80
+ AttributeFormatCharNormalized = 48,
81
+ AttributeFormatUShort = 49,
82
+ AttributeFormatShort = 50,
83
+ AttributeFormatUShortNormalized = 51,
84
+ AttributeFormatShortNormalized = 52,
85
+ AttributeFormatHalf = 53,
86
+ AttributeFormatFloatRG11B10 = 54,
87
+ AttributeFormatFloatRGB9E5 = 55,
88
+ };
89
+
90
+ _MTL_ENUM(NS::UInteger, IndexType) {
91
+ IndexTypeUInt16 = 0,
92
+ IndexTypeUInt32 = 1,
93
+ };
94
+
95
+ _MTL_ENUM(NS::UInteger, StepFunction) {
96
+ StepFunctionConstant = 0,
97
+ StepFunctionPerVertex = 1,
98
+ StepFunctionPerInstance = 2,
99
+ StepFunctionPerPatch = 3,
100
+ StepFunctionPerPatchControlPoint = 4,
101
+ StepFunctionThreadPositionInGridX = 5,
102
+ StepFunctionThreadPositionInGridY = 6,
103
+ StepFunctionThreadPositionInGridXIndexed = 7,
104
+ StepFunctionThreadPositionInGridYIndexed = 8,
105
+ };
106
+
107
+ class BufferLayoutDescriptor : public NS::Copying<BufferLayoutDescriptor>
108
+ {
109
+ public:
110
+ static class BufferLayoutDescriptor* alloc();
111
+
112
+ class BufferLayoutDescriptor* init();
113
+
114
+ NS::UInteger stride() const;
115
+ void setStride(NS::UInteger stride);
116
+
117
+ MTL::StepFunction stepFunction() const;
118
+ void setStepFunction(MTL::StepFunction stepFunction);
119
+
120
+ NS::UInteger stepRate() const;
121
+ void setStepRate(NS::UInteger stepRate);
122
+ };
123
+
124
+ class BufferLayoutDescriptorArray : public NS::Referencing<BufferLayoutDescriptorArray>
125
+ {
126
+ public:
127
+ static class BufferLayoutDescriptorArray* alloc();
128
+
129
+ class BufferLayoutDescriptorArray* init();
130
+
131
+ class BufferLayoutDescriptor* object(NS::UInteger index);
132
+
133
+ void setObject(const class BufferLayoutDescriptor* bufferDesc, NS::UInteger index);
134
+ };
135
+
136
+ class AttributeDescriptor : public NS::Copying<AttributeDescriptor>
137
+ {
138
+ public:
139
+ static class AttributeDescriptor* alloc();
140
+
141
+ class AttributeDescriptor* init();
142
+
143
+ MTL::AttributeFormat format() const;
144
+ void setFormat(MTL::AttributeFormat format);
145
+
146
+ NS::UInteger offset() const;
147
+ void setOffset(NS::UInteger offset);
148
+
149
+ NS::UInteger bufferIndex() const;
150
+ void setBufferIndex(NS::UInteger bufferIndex);
151
+ };
152
+
153
+ class AttributeDescriptorArray : public NS::Referencing<AttributeDescriptorArray>
154
+ {
155
+ public:
156
+ static class AttributeDescriptorArray* alloc();
157
+
158
+ class AttributeDescriptorArray* init();
159
+
160
+ class AttributeDescriptor* object(NS::UInteger index);
161
+
162
+ void setObject(const class AttributeDescriptor* attributeDesc, NS::UInteger index);
163
+ };
164
+
165
+ class StageInputOutputDescriptor : public NS::Copying<StageInputOutputDescriptor>
166
+ {
167
+ public:
168
+ static class StageInputOutputDescriptor* alloc();
169
+
170
+ class StageInputOutputDescriptor* init();
171
+
172
+ static class StageInputOutputDescriptor* stageInputOutputDescriptor();
173
+
174
+ class BufferLayoutDescriptorArray* layouts() const;
175
+
176
+ class AttributeDescriptorArray* attributes() const;
177
+
178
+ MTL::IndexType indexType() const;
179
+ void setIndexType(MTL::IndexType indexType);
180
+
181
+ NS::UInteger indexBufferIndex() const;
182
+ void setIndexBufferIndex(NS::UInteger indexBufferIndex);
183
+
184
+ void reset();
185
+ };
186
+
187
+ }
188
+
189
+ // static method: alloc
190
+ _MTL_INLINE MTL::BufferLayoutDescriptor* MTL::BufferLayoutDescriptor::alloc()
191
+ {
192
+ return NS::Object::alloc<MTL::BufferLayoutDescriptor>(_MTL_PRIVATE_CLS(MTLBufferLayoutDescriptor));
193
+ }
194
+
195
+ // method: init
196
+ _MTL_INLINE MTL::BufferLayoutDescriptor* MTL::BufferLayoutDescriptor::init()
197
+ {
198
+ return NS::Object::init<MTL::BufferLayoutDescriptor>();
199
+ }
200
+
201
+ // property: stride
202
+ _MTL_INLINE NS::UInteger MTL::BufferLayoutDescriptor::stride() const
203
+ {
204
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(stride));
205
+ }
206
+
207
+ _MTL_INLINE void MTL::BufferLayoutDescriptor::setStride(NS::UInteger stride)
208
+ {
209
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setStride_), stride);
210
+ }
211
+
212
+ // property: stepFunction
213
+ _MTL_INLINE MTL::StepFunction MTL::BufferLayoutDescriptor::stepFunction() const
214
+ {
215
+ return Object::sendMessage<MTL::StepFunction>(this, _MTL_PRIVATE_SEL(stepFunction));
216
+ }
217
+
218
+ _MTL_INLINE void MTL::BufferLayoutDescriptor::setStepFunction(MTL::StepFunction stepFunction)
219
+ {
220
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setStepFunction_), stepFunction);
221
+ }
222
+
223
+ // property: stepRate
224
+ _MTL_INLINE NS::UInteger MTL::BufferLayoutDescriptor::stepRate() const
225
+ {
226
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(stepRate));
227
+ }
228
+
229
+ _MTL_INLINE void MTL::BufferLayoutDescriptor::setStepRate(NS::UInteger stepRate)
230
+ {
231
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setStepRate_), stepRate);
232
+ }
233
+
234
+ // static method: alloc
235
+ _MTL_INLINE MTL::BufferLayoutDescriptorArray* MTL::BufferLayoutDescriptorArray::alloc()
236
+ {
237
+ return NS::Object::alloc<MTL::BufferLayoutDescriptorArray>(_MTL_PRIVATE_CLS(MTLBufferLayoutDescriptorArray));
238
+ }
239
+
240
+ // method: init
241
+ _MTL_INLINE MTL::BufferLayoutDescriptorArray* MTL::BufferLayoutDescriptorArray::init()
242
+ {
243
+ return NS::Object::init<MTL::BufferLayoutDescriptorArray>();
244
+ }
245
+
246
+ // method: objectAtIndexedSubscript:
247
+ _MTL_INLINE MTL::BufferLayoutDescriptor* MTL::BufferLayoutDescriptorArray::object(NS::UInteger index)
248
+ {
249
+ return Object::sendMessage<MTL::BufferLayoutDescriptor*>(this, _MTL_PRIVATE_SEL(objectAtIndexedSubscript_), index);
250
+ }
251
+
252
+ // method: setObject:atIndexedSubscript:
253
+ _MTL_INLINE void MTL::BufferLayoutDescriptorArray::setObject(const MTL::BufferLayoutDescriptor* bufferDesc, NS::UInteger index)
254
+ {
255
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setObject_atIndexedSubscript_), bufferDesc, index);
256
+ }
257
+
258
+ // static method: alloc
259
+ _MTL_INLINE MTL::AttributeDescriptor* MTL::AttributeDescriptor::alloc()
260
+ {
261
+ return NS::Object::alloc<MTL::AttributeDescriptor>(_MTL_PRIVATE_CLS(MTLAttributeDescriptor));
262
+ }
263
+
264
+ // method: init
265
+ _MTL_INLINE MTL::AttributeDescriptor* MTL::AttributeDescriptor::init()
266
+ {
267
+ return NS::Object::init<MTL::AttributeDescriptor>();
268
+ }
269
+
270
+ // property: format
271
+ _MTL_INLINE MTL::AttributeFormat MTL::AttributeDescriptor::format() const
272
+ {
273
+ return Object::sendMessage<MTL::AttributeFormat>(this, _MTL_PRIVATE_SEL(format));
274
+ }
275
+
276
+ _MTL_INLINE void MTL::AttributeDescriptor::setFormat(MTL::AttributeFormat format)
277
+ {
278
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setFormat_), format);
279
+ }
280
+
281
+ // property: offset
282
+ _MTL_INLINE NS::UInteger MTL::AttributeDescriptor::offset() const
283
+ {
284
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(offset));
285
+ }
286
+
287
+ _MTL_INLINE void MTL::AttributeDescriptor::setOffset(NS::UInteger offset)
288
+ {
289
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setOffset_), offset);
290
+ }
291
+
292
+ // property: bufferIndex
293
+ _MTL_INLINE NS::UInteger MTL::AttributeDescriptor::bufferIndex() const
294
+ {
295
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(bufferIndex));
296
+ }
297
+
298
+ _MTL_INLINE void MTL::AttributeDescriptor::setBufferIndex(NS::UInteger bufferIndex)
299
+ {
300
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setBufferIndex_), bufferIndex);
301
+ }
302
+
303
+ // static method: alloc
304
+ _MTL_INLINE MTL::AttributeDescriptorArray* MTL::AttributeDescriptorArray::alloc()
305
+ {
306
+ return NS::Object::alloc<MTL::AttributeDescriptorArray>(_MTL_PRIVATE_CLS(MTLAttributeDescriptorArray));
307
+ }
308
+
309
+ // method: init
310
+ _MTL_INLINE MTL::AttributeDescriptorArray* MTL::AttributeDescriptorArray::init()
311
+ {
312
+ return NS::Object::init<MTL::AttributeDescriptorArray>();
313
+ }
314
+
315
+ // method: objectAtIndexedSubscript:
316
+ _MTL_INLINE MTL::AttributeDescriptor* MTL::AttributeDescriptorArray::object(NS::UInteger index)
317
+ {
318
+ return Object::sendMessage<MTL::AttributeDescriptor*>(this, _MTL_PRIVATE_SEL(objectAtIndexedSubscript_), index);
319
+ }
320
+
321
+ // method: setObject:atIndexedSubscript:
322
+ _MTL_INLINE void MTL::AttributeDescriptorArray::setObject(const MTL::AttributeDescriptor* attributeDesc, NS::UInteger index)
323
+ {
324
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setObject_atIndexedSubscript_), attributeDesc, index);
325
+ }
326
+
327
+ // static method: alloc
328
+ _MTL_INLINE MTL::StageInputOutputDescriptor* MTL::StageInputOutputDescriptor::alloc()
329
+ {
330
+ return NS::Object::alloc<MTL::StageInputOutputDescriptor>(_MTL_PRIVATE_CLS(MTLStageInputOutputDescriptor));
331
+ }
332
+
333
+ // method: init
334
+ _MTL_INLINE MTL::StageInputOutputDescriptor* MTL::StageInputOutputDescriptor::init()
335
+ {
336
+ return NS::Object::init<MTL::StageInputOutputDescriptor>();
337
+ }
338
+
339
+ // static method: stageInputOutputDescriptor
340
+ _MTL_INLINE MTL::StageInputOutputDescriptor* MTL::StageInputOutputDescriptor::stageInputOutputDescriptor()
341
+ {
342
+ return Object::sendMessage<MTL::StageInputOutputDescriptor*>(_MTL_PRIVATE_CLS(MTLStageInputOutputDescriptor), _MTL_PRIVATE_SEL(stageInputOutputDescriptor));
343
+ }
344
+
345
+ // property: layouts
346
+ _MTL_INLINE MTL::BufferLayoutDescriptorArray* MTL::StageInputOutputDescriptor::layouts() const
347
+ {
348
+ return Object::sendMessage<MTL::BufferLayoutDescriptorArray*>(this, _MTL_PRIVATE_SEL(layouts));
349
+ }
350
+
351
+ // property: attributes
352
+ _MTL_INLINE MTL::AttributeDescriptorArray* MTL::StageInputOutputDescriptor::attributes() const
353
+ {
354
+ return Object::sendMessage<MTL::AttributeDescriptorArray*>(this, _MTL_PRIVATE_SEL(attributes));
355
+ }
356
+
357
+ // property: indexType
358
+ _MTL_INLINE MTL::IndexType MTL::StageInputOutputDescriptor::indexType() const
359
+ {
360
+ return Object::sendMessage<MTL::IndexType>(this, _MTL_PRIVATE_SEL(indexType));
361
+ }
362
+
363
+ _MTL_INLINE void MTL::StageInputOutputDescriptor::setIndexType(MTL::IndexType indexType)
364
+ {
365
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setIndexType_), indexType);
366
+ }
367
+
368
+ // property: indexBufferIndex
369
+ _MTL_INLINE NS::UInteger MTL::StageInputOutputDescriptor::indexBufferIndex() const
370
+ {
371
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(indexBufferIndex));
372
+ }
373
+
374
+ _MTL_INLINE void MTL::StageInputOutputDescriptor::setIndexBufferIndex(NS::UInteger indexBufferIndex)
375
+ {
376
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setIndexBufferIndex_), indexBufferIndex);
377
+ }
378
+
379
+ // method: reset
380
+ _MTL_INLINE void MTL::StageInputOutputDescriptor::reset()
381
+ {
382
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(reset));
383
+ }
lib/python3.11/site-packages/mlx/include/metal_cpp/Metal/MTLTexture.hpp ADDED
@@ -0,0 +1,685 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
2
+ //
3
+ // Metal/MTLTexture.hpp
4
+ //
5
+ // Copyright 2020-2023 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 "MTLPixelFormat.hpp"
30
+ #include "MTLResource.hpp"
31
+ #include "MTLTexture.hpp"
32
+ #include "MTLTypes.hpp"
33
+ #include <IOSurface/IOSurfaceRef.h>
34
+
35
+ namespace MTL
36
+ {
37
+ _MTL_ENUM(NS::UInteger, TextureType) {
38
+ TextureType1D = 0,
39
+ TextureType1DArray = 1,
40
+ TextureType2D = 2,
41
+ TextureType2DArray = 3,
42
+ TextureType2DMultisample = 4,
43
+ TextureTypeCube = 5,
44
+ TextureTypeCubeArray = 6,
45
+ TextureType3D = 7,
46
+ TextureType2DMultisampleArray = 8,
47
+ TextureTypeTextureBuffer = 9,
48
+ };
49
+
50
+ _MTL_ENUM(uint8_t, TextureSwizzle) {
51
+ TextureSwizzleZero = 0,
52
+ TextureSwizzleOne = 1,
53
+ TextureSwizzleRed = 2,
54
+ TextureSwizzleGreen = 3,
55
+ TextureSwizzleBlue = 4,
56
+ TextureSwizzleAlpha = 5,
57
+ };
58
+
59
+ struct TextureSwizzleChannels
60
+ {
61
+ MTL::TextureSwizzle red;
62
+ MTL::TextureSwizzle green;
63
+ MTL::TextureSwizzle blue;
64
+ MTL::TextureSwizzle alpha;
65
+ } _MTL_PACKED;
66
+
67
+ class SharedTextureHandle : public NS::SecureCoding<SharedTextureHandle>
68
+ {
69
+ public:
70
+ static class SharedTextureHandle* alloc();
71
+
72
+ class SharedTextureHandle* init();
73
+
74
+ class Device* device() const;
75
+
76
+ NS::String* label() const;
77
+ };
78
+
79
+ _MTL_OPTIONS(NS::UInteger, TextureUsage) {
80
+ TextureUsageUnknown = 0,
81
+ TextureUsageShaderRead = 1,
82
+ TextureUsageShaderWrite = 2,
83
+ TextureUsageRenderTarget = 4,
84
+ TextureUsagePixelFormatView = 16,
85
+ TextureUsageShaderAtomic = 32,
86
+ };
87
+
88
+ _MTL_ENUM(NS::Integer, TextureCompressionType) {
89
+ TextureCompressionTypeLossless = 0,
90
+ TextureCompressionTypeLossy = 1,
91
+ };
92
+
93
+ class TextureDescriptor : public NS::Copying<TextureDescriptor>
94
+ {
95
+ public:
96
+ static class TextureDescriptor* alloc();
97
+
98
+ class TextureDescriptor* init();
99
+
100
+ static class TextureDescriptor* texture2DDescriptor(MTL::PixelFormat pixelFormat, NS::UInteger width, NS::UInteger height, bool mipmapped);
101
+
102
+ static class TextureDescriptor* textureCubeDescriptor(MTL::PixelFormat pixelFormat, NS::UInteger size, bool mipmapped);
103
+
104
+ static class TextureDescriptor* textureBufferDescriptor(MTL::PixelFormat pixelFormat, NS::UInteger width, MTL::ResourceOptions resourceOptions, MTL::TextureUsage usage);
105
+
106
+ MTL::TextureType textureType() const;
107
+ void setTextureType(MTL::TextureType textureType);
108
+
109
+ MTL::PixelFormat pixelFormat() const;
110
+ void setPixelFormat(MTL::PixelFormat pixelFormat);
111
+
112
+ NS::UInteger width() const;
113
+ void setWidth(NS::UInteger width);
114
+
115
+ NS::UInteger height() const;
116
+ void setHeight(NS::UInteger height);
117
+
118
+ NS::UInteger depth() const;
119
+ void setDepth(NS::UInteger depth);
120
+
121
+ NS::UInteger mipmapLevelCount() const;
122
+ void setMipmapLevelCount(NS::UInteger mipmapLevelCount);
123
+
124
+ NS::UInteger sampleCount() const;
125
+ void setSampleCount(NS::UInteger sampleCount);
126
+
127
+ NS::UInteger arrayLength() const;
128
+ void setArrayLength(NS::UInteger arrayLength);
129
+
130
+ MTL::ResourceOptions resourceOptions() const;
131
+ void setResourceOptions(MTL::ResourceOptions resourceOptions);
132
+
133
+ MTL::CPUCacheMode cpuCacheMode() const;
134
+ void setCpuCacheMode(MTL::CPUCacheMode cpuCacheMode);
135
+
136
+ MTL::StorageMode storageMode() const;
137
+ void setStorageMode(MTL::StorageMode storageMode);
138
+
139
+ MTL::HazardTrackingMode hazardTrackingMode() const;
140
+ void setHazardTrackingMode(MTL::HazardTrackingMode hazardTrackingMode);
141
+
142
+ MTL::TextureUsage usage() const;
143
+ void setUsage(MTL::TextureUsage usage);
144
+
145
+ bool allowGPUOptimizedContents() const;
146
+ void setAllowGPUOptimizedContents(bool allowGPUOptimizedContents);
147
+
148
+ MTL::TextureCompressionType compressionType() const;
149
+ void setCompressionType(MTL::TextureCompressionType compressionType);
150
+
151
+ MTL::TextureSwizzleChannels swizzle() const;
152
+ void setSwizzle(MTL::TextureSwizzleChannels swizzle);
153
+ };
154
+
155
+ class Texture : public NS::Referencing<Texture, Resource>
156
+ {
157
+ public:
158
+ class Resource* rootResource() const;
159
+
160
+ class Texture* parentTexture() const;
161
+
162
+ NS::UInteger parentRelativeLevel() const;
163
+
164
+ NS::UInteger parentRelativeSlice() const;
165
+
166
+ class Buffer* buffer() const;
167
+
168
+ NS::UInteger bufferOffset() const;
169
+
170
+ NS::UInteger bufferBytesPerRow() const;
171
+
172
+ IOSurfaceRef iosurface() const;
173
+
174
+ NS::UInteger iosurfacePlane() const;
175
+
176
+ MTL::TextureType textureType() const;
177
+
178
+ MTL::PixelFormat pixelFormat() const;
179
+
180
+ NS::UInteger width() const;
181
+
182
+ NS::UInteger height() const;
183
+
184
+ NS::UInteger depth() const;
185
+
186
+ NS::UInteger mipmapLevelCount() const;
187
+
188
+ NS::UInteger sampleCount() const;
189
+
190
+ NS::UInteger arrayLength() const;
191
+
192
+ MTL::TextureUsage usage() const;
193
+
194
+ bool shareable() const;
195
+
196
+ bool framebufferOnly() const;
197
+
198
+ NS::UInteger firstMipmapInTail() const;
199
+
200
+ NS::UInteger tailSizeInBytes() const;
201
+
202
+ bool isSparse() const;
203
+
204
+ bool allowGPUOptimizedContents() const;
205
+
206
+ MTL::TextureCompressionType compressionType() const;
207
+
208
+ MTL::ResourceID gpuResourceID() const;
209
+
210
+ void getBytes(const void* pixelBytes, NS::UInteger bytesPerRow, NS::UInteger bytesPerImage, MTL::Region region, NS::UInteger level, NS::UInteger slice);
211
+
212
+ void replaceRegion(MTL::Region region, NS::UInteger level, NS::UInteger slice, const void* pixelBytes, NS::UInteger bytesPerRow, NS::UInteger bytesPerImage);
213
+
214
+ void getBytes(const void* pixelBytes, NS::UInteger bytesPerRow, MTL::Region region, NS::UInteger level);
215
+
216
+ void replaceRegion(MTL::Region region, NS::UInteger level, const void* pixelBytes, NS::UInteger bytesPerRow);
217
+
218
+ class Texture* newTextureView(MTL::PixelFormat pixelFormat);
219
+
220
+ class Texture* newTextureView(MTL::PixelFormat pixelFormat, MTL::TextureType textureType, NS::Range levelRange, NS::Range sliceRange);
221
+
222
+ class SharedTextureHandle* newSharedTextureHandle();
223
+
224
+ class Texture* remoteStorageTexture() const;
225
+
226
+ class Texture* newRemoteTextureViewForDevice(const class Device* device);
227
+
228
+ MTL::TextureSwizzleChannels swizzle() const;
229
+
230
+ class Texture* newTextureView(MTL::PixelFormat pixelFormat, MTL::TextureType textureType, NS::Range levelRange, NS::Range sliceRange, MTL::TextureSwizzleChannels swizzle);
231
+ };
232
+
233
+ }
234
+
235
+ // static method: alloc
236
+ _MTL_INLINE MTL::SharedTextureHandle* MTL::SharedTextureHandle::alloc()
237
+ {
238
+ return NS::Object::alloc<MTL::SharedTextureHandle>(_MTL_PRIVATE_CLS(MTLSharedTextureHandle));
239
+ }
240
+
241
+ // method: init
242
+ _MTL_INLINE MTL::SharedTextureHandle* MTL::SharedTextureHandle::init()
243
+ {
244
+ return NS::Object::init<MTL::SharedTextureHandle>();
245
+ }
246
+
247
+ // property: device
248
+ _MTL_INLINE MTL::Device* MTL::SharedTextureHandle::device() const
249
+ {
250
+ return Object::sendMessage<MTL::Device*>(this, _MTL_PRIVATE_SEL(device));
251
+ }
252
+
253
+ // property: label
254
+ _MTL_INLINE NS::String* MTL::SharedTextureHandle::label() const
255
+ {
256
+ return Object::sendMessage<NS::String*>(this, _MTL_PRIVATE_SEL(label));
257
+ }
258
+
259
+ // static method: alloc
260
+ _MTL_INLINE MTL::TextureDescriptor* MTL::TextureDescriptor::alloc()
261
+ {
262
+ return NS::Object::alloc<MTL::TextureDescriptor>(_MTL_PRIVATE_CLS(MTLTextureDescriptor));
263
+ }
264
+
265
+ // method: init
266
+ _MTL_INLINE MTL::TextureDescriptor* MTL::TextureDescriptor::init()
267
+ {
268
+ return NS::Object::init<MTL::TextureDescriptor>();
269
+ }
270
+
271
+ // static method: texture2DDescriptorWithPixelFormat:width:height:mipmapped:
272
+ _MTL_INLINE MTL::TextureDescriptor* MTL::TextureDescriptor::texture2DDescriptor(MTL::PixelFormat pixelFormat, NS::UInteger width, NS::UInteger height, bool mipmapped)
273
+ {
274
+ return Object::sendMessage<MTL::TextureDescriptor*>(_MTL_PRIVATE_CLS(MTLTextureDescriptor), _MTL_PRIVATE_SEL(texture2DDescriptorWithPixelFormat_width_height_mipmapped_), pixelFormat, width, height, mipmapped);
275
+ }
276
+
277
+ // static method: textureCubeDescriptorWithPixelFormat:size:mipmapped:
278
+ _MTL_INLINE MTL::TextureDescriptor* MTL::TextureDescriptor::textureCubeDescriptor(MTL::PixelFormat pixelFormat, NS::UInteger size, bool mipmapped)
279
+ {
280
+ return Object::sendMessage<MTL::TextureDescriptor*>(_MTL_PRIVATE_CLS(MTLTextureDescriptor), _MTL_PRIVATE_SEL(textureCubeDescriptorWithPixelFormat_size_mipmapped_), pixelFormat, size, mipmapped);
281
+ }
282
+
283
+ // static method: textureBufferDescriptorWithPixelFormat:width:resourceOptions:usage:
284
+ _MTL_INLINE MTL::TextureDescriptor* MTL::TextureDescriptor::textureBufferDescriptor(MTL::PixelFormat pixelFormat, NS::UInteger width, MTL::ResourceOptions resourceOptions, MTL::TextureUsage usage)
285
+ {
286
+ return Object::sendMessage<MTL::TextureDescriptor*>(_MTL_PRIVATE_CLS(MTLTextureDescriptor), _MTL_PRIVATE_SEL(textureBufferDescriptorWithPixelFormat_width_resourceOptions_usage_), pixelFormat, width, resourceOptions, usage);
287
+ }
288
+
289
+ // property: textureType
290
+ _MTL_INLINE MTL::TextureType MTL::TextureDescriptor::textureType() const
291
+ {
292
+ return Object::sendMessage<MTL::TextureType>(this, _MTL_PRIVATE_SEL(textureType));
293
+ }
294
+
295
+ _MTL_INLINE void MTL::TextureDescriptor::setTextureType(MTL::TextureType textureType)
296
+ {
297
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setTextureType_), textureType);
298
+ }
299
+
300
+ // property: pixelFormat
301
+ _MTL_INLINE MTL::PixelFormat MTL::TextureDescriptor::pixelFormat() const
302
+ {
303
+ return Object::sendMessage<MTL::PixelFormat>(this, _MTL_PRIVATE_SEL(pixelFormat));
304
+ }
305
+
306
+ _MTL_INLINE void MTL::TextureDescriptor::setPixelFormat(MTL::PixelFormat pixelFormat)
307
+ {
308
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setPixelFormat_), pixelFormat);
309
+ }
310
+
311
+ // property: width
312
+ _MTL_INLINE NS::UInteger MTL::TextureDescriptor::width() const
313
+ {
314
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(width));
315
+ }
316
+
317
+ _MTL_INLINE void MTL::TextureDescriptor::setWidth(NS::UInteger width)
318
+ {
319
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setWidth_), width);
320
+ }
321
+
322
+ // property: height
323
+ _MTL_INLINE NS::UInteger MTL::TextureDescriptor::height() const
324
+ {
325
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(height));
326
+ }
327
+
328
+ _MTL_INLINE void MTL::TextureDescriptor::setHeight(NS::UInteger height)
329
+ {
330
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setHeight_), height);
331
+ }
332
+
333
+ // property: depth
334
+ _MTL_INLINE NS::UInteger MTL::TextureDescriptor::depth() const
335
+ {
336
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(depth));
337
+ }
338
+
339
+ _MTL_INLINE void MTL::TextureDescriptor::setDepth(NS::UInteger depth)
340
+ {
341
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setDepth_), depth);
342
+ }
343
+
344
+ // property: mipmapLevelCount
345
+ _MTL_INLINE NS::UInteger MTL::TextureDescriptor::mipmapLevelCount() const
346
+ {
347
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(mipmapLevelCount));
348
+ }
349
+
350
+ _MTL_INLINE void MTL::TextureDescriptor::setMipmapLevelCount(NS::UInteger mipmapLevelCount)
351
+ {
352
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setMipmapLevelCount_), mipmapLevelCount);
353
+ }
354
+
355
+ // property: sampleCount
356
+ _MTL_INLINE NS::UInteger MTL::TextureDescriptor::sampleCount() const
357
+ {
358
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(sampleCount));
359
+ }
360
+
361
+ _MTL_INLINE void MTL::TextureDescriptor::setSampleCount(NS::UInteger sampleCount)
362
+ {
363
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setSampleCount_), sampleCount);
364
+ }
365
+
366
+ // property: arrayLength
367
+ _MTL_INLINE NS::UInteger MTL::TextureDescriptor::arrayLength() const
368
+ {
369
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(arrayLength));
370
+ }
371
+
372
+ _MTL_INLINE void MTL::TextureDescriptor::setArrayLength(NS::UInteger arrayLength)
373
+ {
374
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setArrayLength_), arrayLength);
375
+ }
376
+
377
+ // property: resourceOptions
378
+ _MTL_INLINE MTL::ResourceOptions MTL::TextureDescriptor::resourceOptions() const
379
+ {
380
+ return Object::sendMessage<MTL::ResourceOptions>(this, _MTL_PRIVATE_SEL(resourceOptions));
381
+ }
382
+
383
+ _MTL_INLINE void MTL::TextureDescriptor::setResourceOptions(MTL::ResourceOptions resourceOptions)
384
+ {
385
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setResourceOptions_), resourceOptions);
386
+ }
387
+
388
+ // property: cpuCacheMode
389
+ _MTL_INLINE MTL::CPUCacheMode MTL::TextureDescriptor::cpuCacheMode() const
390
+ {
391
+ return Object::sendMessage<MTL::CPUCacheMode>(this, _MTL_PRIVATE_SEL(cpuCacheMode));
392
+ }
393
+
394
+ _MTL_INLINE void MTL::TextureDescriptor::setCpuCacheMode(MTL::CPUCacheMode cpuCacheMode)
395
+ {
396
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setCpuCacheMode_), cpuCacheMode);
397
+ }
398
+
399
+ // property: storageMode
400
+ _MTL_INLINE MTL::StorageMode MTL::TextureDescriptor::storageMode() const
401
+ {
402
+ return Object::sendMessage<MTL::StorageMode>(this, _MTL_PRIVATE_SEL(storageMode));
403
+ }
404
+
405
+ _MTL_INLINE void MTL::TextureDescriptor::setStorageMode(MTL::StorageMode storageMode)
406
+ {
407
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setStorageMode_), storageMode);
408
+ }
409
+
410
+ // property: hazardTrackingMode
411
+ _MTL_INLINE MTL::HazardTrackingMode MTL::TextureDescriptor::hazardTrackingMode() const
412
+ {
413
+ return Object::sendMessage<MTL::HazardTrackingMode>(this, _MTL_PRIVATE_SEL(hazardTrackingMode));
414
+ }
415
+
416
+ _MTL_INLINE void MTL::TextureDescriptor::setHazardTrackingMode(MTL::HazardTrackingMode hazardTrackingMode)
417
+ {
418
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setHazardTrackingMode_), hazardTrackingMode);
419
+ }
420
+
421
+ // property: usage
422
+ _MTL_INLINE MTL::TextureUsage MTL::TextureDescriptor::usage() const
423
+ {
424
+ return Object::sendMessage<MTL::TextureUsage>(this, _MTL_PRIVATE_SEL(usage));
425
+ }
426
+
427
+ _MTL_INLINE void MTL::TextureDescriptor::setUsage(MTL::TextureUsage usage)
428
+ {
429
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setUsage_), usage);
430
+ }
431
+
432
+ // property: allowGPUOptimizedContents
433
+ _MTL_INLINE bool MTL::TextureDescriptor::allowGPUOptimizedContents() const
434
+ {
435
+ return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(allowGPUOptimizedContents));
436
+ }
437
+
438
+ _MTL_INLINE void MTL::TextureDescriptor::setAllowGPUOptimizedContents(bool allowGPUOptimizedContents)
439
+ {
440
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setAllowGPUOptimizedContents_), allowGPUOptimizedContents);
441
+ }
442
+
443
+ // property: compressionType
444
+ _MTL_INLINE MTL::TextureCompressionType MTL::TextureDescriptor::compressionType() const
445
+ {
446
+ return Object::sendMessage<MTL::TextureCompressionType>(this, _MTL_PRIVATE_SEL(compressionType));
447
+ }
448
+
449
+ _MTL_INLINE void MTL::TextureDescriptor::setCompressionType(MTL::TextureCompressionType compressionType)
450
+ {
451
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setCompressionType_), compressionType);
452
+ }
453
+
454
+ // property: swizzle
455
+ _MTL_INLINE MTL::TextureSwizzleChannels MTL::TextureDescriptor::swizzle() const
456
+ {
457
+ return Object::sendMessage<MTL::TextureSwizzleChannels>(this, _MTL_PRIVATE_SEL(swizzle));
458
+ }
459
+
460
+ _MTL_INLINE void MTL::TextureDescriptor::setSwizzle(MTL::TextureSwizzleChannels swizzle)
461
+ {
462
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setSwizzle_), swizzle);
463
+ }
464
+
465
+ // property: rootResource
466
+ _MTL_INLINE MTL::Resource* MTL::Texture::rootResource() const
467
+ {
468
+ return Object::sendMessage<MTL::Resource*>(this, _MTL_PRIVATE_SEL(rootResource));
469
+ }
470
+
471
+ // property: parentTexture
472
+ _MTL_INLINE MTL::Texture* MTL::Texture::parentTexture() const
473
+ {
474
+ return Object::sendMessage<MTL::Texture*>(this, _MTL_PRIVATE_SEL(parentTexture));
475
+ }
476
+
477
+ // property: parentRelativeLevel
478
+ _MTL_INLINE NS::UInteger MTL::Texture::parentRelativeLevel() const
479
+ {
480
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(parentRelativeLevel));
481
+ }
482
+
483
+ // property: parentRelativeSlice
484
+ _MTL_INLINE NS::UInteger MTL::Texture::parentRelativeSlice() const
485
+ {
486
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(parentRelativeSlice));
487
+ }
488
+
489
+ // property: buffer
490
+ _MTL_INLINE MTL::Buffer* MTL::Texture::buffer() const
491
+ {
492
+ return Object::sendMessage<MTL::Buffer*>(this, _MTL_PRIVATE_SEL(buffer));
493
+ }
494
+
495
+ // property: bufferOffset
496
+ _MTL_INLINE NS::UInteger MTL::Texture::bufferOffset() const
497
+ {
498
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(bufferOffset));
499
+ }
500
+
501
+ // property: bufferBytesPerRow
502
+ _MTL_INLINE NS::UInteger MTL::Texture::bufferBytesPerRow() const
503
+ {
504
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(bufferBytesPerRow));
505
+ }
506
+
507
+ // property: iosurface
508
+ _MTL_INLINE IOSurfaceRef MTL::Texture::iosurface() const
509
+ {
510
+ return Object::sendMessage<IOSurfaceRef>(this, _MTL_PRIVATE_SEL(iosurface));
511
+ }
512
+
513
+ // property: iosurfacePlane
514
+ _MTL_INLINE NS::UInteger MTL::Texture::iosurfacePlane() const
515
+ {
516
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(iosurfacePlane));
517
+ }
518
+
519
+ // property: textureType
520
+ _MTL_INLINE MTL::TextureType MTL::Texture::textureType() const
521
+ {
522
+ return Object::sendMessage<MTL::TextureType>(this, _MTL_PRIVATE_SEL(textureType));
523
+ }
524
+
525
+ // property: pixelFormat
526
+ _MTL_INLINE MTL::PixelFormat MTL::Texture::pixelFormat() const
527
+ {
528
+ return Object::sendMessage<MTL::PixelFormat>(this, _MTL_PRIVATE_SEL(pixelFormat));
529
+ }
530
+
531
+ // property: width
532
+ _MTL_INLINE NS::UInteger MTL::Texture::width() const
533
+ {
534
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(width));
535
+ }
536
+
537
+ // property: height
538
+ _MTL_INLINE NS::UInteger MTL::Texture::height() const
539
+ {
540
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(height));
541
+ }
542
+
543
+ // property: depth
544
+ _MTL_INLINE NS::UInteger MTL::Texture::depth() const
545
+ {
546
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(depth));
547
+ }
548
+
549
+ // property: mipmapLevelCount
550
+ _MTL_INLINE NS::UInteger MTL::Texture::mipmapLevelCount() const
551
+ {
552
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(mipmapLevelCount));
553
+ }
554
+
555
+ // property: sampleCount
556
+ _MTL_INLINE NS::UInteger MTL::Texture::sampleCount() const
557
+ {
558
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(sampleCount));
559
+ }
560
+
561
+ // property: arrayLength
562
+ _MTL_INLINE NS::UInteger MTL::Texture::arrayLength() const
563
+ {
564
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(arrayLength));
565
+ }
566
+
567
+ // property: usage
568
+ _MTL_INLINE MTL::TextureUsage MTL::Texture::usage() const
569
+ {
570
+ return Object::sendMessage<MTL::TextureUsage>(this, _MTL_PRIVATE_SEL(usage));
571
+ }
572
+
573
+ // property: shareable
574
+ _MTL_INLINE bool MTL::Texture::shareable() const
575
+ {
576
+ return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(isShareable));
577
+ }
578
+
579
+ // property: framebufferOnly
580
+ _MTL_INLINE bool MTL::Texture::framebufferOnly() const
581
+ {
582
+ return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(isFramebufferOnly));
583
+ }
584
+
585
+ // property: firstMipmapInTail
586
+ _MTL_INLINE NS::UInteger MTL::Texture::firstMipmapInTail() const
587
+ {
588
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(firstMipmapInTail));
589
+ }
590
+
591
+ // property: tailSizeInBytes
592
+ _MTL_INLINE NS::UInteger MTL::Texture::tailSizeInBytes() const
593
+ {
594
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(tailSizeInBytes));
595
+ }
596
+
597
+ // property: isSparse
598
+ _MTL_INLINE bool MTL::Texture::isSparse() const
599
+ {
600
+ return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(isSparse));
601
+ }
602
+
603
+ // property: allowGPUOptimizedContents
604
+ _MTL_INLINE bool MTL::Texture::allowGPUOptimizedContents() const
605
+ {
606
+ return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(allowGPUOptimizedContents));
607
+ }
608
+
609
+ // property: compressionType
610
+ _MTL_INLINE MTL::TextureCompressionType MTL::Texture::compressionType() const
611
+ {
612
+ return Object::sendMessage<MTL::TextureCompressionType>(this, _MTL_PRIVATE_SEL(compressionType));
613
+ }
614
+
615
+ // property: gpuResourceID
616
+ _MTL_INLINE MTL::ResourceID MTL::Texture::gpuResourceID() const
617
+ {
618
+ return Object::sendMessage<MTL::ResourceID>(this, _MTL_PRIVATE_SEL(gpuResourceID));
619
+ }
620
+
621
+ // method: getBytes:bytesPerRow:bytesPerImage:fromRegion:mipmapLevel:slice:
622
+ _MTL_INLINE void MTL::Texture::getBytes(const void* pixelBytes, NS::UInteger bytesPerRow, NS::UInteger bytesPerImage, MTL::Region region, NS::UInteger level, NS::UInteger slice)
623
+ {
624
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(getBytes_bytesPerRow_bytesPerImage_fromRegion_mipmapLevel_slice_), pixelBytes, bytesPerRow, bytesPerImage, region, level, slice);
625
+ }
626
+
627
+ // method: replaceRegion:mipmapLevel:slice:withBytes:bytesPerRow:bytesPerImage:
628
+ _MTL_INLINE void MTL::Texture::replaceRegion(MTL::Region region, NS::UInteger level, NS::UInteger slice, const void* pixelBytes, NS::UInteger bytesPerRow, NS::UInteger bytesPerImage)
629
+ {
630
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(replaceRegion_mipmapLevel_slice_withBytes_bytesPerRow_bytesPerImage_), region, level, slice, pixelBytes, bytesPerRow, bytesPerImage);
631
+ }
632
+
633
+ // method: getBytes:bytesPerRow:fromRegion:mipmapLevel:
634
+ _MTL_INLINE void MTL::Texture::getBytes(const void* pixelBytes, NS::UInteger bytesPerRow, MTL::Region region, NS::UInteger level)
635
+ {
636
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(getBytes_bytesPerRow_fromRegion_mipmapLevel_), pixelBytes, bytesPerRow, region, level);
637
+ }
638
+
639
+ // method: replaceRegion:mipmapLevel:withBytes:bytesPerRow:
640
+ _MTL_INLINE void MTL::Texture::replaceRegion(MTL::Region region, NS::UInteger level, const void* pixelBytes, NS::UInteger bytesPerRow)
641
+ {
642
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(replaceRegion_mipmapLevel_withBytes_bytesPerRow_), region, level, pixelBytes, bytesPerRow);
643
+ }
644
+
645
+ // method: newTextureViewWithPixelFormat:
646
+ _MTL_INLINE MTL::Texture* MTL::Texture::newTextureView(MTL::PixelFormat pixelFormat)
647
+ {
648
+ return Object::sendMessage<MTL::Texture*>(this, _MTL_PRIVATE_SEL(newTextureViewWithPixelFormat_), pixelFormat);
649
+ }
650
+
651
+ // method: newTextureViewWithPixelFormat:textureType:levels:slices:
652
+ _MTL_INLINE MTL::Texture* MTL::Texture::newTextureView(MTL::PixelFormat pixelFormat, MTL::TextureType textureType, NS::Range levelRange, NS::Range sliceRange)
653
+ {
654
+ return Object::sendMessage<MTL::Texture*>(this, _MTL_PRIVATE_SEL(newTextureViewWithPixelFormat_textureType_levels_slices_), pixelFormat, textureType, levelRange, sliceRange);
655
+ }
656
+
657
+ // method: newSharedTextureHandle
658
+ _MTL_INLINE MTL::SharedTextureHandle* MTL::Texture::newSharedTextureHandle()
659
+ {
660
+ return Object::sendMessage<MTL::SharedTextureHandle*>(this, _MTL_PRIVATE_SEL(newSharedTextureHandle));
661
+ }
662
+
663
+ // property: remoteStorageTexture
664
+ _MTL_INLINE MTL::Texture* MTL::Texture::remoteStorageTexture() const
665
+ {
666
+ return Object::sendMessage<MTL::Texture*>(this, _MTL_PRIVATE_SEL(remoteStorageTexture));
667
+ }
668
+
669
+ // method: newRemoteTextureViewForDevice:
670
+ _MTL_INLINE MTL::Texture* MTL::Texture::newRemoteTextureViewForDevice(const MTL::Device* device)
671
+ {
672
+ return Object::sendMessage<MTL::Texture*>(this, _MTL_PRIVATE_SEL(newRemoteTextureViewForDevice_), device);
673
+ }
674
+
675
+ // property: swizzle
676
+ _MTL_INLINE MTL::TextureSwizzleChannels MTL::Texture::swizzle() const
677
+ {
678
+ return Object::sendMessage<MTL::TextureSwizzleChannels>(this, _MTL_PRIVATE_SEL(swizzle));
679
+ }
680
+
681
+ // method: newTextureViewWithPixelFormat:textureType:levels:slices:swizzle:
682
+ _MTL_INLINE MTL::Texture* MTL::Texture::newTextureView(MTL::PixelFormat pixelFormat, MTL::TextureType textureType, NS::Range levelRange, NS::Range sliceRange, MTL::TextureSwizzleChannels swizzle)
683
+ {
684
+ return Object::sendMessage<MTL::Texture*>(this, _MTL_PRIVATE_SEL(newTextureViewWithPixelFormat_textureType_levels_slices_swizzle_), pixelFormat, textureType, levelRange, sliceRange, swizzle);
685
+ }
lib/python3.11/site-packages/mlx/include/metal_cpp/Metal/MTLTypes.hpp ADDED
@@ -0,0 +1,168 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
2
+ //
3
+ // Metal/MTLTypes.hpp
4
+ //
5
+ // Copyright 2020-2023 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 "MTLTypes.hpp"
30
+
31
+ namespace MTL
32
+ {
33
+ struct Origin
34
+ {
35
+ Origin() = default;
36
+
37
+ Origin(NS::UInteger x, NS::UInteger y, NS::UInteger z);
38
+
39
+ static Origin Make(NS::UInteger x, NS::UInteger y, NS::UInteger z);
40
+
41
+ NS::UInteger x;
42
+ NS::UInteger y;
43
+ NS::UInteger z;
44
+ } _MTL_PACKED;
45
+
46
+ struct Size
47
+ {
48
+ Size() = default;
49
+
50
+ Size(NS::UInteger width, NS::UInteger height, NS::UInteger depth);
51
+
52
+ static Size Make(NS::UInteger width, NS::UInteger height, NS::UInteger depth);
53
+
54
+ NS::UInteger width;
55
+ NS::UInteger height;
56
+ NS::UInteger depth;
57
+ } _MTL_PACKED;
58
+
59
+ struct Region
60
+ {
61
+ Region() = default;
62
+
63
+ Region(NS::UInteger x, NS::UInteger width);
64
+
65
+ Region(NS::UInteger x, NS::UInteger y, NS::UInteger width, NS::UInteger height);
66
+
67
+ Region(NS::UInteger x, NS::UInteger y, NS::UInteger z, NS::UInteger width, NS::UInteger height, NS::UInteger depth);
68
+
69
+ static Region Make1D(NS::UInteger x, NS::UInteger width);
70
+
71
+ static Region Make2D(NS::UInteger x, NS::UInteger y, NS::UInteger width, NS::UInteger height);
72
+
73
+ static Region Make3D(NS::UInteger x, NS::UInteger y, NS::UInteger z, NS::UInteger width, NS::UInteger height, NS::UInteger depth);
74
+
75
+ MTL::Origin origin;
76
+ MTL::Size size;
77
+ } _MTL_PACKED;
78
+
79
+ struct SamplePosition;
80
+
81
+ using Coordinate2D = SamplePosition;
82
+
83
+ struct SamplePosition
84
+ {
85
+ SamplePosition() = default;
86
+
87
+ SamplePosition(float _x, float _y);
88
+
89
+ static SamplePosition Make(float x, float y);
90
+
91
+ float x;
92
+ float y;
93
+ } _MTL_PACKED;
94
+
95
+ struct ResourceID
96
+ {
97
+ uint64_t _impl;
98
+ } _MTL_PACKED;
99
+
100
+ }
101
+
102
+ _MTL_INLINE MTL::Origin::Origin(NS::UInteger _x, NS::UInteger _y, NS::UInteger _z)
103
+ : x(_x)
104
+ , y(_y)
105
+ , z(_z)
106
+ {
107
+ }
108
+
109
+ _MTL_INLINE MTL::Origin MTL::Origin::Make(NS::UInteger x, NS::UInteger y, NS::UInteger z)
110
+ {
111
+ return Origin(x, y, z);
112
+ }
113
+
114
+ _MTL_INLINE MTL::Size::Size(NS::UInteger _width, NS::UInteger _height, NS::UInteger _depth)
115
+ : width(_width)
116
+ , height(_height)
117
+ , depth(_depth)
118
+ {
119
+ }
120
+
121
+ _MTL_INLINE MTL::Size MTL::Size::Make(NS::UInteger width, NS::UInteger height, NS::UInteger depth)
122
+ {
123
+ return Size(width, height, depth);
124
+ }
125
+
126
+ _MTL_INLINE MTL::Region::Region(NS::UInteger x, NS::UInteger width)
127
+ : origin(x, 0, 0)
128
+ , size(width, 1, 1)
129
+ {
130
+ }
131
+
132
+ _MTL_INLINE MTL::Region::Region(NS::UInteger x, NS::UInteger y, NS::UInteger width, NS::UInteger height)
133
+ : origin(x, y, 0)
134
+ , size(width, height, 1)
135
+ {
136
+ }
137
+
138
+ _MTL_INLINE MTL::Region::Region(NS::UInteger x, NS::UInteger y, NS::UInteger z, NS::UInteger width, NS::UInteger height, NS::UInteger depth)
139
+ : origin(x, y, z)
140
+ , size(width, height, depth)
141
+ {
142
+ }
143
+
144
+ _MTL_INLINE MTL::Region MTL::Region::Make1D(NS::UInteger x, NS::UInteger width)
145
+ {
146
+ return Region(x, width);
147
+ }
148
+
149
+ _MTL_INLINE MTL::Region MTL::Region::Make2D(NS::UInteger x, NS::UInteger y, NS::UInteger width, NS::UInteger height)
150
+ {
151
+ return Region(x, y, width, height);
152
+ }
153
+
154
+ _MTL_INLINE MTL::Region MTL::Region::Make3D(NS::UInteger x, NS::UInteger y, NS::UInteger z, NS::UInteger width, NS::UInteger height, NS::UInteger depth)
155
+ {
156
+ return Region(x, y, z, width, height, depth);
157
+ }
158
+
159
+ _MTL_INLINE MTL::SamplePosition::SamplePosition(float _x, float _y)
160
+ : x(_x)
161
+ , y(_y)
162
+ {
163
+ }
164
+
165
+ _MTL_INLINE MTL::SamplePosition MTL::SamplePosition::Make(float x, float y)
166
+ {
167
+ return SamplePosition(x, y);
168
+ }
lib/python3.11/site-packages/mlx/include/metal_cpp/Metal/MTLVersion.hpp ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
2
+ //
3
+ // Metal/MTLVersion.hpp
4
+ //
5
+ // Copyright 2020-2023 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
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
24
+
25
+ #define METALCPP_VERSION_MAJOR 341
26
+ #define METALCPP_VERSION_MINOR 0
27
+ #define METALCPP_VERSION_PATCH 0
28
+
29
+ #define METALCPP_SUPPORTS_VERSION(major, minor, patch) \
30
+ ((major < METALCPP_VERSION_MAJOR) || \
31
+ (major == METALCPP_VERSION_MAJOR && minor < METALCPP_VERSION_MINOR) || \
32
+ (major == METALCPP_VERSION_MAJOR && minor == METALCPP_VERSION_MINOR && patch <= METALCPP_VERSION_PATCH))
lib/python3.11/site-packages/mlx/include/metal_cpp/Metal/MTLVertexDescriptor.hpp ADDED
@@ -0,0 +1,349 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
2
+ //
3
+ // Metal/MTLVertexDescriptor.hpp
4
+ //
5
+ // Copyright 2020-2023 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 "MTLVertexDescriptor.hpp"
30
+
31
+ namespace MTL
32
+ {
33
+
34
+ static const NS::UInteger BufferLayoutStrideDynamic = NS::UIntegerMax;
35
+
36
+ _MTL_ENUM(NS::UInteger, VertexFormat) {
37
+ VertexFormatInvalid = 0,
38
+ VertexFormatUChar2 = 1,
39
+ VertexFormatUChar3 = 2,
40
+ VertexFormatUChar4 = 3,
41
+ VertexFormatChar2 = 4,
42
+ VertexFormatChar3 = 5,
43
+ VertexFormatChar4 = 6,
44
+ VertexFormatUChar2Normalized = 7,
45
+ VertexFormatUChar3Normalized = 8,
46
+ VertexFormatUChar4Normalized = 9,
47
+ VertexFormatChar2Normalized = 10,
48
+ VertexFormatChar3Normalized = 11,
49
+ VertexFormatChar4Normalized = 12,
50
+ VertexFormatUShort2 = 13,
51
+ VertexFormatUShort3 = 14,
52
+ VertexFormatUShort4 = 15,
53
+ VertexFormatShort2 = 16,
54
+ VertexFormatShort3 = 17,
55
+ VertexFormatShort4 = 18,
56
+ VertexFormatUShort2Normalized = 19,
57
+ VertexFormatUShort3Normalized = 20,
58
+ VertexFormatUShort4Normalized = 21,
59
+ VertexFormatShort2Normalized = 22,
60
+ VertexFormatShort3Normalized = 23,
61
+ VertexFormatShort4Normalized = 24,
62
+ VertexFormatHalf2 = 25,
63
+ VertexFormatHalf3 = 26,
64
+ VertexFormatHalf4 = 27,
65
+ VertexFormatFloat = 28,
66
+ VertexFormatFloat2 = 29,
67
+ VertexFormatFloat3 = 30,
68
+ VertexFormatFloat4 = 31,
69
+ VertexFormatInt = 32,
70
+ VertexFormatInt2 = 33,
71
+ VertexFormatInt3 = 34,
72
+ VertexFormatInt4 = 35,
73
+ VertexFormatUInt = 36,
74
+ VertexFormatUInt2 = 37,
75
+ VertexFormatUInt3 = 38,
76
+ VertexFormatUInt4 = 39,
77
+ VertexFormatInt1010102Normalized = 40,
78
+ VertexFormatUInt1010102Normalized = 41,
79
+ VertexFormatUChar4Normalized_BGRA = 42,
80
+ VertexFormatUChar = 45,
81
+ VertexFormatChar = 46,
82
+ VertexFormatUCharNormalized = 47,
83
+ VertexFormatCharNormalized = 48,
84
+ VertexFormatUShort = 49,
85
+ VertexFormatShort = 50,
86
+ VertexFormatUShortNormalized = 51,
87
+ VertexFormatShortNormalized = 52,
88
+ VertexFormatHalf = 53,
89
+ VertexFormatFloatRG11B10 = 54,
90
+ VertexFormatFloatRGB9E5 = 55,
91
+ };
92
+
93
+ _MTL_ENUM(NS::UInteger, VertexStepFunction) {
94
+ VertexStepFunctionConstant = 0,
95
+ VertexStepFunctionPerVertex = 1,
96
+ VertexStepFunctionPerInstance = 2,
97
+ VertexStepFunctionPerPatch = 3,
98
+ VertexStepFunctionPerPatchControlPoint = 4,
99
+ };
100
+
101
+ class VertexBufferLayoutDescriptor : public NS::Copying<VertexBufferLayoutDescriptor>
102
+ {
103
+ public:
104
+ static class VertexBufferLayoutDescriptor* alloc();
105
+
106
+ class VertexBufferLayoutDescriptor* init();
107
+
108
+ NS::UInteger stride() const;
109
+ void setStride(NS::UInteger stride);
110
+
111
+ MTL::VertexStepFunction stepFunction() const;
112
+ void setStepFunction(MTL::VertexStepFunction stepFunction);
113
+
114
+ NS::UInteger stepRate() const;
115
+ void setStepRate(NS::UInteger stepRate);
116
+ };
117
+
118
+ class VertexBufferLayoutDescriptorArray : public NS::Referencing<VertexBufferLayoutDescriptorArray>
119
+ {
120
+ public:
121
+ static class VertexBufferLayoutDescriptorArray* alloc();
122
+
123
+ class VertexBufferLayoutDescriptorArray* init();
124
+
125
+ class VertexBufferLayoutDescriptor* object(NS::UInteger index);
126
+
127
+ void setObject(const class VertexBufferLayoutDescriptor* bufferDesc, NS::UInteger index);
128
+ };
129
+
130
+ class VertexAttributeDescriptor : public NS::Copying<VertexAttributeDescriptor>
131
+ {
132
+ public:
133
+ static class VertexAttributeDescriptor* alloc();
134
+
135
+ class VertexAttributeDescriptor* init();
136
+
137
+ MTL::VertexFormat format() const;
138
+ void setFormat(MTL::VertexFormat format);
139
+
140
+ NS::UInteger offset() const;
141
+ void setOffset(NS::UInteger offset);
142
+
143
+ NS::UInteger bufferIndex() const;
144
+ void setBufferIndex(NS::UInteger bufferIndex);
145
+ };
146
+
147
+ class VertexAttributeDescriptorArray : public NS::Referencing<VertexAttributeDescriptorArray>
148
+ {
149
+ public:
150
+ static class VertexAttributeDescriptorArray* alloc();
151
+
152
+ class VertexAttributeDescriptorArray* init();
153
+
154
+ class VertexAttributeDescriptor* object(NS::UInteger index);
155
+
156
+ void setObject(const class VertexAttributeDescriptor* attributeDesc, NS::UInteger index);
157
+ };
158
+
159
+ class VertexDescriptor : public NS::Copying<VertexDescriptor>
160
+ {
161
+ public:
162
+ static class VertexDescriptor* alloc();
163
+
164
+ class VertexDescriptor* init();
165
+
166
+ static class VertexDescriptor* vertexDescriptor();
167
+
168
+ class VertexBufferLayoutDescriptorArray* layouts() const;
169
+
170
+ class VertexAttributeDescriptorArray* attributes() const;
171
+
172
+ void reset();
173
+ };
174
+
175
+ }
176
+
177
+ // static method: alloc
178
+ _MTL_INLINE MTL::VertexBufferLayoutDescriptor* MTL::VertexBufferLayoutDescriptor::alloc()
179
+ {
180
+ return NS::Object::alloc<MTL::VertexBufferLayoutDescriptor>(_MTL_PRIVATE_CLS(MTLVertexBufferLayoutDescriptor));
181
+ }
182
+
183
+ // method: init
184
+ _MTL_INLINE MTL::VertexBufferLayoutDescriptor* MTL::VertexBufferLayoutDescriptor::init()
185
+ {
186
+ return NS::Object::init<MTL::VertexBufferLayoutDescriptor>();
187
+ }
188
+
189
+ // property: stride
190
+ _MTL_INLINE NS::UInteger MTL::VertexBufferLayoutDescriptor::stride() const
191
+ {
192
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(stride));
193
+ }
194
+
195
+ _MTL_INLINE void MTL::VertexBufferLayoutDescriptor::setStride(NS::UInteger stride)
196
+ {
197
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setStride_), stride);
198
+ }
199
+
200
+ // property: stepFunction
201
+ _MTL_INLINE MTL::VertexStepFunction MTL::VertexBufferLayoutDescriptor::stepFunction() const
202
+ {
203
+ return Object::sendMessage<MTL::VertexStepFunction>(this, _MTL_PRIVATE_SEL(stepFunction));
204
+ }
205
+
206
+ _MTL_INLINE void MTL::VertexBufferLayoutDescriptor::setStepFunction(MTL::VertexStepFunction stepFunction)
207
+ {
208
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setStepFunction_), stepFunction);
209
+ }
210
+
211
+ // property: stepRate
212
+ _MTL_INLINE NS::UInteger MTL::VertexBufferLayoutDescriptor::stepRate() const
213
+ {
214
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(stepRate));
215
+ }
216
+
217
+ _MTL_INLINE void MTL::VertexBufferLayoutDescriptor::setStepRate(NS::UInteger stepRate)
218
+ {
219
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setStepRate_), stepRate);
220
+ }
221
+
222
+ // static method: alloc
223
+ _MTL_INLINE MTL::VertexBufferLayoutDescriptorArray* MTL::VertexBufferLayoutDescriptorArray::alloc()
224
+ {
225
+ return NS::Object::alloc<MTL::VertexBufferLayoutDescriptorArray>(_MTL_PRIVATE_CLS(MTLVertexBufferLayoutDescriptorArray));
226
+ }
227
+
228
+ // method: init
229
+ _MTL_INLINE MTL::VertexBufferLayoutDescriptorArray* MTL::VertexBufferLayoutDescriptorArray::init()
230
+ {
231
+ return NS::Object::init<MTL::VertexBufferLayoutDescriptorArray>();
232
+ }
233
+
234
+ // method: objectAtIndexedSubscript:
235
+ _MTL_INLINE MTL::VertexBufferLayoutDescriptor* MTL::VertexBufferLayoutDescriptorArray::object(NS::UInteger index)
236
+ {
237
+ return Object::sendMessage<MTL::VertexBufferLayoutDescriptor*>(this, _MTL_PRIVATE_SEL(objectAtIndexedSubscript_), index);
238
+ }
239
+
240
+ // method: setObject:atIndexedSubscript:
241
+ _MTL_INLINE void MTL::VertexBufferLayoutDescriptorArray::setObject(const MTL::VertexBufferLayoutDescriptor* bufferDesc, NS::UInteger index)
242
+ {
243
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setObject_atIndexedSubscript_), bufferDesc, index);
244
+ }
245
+
246
+ // static method: alloc
247
+ _MTL_INLINE MTL::VertexAttributeDescriptor* MTL::VertexAttributeDescriptor::alloc()
248
+ {
249
+ return NS::Object::alloc<MTL::VertexAttributeDescriptor>(_MTL_PRIVATE_CLS(MTLVertexAttributeDescriptor));
250
+ }
251
+
252
+ // method: init
253
+ _MTL_INLINE MTL::VertexAttributeDescriptor* MTL::VertexAttributeDescriptor::init()
254
+ {
255
+ return NS::Object::init<MTL::VertexAttributeDescriptor>();
256
+ }
257
+
258
+ // property: format
259
+ _MTL_INLINE MTL::VertexFormat MTL::VertexAttributeDescriptor::format() const
260
+ {
261
+ return Object::sendMessage<MTL::VertexFormat>(this, _MTL_PRIVATE_SEL(format));
262
+ }
263
+
264
+ _MTL_INLINE void MTL::VertexAttributeDescriptor::setFormat(MTL::VertexFormat format)
265
+ {
266
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setFormat_), format);
267
+ }
268
+
269
+ // property: offset
270
+ _MTL_INLINE NS::UInteger MTL::VertexAttributeDescriptor::offset() const
271
+ {
272
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(offset));
273
+ }
274
+
275
+ _MTL_INLINE void MTL::VertexAttributeDescriptor::setOffset(NS::UInteger offset)
276
+ {
277
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setOffset_), offset);
278
+ }
279
+
280
+ // property: bufferIndex
281
+ _MTL_INLINE NS::UInteger MTL::VertexAttributeDescriptor::bufferIndex() const
282
+ {
283
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(bufferIndex));
284
+ }
285
+
286
+ _MTL_INLINE void MTL::VertexAttributeDescriptor::setBufferIndex(NS::UInteger bufferIndex)
287
+ {
288
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setBufferIndex_), bufferIndex);
289
+ }
290
+
291
+ // static method: alloc
292
+ _MTL_INLINE MTL::VertexAttributeDescriptorArray* MTL::VertexAttributeDescriptorArray::alloc()
293
+ {
294
+ return NS::Object::alloc<MTL::VertexAttributeDescriptorArray>(_MTL_PRIVATE_CLS(MTLVertexAttributeDescriptorArray));
295
+ }
296
+
297
+ // method: init
298
+ _MTL_INLINE MTL::VertexAttributeDescriptorArray* MTL::VertexAttributeDescriptorArray::init()
299
+ {
300
+ return NS::Object::init<MTL::VertexAttributeDescriptorArray>();
301
+ }
302
+
303
+ // method: objectAtIndexedSubscript:
304
+ _MTL_INLINE MTL::VertexAttributeDescriptor* MTL::VertexAttributeDescriptorArray::object(NS::UInteger index)
305
+ {
306
+ return Object::sendMessage<MTL::VertexAttributeDescriptor*>(this, _MTL_PRIVATE_SEL(objectAtIndexedSubscript_), index);
307
+ }
308
+
309
+ // method: setObject:atIndexedSubscript:
310
+ _MTL_INLINE void MTL::VertexAttributeDescriptorArray::setObject(const MTL::VertexAttributeDescriptor* attributeDesc, NS::UInteger index)
311
+ {
312
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setObject_atIndexedSubscript_), attributeDesc, index);
313
+ }
314
+
315
+ // static method: alloc
316
+ _MTL_INLINE MTL::VertexDescriptor* MTL::VertexDescriptor::alloc()
317
+ {
318
+ return NS::Object::alloc<MTL::VertexDescriptor>(_MTL_PRIVATE_CLS(MTLVertexDescriptor));
319
+ }
320
+
321
+ // method: init
322
+ _MTL_INLINE MTL::VertexDescriptor* MTL::VertexDescriptor::init()
323
+ {
324
+ return NS::Object::init<MTL::VertexDescriptor>();
325
+ }
326
+
327
+ // static method: vertexDescriptor
328
+ _MTL_INLINE MTL::VertexDescriptor* MTL::VertexDescriptor::vertexDescriptor()
329
+ {
330
+ return Object::sendMessage<MTL::VertexDescriptor*>(_MTL_PRIVATE_CLS(MTLVertexDescriptor), _MTL_PRIVATE_SEL(vertexDescriptor));
331
+ }
332
+
333
+ // property: layouts
334
+ _MTL_INLINE MTL::VertexBufferLayoutDescriptorArray* MTL::VertexDescriptor::layouts() const
335
+ {
336
+ return Object::sendMessage<MTL::VertexBufferLayoutDescriptorArray*>(this, _MTL_PRIVATE_SEL(layouts));
337
+ }
338
+
339
+ // property: attributes
340
+ _MTL_INLINE MTL::VertexAttributeDescriptorArray* MTL::VertexDescriptor::attributes() const
341
+ {
342
+ return Object::sendMessage<MTL::VertexAttributeDescriptorArray*>(this, _MTL_PRIVATE_SEL(attributes));
343
+ }
344
+
345
+ // method: reset
346
+ _MTL_INLINE void MTL::VertexDescriptor::reset()
347
+ {
348
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(reset));
349
+ }
lib/python3.11/site-packages/mlx/include/metal_cpp/Metal/MTLVisibleFunctionTable.hpp ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
2
+ //
3
+ // Metal/MTLVisibleFunctionTable.hpp
4
+ //
5
+ // Copyright 2020-2023 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 "MTLResource.hpp"
30
+ #include "MTLTypes.hpp"
31
+
32
+ namespace MTL
33
+ {
34
+ class VisibleFunctionTableDescriptor : public NS::Copying<VisibleFunctionTableDescriptor>
35
+ {
36
+ public:
37
+ static class VisibleFunctionTableDescriptor* alloc();
38
+
39
+ class VisibleFunctionTableDescriptor* init();
40
+
41
+ static class VisibleFunctionTableDescriptor* visibleFunctionTableDescriptor();
42
+
43
+ NS::UInteger functionCount() const;
44
+ void setFunctionCount(NS::UInteger functionCount);
45
+ };
46
+
47
+ class VisibleFunctionTable : public NS::Referencing<VisibleFunctionTable, Resource>
48
+ {
49
+ public:
50
+ MTL::ResourceID gpuResourceID() const;
51
+
52
+ void setFunction(const class FunctionHandle* function, NS::UInteger index);
53
+
54
+ void setFunctions(const class FunctionHandle* const functions[], NS::Range range);
55
+ };
56
+
57
+ }
58
+
59
+ // static method: alloc
60
+ _MTL_INLINE MTL::VisibleFunctionTableDescriptor* MTL::VisibleFunctionTableDescriptor::alloc()
61
+ {
62
+ return NS::Object::alloc<MTL::VisibleFunctionTableDescriptor>(_MTL_PRIVATE_CLS(MTLVisibleFunctionTableDescriptor));
63
+ }
64
+
65
+ // method: init
66
+ _MTL_INLINE MTL::VisibleFunctionTableDescriptor* MTL::VisibleFunctionTableDescriptor::init()
67
+ {
68
+ return NS::Object::init<MTL::VisibleFunctionTableDescriptor>();
69
+ }
70
+
71
+ // static method: visibleFunctionTableDescriptor
72
+ _MTL_INLINE MTL::VisibleFunctionTableDescriptor* MTL::VisibleFunctionTableDescriptor::visibleFunctionTableDescriptor()
73
+ {
74
+ return Object::sendMessage<MTL::VisibleFunctionTableDescriptor*>(_MTL_PRIVATE_CLS(MTLVisibleFunctionTableDescriptor), _MTL_PRIVATE_SEL(visibleFunctionTableDescriptor));
75
+ }
76
+
77
+ // property: functionCount
78
+ _MTL_INLINE NS::UInteger MTL::VisibleFunctionTableDescriptor::functionCount() const
79
+ {
80
+ return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(functionCount));
81
+ }
82
+
83
+ _MTL_INLINE void MTL::VisibleFunctionTableDescriptor::setFunctionCount(NS::UInteger functionCount)
84
+ {
85
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setFunctionCount_), functionCount);
86
+ }
87
+
88
+ // property: gpuResourceID
89
+ _MTL_INLINE MTL::ResourceID MTL::VisibleFunctionTable::gpuResourceID() const
90
+ {
91
+ return Object::sendMessage<MTL::ResourceID>(this, _MTL_PRIVATE_SEL(gpuResourceID));
92
+ }
93
+
94
+ // method: setFunction:atIndex:
95
+ _MTL_INLINE void MTL::VisibleFunctionTable::setFunction(const MTL::FunctionHandle* function, NS::UInteger index)
96
+ {
97
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setFunction_atIndex_), function, index);
98
+ }
99
+
100
+ // method: setFunctions:withRange:
101
+ _MTL_INLINE void MTL::VisibleFunctionTable::setFunctions(const MTL::FunctionHandle* const functions[], NS::Range range)
102
+ {
103
+ Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setFunctions_withRange_), functions, range);
104
+ }
lib/python3.11/site-packages/mlx/include/metal_cpp/Metal/Metal.hpp ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
2
+ //
3
+ // Metal/Metal.hpp
4
+ //
5
+ // Copyright 2020-2023 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
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
24
+
25
+ #include "MTLAccelerationStructure.hpp"
26
+ #include "MTLAccelerationStructureCommandEncoder.hpp"
27
+ #include "MTLAccelerationStructureTypes.hpp"
28
+ #include "MTLArgument.hpp"
29
+ #include "MTLArgumentEncoder.hpp"
30
+ #include "MTLBinaryArchive.hpp"
31
+ #include "MTLBlitCommandEncoder.hpp"
32
+ #include "MTLBlitPass.hpp"
33
+ #include "MTLBuffer.hpp"
34
+ #include "MTLCaptureManager.hpp"
35
+ #include "MTLCaptureScope.hpp"
36
+ #include "MTLCommandBuffer.hpp"
37
+ #include "MTLCommandEncoder.hpp"
38
+ #include "MTLCommandQueue.hpp"
39
+ #include "MTLComputeCommandEncoder.hpp"
40
+ #include "MTLComputePass.hpp"
41
+ #include "MTLComputePipeline.hpp"
42
+ #include "MTLCounters.hpp"
43
+ #include "MTLDefines.hpp"
44
+ #include "MTLDepthStencil.hpp"
45
+ #include "MTLDevice.hpp"
46
+ #include "MTLDrawable.hpp"
47
+ #include "MTLDynamicLibrary.hpp"
48
+ #include "MTLEvent.hpp"
49
+ #include "MTLFence.hpp"
50
+ #include "MTLFunctionConstantValues.hpp"
51
+ #include "MTLFunctionDescriptor.hpp"
52
+ #include "MTLFunctionHandle.hpp"
53
+ #include "MTLFunctionLog.hpp"
54
+ #include "MTLFunctionStitching.hpp"
55
+ #include "MTLHeaderBridge.hpp"
56
+ #include "MTLHeap.hpp"
57
+ #include "MTLIndirectCommandBuffer.hpp"
58
+ #include "MTLIndirectCommandEncoder.hpp"
59
+ #include "MTLIntersectionFunctionTable.hpp"
60
+ #include "MTLIOCommandBuffer.hpp"
61
+ #include "MTLIOCommandQueue.hpp"
62
+ #include "MTLIOCompressor.hpp"
63
+ #include "MTLLibrary.hpp"
64
+ #include "MTLLinkedFunctions.hpp"
65
+ #include "MTLParallelRenderCommandEncoder.hpp"
66
+ #include "MTLPipeline.hpp"
67
+ #include "MTLPixelFormat.hpp"
68
+ #include "MTLPrivate.hpp"
69
+ #include "MTLRasterizationRate.hpp"
70
+ #include "MTLRenderCommandEncoder.hpp"
71
+ #include "MTLRenderPass.hpp"
72
+ #include "MTLRenderPipeline.hpp"
73
+ #include "MTLResource.hpp"
74
+ #include "MTLResourceStateCommandEncoder.hpp"
75
+ #include "MTLResourceStatePass.hpp"
76
+ #include "MTLSampler.hpp"
77
+ #include "MTLStageInputOutputDescriptor.hpp"
78
+ #include "MTLTexture.hpp"
79
+ #include "MTLTypes.hpp"
80
+ #include "MTLVertexDescriptor.hpp"
81
+ #include "MTLVisibleFunctionTable.hpp"
82
+ #include "MTLVersion.hpp"
83
+
84
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
lib/python3.11/site-packages/mlx/include/metal_cpp/MetalFX/MTLFXDefines.hpp ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
2
+ //
3
+ // MetalFX/MTLFXDefines.hpp
4
+ //
5
+ // Copyright 2020-2023 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
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
24
+
25
+ #include "../Foundation/NSDefines.hpp"
26
+
27
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
28
+
29
+ #define _MTLFX_EXPORT _NS_EXPORT
30
+ #define _MTLFX_EXTERN _NS_EXTERN
31
+ #define _MTLFX_INLINE _NS_INLINE
32
+ #define _MTLFX_PACKED _NS_PACKED
33
+
34
+ #define _MTLFX_CONST( type, name ) _NS_CONST( type, name )
35
+ #define _MTLFX_ENUM( type, name ) _NS_ENUM( type, name )
36
+ #define _MTLFX_OPTIONS( type, name ) _NS_OPTIONS( type, name )
37
+
38
+ #define _MTLFX_VALIDATE_SIZE( mtlfx, name ) _NS_VALIDATE_SIZE( mtlfx, name )
39
+ #define _MTLFX_VALIDATE_ENUM( mtlfx, name ) _NS_VALIDATE_ENUM( mtlfx, name )
40
+
41
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
lib/python3.11/site-packages/mlx/include/metal_cpp/MetalFX/MTLFXPrivate.hpp ADDED
@@ -0,0 +1,281 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
2
+ //
3
+ // MetalFX/MTLFXPrivate.hpp
4
+ //
5
+ // Copyright 2020-2023 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
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
24
+
25
+ #include "MTLFXDefines.hpp"
26
+
27
+ #include <objc/runtime.h>
28
+
29
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
30
+
31
+ #define _MTLFX_PRIVATE_CLS( symbol ) ( Private::Class::s_k##symbol )
32
+ #define _MTLFX_PRIVATE_SEL( accessor ) ( Private::Selector::s_k##accessor )
33
+
34
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
35
+
36
+ #if defined( MTLFX_PRIVATE_IMPLEMENTATION )
37
+
38
+ #if defined( METALCPP_SYMBOL_VISIBILITY_HIDDEN )
39
+ #define _MTLFX_PRIVATE_VISIBILITY __attribute__( ( visibility("hidden" ) ) )
40
+ #else
41
+ #define _MTLFX_PRIVATE_VISIBILITY __attribute__( ( visibility("default" ) ) )
42
+ #endif // METALCPP_SYMBOL_VISIBILITY_HIDDEN
43
+
44
+ #define _MTLFX_PRIVATE_IMPORT __attribute__( ( weak_import ) )
45
+
46
+ #ifdef __OBJC__
47
+ #define _MTLFX_PRIVATE_OBJC_LOOKUP_CLASS( symbol ) ( ( __bridge void* ) objc_lookUpClass( #symbol ) )
48
+ #define _MTLFX_PRIVATE_OBJC_GET_PROTOCOL( symbol ) ( ( __bridge void* ) objc_getProtocol( #symbol ) )
49
+ #else
50
+ #define _MTLFX_PRIVATE_OBJC_LOOKUP_CLASS( symbol ) objc_lookUpClass(#symbol)
51
+ #define _MTLFX_PRIVATE_OBJC_GET_PROTOCOL( symbol ) objc_getProtocol(#symbol)
52
+ #endif // __OBJC__
53
+
54
+ #define _MTLFX_PRIVATE_DEF_CLS( symbol ) void* s_k##symbol _MTLFX_PRIVATE_VISIBILITY = _MTLFX_PRIVATE_OBJC_LOOKUP_CLASS( symbol )
55
+ #define _MTLFX_PRIVATE_DEF_PRO( symbol ) void* s_k##symbol _MTLFX_PRIVATE_VISIBILITY = _MTLFX_PRIVATE_OBJC_GET_PROTOCOL( symbol )
56
+ #define _MTLFX_PRIVATE_DEF_SEL( accessor, symbol ) SEL s_k##accessor _MTLFX_PRIVATE_VISIBILITY = sel_registerName( symbol )
57
+
58
+ #include <dlfcn.h>
59
+ #define MTLFX_DEF_FUNC( name, signature ) using Fn##name = signature; \
60
+ Fn##name name = reinterpret_cast< Fn##name >( dlsym( RTLD_DEFAULT, #name ) )
61
+
62
+ namespace MTLFX::Private
63
+ {
64
+ template <typename _Type>
65
+
66
+ inline _Type const LoadSymbol(const char* pSymbol)
67
+ {
68
+ const _Type* pAddress = static_cast<_Type*>(dlsym(RTLD_DEFAULT, pSymbol));
69
+
70
+ return pAddress ? *pAddress : nullptr;
71
+ }
72
+ } // MTLFX::Private
73
+
74
+ #if defined( __MAC_13_0 ) || defined( __MAC_14_0 ) || defined( __IPHONE_16_0 ) || defined( __IPHONE_17_0 ) || defined( __TVOS_16_0 ) || defined( __TVOS_17_0 )
75
+
76
+ #define _MTLFX_PRIVATE_DEF_STR( type, symbol ) \
77
+ _MTLFX_EXTERN type const MTLFX##symbol _MTLFX_PRIVATE_IMPORT; \
78
+ type const MTLFX::symbol = ( nullptr != &MTLFX##symbol ) ? MTLFX##ssymbol : nullptr
79
+
80
+ #define _MTLFX_PRIVATE_DEF_CONST( type, symbol ) \
81
+ _MTLFX_EXTERN type const MTLFX##ssymbol _MTLFX_PRIVATE_IMPORT; \
82
+ type const MTLFX::symbol = (nullptr != &MTLFX##ssymbol) ? MTLFX##ssymbol : nullptr
83
+
84
+ #define _MTLFX_PRIVATE_DEF_WEAK_CONST( type, symbol ) \
85
+ _MTLFX_EXTERN type const MTLFX##ssymbol; \
86
+ type const MTLFX::symbol = Private::LoadSymbol< type >( "MTLFX" #symbol )
87
+
88
+ #else
89
+
90
+ #define _MTLFX_PRIVATE_DEF_STR( type, symbol ) \
91
+ _MTLFX_EXTERN type const MTLFX##ssymbol; \
92
+ type const MTLFX::symbol = Private::LoadSymbol< type >( "MTLFX" #symbol )
93
+
94
+ #define _MTLFX_PRIVATE_DEF_CONST( type, symbol ) \
95
+ _MTLFX_EXTERN type const MTLFX##ssymbol; \
96
+ type const MTLFX::symbol = Private::LoadSymbol< type >( "MTLFX" #symbol )
97
+
98
+ #define _MTLFX_PRIVATE_DEF_WEAK_CONST( type, symbol ) _MTLFX_PRIVATE_DEF_CONST( type, symbol )
99
+
100
+ #endif // defined( __MAC_13_0 ) || defined( __MAC_14_0 ) || defined( __IPHONE_16_0 ) || defined( __IPHONE_17_0 ) || defined( __TVOS_16_0 ) || defined( __TVOS_17_0 )
101
+
102
+ #else
103
+
104
+ #define _MTLFX_PRIVATE_DEF_CLS( symbol ) extern void* s_k##symbol
105
+ #define _MTLFX_PRIVATE_DEF_PRO( symbol ) extern void* s_k##symbol
106
+ #define _MTLFX_PRIVATE_DEF_SEL( accessor, symbol ) extern SEL s_k##accessor
107
+ #define _MTLFX_PRIVATE_DEF_STR( type, symbol ) extern type const MTLFX::symbol
108
+ #define _MTLFX_PRIVATE_DEF_CONST( type, symbol ) extern type const MTLFX::symbol
109
+ #define _MTLFX_PRIVATE_DEF_WEAK_CONST( type, symbol ) extern type const MTLFX::symbol
110
+
111
+ #endif // MTLFX_PRIVATE_IMPLEMENTATION
112
+
113
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
114
+
115
+ namespace MTLFX
116
+ {
117
+ namespace Private
118
+ {
119
+ namespace Class
120
+ {
121
+ _MTLFX_PRIVATE_DEF_CLS( MTLFXSpatialScalerDescriptor );
122
+ _MTLFX_PRIVATE_DEF_CLS( MTLFXTemporalScalerDescriptor );
123
+ } // Class
124
+ } // Private
125
+ } // MTLFX
126
+
127
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
128
+
129
+ namespace MTLFX
130
+ {
131
+ namespace Private
132
+ {
133
+ namespace Protocol
134
+ {
135
+ _MTLFX_PRIVATE_DEF_PRO( MTLFXSpatialScaler );
136
+ _MTLFX_PRIVATE_DEF_PRO( MTLFXTemporalScaler );
137
+ } // Protocol
138
+ } // Private
139
+ } // MTLFX
140
+
141
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
142
+
143
+ namespace MTLFX
144
+ {
145
+ namespace Private
146
+ {
147
+ namespace Selector
148
+ {
149
+ _MTLFX_PRIVATE_DEF_SEL( colorProcessingMode,
150
+ "colorProcessingMode" );
151
+ _MTLFX_PRIVATE_DEF_SEL( colorTexture,
152
+ "colorTexture" );
153
+ _MTLFX_PRIVATE_DEF_SEL( colorTextureFormat,
154
+ "colorTextureFormat" );
155
+ _MTLFX_PRIVATE_DEF_SEL( colorTextureUsage,
156
+ "colorTextureUsage" );
157
+ _MTLFX_PRIVATE_DEF_SEL( depthTexture,
158
+ "depthTexture" );
159
+ _MTLFX_PRIVATE_DEF_SEL( depthTextureFormat,
160
+ "depthTextureFormat" );
161
+ _MTLFX_PRIVATE_DEF_SEL( depthTextureUsage,
162
+ "depthTextureUsage" );
163
+ _MTLFX_PRIVATE_DEF_SEL( encodeToCommandBuffer_,
164
+ "encodeToCommandBuffer:" );
165
+ _MTLFX_PRIVATE_DEF_SEL( exposureTexture,
166
+ "exposureTexture" );
167
+ _MTLFX_PRIVATE_DEF_SEL( fence,
168
+ "fence" );
169
+ _MTLFX_PRIVATE_DEF_SEL( inputContentHeight,
170
+ "inputContentHeight" );
171
+ _MTLFX_PRIVATE_DEF_SEL( inputContentMaxScale,
172
+ "inputContentMaxScale" );
173
+ _MTLFX_PRIVATE_DEF_SEL( inputContentMinScale,
174
+ "inputContentMinScale" );
175
+ _MTLFX_PRIVATE_DEF_SEL( inputContentWidth,
176
+ "inputContentWidth" );
177
+ _MTLFX_PRIVATE_DEF_SEL( inputHeight,
178
+ "inputHeight" );
179
+ _MTLFX_PRIVATE_DEF_SEL( inputWidth,
180
+ "inputWidth" );
181
+ _MTLFX_PRIVATE_DEF_SEL( isAutoExposureEnabled,
182
+ "isAutoExposureEnabled" );
183
+ _MTLFX_PRIVATE_DEF_SEL( isDepthReversed,
184
+ "isDepthReversed" );
185
+ _MTLFX_PRIVATE_DEF_SEL( isInputContentPropertiesEnabled,
186
+ "isInputContentPropertiesEnabled" );
187
+ _MTLFX_PRIVATE_DEF_SEL( jitterOffsetX,
188
+ "jitterOffsetX" );
189
+ _MTLFX_PRIVATE_DEF_SEL( jitterOffsetY,
190
+ "jitterOffsetY" );
191
+ _MTLFX_PRIVATE_DEF_SEL( motionTexture,
192
+ "motionTexture" );
193
+ _MTLFX_PRIVATE_DEF_SEL( motionTextureFormat,
194
+ "motionTextureFormat" );
195
+ _MTLFX_PRIVATE_DEF_SEL( motionTextureUsage,
196
+ "motionTextureUsage" );
197
+ _MTLFX_PRIVATE_DEF_SEL( motionVectorScaleX,
198
+ "motionVectorScaleX" );
199
+ _MTLFX_PRIVATE_DEF_SEL( motionVectorScaleY,
200
+ "motionVectorScaleY" );
201
+ _MTLFX_PRIVATE_DEF_SEL( newSpatialScalerWithDevice_,
202
+ "newSpatialScalerWithDevice:" );
203
+ _MTLFX_PRIVATE_DEF_SEL( newTemporalScalerWithDevice_,
204
+ "newTemporalScalerWithDevice:" );
205
+ _MTLFX_PRIVATE_DEF_SEL( outputHeight,
206
+ "outputHeight" );
207
+ _MTLFX_PRIVATE_DEF_SEL( outputTexture,
208
+ "outputTexture" );
209
+ _MTLFX_PRIVATE_DEF_SEL( outputTextureFormat,
210
+ "outputTextureFormat" );
211
+ _MTLFX_PRIVATE_DEF_SEL( outputTextureUsage,
212
+ "outputTextureUsage" );
213
+ _MTLFX_PRIVATE_DEF_SEL( outputWidth,
214
+ "outputWidth" );
215
+ _MTLFX_PRIVATE_DEF_SEL( preExposure,
216
+ "preExposure" );
217
+ _MTLFX_PRIVATE_DEF_SEL( reset,
218
+ "reset" );
219
+ _MTLFX_PRIVATE_DEF_SEL( setAutoExposureEnabled_,
220
+ "setAutoExposureEnabled:" );
221
+ _MTLFX_PRIVATE_DEF_SEL( setColorProcessingMode_,
222
+ "setColorProcessingMode:" );
223
+ _MTLFX_PRIVATE_DEF_SEL( setColorTexture_,
224
+ "setColorTexture:" );
225
+ _MTLFX_PRIVATE_DEF_SEL( setColorTextureFormat_,
226
+ "setColorTextureFormat:" );
227
+ _MTLFX_PRIVATE_DEF_SEL( setDepthReversed_,
228
+ "setDepthReversed:" );
229
+ _MTLFX_PRIVATE_DEF_SEL( setDepthTexture_,
230
+ "setDepthTexture:" );
231
+ _MTLFX_PRIVATE_DEF_SEL( setDepthTextureFormat_,
232
+ "setDepthTextureFormat:" );
233
+ _MTLFX_PRIVATE_DEF_SEL( setExposureTexture_,
234
+ "setExposureTexture:" );
235
+ _MTLFX_PRIVATE_DEF_SEL( setFence_,
236
+ "setFence:" );
237
+ _MTLFX_PRIVATE_DEF_SEL( setInputContentHeight_,
238
+ "setInputContentHeight:" );
239
+ _MTLFX_PRIVATE_DEF_SEL( setInputContentMaxScale_,
240
+ "setInputContentMaxScale:" );
241
+ _MTLFX_PRIVATE_DEF_SEL( setInputContentMinScale_,
242
+ "setInputContentMinScale:" );
243
+ _MTLFX_PRIVATE_DEF_SEL( setInputContentPropertiesEnabled_,
244
+ "setInputContentPropertiesEnabled:" );
245
+ _MTLFX_PRIVATE_DEF_SEL( setInputContentWidth_,
246
+ "setInputContentWidth_:" );
247
+ _MTLFX_PRIVATE_DEF_SEL( setInputHeight_,
248
+ "setInputHeight:" );
249
+ _MTLFX_PRIVATE_DEF_SEL( setInputWidth_,
250
+ "setInputWidth:" );
251
+ _MTLFX_PRIVATE_DEF_SEL( setJitterOffsetX_,
252
+ "setJitterOffsetX:" );
253
+ _MTLFX_PRIVATE_DEF_SEL( setJitterOffsetY_,
254
+ "setJitterOffsetY:" );
255
+ _MTLFX_PRIVATE_DEF_SEL( setMotionTexture_,
256
+ "setMotionTexture:" );
257
+ _MTLFX_PRIVATE_DEF_SEL( setMotionTextureFormat_,
258
+ "setMotionTextureFormat:" );
259
+ _MTLFX_PRIVATE_DEF_SEL( setMotionVectorScaleX_,
260
+ "setMotionVectorScaleX:" );
261
+ _MTLFX_PRIVATE_DEF_SEL( setMotionVectorScaleY_,
262
+ "setMotionVectorScaleY:" );
263
+ _MTLFX_PRIVATE_DEF_SEL( setOutputHeight_,
264
+ "setOutputHeight:" );
265
+ _MTLFX_PRIVATE_DEF_SEL( setOutputTexture_,
266
+ "setOutputTexture:" );
267
+ _MTLFX_PRIVATE_DEF_SEL( setOutputTextureFormat_,
268
+ "setOutputTextureFormat:" );
269
+ _MTLFX_PRIVATE_DEF_SEL( setOutputWidth_,
270
+ "setOutputWidth:" );
271
+ _MTLFX_PRIVATE_DEF_SEL( setPreExposure_,
272
+ "setPreExposure:" );
273
+ _MTLFX_PRIVATE_DEF_SEL( setReset_,
274
+ "setReset:" );
275
+ _MTLFX_PRIVATE_DEF_SEL( supportsDevice_,
276
+ "supportsDevice:" );
277
+ } // Selector
278
+ } // Private
279
+ } // MTLFX
280
+
281
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
lib/python3.11/site-packages/mlx/include/metal_cpp/MetalFX/MTLFXSpatialScaler.hpp ADDED
@@ -0,0 +1,372 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
2
+ //
3
+ // MetalFX/MTLFXSpatialScaler.hpp
4
+ //
5
+ // Copyright 2020-2023 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
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
24
+
25
+ #include "MTLFXDefines.hpp"
26
+ #include "MTLFXPrivate.hpp"
27
+
28
+ #include "../Metal/Metal.hpp"
29
+
30
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
31
+
32
+ namespace MTLFX
33
+ {
34
+ _MTLFX_ENUM( NS::Integer, SpatialScalerColorProcessingMode )
35
+ {
36
+ SpatialScalerColorProcessingModePerceptual = 0,
37
+ SpatialScalerColorProcessingModeLinear = 1,
38
+ SpatialScalerColorProcessingModeHDR = 2
39
+ };
40
+
41
+ class SpatialScalerDescriptor : public NS::Copying< SpatialScalerDescriptor >
42
+ {
43
+ public:
44
+ static class SpatialScalerDescriptor* alloc();
45
+ class SpatialScalerDescriptor* init();
46
+
47
+ MTL::PixelFormat colorTextureFormat() const;
48
+ void setColorTextureFormat( MTL::PixelFormat format );
49
+
50
+ MTL::PixelFormat outputTextureFormat() const;
51
+ void setOutputTextureFormat( MTL::PixelFormat format );
52
+
53
+ NS::UInteger inputWidth() const;
54
+ void setInputWidth( NS::UInteger width );
55
+
56
+ NS::UInteger inputHeight() const;
57
+ void setInputHeight( NS::UInteger height );
58
+
59
+ NS::UInteger outputWidth() const;
60
+ void setOutputWidth( NS::UInteger width );
61
+
62
+ NS::UInteger outputHeight() const;
63
+ void setOutputHeight( NS::UInteger height );
64
+
65
+ SpatialScalerColorProcessingMode colorProcessingMode() const;
66
+ void setColorProcessingMode( SpatialScalerColorProcessingMode mode );
67
+
68
+ class SpatialScaler* newSpatialScaler( const MTL::Device* pDevice );
69
+
70
+ static bool supportsDevice( const MTL::Device* );
71
+ };
72
+
73
+ class SpatialScaler : public NS::Referencing< SpatialScaler >
74
+ {
75
+ public:
76
+ MTL::TextureUsage colorTextureUsage() const;
77
+ MTL::TextureUsage outputTextureUsage() const;
78
+
79
+ NS::UInteger inputContentWidth() const;
80
+ void setInputContentWidth( NS::UInteger width );
81
+
82
+ NS::UInteger inputContentHeight() const;
83
+ void setInputContentHeight( NS::UInteger height );
84
+
85
+ MTL::Texture* colorTexture() const;
86
+ void setColorTexture( MTL::Texture* pTexture );
87
+
88
+ MTL::Texture* outputTexture() const;
89
+ void setOutputTexture( MTL::Texture* pTexture );
90
+
91
+ MTL::PixelFormat colorTextureFormat() const;
92
+ MTL::PixelFormat outputTextureFormat() const;
93
+ NS::UInteger inputWidth() const;
94
+ NS::UInteger inputHeight() const;
95
+ NS::UInteger outputWidth() const;
96
+ NS::UInteger outputHeight() const;
97
+ SpatialScalerColorProcessingMode colorProcessingMode() const;
98
+
99
+ MTL::Fence* fence() const;
100
+ void setFence( MTL::Fence* pFence );
101
+
102
+ void encodeToCommandBuffer( MTL::CommandBuffer* pCommandBuffer );
103
+ };
104
+ }
105
+
106
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
107
+
108
+ _MTLFX_INLINE MTLFX::SpatialScalerDescriptor* MTLFX::SpatialScalerDescriptor::alloc()
109
+ {
110
+ return NS::Object::alloc< SpatialScalerDescriptor >( _MTLFX_PRIVATE_CLS( MTLFXSpatialScalerDescriptor ) );
111
+ }
112
+
113
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
114
+
115
+ _MTLFX_INLINE MTLFX::SpatialScalerDescriptor* MTLFX::SpatialScalerDescriptor::init()
116
+ {
117
+ return NS::Object::init< SpatialScalerDescriptor >();
118
+ }
119
+
120
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
121
+
122
+ _MTLFX_INLINE MTL::PixelFormat MTLFX::SpatialScalerDescriptor::colorTextureFormat() const
123
+ {
124
+ return Object::sendMessage< MTL::PixelFormat >( this, _MTLFX_PRIVATE_SEL( colorTextureFormat ) );
125
+ }
126
+
127
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
128
+
129
+ _MTLFX_INLINE void MTLFX::SpatialScalerDescriptor::setColorTextureFormat( MTL::PixelFormat format )
130
+ {
131
+ Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setColorTextureFormat_ ), format );
132
+ }
133
+
134
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
135
+
136
+ _MTLFX_INLINE MTL::PixelFormat MTLFX::SpatialScalerDescriptor::outputTextureFormat() const
137
+ {
138
+ return Object::sendMessage< MTL::PixelFormat >( this, _MTLFX_PRIVATE_SEL( outputTextureFormat ) );
139
+ }
140
+
141
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
142
+
143
+ _MTLFX_INLINE void MTLFX::SpatialScalerDescriptor::setOutputTextureFormat( MTL::PixelFormat format )
144
+ {
145
+ Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setOutputTextureFormat_ ), format );
146
+ }
147
+
148
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
149
+
150
+ _MTLFX_INLINE NS::UInteger MTLFX::SpatialScalerDescriptor::inputWidth() const
151
+ {
152
+ return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( inputWidth ) );
153
+ }
154
+
155
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
156
+
157
+ _MTLFX_INLINE void MTLFX::SpatialScalerDescriptor::setInputWidth( NS::UInteger width )
158
+ {
159
+ Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setInputWidth_ ), width );
160
+ }
161
+
162
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
163
+
164
+ _MTLFX_INLINE NS::UInteger MTLFX::SpatialScalerDescriptor::inputHeight() const
165
+ {
166
+ return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( inputHeight ) );
167
+ }
168
+
169
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
170
+
171
+ _MTLFX_INLINE void MTLFX::SpatialScalerDescriptor::setInputHeight( NS::UInteger height )
172
+ {
173
+ Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setInputHeight_ ), height );
174
+ }
175
+
176
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
177
+
178
+ _MTLFX_INLINE NS::UInteger MTLFX::SpatialScalerDescriptor::outputWidth() const
179
+ {
180
+ return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( outputWidth ) );
181
+ }
182
+
183
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
184
+
185
+ _MTLFX_INLINE void MTLFX::SpatialScalerDescriptor::setOutputWidth( NS::UInteger width )
186
+ {
187
+ Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setOutputWidth_ ), width );
188
+ }
189
+
190
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
191
+
192
+ _MTLFX_INLINE NS::UInteger MTLFX::SpatialScalerDescriptor::outputHeight() const
193
+ {
194
+ return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( outputHeight ) );
195
+ }
196
+
197
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
198
+
199
+ _MTLFX_INLINE void MTLFX::SpatialScalerDescriptor::setOutputHeight( NS::UInteger height )
200
+ {
201
+ Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setOutputHeight_ ), height );
202
+ }
203
+
204
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
205
+
206
+ _MTLFX_INLINE MTLFX::SpatialScalerColorProcessingMode MTLFX::SpatialScalerDescriptor::colorProcessingMode() const
207
+ {
208
+ return Object::sendMessage< SpatialScalerColorProcessingMode >( this, _MTLFX_PRIVATE_SEL( colorProcessingMode ) );
209
+ }
210
+
211
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
212
+
213
+ _MTLFX_INLINE void MTLFX::SpatialScalerDescriptor::setColorProcessingMode( SpatialScalerColorProcessingMode mode )
214
+ {
215
+ Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setColorProcessingMode_ ), mode );
216
+ }
217
+
218
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
219
+
220
+ _MTLFX_INLINE MTLFX::SpatialScaler* MTLFX::SpatialScalerDescriptor::newSpatialScaler( const MTL::Device* pDevice )
221
+ {
222
+ return Object::sendMessage< SpatialScaler* >( this, _MTLFX_PRIVATE_SEL( newSpatialScalerWithDevice_ ), pDevice );
223
+ }
224
+
225
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
226
+
227
+ _MTLFX_INLINE bool MTLFX::SpatialScalerDescriptor::supportsDevice( const MTL::Device* pDevice )
228
+ {
229
+ return Object::sendMessageSafe< bool >( _NS_PRIVATE_CLS( MTLFXSpatialScalerDescriptor ), _MTLFX_PRIVATE_SEL( supportsDevice_ ), pDevice );
230
+ }
231
+
232
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
233
+
234
+ _MTLFX_INLINE MTL::TextureUsage MTLFX::SpatialScaler::colorTextureUsage() const
235
+ {
236
+ return Object::sendMessage< MTL::TextureUsage >( this, _MTLFX_PRIVATE_SEL( colorTextureUsage ) );
237
+ }
238
+
239
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
240
+
241
+ _MTLFX_INLINE MTL::TextureUsage MTLFX::SpatialScaler::outputTextureUsage() const
242
+ {
243
+ return Object::sendMessage< MTL::TextureUsage >( this, _MTLFX_PRIVATE_SEL( outputTextureUsage ) );
244
+ }
245
+
246
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
247
+
248
+ _MTLFX_INLINE NS::UInteger MTLFX::SpatialScaler::inputContentWidth() const
249
+ {
250
+ return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( inputContentWidth ) );
251
+ }
252
+
253
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
254
+
255
+ _MTLFX_INLINE void MTLFX::SpatialScaler::setInputContentWidth( NS::UInteger width )
256
+ {
257
+ Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setInputContentWidth_ ), width );
258
+ }
259
+
260
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
261
+
262
+ _MTLFX_INLINE NS::UInteger MTLFX::SpatialScaler::inputContentHeight() const
263
+ {
264
+ return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( inputContentHeight ) );
265
+ }
266
+
267
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
268
+
269
+ _MTLFX_INLINE void MTLFX::SpatialScaler::setInputContentHeight( NS::UInteger height )
270
+ {
271
+ Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setInputContentHeight_ ), height );
272
+ }
273
+
274
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
275
+
276
+ _MTLFX_INLINE MTL::Texture* MTLFX::SpatialScaler::colorTexture() const
277
+ {
278
+ return Object::sendMessage< MTL::Texture* >( this, _MTLFX_PRIVATE_SEL( colorTexture ) );
279
+ }
280
+
281
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
282
+
283
+ _MTLFX_INLINE void MTLFX::SpatialScaler::setColorTexture( MTL::Texture* pTexture )
284
+ {
285
+ Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setColorTexture_ ), pTexture );
286
+ }
287
+
288
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
289
+
290
+ _MTLFX_INLINE MTL::Texture* MTLFX::SpatialScaler::outputTexture() const
291
+ {
292
+ return Object::sendMessage< MTL::Texture* >( this, _MTLFX_PRIVATE_SEL( outputTexture ) );
293
+ }
294
+
295
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
296
+
297
+ _MTLFX_INLINE void MTLFX::SpatialScaler::setOutputTexture( MTL::Texture* pTexture )
298
+ {
299
+ Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setOutputTexture_ ), pTexture );
300
+ }
301
+
302
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
303
+
304
+ _MTLFX_INLINE MTL::PixelFormat MTLFX::SpatialScaler::colorTextureFormat() const
305
+ {
306
+ return Object::sendMessage< MTL::PixelFormat >( this, _MTLFX_PRIVATE_SEL( colorTextureFormat ) );
307
+ }
308
+
309
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
310
+
311
+ _MTLFX_INLINE MTL::PixelFormat MTLFX::SpatialScaler::outputTextureFormat() const
312
+ {
313
+ return Object::sendMessage< MTL::PixelFormat >( this, _MTLFX_PRIVATE_SEL( outputTextureFormat ) );
314
+ }
315
+
316
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
317
+
318
+ _MTLFX_INLINE NS::UInteger MTLFX::SpatialScaler::inputWidth() const
319
+ {
320
+ return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( inputWidth ) );
321
+ }
322
+
323
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
324
+
325
+ _MTLFX_INLINE NS::UInteger MTLFX::SpatialScaler::inputHeight() const
326
+ {
327
+ return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( inputHeight ) );
328
+ }
329
+
330
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
331
+
332
+ _MTLFX_INLINE NS::UInteger MTLFX::SpatialScaler::outputWidth() const
333
+ {
334
+ return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( outputWidth ) );
335
+ }
336
+
337
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
338
+
339
+ _MTLFX_INLINE NS::UInteger MTLFX::SpatialScaler::outputHeight() const
340
+ {
341
+ return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( outputHeight ) );
342
+ }
343
+
344
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
345
+
346
+ _MTLFX_INLINE MTLFX::SpatialScalerColorProcessingMode MTLFX::SpatialScaler::colorProcessingMode() const
347
+ {
348
+ return Object::sendMessage< SpatialScalerColorProcessingMode >( this, _MTLFX_PRIVATE_SEL( colorProcessingMode ) );
349
+ }
350
+
351
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
352
+
353
+ _MTLFX_INLINE MTL::Fence* MTLFX::SpatialScaler::fence() const
354
+ {
355
+ return Object::sendMessage< MTL::Fence* >( this, _MTLFX_PRIVATE_SEL( fence ) );
356
+ }
357
+
358
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
359
+
360
+ _MTLFX_INLINE void MTLFX::SpatialScaler::setFence( MTL::Fence* pFence )
361
+ {
362
+ Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setFence_ ), pFence );
363
+ }
364
+
365
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
366
+
367
+ _MTLFX_INLINE void MTLFX::SpatialScaler::encodeToCommandBuffer( MTL::CommandBuffer* pCommandBuffer )
368
+ {
369
+ Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( encodeToCommandBuffer_ ), pCommandBuffer );
370
+ }
371
+
372
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
lib/python3.11/site-packages/mlx/include/metal_cpp/MetalFX/MTLFXTemporalScaler.hpp ADDED
@@ -0,0 +1,660 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
2
+ //
3
+ // MetalFX/MTLFXTemporalScaler.hpp
4
+ //
5
+ // Copyright 2020-2023 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
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
24
+
25
+ #include "MTLFXDefines.hpp"
26
+ #include "MTLFXPrivate.hpp"
27
+
28
+ #include "../Metal/Metal.hpp"
29
+
30
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
31
+
32
+ namespace MTLFX
33
+ {
34
+ class TemporalScalerDescriptor : public NS::Copying< TemporalScalerDescriptor >
35
+ {
36
+ public:
37
+ static class TemporalScalerDescriptor* alloc();
38
+ class TemporalScalerDescriptor* init();
39
+
40
+ MTL::PixelFormat colorTextureFormat() const;
41
+ void setColorTextureFormat( MTL::PixelFormat format );
42
+
43
+ MTL::PixelFormat depthTextureFormat() const;
44
+ void setDepthTextureFormat( MTL::PixelFormat format );
45
+
46
+ MTL::PixelFormat motionTextureFormat() const;
47
+ void setMotionTextureFormat( MTL::PixelFormat format );
48
+
49
+ MTL::PixelFormat outputTextureFormat() const;
50
+ void setOutputTextureFormat( MTL::PixelFormat format );
51
+
52
+ NS::UInteger inputWidth() const;
53
+ void setInputWidth( NS::UInteger width );
54
+
55
+ NS::UInteger inputHeight() const;
56
+ void setInputHeight( NS::UInteger height );
57
+
58
+ NS::UInteger outputWidth() const;
59
+ void setOutputWidth( NS::UInteger width );
60
+
61
+ NS::UInteger outputHeight() const;
62
+ void setOutputHeight( NS::UInteger height );
63
+
64
+ bool isAutoExposureEnabled() const;
65
+ void setAutoExposureEnabled( bool enabled );
66
+
67
+ bool isInputContentPropertiesEnabled() const;
68
+ void setInputContentPropertiesEnabled( bool enabled );
69
+
70
+ float inputContentMinScale() const;
71
+ void setInputContentMinScale( float scale );
72
+
73
+ float inputContentMaxScale() const;
74
+ void setInputContentMaxScale( float scale );
75
+
76
+ class TemporalScaler* newTemporalScaler( const MTL::Device* pDevice ) const;
77
+
78
+ static bool supportsDevice( const MTL::Device* pDevice );
79
+ };
80
+
81
+ class TemporalScaler : public NS::Referencing< TemporalScaler >
82
+ {
83
+ public:
84
+ MTL::TextureUsage colorTextureUsage() const;
85
+ MTL::TextureUsage depthTextureUsage() const;
86
+ MTL::TextureUsage motionTextureUsage() const;
87
+ MTL::TextureUsage outputTextureUsage() const;
88
+
89
+ NS::UInteger inputContentWidth() const;
90
+ void setInputContentWidth( NS::UInteger width );
91
+
92
+ NS::UInteger inputContentHeight() const;
93
+ void setInputContentHeight( NS::UInteger height );
94
+
95
+ MTL::Texture* colorTexture() const;
96
+ void setColorTexture( MTL::Texture* pTexture );
97
+
98
+ MTL::Texture* depthTexture() const;
99
+ void setDepthTexture( MTL::Texture* pTexture );
100
+
101
+ MTL::Texture* motionTexture() const;
102
+ void setMotionTexture( MTL::Texture* pTexture );
103
+
104
+ MTL::Texture* outputTexture() const;
105
+ void setOutputTexture( MTL::Texture* pTexture );
106
+
107
+ MTL::Texture* exposureTexture() const;
108
+ void setExposureTexture( MTL::Texture* pTexture );
109
+
110
+ float preExposure() const;
111
+ void setPreExposure( float preExposure );
112
+
113
+ float jitterOffsetX() const;
114
+ void setJitterOffsetX( float offset );
115
+
116
+ float jitterOffsetY() const;
117
+ void setJitterOffsetY( float offset );
118
+
119
+ float motionVectorScaleX() const;
120
+ void setMotionVectorScaleX( float scale );
121
+
122
+ float motionVectorScaleY() const;
123
+ void setMotionVectorScaleY( float scale );
124
+
125
+ bool reset() const;
126
+ void setReset( bool reset );
127
+
128
+ bool isDepthReversed() const;
129
+ void setDepthReversed( bool depthReversed );
130
+
131
+ MTL::PixelFormat colorTextureFormat() const;
132
+ MTL::PixelFormat depthTextureFormat() const;
133
+ MTL::PixelFormat motionTextureFormat() const;
134
+ MTL::PixelFormat outputTextureFormat() const;
135
+ NS::UInteger inputWidth() const;
136
+ NS::UInteger inputHeight() const;
137
+ NS::UInteger outputWidth() const;
138
+ NS::UInteger outputHeight() const;
139
+ float inputContentMinScale() const;
140
+ float inputContentMaxScale() const;
141
+
142
+ MTL::Fence* fence() const;
143
+ void setFence( MTL::Fence* pFence );
144
+
145
+ void encodeToCommandBuffer( MTL::CommandBuffer* pCommandBuffer );
146
+ };
147
+ }
148
+
149
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
150
+
151
+ _MTLFX_INLINE MTLFX::TemporalScalerDescriptor* MTLFX::TemporalScalerDescriptor::alloc()
152
+ {
153
+ return NS::Object::alloc< TemporalScalerDescriptor >( _MTLFX_PRIVATE_CLS( MTLFXTemporalScalerDescriptor ) );
154
+ }
155
+
156
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
157
+
158
+ _MTLFX_INLINE MTLFX::TemporalScalerDescriptor* MTLFX::TemporalScalerDescriptor::init()
159
+ {
160
+ return NS::Object::init< TemporalScalerDescriptor >();
161
+ }
162
+
163
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
164
+
165
+ _MTLFX_INLINE MTL::PixelFormat MTLFX::TemporalScalerDescriptor::colorTextureFormat() const
166
+ {
167
+ return Object::sendMessage< MTL::PixelFormat >( this, _MTLFX_PRIVATE_SEL( colorTextureFormat ) );
168
+ }
169
+
170
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
171
+
172
+ _MTLFX_INLINE void MTLFX::TemporalScalerDescriptor::setColorTextureFormat( MTL::PixelFormat format )
173
+ {
174
+ Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setColorTextureFormat_ ), format );
175
+ }
176
+
177
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
178
+
179
+ _MTLFX_INLINE MTL::PixelFormat MTLFX::TemporalScalerDescriptor::depthTextureFormat() const
180
+ {
181
+ return Object::sendMessage< MTL::PixelFormat >( this, _MTLFX_PRIVATE_SEL( depthTextureFormat ) );
182
+ }
183
+
184
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
185
+
186
+ _MTLFX_INLINE void MTLFX::TemporalScalerDescriptor::setDepthTextureFormat( MTL::PixelFormat format )
187
+ {
188
+ Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setDepthTextureFormat_ ), format );
189
+ }
190
+
191
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
192
+
193
+ _MTLFX_INLINE MTL::PixelFormat MTLFX::TemporalScalerDescriptor::motionTextureFormat() const
194
+ {
195
+ return Object::sendMessage< MTL::PixelFormat >( this, _MTLFX_PRIVATE_SEL( motionTextureFormat ) );
196
+ }
197
+
198
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
199
+
200
+ _MTLFX_INLINE void MTLFX::TemporalScalerDescriptor::setMotionTextureFormat( MTL::PixelFormat format )
201
+ {
202
+ Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setMotionTextureFormat_ ), format );
203
+ }
204
+
205
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
206
+
207
+ _MTLFX_INLINE MTL::PixelFormat MTLFX::TemporalScalerDescriptor::outputTextureFormat() const
208
+ {
209
+ return Object::sendMessage< MTL::PixelFormat >( this, _MTLFX_PRIVATE_SEL( outputTextureFormat ) );
210
+ }
211
+
212
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
213
+
214
+ _MTLFX_INLINE void MTLFX::TemporalScalerDescriptor::setOutputTextureFormat( MTL::PixelFormat format )
215
+ {
216
+ Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setOutputTextureFormat_ ), format );
217
+ }
218
+
219
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
220
+
221
+ _MTLFX_INLINE NS::UInteger MTLFX::TemporalScalerDescriptor::inputWidth() const
222
+ {
223
+ return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( inputWidth ) );
224
+ }
225
+
226
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
227
+
228
+ _MTLFX_INLINE void MTLFX::TemporalScalerDescriptor::setInputWidth( NS::UInteger width )
229
+ {
230
+ Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setInputWidth_ ), width );
231
+ }
232
+
233
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
234
+
235
+ _MTLFX_INLINE NS::UInteger MTLFX::TemporalScalerDescriptor::inputHeight() const
236
+ {
237
+ return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( inputHeight ) );
238
+ }
239
+
240
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
241
+
242
+ _MTLFX_INLINE void MTLFX::TemporalScalerDescriptor::setInputHeight( NS::UInteger height )
243
+ {
244
+ Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setInputHeight_ ), height );
245
+ }
246
+
247
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
248
+
249
+ _MTLFX_INLINE NS::UInteger MTLFX::TemporalScalerDescriptor::outputWidth() const
250
+ {
251
+ return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( outputWidth ) );
252
+ }
253
+
254
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
255
+
256
+ _MTLFX_INLINE void MTLFX::TemporalScalerDescriptor::setOutputWidth( NS::UInteger width )
257
+ {
258
+ Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setOutputWidth_ ), width );
259
+ }
260
+
261
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
262
+
263
+ _MTLFX_INLINE NS::UInteger MTLFX::TemporalScalerDescriptor::outputHeight() const
264
+ {
265
+ return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( outputHeight ) );
266
+ }
267
+
268
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
269
+
270
+ _MTLFX_INLINE void MTLFX::TemporalScalerDescriptor::setOutputHeight( NS::UInteger height )
271
+ {
272
+ Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setOutputHeight_ ), height );
273
+ }
274
+
275
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
276
+
277
+ _MTLFX_INLINE bool MTLFX::TemporalScalerDescriptor::isAutoExposureEnabled() const
278
+ {
279
+ return Object::sendMessage< bool >( this, _MTLFX_PRIVATE_SEL( isAutoExposureEnabled ) );
280
+ }
281
+
282
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
283
+
284
+ _MTLFX_INLINE void MTLFX::TemporalScalerDescriptor::setAutoExposureEnabled( bool enabled )
285
+ {
286
+ Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setAutoExposureEnabled_ ), enabled );
287
+ }
288
+
289
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
290
+
291
+ _MTLFX_INLINE bool MTLFX::TemporalScalerDescriptor::isInputContentPropertiesEnabled() const
292
+ {
293
+ return Object::sendMessage< bool >( this, _MTLFX_PRIVATE_SEL( isInputContentPropertiesEnabled ) );
294
+ }
295
+
296
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
297
+
298
+ _MTLFX_INLINE void MTLFX::TemporalScalerDescriptor::setInputContentPropertiesEnabled( bool enabled )
299
+ {
300
+ Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setInputContentPropertiesEnabled_ ), enabled );
301
+ }
302
+
303
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
304
+
305
+ _MTLFX_INLINE float MTLFX::TemporalScalerDescriptor::inputContentMinScale() const
306
+ {
307
+ return Object::sendMessage< float >( this, _MTLFX_PRIVATE_SEL( inputContentMinScale ) );
308
+ }
309
+
310
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
311
+
312
+ _MTLFX_INLINE void MTLFX::TemporalScalerDescriptor::setInputContentMinScale( float scale )
313
+ {
314
+ Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setInputContentMinScale_ ), scale );
315
+ }
316
+
317
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
318
+
319
+ _MTLFX_INLINE float MTLFX::TemporalScalerDescriptor::inputContentMaxScale() const
320
+ {
321
+ return Object::sendMessage< float >( this, _MTLFX_PRIVATE_SEL( inputContentMaxScale ) );
322
+ }
323
+
324
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
325
+
326
+ _MTLFX_INLINE void MTLFX::TemporalScalerDescriptor::setInputContentMaxScale( float scale )
327
+ {
328
+ Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setInputContentMaxScale_ ), scale );
329
+ }
330
+
331
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
332
+
333
+ _MTLFX_INLINE MTLFX::TemporalScaler* MTLFX::TemporalScalerDescriptor::newTemporalScaler( const MTL::Device* pDevice ) const
334
+ {
335
+ return Object::sendMessage< TemporalScaler* >( this, _MTLFX_PRIVATE_SEL( newTemporalScalerWithDevice_ ), pDevice );
336
+ }
337
+
338
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
339
+
340
+ _MTLFX_INLINE bool MTLFX::TemporalScalerDescriptor::supportsDevice( const MTL::Device* pDevice )
341
+ {
342
+ return Object::sendMessageSafe< bool >( _NS_PRIVATE_CLS( MTLFXTemporalScalerDescriptor ), _MTLFX_PRIVATE_SEL( supportsDevice_ ), pDevice );
343
+ }
344
+
345
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
346
+
347
+ _MTLFX_INLINE MTL::TextureUsage MTLFX::TemporalScaler::colorTextureUsage() const
348
+ {
349
+ return Object::sendMessage< MTL::TextureUsage >( this, _MTLFX_PRIVATE_SEL( colorTextureUsage ) );
350
+ }
351
+
352
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
353
+
354
+ _MTLFX_INLINE MTL::TextureUsage MTLFX::TemporalScaler::depthTextureUsage() const
355
+ {
356
+ return Object::sendMessage< MTL::TextureUsage >( this, _MTLFX_PRIVATE_SEL( depthTextureUsage ) );
357
+ }
358
+
359
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
360
+
361
+ _MTLFX_INLINE MTL::TextureUsage MTLFX::TemporalScaler::motionTextureUsage() const
362
+ {
363
+ return Object::sendMessage< MTL::TextureUsage >( this, _MTLFX_PRIVATE_SEL( motionTextureUsage ) );
364
+ }
365
+
366
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
367
+
368
+ _MTLFX_INLINE MTL::TextureUsage MTLFX::TemporalScaler::outputTextureUsage() const
369
+ {
370
+ return Object::sendMessage< MTL::TextureUsage >( this, _MTLFX_PRIVATE_SEL( outputTextureUsage ) );
371
+ }
372
+
373
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
374
+
375
+ _MTLFX_INLINE NS::UInteger MTLFX::TemporalScaler::inputContentWidth() const
376
+ {
377
+ return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( inputContentWidth ) );
378
+ }
379
+
380
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
381
+
382
+ _MTLFX_INLINE void MTLFX::TemporalScaler::setInputContentWidth( NS::UInteger width )
383
+ {
384
+ Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setInputContentWidth_ ), width );
385
+ }
386
+
387
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
388
+
389
+ _MTLFX_INLINE NS::UInteger MTLFX::TemporalScaler::inputContentHeight() const
390
+ {
391
+ return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( inputContentHeight ) );
392
+ }
393
+
394
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
395
+
396
+ _MTLFX_INLINE void MTLFX::TemporalScaler::setInputContentHeight( NS::UInteger height )
397
+ {
398
+ Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setInputContentHeight_ ), height );
399
+ }
400
+
401
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
402
+
403
+ _MTLFX_INLINE MTL::Texture* MTLFX::TemporalScaler::colorTexture() const
404
+ {
405
+ return Object::sendMessage< MTL::Texture* >( this, _MTLFX_PRIVATE_SEL( colorTexture ) );
406
+ }
407
+
408
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
409
+
410
+ _MTLFX_INLINE void MTLFX::TemporalScaler::setColorTexture( MTL::Texture* pTexture )
411
+ {
412
+ Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setColorTexture_ ), pTexture );
413
+ }
414
+
415
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
416
+
417
+ _MTLFX_INLINE MTL::Texture* MTLFX::TemporalScaler::depthTexture() const
418
+ {
419
+ return Object::sendMessage< MTL::Texture* >( this, _MTLFX_PRIVATE_SEL( depthTexture ) );
420
+ }
421
+
422
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
423
+
424
+ _MTLFX_INLINE void MTLFX::TemporalScaler::setDepthTexture( MTL::Texture* pTexture )
425
+ {
426
+ Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setDepthTexture_ ), pTexture );
427
+ }
428
+
429
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
430
+
431
+ _MTLFX_INLINE MTL::Texture* MTLFX::TemporalScaler::motionTexture() const
432
+ {
433
+ return Object::sendMessage< MTL::Texture* >( this, _MTLFX_PRIVATE_SEL( motionTexture ) );
434
+ }
435
+
436
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
437
+
438
+ _MTLFX_INLINE void MTLFX::TemporalScaler::setMotionTexture( MTL::Texture* pTexture )
439
+ {
440
+ Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setMotionTexture_ ), pTexture );
441
+ }
442
+
443
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
444
+
445
+ _MTLFX_INLINE MTL::Texture* MTLFX::TemporalScaler::outputTexture() const
446
+ {
447
+ return Object::sendMessage< MTL::Texture* >( this, _MTLFX_PRIVATE_SEL( outputTexture ) );
448
+ }
449
+
450
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
451
+
452
+ _MTLFX_INLINE void MTLFX::TemporalScaler::setOutputTexture( MTL::Texture* pTexture )
453
+ {
454
+ Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setOutputTexture_ ), pTexture );
455
+ }
456
+
457
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
458
+
459
+ _MTLFX_INLINE MTL::Texture* MTLFX::TemporalScaler::exposureTexture() const
460
+ {
461
+ return Object::sendMessage< MTL::Texture* >( this, _MTLFX_PRIVATE_SEL( exposureTexture ) );
462
+ }
463
+
464
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
465
+
466
+ _MTLFX_INLINE void MTLFX::TemporalScaler::setExposureTexture( MTL::Texture* pTexture )
467
+ {
468
+ Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setExposureTexture_ ), pTexture );
469
+ }
470
+
471
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
472
+
473
+ _MTLFX_INLINE float MTLFX::TemporalScaler::preExposure() const
474
+ {
475
+ return Object::sendMessage< float >( this, _MTLFX_PRIVATE_SEL( preExposure ) );
476
+ }
477
+
478
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
479
+
480
+ _MTLFX_INLINE void MTLFX::TemporalScaler::setPreExposure( float preExposure )
481
+ {
482
+ Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setPreExposure_ ), preExposure );
483
+ }
484
+
485
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
486
+
487
+ _MTLFX_INLINE float MTLFX::TemporalScaler::jitterOffsetX() const
488
+ {
489
+ return Object::sendMessage< float >( this, _MTLFX_PRIVATE_SEL( jitterOffsetX ) );
490
+ }
491
+
492
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
493
+
494
+ _MTLFX_INLINE void MTLFX::TemporalScaler::setJitterOffsetX( float offset )
495
+ {
496
+ Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setJitterOffsetX_ ), offset );
497
+ }
498
+
499
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
500
+
501
+ _MTLFX_INLINE float MTLFX::TemporalScaler::jitterOffsetY() const
502
+ {
503
+ return Object::sendMessage< float >( this, _MTLFX_PRIVATE_SEL( jitterOffsetY ) );
504
+ }
505
+
506
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
507
+
508
+ _MTLFX_INLINE void MTLFX::TemporalScaler::setJitterOffsetY( float offset )
509
+ {
510
+ Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setJitterOffsetY_ ), offset );
511
+ }
512
+
513
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
514
+
515
+ _MTLFX_INLINE float MTLFX::TemporalScaler::motionVectorScaleX() const
516
+ {
517
+ return Object::sendMessage< float >( this, _MTLFX_PRIVATE_SEL( motionVectorScaleX ) );
518
+ }
519
+
520
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
521
+
522
+ _MTLFX_INLINE void MTLFX::TemporalScaler::setMotionVectorScaleX( float scale )
523
+ {
524
+ Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setMotionVectorScaleX_ ), scale );
525
+ }
526
+
527
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
528
+
529
+ _MTLFX_INLINE float MTLFX::TemporalScaler::motionVectorScaleY() const
530
+ {
531
+ return Object::sendMessage< float >( this, _MTLFX_PRIVATE_SEL( motionVectorScaleY ) );
532
+ }
533
+
534
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
535
+
536
+ _MTLFX_INLINE void MTLFX::TemporalScaler::setMotionVectorScaleY( float scale )
537
+ {
538
+ Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setMotionVectorScaleY_ ), scale );
539
+ }
540
+
541
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
542
+
543
+ _MTLFX_INLINE bool MTLFX::TemporalScaler::reset() const
544
+ {
545
+ return Object::sendMessage< bool >( this, _MTLFX_PRIVATE_SEL( reset ) );
546
+ }
547
+
548
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
549
+
550
+ _MTLFX_INLINE void MTLFX::TemporalScaler::setReset( bool reset )
551
+ {
552
+ Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setReset_ ), reset );
553
+ }
554
+
555
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
556
+
557
+ _MTLFX_INLINE bool MTLFX::TemporalScaler::isDepthReversed() const
558
+ {
559
+ return Object::sendMessage< bool >( this, _MTLFX_PRIVATE_SEL( isDepthReversed ) );
560
+ }
561
+
562
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
563
+
564
+ _MTLFX_INLINE void MTLFX::TemporalScaler::setDepthReversed( bool depthReversed )
565
+ {
566
+ Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setDepthReversed_ ), depthReversed );
567
+ }
568
+
569
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
570
+
571
+ _MTLFX_INLINE MTL::PixelFormat MTLFX::TemporalScaler::colorTextureFormat() const
572
+ {
573
+ return Object::sendMessage< MTL::PixelFormat >( this, _MTLFX_PRIVATE_SEL( colorTextureFormat ) );
574
+ }
575
+
576
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
577
+
578
+ _MTLFX_INLINE MTL::PixelFormat MTLFX::TemporalScaler::depthTextureFormat() const
579
+ {
580
+ return Object::sendMessage< MTL::PixelFormat >( this, _MTLFX_PRIVATE_SEL( depthTextureFormat ) );
581
+ }
582
+
583
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
584
+
585
+ _MTLFX_INLINE MTL::PixelFormat MTLFX::TemporalScaler::motionTextureFormat() const
586
+ {
587
+ return Object::sendMessage< MTL::PixelFormat >( this, _MTLFX_PRIVATE_SEL( motionTextureFormat ) );
588
+ }
589
+
590
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
591
+
592
+ _MTLFX_INLINE MTL::PixelFormat MTLFX::TemporalScaler::outputTextureFormat() const
593
+ {
594
+ return Object::sendMessage< MTL::PixelFormat >( this, _MTLFX_PRIVATE_SEL( outputTextureFormat ) );
595
+ }
596
+
597
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
598
+
599
+ _MTLFX_INLINE NS::UInteger MTLFX::TemporalScaler::inputWidth() const
600
+ {
601
+ return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( inputWidth ) );
602
+ }
603
+
604
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
605
+
606
+ _MTLFX_INLINE NS::UInteger MTLFX::TemporalScaler::inputHeight() const
607
+ {
608
+ return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( inputHeight ) );
609
+ }
610
+
611
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
612
+
613
+ _MTLFX_INLINE NS::UInteger MTLFX::TemporalScaler::outputWidth() const
614
+ {
615
+ return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( outputWidth ) );
616
+ }
617
+
618
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
619
+
620
+ _MTLFX_INLINE NS::UInteger MTLFX::TemporalScaler::outputHeight() const
621
+ {
622
+ return Object::sendMessage< NS::UInteger >( this, _MTLFX_PRIVATE_SEL( outputHeight ) );
623
+ }
624
+
625
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
626
+
627
+ _MTLFX_INLINE float MTLFX::TemporalScaler::inputContentMinScale() const
628
+ {
629
+ return Object::sendMessage< float >( this, _MTLFX_PRIVATE_SEL( inputContentMinScale ) );
630
+ }
631
+
632
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
633
+
634
+ _MTLFX_INLINE float MTLFX::TemporalScaler::inputContentMaxScale() const
635
+ {
636
+ return Object::sendMessage< float >( this, _MTLFX_PRIVATE_SEL( inputContentMaxScale ) );
637
+ }
638
+
639
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
640
+
641
+ _MTLFX_INLINE MTL::Fence* MTLFX::TemporalScaler::fence() const
642
+ {
643
+ return Object::sendMessage< MTL::Fence* >( this, _MTLFX_PRIVATE_SEL( fence ) );
644
+ }
645
+
646
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
647
+
648
+ _MTLFX_INLINE void MTLFX::TemporalScaler::setFence( MTL::Fence* pFence )
649
+ {
650
+ Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( setFence_ ), pFence );
651
+ }
652
+
653
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
654
+
655
+ _MTLFX_INLINE void MTLFX::TemporalScaler::encodeToCommandBuffer( MTL::CommandBuffer* pCommandBuffer )
656
+ {
657
+ Object::sendMessage< void >( this, _MTL_PRIVATE_SEL( encodeToCommandBuffer_ ), pCommandBuffer );
658
+ }
659
+
660
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
lib/python3.11/site-packages/mlx/include/metal_cpp/MetalFX/MetalFX.hpp ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
2
+ //
3
+ // MetalFX/MetalFX.hpp
4
+ //
5
+ // Copyright 2020-2023 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
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
24
+
25
+ #include "MTLFXSpatialScaler.hpp"
26
+ #include "MTLFXTemporalScaler.hpp"
27
+
28
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
lib/python3.11/site-packages/mlx/include/metal_cpp/QuartzCore/CADefines.hpp ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
2
+ //
3
+ // QuartzCore/CADefines.hpp
4
+ //
5
+ // Copyright 2020-2023 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
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
24
+
25
+ #include "../Foundation/NSDefines.hpp"
26
+
27
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
28
+
29
+ #define _CA_EXPORT _NS_EXPORT
30
+ #define _CA_EXTERN _NS_EXTERN
31
+ #define _CA_INLINE _NS_INLINE
32
+ #define _CA_PACKED _NS_PACKED
33
+
34
+ #define _CA_CONST(type, name) _NS_CONST(type, name)
35
+ #define _CA_ENUM(type, name) _NS_ENUM(type, name)
36
+ #define _CA_OPTIONS(type, name) _NS_OPTIONS(type, name)
37
+
38
+ #define _CA_VALIDATE_SIZE(ns, name) _NS_VALIDATE_SIZE(ns, name)
39
+ #define _CA_VALIDATE_ENUM(ns, name) _NS_VALIDATE_ENUM(ns, name)
40
+
41
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
lib/python3.11/site-packages/mlx/include/metal_cpp/QuartzCore/CAMetalDrawable.hpp ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
2
+ //
3
+ // QuartzCore/CAMetalDrawable.hpp
4
+ //
5
+ // Copyright 2020-2023 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
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
24
+
25
+ #include "../Metal/MTLDrawable.hpp"
26
+ #include "../Metal/MTLTexture.hpp"
27
+
28
+ #include "CADefines.hpp"
29
+ #include "CAPrivate.hpp"
30
+
31
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
32
+
33
+ namespace CA
34
+ {
35
+ class MetalDrawable : public NS::Referencing<MetalDrawable, MTL::Drawable>
36
+ {
37
+ public:
38
+ class MetalLayer* layer() const;
39
+ MTL::Texture* texture() const;
40
+ };
41
+ }
42
+
43
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
44
+
45
+ _CA_INLINE CA::MetalLayer* CA::MetalDrawable::layer() const
46
+ {
47
+ return Object::sendMessage<MetalLayer*>(this, _CA_PRIVATE_SEL(layer));
48
+ }
49
+
50
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
51
+
52
+ _CA_INLINE MTL::Texture* CA::MetalDrawable::texture() const
53
+ {
54
+ return Object::sendMessage<MTL::Texture*>(this, _CA_PRIVATE_SEL(texture));
55
+ }
56
+
57
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
lib/python3.11/site-packages/mlx/include/metal_cpp/QuartzCore/CAMetalLayer.hpp ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
2
+ //
3
+ // QuartzCore/CAMetalDrawable.hpp
4
+ //
5
+ // Copyright 2020-2023 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
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
24
+
25
+ #include "../Metal/MTLPixelFormat.hpp"
26
+ #include "../Metal/MTLTexture.hpp"
27
+ #include <CoreGraphics/CGGeometry.h>
28
+
29
+ #include "CADefines.hpp"
30
+ #include "CAMetalDrawable.hpp"
31
+ #include "CAPrivate.hpp"
32
+
33
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
34
+
35
+ namespace CA
36
+ {
37
+
38
+ class MetalLayer : public NS::Referencing<MetalLayer>
39
+ {
40
+ public:
41
+ static class MetalLayer* layer();
42
+
43
+ MTL::Device* device() const;
44
+ void setDevice(MTL::Device* device);
45
+
46
+ MTL::PixelFormat pixelFormat() const;
47
+ void setPixelFormat(MTL::PixelFormat pixelFormat);
48
+
49
+ bool framebufferOnly() const;
50
+ void setFramebufferOnly(bool framebufferOnly);
51
+
52
+ CGSize drawableSize() const;
53
+ void setDrawableSize(CGSize drawableSize);
54
+
55
+ class MetalDrawable* nextDrawable();
56
+ };
57
+ } // namespace CA
58
+
59
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
60
+ _CA_INLINE CA::MetalLayer* CA::MetalLayer::layer()
61
+ {
62
+ return Object::sendMessage<CA::MetalLayer*>(_CA_PRIVATE_CLS(CAMetalLayer), _CA_PRIVATE_SEL(layer));
63
+ }
64
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
65
+
66
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
67
+
68
+ _CA_INLINE MTL::Device* CA::MetalLayer::device() const
69
+ {
70
+ return Object::sendMessage<MTL::Device*>(this, _CA_PRIVATE_SEL(device));
71
+ }
72
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
73
+
74
+ _CA_INLINE void CA::MetalLayer::setDevice(MTL::Device* device)
75
+ {
76
+ return Object::sendMessage<void>(this, _CA_PRIVATE_SEL(setDevice_), device);
77
+ }
78
+
79
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
80
+
81
+ _CA_INLINE MTL::PixelFormat CA::MetalLayer::pixelFormat() const
82
+ {
83
+ return Object::sendMessage<MTL::PixelFormat>(this,
84
+ _CA_PRIVATE_SEL(pixelFormat));
85
+ }
86
+
87
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
88
+
89
+ _CA_INLINE void CA::MetalLayer::setPixelFormat(MTL::PixelFormat pixelFormat)
90
+ {
91
+ return Object::sendMessage<void>(this, _CA_PRIVATE_SEL(setPixelFormat_),
92
+ pixelFormat);
93
+ }
94
+
95
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
96
+
97
+ _CA_INLINE bool CA::MetalLayer::framebufferOnly() const
98
+ {
99
+ return Object::sendMessage<bool>(this, _CA_PRIVATE_SEL(framebufferOnly));
100
+ }
101
+
102
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
103
+
104
+ _CA_INLINE void CA::MetalLayer::setFramebufferOnly(bool framebufferOnly)
105
+ {
106
+ return Object::sendMessage<void>(this, _CA_PRIVATE_SEL(setFramebufferOnly_),
107
+ framebufferOnly);
108
+ }
109
+
110
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
111
+
112
+ _CA_INLINE CGSize CA::MetalLayer::drawableSize() const
113
+ {
114
+ return Object::sendMessage<CGSize>(this, _CA_PRIVATE_SEL(drawableSize));
115
+ }
116
+
117
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
118
+
119
+ _CA_INLINE void CA::MetalLayer::setDrawableSize(CGSize drawableSize)
120
+ {
121
+ return Object::sendMessage<void>(this, _CA_PRIVATE_SEL(setDrawableSize_),
122
+ drawableSize);
123
+ }
124
+
125
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
126
+
127
+ _CA_INLINE CA::MetalDrawable* CA::MetalLayer::nextDrawable()
128
+ {
129
+ return Object::sendMessage<MetalDrawable*>(this,
130
+ _CA_PRIVATE_SEL(nextDrawable));
131
+ }
lib/python3.11/site-packages/mlx/include/metal_cpp/QuartzCore/CAPrivate.hpp ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
2
+ //
3
+ // QuartzCore/CAPrivate.hpp
4
+ //
5
+ // Copyright 2020-2023 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
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
24
+
25
+ #include "CADefines.hpp"
26
+
27
+ #include <objc/runtime.h>
28
+
29
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
30
+
31
+ #define _CA_PRIVATE_CLS(symbol) (Private::Class::s_k##symbol)
32
+ #define _CA_PRIVATE_SEL(accessor) (Private::Selector::s_k##accessor)
33
+
34
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
35
+
36
+ #if defined(CA_PRIVATE_IMPLEMENTATION)
37
+
38
+ #ifdef METALCPP_SYMBOL_VISIBILITY_HIDDEN
39
+ #define _CA_PRIVATE_VISIBILITY __attribute__((visibility("hidden")))
40
+ #else
41
+ #define _CA_PRIVATE_VISIBILITY __attribute__((visibility("default")))
42
+ #endif // METALCPP_SYMBOL_VISIBILITY_HIDDEN
43
+
44
+ #define _CA_PRIVATE_IMPORT __attribute__((weak_import))
45
+
46
+ #ifdef __OBJC__
47
+ #define _CA_PRIVATE_OBJC_LOOKUP_CLASS(symbol) ((__bridge void*)objc_lookUpClass(#symbol))
48
+ #define _CA_PRIVATE_OBJC_GET_PROTOCOL(symbol) ((__bridge void*)objc_getProtocol(#symbol))
49
+ #else
50
+ #define _CA_PRIVATE_OBJC_LOOKUP_CLASS(symbol) objc_lookUpClass(#symbol)
51
+ #define _CA_PRIVATE_OBJC_GET_PROTOCOL(symbol) objc_getProtocol(#symbol)
52
+ #endif // __OBJC__
53
+
54
+ #define _CA_PRIVATE_DEF_CLS(symbol) void* s_k##symbol _CA_PRIVATE_VISIBILITY = _CA_PRIVATE_OBJC_LOOKUP_CLASS(symbol)
55
+ #define _CA_PRIVATE_DEF_PRO(symbol) void* s_k##symbol _CA_PRIVATE_VISIBILITY = _CA_PRIVATE_OBJC_GET_PROTOCOL(symbol)
56
+ #define _CA_PRIVATE_DEF_SEL(accessor, symbol) SEL s_k##accessor _CA_PRIVATE_VISIBILITY = sel_registerName(symbol)
57
+ #define _CA_PRIVATE_DEF_STR(type, symbol) \
58
+ _CA_EXTERN type const CA##symbol _CA_PRIVATE_IMPORT; \
59
+ type const CA::symbol = (nullptr != &CA##symbol) ? CA##symbol : nullptr
60
+
61
+ #else
62
+
63
+ #define _CA_PRIVATE_DEF_CLS(symbol) extern void* s_k##symbol
64
+ #define _CA_PRIVATE_DEF_PRO(symbol) extern void* s_k##symbol
65
+ #define _CA_PRIVATE_DEF_SEL(accessor, symbol) extern SEL s_k##accessor
66
+ #define _CA_PRIVATE_DEF_STR(type, symbol) extern type const CA::symbol
67
+
68
+ #endif // CA_PRIVATE_IMPLEMENTATION
69
+
70
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
71
+
72
+ namespace CA
73
+ {
74
+ namespace Private
75
+ {
76
+ namespace Class
77
+ {
78
+ _CA_PRIVATE_DEF_CLS(CAMetalLayer);
79
+ } // Class
80
+ } // Private
81
+ } // CA
82
+
83
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
84
+
85
+ namespace CA
86
+ {
87
+ namespace Private
88
+ {
89
+ namespace Protocol
90
+ {
91
+
92
+ _CA_PRIVATE_DEF_PRO(CAMetalDrawable);
93
+
94
+ } // Protocol
95
+ } // Private
96
+ } // CA
97
+
98
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
99
+
100
+ namespace CA
101
+ {
102
+ namespace Private
103
+ {
104
+ namespace Selector
105
+ {
106
+ _CA_PRIVATE_DEF_SEL(device,
107
+ "device");
108
+ _CA_PRIVATE_DEF_SEL(drawableSize,
109
+ "drawableSize");
110
+ _CA_PRIVATE_DEF_SEL(framebufferOnly,
111
+ "framebufferOnly");
112
+ _CA_PRIVATE_DEF_SEL(layer,
113
+ "layer");
114
+ _CA_PRIVATE_DEF_SEL(nextDrawable,
115
+ "nextDrawable");
116
+ _CA_PRIVATE_DEF_SEL(pixelFormat,
117
+ "pixelFormat");
118
+ _CA_PRIVATE_DEF_SEL(setDevice_,
119
+ "setDevice:");
120
+ _CA_PRIVATE_DEF_SEL(setDrawableSize_,
121
+ "setDrawableSize:");
122
+ _CA_PRIVATE_DEF_SEL(setFramebufferOnly_,
123
+ "setFramebufferOnly:");
124
+ _CA_PRIVATE_DEF_SEL(setPixelFormat_,
125
+ "setPixelFormat:");
126
+ _CA_PRIVATE_DEF_SEL(texture,
127
+ "texture");
128
+ } // Class
129
+ } // Private
130
+ } // CA
131
+
132
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
lib/python3.11/site-packages/mlx/include/metal_cpp/QuartzCore/QuartzCore.hpp ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
2
+ //
3
+ // QuartzCore/QuartzCore.hpp
4
+ //
5
+ // Copyright 2020-2023 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
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
24
+
25
+ #include "CAMetalDrawable.hpp"
26
+ #include "CAMetalLayer.hpp"
27
+
28
+ //-------------------------------------------------------------------------------------------------------------------------------------------------------------
lib/python3.11/site-packages/mlx/include/metal_cpp/README.md ADDED
@@ -0,0 +1,311 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## About
2
+
3
+ **metal-cpp** is a low overhead and header only C++ interface for Metal that helps developers add Metal functionality to graphics applications that are written in C++ (such as game engines). **metal-cpp** removes the need to create a shim and allows developers to call Metal functions directly from anywhere in their existing C++ code.
4
+
5
+
6
+ ## Highlights
7
+
8
+ - Drop in C++ alternative interface to the Metal Objective-C headers.
9
+ - Direct mapping of all Metal Objective-C classes, constants and enums to C++ in the MTL C++ namespace.
10
+ - No measurable overhead compared to calling Metal Objective-C headers, due to inlining of C++ function calls.
11
+ - No usage of wrapper containers that require additional allocations.
12
+ - Requires C++17 due to the usage of `constexpr` in `NS::Object`.
13
+ - Identical header files and function/constant/enum availability for iOS, macOS and tvOS.
14
+ - Backwards compatibility: All `bool MTL::Device::supports...()` functions check if their required selectors exist and automatically return `false` if not.
15
+ - String (`ErrorDomain`) constants are weak linked and automatically set to `nullptr` if not available.
16
+
17
+ ## Changelog
18
+
19
+ | Version | Changes |
20
+ |-|-|
21
+ | macOS 14, iOS 17 | Add support for the **MetalFX** framework. <br/>Add all the APIs in macOS 14 and iOS 17. |
22
+ | macOS 13.3, iOS 16.4 | Add all the APIs in macOS 13.3 and iOS 16.4. |
23
+ | macOS 13, iOS 16| Add all the APIs in macOS 13 and iOS 16.<br />New optional `NS::SharedPtr<T>` type to assist with memory management.<br/>New convenience function to create a `CA::MetalLayer`.<br/>New `MTLSTR(str)` macro allows faster string creation from literals.<br/>Fix a problem with the signature of functions that take an array of pointers as input.<br/>Fix a problem with the signature of the `setGroups()` function in `MTL::LinkedFunctions`.|
24
+ | macOS 12, iOS 15 | Initial release. |
25
+
26
+ ## Memory Allocation Policy
27
+
28
+ **metal-cpp** follows the object allocation policies of Cocoa, Cocoa Touch, and CoreFoundation. Understanding these rules is especially important when using metal-cpp, as C++ objects are not eligible for automatic reference counting (ARC).
29
+
30
+ **metal-cpp** objects are reference counted. To help convey and manage object lifecycles, the following conventions are observed:
31
+
32
+ 1. *You own any object returned by methods whose name begins with* `alloc` *,* `new` *,* `copy` *,* `mutableCopy` *, or* `Create`. The method returns these objects with `retainCount` equals to `1`.
33
+ 2. *You can take ownership of an object by calling its* ```retain()``` *method*. A received object is normally guaranteed to remain valid within the method it was received in. You use `retain` in two situations: (1) In the implementation of an accessor method (a setter) or to take ownership of an object; and (2) To prevent an object from being deallocated as a side-effect of some other operation.
34
+ 3. *When you no longer need it, you must relinquish ownership of an object you own*. You relinquish ownership by calling its `release()` or `autorelease()` method.
35
+ 4. *You must not relinquish ownership of an object you do not own*.
36
+
37
+ When an object's `retainCount` reaches `0`, the object is immediately deallocated. It is illegal to call methods on a deallocated object and it may lead to an application crash.
38
+
39
+ ### AutoreleasePools and Objects
40
+
41
+ Several methods that create temporary objects in **metal-cpp** add them to an `AutoreleasePool` to help manage their lifetimes. In these situations, after **metal-cpp** creates the object, it adds it to an `AutoreleasePool`, which will release its objects when you release (or drain) it.
42
+
43
+ By adding temporary objects to an AutoreleasePool, you do not need to explicitly call `release()` to deallocate them. Instead, you can rely on the `AutoreleasePool` to implicitly manage those lifetimes.
44
+
45
+ If you create an object with a method that does not begin with `alloc`, `new`, `copy`, `mutableCopy`, or `Create`, the creating method adds the object to an autorelease pool.
46
+
47
+ The typical scope of an `AutoreleasePool` is one frame of rendering for the main thread of the program. When the thread returns control to the RunLoop (an object responsible for receiving input and events from the windowing system), the pool is *drained*, releasing its objects.
48
+
49
+ You can create and manage additional `AutoreleasePool`s at smaller scopes to reduce your program's working set, and you are required to do so for any additional threads your program creates.
50
+
51
+ If an object's lifecycle needs to be extended beyond the scope of an `AutoreleasePool` instance, you can claim ownership of it by calling its `retain()` method before the pool is drained. In these cases, you are responsible for making the appropriate `release()` call on the object after you no longer need it.
52
+
53
+ You can find a more-detailed introduction to the memory management rules here: https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmRules.html, and here: https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFMemoryMgmt/Concepts/Ownership.html
54
+
55
+ For more details about the application's RunLoop, please find its documentation here: https://developer.apple.com/documentation/foundation/nsrunloop
56
+
57
+ ### Use and debug AutoreleasePools
58
+
59
+ When you create an autoreleased object and there is no enclosing `AutoreleasePool`, the object is leaked.
60
+
61
+ To prevent this, you normally create an `AutoreleasePool` in your program's `main` function, and in the entry function for every thread you create. You may also create additional `AutoreleasePool`s to avoid growing your program's high memory watermark when you create several autoreleased objects, such as when rendering.
62
+
63
+ Use the Environment Variable `OBJC_DEBUG_MISSING_POOLS=YES` to print a runtime warning when an autoreleased object is leaked because no enclosing `AutoreleasePool` is available for its thread.
64
+
65
+ You can also run `leaks --autoreleasePools` on a memgraph file or a process ID (macOS only) to view a listing of your program's `AutoreleasePool`s and all objects they contain.
66
+
67
+ ### NS::SharedPtr
68
+
69
+ The **metal-cpp** headers include an optional `NS::SharedPtr<>` (shared pointer) template that can help you manually manage memory in your apps.
70
+
71
+ Shared pointers in **metal-cpp** are different from `std::shared_ptr<>` in that they implement specific optimizations for its memory model. For example, **metal-cpp**'s shared pointers avoid the overhead of the standard library's version by leveraging the reference counting implementation of the `NS::Object` type.
72
+
73
+ #### Note
74
+
75
+ The **metal-cpp** shared pointer’s destructor method always calls the `release()` method of the pointer that it wraps.
76
+
77
+ You can create an `NS::SharedPtr<>` by calling the metal-cpp's factory method that's appropriate for your application's intent:
78
+
79
+ * You can **transfer** ownership of a pointer to a new shared pointer instance by calling the `NS::TransferPtr()` factory function, which is the correct function for Resource Acquisition is Initialization (RAII) implementations because it doesn't increase the pointee's retain count.
80
+
81
+ * You can **share** ownership of a pointer with another entity by calling the `NS::RetainPtr()` factory function. This function can also extend an object's lifecycle beyond an `AutoreleasePool` instance's scope because it creates a strong reference to the pointee and increases its retain count.
82
+
83
+ Usage of `NS::SharedPtr<>` is optional.
84
+
85
+ ### nullptr
86
+
87
+ Similar to Objective-C, it is legal to call any method, including `retain()` and `release()`, on `nullptr` "objects". While calling methods on `nullptr` still does incur in function call overhead, the effective result is equivalent of a NOP.
88
+
89
+ Conversely, do not assume that because calling a method on a pointer did not result in a crash, that the pointed-to object is valid.
90
+
91
+ ## Adding metal-cpp to a Project
92
+
93
+ Simply include `Metal/Metal.hpp`. To ensure that the selector and class symbols are linked, add to one of your cpp files:
94
+
95
+ ```cpp
96
+ #define NS_PRIVATE_IMPLEMENTATION
97
+ #define MTL_PRIVATE_IMPLEMENTATION
98
+
99
+ #include "Metal/Metal.hpp"
100
+ ```
101
+
102
+ If you want to use the QuartzCore wrapper, add:
103
+
104
+ ```cpp
105
+ #define CA_PRIVATE_IMPLEMENTATION
106
+
107
+ #include "QuartzCore/QuartzCore.hpp"
108
+ ```
109
+
110
+ ## Generating a Single Header File
111
+
112
+ Purely optional: You can generate a single header file that contains all **metal-cpp** headers via:
113
+
114
+ ```shell
115
+ ./SingleHeader/MakeSingleHeader.py Foundation/Foundation.hpp QuartzCore/QuartzCore.hpp Metal/Metal.hpp MetalFX/MetalFX.hpp
116
+ ```
117
+
118
+ By default the generator script writes its output to `./SingleHeader/Metal.hpp`. Use the `-o` option to customize output filename.
119
+
120
+ ## Global Symbol Visibility
121
+
122
+ metal-cpp marks all its symbols with `default` visibility. Define the macro: `METALCPP_SYMBOL_VISIBILITY_HIDDEN` to override this behavior and hide its symbols.
123
+
124
+ ## Examples
125
+
126
+ #### Creating the device
127
+
128
+ ###### Objective-C (with automatic reference counting)
129
+
130
+ ```objc
131
+ id< MTLDevice > device = MTLCreateSystemDefaultDevice();
132
+
133
+ // ...
134
+ ```
135
+
136
+ ###### Objective-C
137
+
138
+ ```objc
139
+ id< MTLDevice > device = MTLCreateSystemDefaultDevice();
140
+
141
+ // ...
142
+
143
+ [device release];
144
+ ```
145
+
146
+ ###### C++
147
+
148
+ ```cpp
149
+ MTL::Device* pDevice = MTL::CreateSystemDefaultDevice();
150
+
151
+ // ...
152
+
153
+ pDevice->release();
154
+ ```
155
+
156
+ ###### C++ (using NS::SharedPtr)
157
+
158
+ ```cpp
159
+ NS::SharedPtr< MTL::Device > pDevice = NS::TransferPtr( MTL::CreateSystemDefaultDevice() );
160
+
161
+ // ...
162
+ ```
163
+
164
+ #### Metal function calls map directly to C++
165
+
166
+ ###### Objective-C (with automatic reference counting)
167
+
168
+ ```objc
169
+ MTLSamplerDescriptor* samplerDescriptor = [[MTLSamplerDescriptor alloc] init];
170
+
171
+ [samplerDescriptor setSAddressMode: MTLSamplerAddressModeRepeat];
172
+ [samplerDescriptor setTAddressMode: MTLSamplerAddressModeRepeat];
173
+ [samplerDescriptor setRAddressMode: MTLSamplerAddressModeRepeat];
174
+ [samplerDescriptor setMagFilter: MTLSamplerMinMagFilterLinear];
175
+ [samplerDescriptor setMinFilter: MTLSamplerMinMagFilterLinear];
176
+ [samplerDescriptor setMipFilter: MTLSamplerMipFilterLinear];
177
+ [samplerDescriptor setSupportArgumentBuffers: YES];
178
+
179
+ id< MTLSamplerState > samplerState = [device newSamplerStateWithDescriptor:samplerDescriptor];
180
+ ```
181
+
182
+ ###### Objective-C
183
+
184
+ ```objc
185
+ MTLSamplerDescriptor* samplerDescriptor = [[MTLSamplerDescriptor alloc] init];
186
+
187
+ [samplerDescriptor setSAddressMode: MTLSamplerAddressModeRepeat];
188
+ [samplerDescriptor setTAddressMode: MTLSamplerAddressModeRepeat];
189
+ [samplerDescriptor setRAddressMode: MTLSamplerAddressModeRepeat];
190
+ [samplerDescriptor setMagFilter: MTLSamplerMinMagFilterLinear];
191
+ [samplerDescriptor setMinFilter: MTLSamplerMinMagFilterLinear];
192
+ [samplerDescriptor setMipFilter: MTLSamplerMipFilterLinear];
193
+ [samplerDescriptor setSupportArgumentBuffers: YES];
194
+
195
+ id< MTLSamplerState > samplerState = [device newSamplerStateWithDescriptor:samplerDescriptor];
196
+
197
+ [samplerDescriptor release];
198
+
199
+ // ...
200
+
201
+ [samplerState release];
202
+ ```
203
+
204
+ ###### C++
205
+
206
+ ```cpp
207
+ MTL::SamplerDescriptor* pSamplerDescriptor = MTL::SamplerDescriptor::alloc()->init();
208
+
209
+ pSamplerDescriptor->setSAddressMode( MTL::SamplerAddressModeRepeat );
210
+ pSamplerDescriptor->setTAddressMode( MTL::SamplerAddressModeRepeat );
211
+ pSamplerDescriptor->setRAddressMode( MTL::SamplerAddressModeRepeat );
212
+ pSamplerDescriptor->setMagFilter( MTL::SamplerMinMagFilterLinear );
213
+ pSamplerDescriptor->setMinFilter( MTL::SamplerMinMagFilterLinear );
214
+ pSamplerDescriptor->setMipFilter( MTL::SamplerMipFilterLinear );
215
+ pSamplerDescriptor->setSupportArgumentBuffers( true );
216
+
217
+ MTL::SamplerState* pSamplerState = pDevice->newSamplerState( pSamplerDescriptor );
218
+
219
+ pSamplerDescriptor->release();
220
+
221
+ // ...
222
+
223
+ pSamplerState->release();
224
+ ```
225
+
226
+ ###### C++ (using NS::SharedPtr)
227
+
228
+ ```cpp
229
+ NS::SharedPtr< MTL::SamplerDescriptor > pSamplerDescriptor = NS::TransferPtr( MTL::SamplerDescriptor::alloc()->init() );
230
+
231
+ pSamplerDescriptor->setSAddressMode( MTL::SamplerAddressModeRepeat );
232
+ pSamplerDescriptor->setTAddressMode( MTL::SamplerAddressModeRepeat );
233
+ pSamplerDescriptor->setRAddressMode( MTL::SamplerAddressModeRepeat );
234
+ pSamplerDescriptor->setMagFilter( MTL::SamplerMinMagFilterLinear );
235
+ pSamplerDescriptor->setMinFilter( MTL::SamplerMinMagFilterLinear );
236
+ pSamplerDescriptor->setMipFilter( MTL::SamplerMipFilterLinear );
237
+ pSamplerDescriptor->setSupportArgumentBuffers( true );
238
+
239
+ NS::SharedPtr< MTL::SamplerState > pSamplerState( pDevice->newSamplerState( pSamplerDescriptor ) );
240
+ ```
241
+
242
+ #### A subset of bindings for Foundation classes is provided for seamless integration
243
+
244
+ ###### Objective-C (with automatic reference counting)
245
+
246
+ ```objc
247
+ NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
248
+ NSString* string = [NSString stringWithCString: "Hello World" encoding: NSASCIIStringEncoding];
249
+
250
+ printf( "string = \"%s\"\n", [string cStringUsingEncoding: NSASCIIStringEncoding] );
251
+ ```
252
+
253
+ ###### Objective-C
254
+
255
+ ```objc
256
+ NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
257
+ NSString* string = [NSString stringWithCString: "Hello World" encoding: NSASCIIStringEncoding];
258
+
259
+ printf( "string = \"%s\"\n", [string cStringUsingEncoding: NSASCIIStringEncoding] );
260
+
261
+ [pool release];
262
+ ```
263
+
264
+ ###### C++
265
+
266
+ ```cpp
267
+ NS::AutoreleasePool* pPool = NS::AutoreleasePool::alloc()->init();
268
+ NS::String* pString = NS::String::string( "Hello World", NS::ASCIIStringEncoding );
269
+
270
+ printf( "pString = \"%s\"\n", pString->cString( NS::ASCIIStringEncoding ) );
271
+
272
+ pPool->release();
273
+ ```
274
+
275
+ ###### C++ (using NS::SharedPtr)
276
+
277
+ ```cpp
278
+ NS::SharedPtr< NS::AutoreleasePool > pPool = NS::TransferPtr( NS::AutoreleasePool::alloc()->init() );
279
+ NS::String* pString = NS::String::string( "Hello World", NS::ASCIIStringEncoding );
280
+
281
+ printf( "pString = \"%s\"\n", pString->cString( NS::ASCIIStringEncoding ) );
282
+ ```
283
+
284
+ #### Containers
285
+
286
+ Use the CoreFoundation framework to create `NS::Array` and `NS::Dictionary` instances.
287
+
288
+ ```cpp
289
+ MTL::AccelerationStructureTriangleGeometryDescriptor* pGeoDescriptor = MTL::AccelerationStructureTriangleGeometryDescriptor::alloc()->init();
290
+ CFTypeRef descriptors[] = { ( CFTypeRef )( pGeoDescriptor ) };
291
+ NS::Array* pGeoDescriptors = ( NS::Array* )( CFArrayCreate( kCFAllocatorDefault, descriptors, SIZEOF_ARRAY( descriptors), &kCFTypeArrayCallBacks ) );
292
+
293
+ // ...
294
+
295
+ pGeoDescriptors->release();
296
+ ```
297
+
298
+ Containers, such as `NS::Array` and `NS::Dictionary`, retain the objects they hold and release them when the container is deallocated.
299
+
300
+ #### Accessing the Metal Drawable
301
+
302
+ ```cpp
303
+ #import <QuartzCore/QuartzCore.hpp>
304
+
305
+ // ...
306
+
307
+ CA::MetalLayer* pMetalLayer = /* layer associated with the view */;
308
+ CA::MetalDrawable* pMetalDrawable = pMetalLayer->nextDrawable();
309
+
310
+ // ...
311
+ ```
lib/python3.11/site-packages/mlx/include/metal_cpp/SingleHeader/MakeSingleHeader.py ADDED
@@ -0,0 +1,271 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+
3
+ #--------------------------------------------------------------------------------------------------------------------------------------------------------------
4
+ #
5
+ # SingleHeader/MakeSingleHeader.py
6
+ #
7
+ # Copyright 2020-2023 Apple Inc.
8
+ #
9
+ # Licensed under the Apache License, Version 2.0 (the "License");
10
+ # you may not use this file except in compliance with the License.
11
+ # You may obtain a copy of the License at
12
+ #
13
+ # http://www.apache.org/licenses/LICENSE-2.0
14
+ #
15
+ # Unless required by applicable law or agreed to in writing, software
16
+ # distributed under the License is distributed on an "AS IS" BASIS,
17
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ # See the License for the specific language governing permissions and
19
+ # limitations under the License.
20
+ #
21
+ #--------------------------------------------------------------------------------------------------------------------------------------------------------------
22
+
23
+ import argparse
24
+ import datetime
25
+ import logging
26
+ import os
27
+ import re
28
+ import subprocess
29
+ import sys
30
+
31
+ #--------------------------------------------------------------------------------------------------------------------------------------------------------------
32
+
33
+ class HeaderPrefix( object ):
34
+ __template = ( '//\n'
35
+ '// {file}\n'
36
+ '//\n'
37
+ '// {meta_data}\n'
38
+ '//\n'
39
+ '// Copyright 2020-2023 Apple Inc.\n'
40
+ '//\n'
41
+ '// Licensed under the Apache License, Version 2.0 (the "License");\n'
42
+ '// you may not use this file except in compliance with the License.\n'
43
+ '// You may obtain a copy of the License at\n'
44
+ '//\n'
45
+ '// http://www.apache.org/licenses/LICENSE-2.0\n'
46
+ '//\n'
47
+ '// Unless required by applicable law or agreed to in writing, software\n'
48
+ '// distributed under the License is distributed on an "AS IS" BASIS,\n'
49
+ '// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n'
50
+ '// See the License for the specific language governing permissions and\n'
51
+ '// limitations under the License.\n'
52
+ '//\n'
53
+ '\n' )
54
+
55
+ __template_commit = 'Autogenerated from commit {commit}.'
56
+ __template_date = 'Autogenerated on %B %d, %Y.'
57
+
58
+ def __init__( self, file ):
59
+ self.__file = file
60
+
61
+ def __str__( self ):
62
+ return self.__template.format( file = self.__file, meta_data = self.__meta_data_string() )
63
+
64
+ def __get_commit_hash( self ):
65
+ git_commit_hash = None
66
+
67
+ try:
68
+ git_dir = os.path.dirname( os.path.realpath( __file__ ) )
69
+ proc = subprocess.Popen( [ 'git', 'rev-parse', 'HEAD' ], cwd = git_dir, stdout = subprocess.PIPE, stderr = subprocess.PIPE )
70
+ git_commit_hash = proc.stdout.read().decode( 'utf-8', 'replace' ).strip()
71
+ except:
72
+ logging.error( 'Failed to determine git commit hash!' )
73
+ pass
74
+
75
+ return git_commit_hash
76
+
77
+ def __get_commit_string( self ):
78
+ meta_data = None
79
+ git_commit_hash = self.__get_commit_hash()
80
+
81
+ if git_commit_hash:
82
+ meta_data = self.__template_commit.format( commit = git_commit_hash )
83
+
84
+ return meta_data
85
+
86
+ def __get_date_string( self ):
87
+ today = datetime.date.today()
88
+
89
+ return today.strftime( self.__template_date )
90
+
91
+ def __meta_data_string( self ):
92
+ meta_data = self.__get_commit_string()
93
+
94
+ if not meta_data:
95
+ meta_data = self.__get_date_string()
96
+
97
+ return meta_data
98
+
99
+ #--------------------------------------------------------------------------------------------------------------------------------------------------------------
100
+
101
+ class SingleHeader( object ):
102
+ __pragma_once = '#pragma once\n\n'
103
+
104
+ def __init__( self ):
105
+ self.__header_paths = list()
106
+
107
+ def __str__( self ):
108
+ return self.process()
109
+
110
+ def append( self, header_path ):
111
+ self.__header_paths.append( header_path )
112
+
113
+ def process( self ):
114
+ out_header = self.__pragma_once
115
+
116
+ self.__included_headers = set()
117
+ self.__base_path = list()
118
+
119
+ for header_path in self.__header_paths:
120
+ out_header += self.__process_header( header_path )
121
+
122
+ return self.__strip_empty_lines( out_header )
123
+
124
+ def __read_header( self, path ):
125
+ path = os.path.realpath( path )
126
+
127
+ try:
128
+ f = open( path, 'r' )
129
+ except:
130
+ raise RuntimeError( 'Failed to open file \"' + path + '\" for read!' )
131
+
132
+ return f.read()
133
+
134
+ def __strip_pragma_once( self, header ):
135
+ return re.sub( '\\s*#pragma once\s*\\/\\/-*\\n', '', header )
136
+
137
+ def __strip_comments( self, header ):
138
+ return re.sub( '^//.*\\n', '', header, flags = re.MULTILINE )
139
+
140
+ def __strip_empty_lines( self, header ):
141
+ return re.sub( '\\n\\n+', '\\n\\n', header, flags = re.MULTILINE )
142
+
143
+ def __substitute_include_directive( self, match ):
144
+ header_path = match.group( 'HEADER_PATH' )
145
+
146
+ logging.info( '\tSubstituting \"' + header_path + '\"...' )
147
+
148
+ return self.__process_header( os.path.join( self.__base_path[-1], header_path ) )
149
+
150
+ def __process_include_directives( self, header ):
151
+ return re.sub( '^\\s*#include\\s\\"(?P<HEADER_PATH>\\S*)\\"', self.__substitute_include_directive, header, flags = re.MULTILINE )
152
+
153
+ def __process_foundation_directives( self, header ):
154
+ if header.find("#include <Foundation/Foundation.hpp>") != -1:
155
+ logging.info( '\tSubstituting <Foundation/Foundation.hpp>...' )
156
+ return header.replace("#include <Foundation/Foundation.hpp>", self.__process_header( os.path.join( self.__base_path[-1], "../Foundation/Foundation.hpp" ) ) )
157
+ return header
158
+
159
+
160
+ def __process_header( self, header_path ):
161
+ out_header = ''
162
+
163
+ header_path = os.path.realpath( header_path )
164
+
165
+ if not header_path in self.__included_headers:
166
+ logging.info( 'Processing \"' + header_path + '\"...' )
167
+
168
+ self.__base_path.append( os.path.dirname( header_path ) )
169
+ self.__included_headers.add( header_path )
170
+
171
+ out_header = self.__read_header( header_path )
172
+ out_header = self.__strip_pragma_once( out_header )
173
+ out_header = self.__strip_comments( out_header )
174
+ out_header = self.__process_include_directives( out_header )
175
+ out_header = self.__process_foundation_directives( out_header )
176
+
177
+ self.__base_path.pop()
178
+ else:
179
+ logging.info( '\tSkipping \"' + header_path + '\"...' )
180
+
181
+ return out_header
182
+
183
+ #--------------------------------------------------------------------------------------------------------------------------------------------------------------
184
+
185
+ def create_argument_parser():
186
+ parser = argparse.ArgumentParser()
187
+ base_path = os.path.dirname( os.path.realpath( __file__ ) )
188
+ output_path = os.path.join( base_path, 'Metal.hpp' )
189
+
190
+ parser.add_argument( '-o', '--output', dest = 'output_path', metavar = 'PATH', default = output_path, help = 'Output path for the single header file.' )
191
+ parser.add_argument( '-v', '--verbose', action = 'store_true', help = 'Show verbose output.' )
192
+ parser.add_argument( dest = 'header_paths', metavar = 'HEADER_FILE', nargs='+', help = 'Input header file.' )
193
+
194
+ return parser
195
+
196
+ #--------------------------------------------------------------------------------------------------------------------------------------------------------------
197
+
198
+ def parse_arguments():
199
+ parser = create_argument_parser()
200
+ args = parser.parse_args()
201
+
202
+ if args.verbose:
203
+ logging.getLogger().setLevel( logging.INFO )
204
+ else:
205
+ logging.getLogger().setLevel( logging.ERROR )
206
+
207
+ return args
208
+
209
+ #--------------------------------------------------------------------------------------------------------------------------------------------------------------
210
+
211
+ def make_header( args ):
212
+ prefix = HeaderPrefix( os.path.basename( args.output_path ) )
213
+ header = SingleHeader()
214
+
215
+ for header_path in args.header_paths:
216
+ header.append( header_path )
217
+
218
+ return str( prefix ) + str( header )
219
+
220
+ #--------------------------------------------------------------------------------------------------------------------------------------------------------------
221
+
222
+ def make_dir( path ):
223
+ try:
224
+ if not os.path.exists( path ):
225
+ os.makedirs( path )
226
+ except os.error:
227
+ pass
228
+ except:
229
+ raise
230
+
231
+ #--------------------------------------------------------------------------------------------------------------------------------------------------------------
232
+
233
+ def write_header( args, content ):
234
+ path = os.path.realpath( args.output_path )
235
+
236
+ logging.info( 'Writing \"' + path + '\"...' )
237
+
238
+ make_dir( os.path.dirname( path ) )
239
+
240
+ try:
241
+ f = open( path, 'w' )
242
+ except:
243
+ raise RuntimeError( 'Failed to open file \"' + path + '\" for write!' )
244
+
245
+ f.write( content )
246
+
247
+ #--------------------------------------------------------------------------------------------------------------------------------------------------------------
248
+
249
+ if __name__ == '__main__':
250
+ result = -1
251
+
252
+ try:
253
+ if sys.getdefaultencoding().lower() == 'ascii':
254
+ reload( sys )
255
+ sys.setdefaultencoding( 'utf-8' )
256
+
257
+ args = parse_arguments()
258
+ header = make_header( args )
259
+
260
+ write_header( args, header )
261
+
262
+ result = 0
263
+
264
+ except ( KeyboardInterrupt, SystemExit ):
265
+ pass
266
+ except:
267
+ raise
268
+
269
+ sys.exit( result )
270
+
271
+ #--------------------------------------------------------------------------------------------------------------------------------------------------------------
lib/python3.11/site-packages/mlx/include/metal_cpp/SingleHeader/__pycache__/MakeSingleHeader.cpython-311.pyc ADDED
Binary file (13.9 kB). View file
 
lib/python3.11/site-packages/mlx/include/mlx/3rdparty/pocketfft.h ADDED
The diff for this file is too large to render. See raw diff
 
lib/python3.11/site-packages/mlx/include/mlx/allocator.h ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Copyright © 2023 Apple Inc.
2
+
3
+ #pragma once
4
+
5
+ #include <cstdlib>
6
+
7
+ namespace mlx::core::allocator {
8
+
9
+ // Simple wrapper around buffer pointers
10
+ // WARNING: Only Buffer objects constructed from and those that wrap
11
+ // raw pointers from mlx::allocator are supported.
12
+ class Buffer {
13
+ private:
14
+ void* ptr_;
15
+
16
+ public:
17
+ Buffer(void* ptr) : ptr_(ptr){};
18
+
19
+ // Get the raw data pointer from the buffer
20
+ void* raw_ptr();
21
+
22
+ // Get the buffer pointer from the buffer
23
+ const void* ptr() const {
24
+ return ptr_;
25
+ };
26
+ void* ptr() {
27
+ return ptr_;
28
+ };
29
+ };
30
+
31
+ Buffer malloc(size_t size);
32
+
33
+ void free(Buffer buffer);
34
+
35
+ // Wait for running tasks to finish and free up memory
36
+ // if allocation fails
37
+ Buffer malloc_or_wait(size_t size);
38
+
39
+ class Allocator {
40
+ /** Abstract base class for a memory allocator. */
41
+ public:
42
+ virtual Buffer malloc(size_t size, bool allow_swap = false) = 0;
43
+ virtual void free(Buffer buffer) = 0;
44
+
45
+ Allocator() = default;
46
+ Allocator(const Allocator& other) = delete;
47
+ Allocator(Allocator&& other) = delete;
48
+ Allocator& operator=(const Allocator& other) = delete;
49
+ Allocator& operator=(Allocator&& other) = delete;
50
+ virtual ~Allocator() = default;
51
+ };
52
+
53
+ Allocator& allocator();
54
+
55
+ class CommonAllocator : public Allocator {
56
+ /** A general CPU allocator. */
57
+ public:
58
+ virtual Buffer malloc(size_t size, bool allow_swap = false) override;
59
+ virtual void free(Buffer buffer) override;
60
+
61
+ private:
62
+ CommonAllocator() = default;
63
+ friend Allocator& allocator();
64
+ };
65
+
66
+ } // namespace mlx::core::allocator
lib/python3.11/site-packages/mlx/include/mlx/array.h ADDED
@@ -0,0 +1,438 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Copyright © 2023 Apple Inc.
2
+
3
+ #pragma once
4
+ #include <algorithm>
5
+ #include <cstdint>
6
+ #include <functional>
7
+ #include <memory>
8
+ #include <vector>
9
+
10
+ #include "mlx/allocator.h"
11
+ #include "mlx/dtype.h"
12
+
13
+ namespace mlx::core {
14
+
15
+ // Forward declaration
16
+ class Primitive;
17
+ using deleter_t = std::function<void(allocator::Buffer)>;
18
+
19
+ class array {
20
+ /* An array is really a node in a graph. It contains a shared ArrayDesc
21
+ * object */
22
+
23
+ public:
24
+ /** Construct a scalar array with zero dimensions. */
25
+ template <typename T>
26
+ explicit array(T val, Dtype dtype = TypeToDtype<T>());
27
+
28
+ /* Special case since std::complex can't be implicitly converted to other
29
+ * types. */
30
+ explicit array(const std::complex<float>& val, Dtype dtype = complex64);
31
+
32
+ template <typename It>
33
+ array(
34
+ It data,
35
+ const std::vector<int>& shape,
36
+ Dtype dtype =
37
+ TypeToDtype<typename std::iterator_traits<It>::value_type>());
38
+
39
+ template <typename T>
40
+ array(std::initializer_list<T> data, Dtype dtype = TypeToDtype<T>());
41
+
42
+ /* Special case so empty lists default to float32. */
43
+ array(std::initializer_list<float> data);
44
+
45
+ template <typename T>
46
+ array(
47
+ std::initializer_list<T> data,
48
+ const std::vector<int>& shape,
49
+ Dtype dtype = TypeToDtype<T>());
50
+
51
+ /* Build an array from a buffer */
52
+ array(
53
+ allocator::Buffer data,
54
+ const std::vector<int>& shape,
55
+ Dtype dtype,
56
+ deleter_t deleter = allocator::free);
57
+
58
+ /** Assignment to rvalue does not compile. */
59
+ array& operator=(const array& other) && = delete;
60
+ array& operator=(array&& other) && = delete;
61
+
62
+ /** Default copy and move constructors otherwise. */
63
+ array& operator=(array&& other) & = default;
64
+ array(const array& other) = default;
65
+ array(array&& other) = default;
66
+
67
+ array& operator=(const array& other) & {
68
+ if (this->id() != other.id()) {
69
+ this->array_desc_ = other.array_desc_;
70
+ }
71
+ return *this;
72
+ };
73
+
74
+ /** The size of the array's datatype in bytes. */
75
+ size_t itemsize() const {
76
+ return size_of(dtype());
77
+ };
78
+
79
+ /** The number of elements in the array. */
80
+ size_t size() const {
81
+ return array_desc_->size;
82
+ };
83
+
84
+ /** The number of bytes in the array. */
85
+ size_t nbytes() const {
86
+ return size() * itemsize();
87
+ };
88
+
89
+ /** The number of dimensions of the array. */
90
+ size_t ndim() const {
91
+ return array_desc_->shape.size();
92
+ };
93
+
94
+ /** The shape of the array as a vector of integers. */
95
+ const std::vector<int>& shape() const {
96
+ return array_desc_->shape;
97
+ };
98
+
99
+ /**
100
+ * Get the size of the corresponding dimension.
101
+ *
102
+ * This function supports negative indexing and provides
103
+ * bounds checking. */
104
+ int shape(int dim) const {
105
+ return shape().at(dim < 0 ? dim + ndim() : dim);
106
+ };
107
+
108
+ /** The strides of the array. */
109
+ const std::vector<size_t>& strides() const {
110
+ return array_desc_->strides;
111
+ };
112
+
113
+ /** Get the arrays data type. */
114
+ Dtype dtype() const {
115
+ return array_desc_->dtype;
116
+ };
117
+
118
+ /** Evaluate the array. */
119
+ void eval(bool retain_graph = false);
120
+
121
+ /** Get the value from a scalar array. */
122
+ template <typename T>
123
+ T item(bool retain_graph = false);
124
+
125
+ struct ArrayIterator {
126
+ using iterator_category = std::random_access_iterator_tag;
127
+ using difference_type = size_t;
128
+ using value_type = const array;
129
+ using reference = value_type;
130
+
131
+ explicit ArrayIterator(const array& arr, int idx = 0) : arr(arr), idx(idx) {
132
+ if (arr.ndim() == 0) {
133
+ throw std::invalid_argument("Cannot iterate over 0-d array.");
134
+ }
135
+ }
136
+
137
+ reference operator*() const;
138
+
139
+ ArrayIterator& operator+(difference_type diff) {
140
+ idx += diff;
141
+ return *this;
142
+ }
143
+
144
+ ArrayIterator& operator++() {
145
+ idx++;
146
+ return *this;
147
+ }
148
+
149
+ friend bool operator==(const ArrayIterator& a, const ArrayIterator& b) {
150
+ return a.arr.id() == b.arr.id() && a.idx == b.idx;
151
+ };
152
+ friend bool operator!=(const ArrayIterator& a, const ArrayIterator& b) {
153
+ return !(a == b);
154
+ };
155
+
156
+ private:
157
+ const array& arr;
158
+ int idx;
159
+ };
160
+
161
+ ArrayIterator begin() const {
162
+ return ArrayIterator(*this);
163
+ }
164
+ ArrayIterator end() const {
165
+ return ArrayIterator(*this, shape(0));
166
+ }
167
+
168
+ /**
169
+ * The following methods should be used with caution.
170
+ * They are intended for use by the backend implementation and the
171
+ * API may change.
172
+ */
173
+
174
+ array(
175
+ const std::vector<int>& shape,
176
+ Dtype dtype,
177
+ std::unique_ptr<Primitive> primitive,
178
+ const std::vector<array>& inputs);
179
+
180
+ /** A unique identifier for an array. */
181
+ std::uintptr_t id() const {
182
+ return reinterpret_cast<std::uintptr_t>(array_desc_.get());
183
+ }
184
+
185
+ struct Data {
186
+ allocator::Buffer buffer;
187
+ deleter_t d;
188
+ Data(allocator::Buffer buffer, deleter_t d = allocator::free)
189
+ : buffer(buffer), d(d){};
190
+ // Not copyable
191
+ Data(const Data& d) = delete;
192
+ Data& operator=(const Data& d) = delete;
193
+ ~Data() {
194
+ d(buffer);
195
+ }
196
+ };
197
+
198
+ struct Flags {
199
+ // True if there are no gaps in the underlying data. Each item
200
+ // in the underlying data buffer belongs to at least one index.
201
+ bool contiguous : 1;
202
+
203
+ bool row_contiguous : 1;
204
+ bool col_contiguous : 1;
205
+ };
206
+
207
+ /** The array's primitive. */
208
+ Primitive& primitive() const {
209
+ return *(array_desc_->primitive);
210
+ };
211
+
212
+ /** Check if the array has an attached primitive or is a leaf node. */
213
+ bool has_primitive() const {
214
+ return array_desc_->primitive != nullptr;
215
+ };
216
+
217
+ /** The array's inputs. */
218
+ const std::vector<array>& inputs() const {
219
+ return array_desc_->inputs;
220
+ };
221
+
222
+ /** A non-const reference to the array's inputs so that they can be used to
223
+ * edit the graph. */
224
+ std::vector<array>& editable_inputs() {
225
+ return array_desc_->inputs;
226
+ }
227
+
228
+ /** Detach the array from the graph. */
229
+ void detach();
230
+
231
+ /** Get the Flags bit-field. */
232
+ const Flags& flags() const {
233
+ return array_desc_->flags;
234
+ };
235
+
236
+ /** The size (in elements) of the underlying buffer the array points to. */
237
+ size_t data_size() const {
238
+ return array_desc_->data_size;
239
+ };
240
+
241
+ allocator::Buffer& buffer() {
242
+ return array_desc_->data->buffer;
243
+ };
244
+ const allocator::Buffer& buffer() const {
245
+ return array_desc_->data->buffer;
246
+ };
247
+
248
+ template <typename T>
249
+ T* data() {
250
+ return static_cast<T*>(array_desc_->data_ptr);
251
+ };
252
+
253
+ template <typename T>
254
+ const T* data() const {
255
+ return static_cast<T*>(array_desc_->data_ptr);
256
+ };
257
+
258
+ // Check if the array has been evaluated
259
+ bool is_evaled() const {
260
+ return array_desc_->data != nullptr;
261
+ }
262
+
263
+ // Mark the array as a tracer array (true) or not.
264
+ void set_tracer(bool is_tracer) {
265
+ array_desc_->is_tracer = is_tracer;
266
+ }
267
+ // Check if the array is a tracer array
268
+ bool is_tracer() const {
269
+ return array_desc_->is_tracer;
270
+ }
271
+
272
+ void set_data(allocator::Buffer buffer, deleter_t d = allocator::free);
273
+
274
+ void set_data(
275
+ allocator::Buffer buffer,
276
+ size_t data_size,
277
+ std::vector<size_t> strides,
278
+ Flags flags,
279
+ deleter_t d = allocator::free);
280
+
281
+ void copy_shared_buffer(
282
+ const array& other,
283
+ const std::vector<size_t>& strides,
284
+ Flags flags,
285
+ size_t data_size,
286
+ size_t offset = 0);
287
+
288
+ void copy_shared_buffer(const array& other);
289
+
290
+ void overwrite_descriptor(const array& other) {
291
+ array_desc_ = other.array_desc_;
292
+ }
293
+
294
+ private:
295
+ // Initialize the arrays data
296
+ template <typename It>
297
+ void init(const It src);
298
+
299
+ struct ArrayDesc {
300
+ std::vector<int> shape;
301
+ std::vector<size_t> strides;
302
+ size_t size;
303
+ Dtype dtype;
304
+ std::unique_ptr<Primitive> primitive{nullptr};
305
+
306
+ // Indicates an array is being used in a graph transform
307
+ // and should not be detached from the graph
308
+ bool is_tracer{false};
309
+
310
+ // This is a shared pointer so that *different* arrays
311
+ // can share the underlying data buffer.
312
+ std::shared_ptr<Data> data{nullptr};
313
+
314
+ // Properly offset data pointer
315
+ void* data_ptr{nullptr};
316
+
317
+ // The size in elements of the data buffer the array accesses
318
+ // This can be different than the actual size of the array if it
319
+ // has been broadcast or irregularly strided.
320
+ size_t data_size;
321
+
322
+ // Contains useful meta data about the array
323
+ Flags flags;
324
+
325
+ std::vector<array> inputs;
326
+
327
+ explicit ArrayDesc(const std::vector<int>& shape, Dtype dtype);
328
+
329
+ explicit ArrayDesc(
330
+ const std::vector<int>& shape,
331
+ Dtype dtype,
332
+ std::unique_ptr<Primitive> primitive,
333
+ const std::vector<array>& inputs);
334
+
335
+ ~ArrayDesc();
336
+ };
337
+
338
+ // The ArrayDesc contains the details of the materialized array including the
339
+ // shape, strides, the data type. It also includes
340
+ // the primitive which knows how to compute the array's data from its inputs
341
+ // and a the list of array's inputs for the primitive.
342
+ std::shared_ptr<ArrayDesc> array_desc_{nullptr};
343
+ };
344
+
345
+ template <typename T>
346
+ array::array(T val, Dtype dtype /* = TypeToDtype<T>() */)
347
+ : array_desc_(std::make_shared<ArrayDesc>(std::vector<int>{}, dtype)) {
348
+ init(&val);
349
+ }
350
+
351
+ template <typename It>
352
+ array::array(
353
+ It data,
354
+ const std::vector<int>& shape,
355
+ Dtype dtype /* = TypeToDtype<typename std::iterator_traits<It>::value_type>() */) :
356
+ array_desc_(std::make_shared<ArrayDesc>(shape, dtype)) {
357
+ init(data);
358
+ }
359
+
360
+ template <typename T>
361
+ array::array(
362
+ std::initializer_list<T> data,
363
+ Dtype dtype /* = TypeToDtype<T>() */)
364
+ : array_desc_(std::make_shared<ArrayDesc>(
365
+ std::vector<int>{static_cast<int>(data.size())},
366
+ dtype)) {
367
+ init(data.begin());
368
+ }
369
+
370
+ template <typename T>
371
+ array::array(
372
+ std::initializer_list<T> data,
373
+ const std::vector<int>& shape,
374
+ Dtype dtype /* = TypeToDtype<T>() */)
375
+ : array_desc_(std::make_shared<ArrayDesc>(shape, dtype)) {
376
+ if (data.size() != size()) {
377
+ throw std::invalid_argument(
378
+ "Data size and provided shape mismatch in array construction.");
379
+ }
380
+ init(data.begin());
381
+ }
382
+
383
+ template <typename T>
384
+ T array::item(bool retain_graph /* = false */) {
385
+ if (size() != 1) {
386
+ throw std::invalid_argument("item can only be called on arrays of size 1.");
387
+ }
388
+ eval(retain_graph);
389
+ return *data<T>();
390
+ }
391
+
392
+ template <typename It>
393
+ void array::init(It src) {
394
+ set_data(allocator::malloc(size() * size_of(dtype())));
395
+ switch (dtype()) {
396
+ case bool_:
397
+ std::copy(src, src + size(), data<bool>());
398
+ break;
399
+ case uint8:
400
+ std::copy(src, src + size(), data<uint8_t>());
401
+ break;
402
+ case uint16:
403
+ std::copy(src, src + size(), data<uint16_t>());
404
+ break;
405
+ case uint32:
406
+ std::copy(src, src + size(), data<uint32_t>());
407
+ break;
408
+ case uint64:
409
+ std::copy(src, src + size(), data<uint64_t>());
410
+ break;
411
+ case int8:
412
+ std::copy(src, src + size(), data<int8_t>());
413
+ break;
414
+ case int16:
415
+ std::copy(src, src + size(), data<int16_t>());
416
+ break;
417
+ case int32:
418
+ std::copy(src, src + size(), data<int32_t>());
419
+ break;
420
+ case int64:
421
+ std::copy(src, src + size(), data<int64_t>());
422
+ break;
423
+ case float16:
424
+ std::copy(src, src + size(), data<float16_t>());
425
+ break;
426
+ case float32:
427
+ std::copy(src, src + size(), data<float>());
428
+ break;
429
+ case bfloat16:
430
+ std::copy(src, src + size(), data<bfloat16_t>());
431
+ break;
432
+ case complex64:
433
+ std::copy(src, src + size(), data<complex64_t>());
434
+ break;
435
+ }
436
+ }
437
+
438
+ } // namespace mlx::core
lib/python3.11/site-packages/mlx/include/mlx/backend/accelerate/utils.h ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Copyright © 2023 Apple Inc.
2
+
3
+ #pragma once
4
+
5
+ #include <vecLib/BNNS/bnns.h>
6
+ #include "mlx/dtype.h"
7
+
8
+ namespace mlx::core {
9
+
10
+ BNNSDataType to_bnns_dtype(Dtype mlx_dtype) {
11
+ uint32_t size_bits = size_of(mlx_dtype) * 8;
12
+ switch (kindof(mlx_dtype)) {
13
+ case Dtype::Kind::b:
14
+ return BNNSDataTypeBoolean;
15
+ case Dtype::Kind::u:
16
+ return BNNSDataType(BNNSDataTypeUIntBit | size_bits);
17
+ case Dtype::Kind::i:
18
+ return BNNSDataType(BNNSDataTypeIntBit | size_bits);
19
+ case Dtype::Kind::f:
20
+ return BNNSDataType(BNNSDataTypeFloatBit | size_bits);
21
+ case Dtype::Kind::V:
22
+ return BNNSDataTypeBFloat16;
23
+ case Dtype::Kind::c:
24
+ throw std::invalid_argument("BNNS does not support complex types");
25
+ }
26
+ }
27
+
28
+ } // namespace mlx::core
lib/python3.11/site-packages/mlx/include/mlx/backend/common/arange.h ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Copyright © 2023 Apple Inc.
2
+
3
+ #pragma once
4
+
5
+ #include "mlx/allocator.h"
6
+ #include "mlx/array.h"
7
+
8
+ namespace mlx::core {
9
+
10
+ namespace {
11
+
12
+ template <typename T>
13
+ void arange(T start, T next, array& out, size_t size) {
14
+ auto ptr = out.data<T>();
15
+ auto step_size = next - start;
16
+ for (int i = 0; i < size; ++i) {
17
+ ptr[i] = start;
18
+ start += step_size;
19
+ }
20
+ }
21
+
22
+ } // namespace
23
+
24
+ void arange(
25
+ const std::vector<array>& inputs,
26
+ array& out,
27
+ double start,
28
+ double step) {
29
+ assert(inputs.size() == 0);
30
+ out.set_data(allocator::malloc_or_wait(out.nbytes()));
31
+ switch (out.dtype()) {
32
+ case bool_:
33
+ throw std::runtime_error("Bool type unsupported for arange.");
34
+ break;
35
+ case uint8:
36
+ arange<uint8_t>(start, start + step, out, out.size());
37
+ break;
38
+ case uint16:
39
+ arange<uint16_t>(start, start + step, out, out.size());
40
+ break;
41
+ case uint32:
42
+ arange<uint32_t>(start, start + step, out, out.size());
43
+ break;
44
+ case uint64:
45
+ arange<uint64_t>(start, start + step, out, out.size());
46
+ break;
47
+ case int8:
48
+ arange<int8_t>(start, start + step, out, out.size());
49
+ break;
50
+ case int16:
51
+ arange<int16_t>(start, start + step, out, out.size());
52
+ break;
53
+ case int32:
54
+ arange<int32_t>(start, start + step, out, out.size());
55
+ break;
56
+ case int64:
57
+ arange<int64_t>(start, start + step, out, out.size());
58
+ break;
59
+ case float16:
60
+ arange<float16_t>(start, start + step, out, out.size());
61
+ break;
62
+ case float32:
63
+ arange<float>(start, start + step, out, out.size());
64
+ break;
65
+ case bfloat16:
66
+ arange<bfloat16_t>(start, start + step, out, out.size());
67
+ break;
68
+ case complex64:
69
+ arange<complex64_t>(start, start + step, out, out.size());
70
+ break;
71
+ }
72
+ }
73
+
74
+ } // namespace mlx::core
lib/python3.11/site-packages/mlx/include/mlx/backend/common/binary.h ADDED
@@ -0,0 +1,556 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Copyright © 2023 Apple Inc.
2
+
3
+ #pragma once
4
+
5
+ #include "mlx/allocator.h"
6
+ #include "mlx/array.h"
7
+ #include "mlx/backend/common/utils.h"
8
+
9
+ namespace mlx::core {
10
+
11
+ namespace {
12
+
13
+ enum BinaryOpType {
14
+ ScalarScalar,
15
+ ScalarVector,
16
+ VectorScalar,
17
+ VectorVector,
18
+ General,
19
+ };
20
+
21
+ BinaryOpType get_binary_op_type(const array& a, const array& b) {
22
+ BinaryOpType bopt;
23
+ if (a.data_size() == 1 && b.data_size() == 1) {
24
+ bopt = ScalarScalar;
25
+ } else if (a.data_size() == 1 && b.flags().contiguous) {
26
+ bopt = ScalarVector;
27
+ } else if (b.data_size() == 1 && a.flags().contiguous) {
28
+ bopt = VectorScalar;
29
+ } else if (
30
+ a.flags().row_contiguous && b.flags().row_contiguous ||
31
+ a.flags().col_contiguous && b.flags().col_contiguous) {
32
+ bopt = VectorVector;
33
+ } else {
34
+ bopt = General;
35
+ }
36
+ return bopt;
37
+ }
38
+
39
+ void set_binary_op_output_data(
40
+ const array& a,
41
+ const array& b,
42
+ array& out,
43
+ BinaryOpType bopt) {
44
+ switch (bopt) {
45
+ case ScalarScalar:
46
+ out.set_data(
47
+ allocator::malloc_or_wait(out.itemsize()), 1, a.strides(), a.flags());
48
+ break;
49
+ case ScalarVector:
50
+ out.set_data(
51
+ allocator::malloc_or_wait(b.data_size() * out.itemsize()),
52
+ b.data_size(),
53
+ b.strides(),
54
+ b.flags());
55
+ break;
56
+ case VectorScalar:
57
+ case VectorVector:
58
+ out.set_data(
59
+ allocator::malloc_or_wait(a.data_size() * out.itemsize()),
60
+ a.data_size(),
61
+ a.strides(),
62
+ a.flags());
63
+ break;
64
+ case General:
65
+ out.set_data(allocator::malloc_or_wait(out.nbytes()));
66
+ break;
67
+ }
68
+ }
69
+
70
+ struct UseDefaultBinaryOp {
71
+ template <typename T, typename U>
72
+ void operator()(const T* a, const T* b, U* dst, int size) {
73
+ // Should we throw? This should normally never be called.
74
+ assert(false);
75
+ }
76
+ };
77
+
78
+ template <typename T, typename U, typename Op>
79
+ struct DefaultVectorScalar {
80
+ Op op;
81
+
82
+ DefaultVectorScalar(Op op_) : op(op_) {}
83
+
84
+ void operator()(const T* a, const T* b, U* dst, int size) {
85
+ T scalar = *b;
86
+ while (size-- > 0) {
87
+ *dst = op(*a, scalar);
88
+ dst++;
89
+ a++;
90
+ }
91
+ }
92
+ };
93
+
94
+ template <typename T, typename U, typename Op>
95
+ struct DefaultScalarVector {
96
+ Op op;
97
+
98
+ DefaultScalarVector(Op op_) : op(op_) {}
99
+
100
+ void operator()(const T* a, const T* b, U* dst, int size) {
101
+ T scalar = *a;
102
+ while (size-- > 0) {
103
+ *dst = op(scalar, *b);
104
+ dst++;
105
+ b++;
106
+ }
107
+ }
108
+ };
109
+
110
+ template <typename T, typename U, typename Op>
111
+ struct DefaultVectorVector {
112
+ Op op;
113
+
114
+ DefaultVectorVector(Op op_) : op(op_) {}
115
+
116
+ void operator()(const T* a, const T* b, U* dst, int size) {
117
+ while (size-- > 0) {
118
+ *dst = op(*a, *b);
119
+ dst++;
120
+ a++;
121
+ b++;
122
+ }
123
+ }
124
+ };
125
+
126
+ template <typename T, typename U, typename Op>
127
+ void binary_op_dims1(const array& a, const array& b, array& out, Op op) {
128
+ const T* a_ptr = a.data<T>();
129
+ const T* b_ptr = b.data<T>();
130
+ U* dst = out.data<U>();
131
+ size_t a_idx = 0;
132
+ size_t b_idx = 0;
133
+ for (size_t i = 0; i < out.size(); ++i) {
134
+ dst[i] = op(a_ptr[a_idx], b_ptr[b_idx]);
135
+ a_idx += a.strides()[0];
136
+ b_idx += b.strides()[0];
137
+ }
138
+ }
139
+
140
+ template <typename T, typename U, typename Op>
141
+ void binary_op_dims1(
142
+ const array& a,
143
+ const array& b,
144
+ array& out,
145
+ Op op,
146
+ int stride) {
147
+ const T* a_ptr = a.data<T>();
148
+ const T* b_ptr = b.data<T>();
149
+ U* dst = out.data<U>();
150
+ size_t a_idx = 0;
151
+ size_t b_idx = 0;
152
+ for (size_t i = 0; i < a.shape()[0]; i++) {
153
+ op(a_ptr + a_idx, b_ptr + b_idx, dst, stride);
154
+ a_idx += a.strides()[0];
155
+ b_idx += b.strides()[0];
156
+ dst += stride;
157
+ }
158
+ }
159
+
160
+ template <typename T, typename U, typename Op>
161
+ void binary_op_dims2(const array& a, const array& b, array& out, Op op) {
162
+ const T* a_ptr = a.data<T>();
163
+ const T* b_ptr = b.data<T>();
164
+ U* dst = out.data<U>();
165
+ size_t a_idx = 0;
166
+ size_t b_idx = 0;
167
+ size_t out_idx = 0;
168
+ for (size_t i = 0; i < a.shape()[0]; ++i) {
169
+ for (size_t j = 0; j < a.shape()[1]; ++j) {
170
+ dst[out_idx++] = op(a_ptr[a_idx], b_ptr[b_idx]);
171
+ a_idx += a.strides()[1];
172
+ b_idx += b.strides()[1];
173
+ }
174
+ a_idx += a.strides()[0] - a.strides()[1] * a.shape()[1];
175
+ b_idx += b.strides()[0] - b.strides()[1] * b.shape()[1];
176
+ }
177
+ }
178
+
179
+ template <typename T, typename U, typename Op>
180
+ void binary_op_dims2(
181
+ const array& a,
182
+ const array& b,
183
+ array& out,
184
+ Op op,
185
+ int stride) {
186
+ const T* a_ptr = a.data<T>();
187
+ const T* b_ptr = b.data<T>();
188
+ U* dst = out.data<U>();
189
+ size_t a_idx = 0;
190
+ size_t b_idx = 0;
191
+ for (size_t i = 0; i < a.shape()[0]; ++i) {
192
+ for (size_t j = 0; j < a.shape()[1]; ++j) {
193
+ op(a_ptr + a_idx, b_ptr + b_idx, dst, stride);
194
+ a_idx += a.strides()[1];
195
+ b_idx += b.strides()[1];
196
+ dst += stride;
197
+ }
198
+ a_idx += a.strides()[0] - a.strides()[1] * a.shape()[1];
199
+ b_idx += b.strides()[0] - b.strides()[1] * b.shape()[1];
200
+ }
201
+ }
202
+
203
+ template <typename T, typename U, typename Op>
204
+ void binary_op_dims3(const array& a, const array& b, array& out, Op op) {
205
+ const T* a_ptr = a.data<T>();
206
+ const T* b_ptr = b.data<T>();
207
+ U* dst = out.data<U>();
208
+ size_t a_idx = 0;
209
+ size_t b_idx = 0;
210
+ size_t out_idx = 0;
211
+ for (size_t i = 0; i < a.shape()[0]; ++i) {
212
+ for (size_t j = 0; j < a.shape()[1]; ++j) {
213
+ for (size_t k = 0; k < a.shape()[2]; ++k) {
214
+ dst[out_idx++] = op(a_ptr[a_idx], b_ptr[b_idx]);
215
+ a_idx += a.strides()[2];
216
+ b_idx += b.strides()[2];
217
+ }
218
+ a_idx += a.strides()[1] - a.strides()[2] * a.shape()[2];
219
+ b_idx += b.strides()[1] - b.strides()[2] * b.shape()[2];
220
+ }
221
+ a_idx += a.strides()[0] - a.strides()[1] * a.shape()[1];
222
+ b_idx += b.strides()[0] - b.strides()[1] * b.shape()[1];
223
+ }
224
+ }
225
+
226
+ template <typename T, typename U, typename Op>
227
+ void binary_op_dims4(const array& a, const array& b, array& out, Op op) {
228
+ const T* a_ptr = a.data<T>();
229
+ const T* b_ptr = b.data<T>();
230
+ U* dst = out.data<U>();
231
+ size_t a_idx = 0;
232
+ size_t b_idx = 0;
233
+ size_t out_idx = 0;
234
+ for (size_t i = 0; i < a.shape()[0]; ++i) {
235
+ for (size_t j = 0; j < a.shape()[1]; ++j) {
236
+ for (size_t k = 0; k < a.shape()[2]; ++k) {
237
+ for (size_t ii = 0; ii < a.shape()[3]; ++ii) {
238
+ dst[out_idx++] = op(a_ptr[a_idx], b_ptr[b_idx]);
239
+ a_idx += a.strides()[3];
240
+ b_idx += b.strides()[3];
241
+ }
242
+ a_idx += a.strides()[2] - a.strides()[3] * a.shape()[3];
243
+ b_idx += b.strides()[2] - b.strides()[3] * b.shape()[3];
244
+ }
245
+ a_idx += a.strides()[1] - a.strides()[2] * a.shape()[2];
246
+ b_idx += b.strides()[1] - b.strides()[2] * b.shape()[2];
247
+ }
248
+ a_idx += a.strides()[0] - a.strides()[1] * a.shape()[1];
249
+ b_idx += b.strides()[0] - b.strides()[1] * b.shape()[1];
250
+ }
251
+ }
252
+
253
+ template <typename T, typename U, typename Op>
254
+ void binary_op_dispatch_dims(
255
+ const array& a,
256
+ const array& b,
257
+ array& out,
258
+ Op op) {
259
+ switch (out.ndim()) {
260
+ case 1:
261
+ binary_op_dims1<T, U, Op>(a, b, out, op);
262
+ return;
263
+ case 2:
264
+ binary_op_dims2<T, U, Op>(a, b, out, op);
265
+ return;
266
+ case 3:
267
+ binary_op_dims3<T, U, Op>(a, b, out, op);
268
+ return;
269
+ case 4:
270
+ binary_op_dims4<T, U, Op>(a, b, out, op);
271
+ return;
272
+ }
273
+
274
+ const T* a_ptr = a.data<T>();
275
+ const T* b_ptr = b.data<T>();
276
+ U* dst = out.data<U>();
277
+ for (size_t i = 0; i < out.size(); i++) {
278
+ int a_idx = elem_to_loc(i, a.shape(), a.strides());
279
+ int b_idx = elem_to_loc(i, b.shape(), b.strides());
280
+ dst[i] = op(a_ptr[a_idx], b_ptr[b_idx]);
281
+ }
282
+ }
283
+
284
+ template <typename T, typename U, typename Op>
285
+ void binary_op_dispatch_dims(
286
+ const array& a,
287
+ const array& b,
288
+ array& out,
289
+ Op op,
290
+ int dim,
291
+ int stride) {
292
+ // Number of dimensions to loop over for vectorized ops
293
+ switch (dim) {
294
+ case 1:
295
+ binary_op_dims1<T, U, Op>(a, b, out, op, stride);
296
+ return;
297
+ case 2:
298
+ binary_op_dims2<T, U, Op>(a, b, out, op, stride);
299
+ return;
300
+ }
301
+
302
+ const T* a_ptr = a.data<T>();
303
+ const T* b_ptr = b.data<T>();
304
+ U* dst = out.data<U>();
305
+ for (size_t i = 0; i < out.size(); i += stride) {
306
+ int a_idx = elem_to_loc(i, a.shape(), a.strides());
307
+ int b_idx = elem_to_loc(i, b.shape(), b.strides());
308
+ op(a_ptr + a_idx, b_ptr + b_idx, dst, stride);
309
+ dst += stride;
310
+ }
311
+ }
312
+
313
+ template <
314
+ typename T,
315
+ typename U,
316
+ typename Op,
317
+ typename OpSV,
318
+ typename OpVS,
319
+ typename OpVV>
320
+ void binary_op(
321
+ const array& a,
322
+ const array& b,
323
+ array& out,
324
+ Op op,
325
+ OpSV opsv,
326
+ OpVS opvs,
327
+ OpVV opvv) {
328
+ auto bopt = get_binary_op_type(a, b);
329
+ set_binary_op_output_data(a, b, out, bopt);
330
+
331
+ // The full computation is scalar scalar so call the base op once
332
+ if (bopt == ScalarScalar) {
333
+ *(out.data<U>()) = op(*a.data<T>(), *b.data<T>());
334
+ return;
335
+ }
336
+
337
+ // The full computation is scalar vector so delegate to the op
338
+ if (bopt == ScalarVector) {
339
+ opsv(a.data<T>(), b.data<T>(), out.data<U>(), b.data_size());
340
+ return;
341
+ }
342
+
343
+ // The full computation is vector scalar so delegate to the op
344
+ if (bopt == VectorScalar) {
345
+ opvs(a.data<T>(), b.data<T>(), out.data<U>(), a.data_size());
346
+ return;
347
+ }
348
+
349
+ // The full computation is vector vector so delegate to the op
350
+ if (bopt == VectorVector) {
351
+ opvv(a.data<T>(), b.data<T>(), out.data<U>(), out.size());
352
+ return;
353
+ }
354
+
355
+ // General computation so let's try to optimize
356
+
357
+ // Get the left-most dim such that the array is row contiguous after
358
+ auto& strides = out.strides();
359
+ auto leftmost_rc_dim = [&strides](const array& arr) {
360
+ int d = arr.ndim() - 1;
361
+ for (; d >= 0 && arr.strides()[d] == strides[d]; d--) {
362
+ }
363
+ return d + 1;
364
+ };
365
+ auto a_rc_dim = leftmost_rc_dim(a);
366
+ auto b_rc_dim = leftmost_rc_dim(b);
367
+
368
+ // Get the left-most dim such that the array is a broadcasted "scalar" after
369
+ auto leftmost_s_dim = [](const array& arr) {
370
+ int d = arr.ndim() - 1;
371
+ for (; d >= 0 && arr.strides()[d] == 0; d--) {
372
+ }
373
+ return d + 1;
374
+ };
375
+ auto a_s_dim = leftmost_s_dim(a);
376
+ auto b_s_dim = leftmost_s_dim(b);
377
+
378
+ auto ndim = out.ndim();
379
+
380
+ // Case 1: LxM and FxM where L and F are broadcastable and M is row contiguous
381
+ int dim = ndim;
382
+ if (int d = std::max(a_rc_dim, b_rc_dim); d < ndim) {
383
+ bopt = VectorVector;
384
+ dim = d;
385
+ // Case 2: LxM and Fx1 where L and F are broadcastable and M is row
386
+ // contiguous
387
+ } else if (int d = std::max(a_rc_dim, b_s_dim); d < ndim) {
388
+ bopt = VectorScalar;
389
+ dim = d;
390
+ // Case 3: Lx1 and FxM where L and F are broadcastable and M is row
391
+ // contiguous
392
+ } else if (int d = std::max(a_s_dim, b_rc_dim); d < ndim) {
393
+ bopt = ScalarVector;
394
+ dim = d;
395
+ }
396
+
397
+ // Can be sure dim > 0 since otherwise we would have used one of the fully
398
+ // contiguous methods above. Except for the case that the flags do not
399
+ // correspond to the underlying contiguity.
400
+ size_t stride;
401
+ if (dim == 0 || strides[dim - 1] < 16) {
402
+ stride = 1;
403
+ bopt = General;
404
+ dim = ndim;
405
+ } else {
406
+ stride = strides[dim - 1];
407
+ }
408
+
409
+ switch (bopt) {
410
+ case VectorVector:
411
+ binary_op_dispatch_dims<T, U>(a, b, out, opvv, dim, stride);
412
+ break;
413
+ case VectorScalar:
414
+ binary_op_dispatch_dims<T, U>(a, b, out, opvs, dim, stride);
415
+ break;
416
+ case ScalarVector:
417
+ binary_op_dispatch_dims<T, U>(a, b, out, opsv, dim, stride);
418
+ break;
419
+ default:
420
+ binary_op_dispatch_dims<T, U>(a, b, out, op);
421
+ break;
422
+ }
423
+ }
424
+
425
+ template <typename T, typename Op, typename OpSV, typename OpVS, typename OpVV>
426
+ void binary_op(
427
+ const array& a,
428
+ const array& b,
429
+ array& out,
430
+ Op op,
431
+ OpSV opsv,
432
+ OpVS opvs,
433
+ OpVV opvv) {
434
+ // TODO: The following mess of constexpr evaluations can probably be achieved
435
+ // with template specializations and overloading. Would it be simpler?
436
+
437
+ if (std::is_same<decltype(opsv), UseDefaultBinaryOp>::value) {
438
+ if (std::is_same<decltype(opvs), UseDefaultBinaryOp>::value) {
439
+ if (std::is_same<decltype(opvv), UseDefaultBinaryOp>::value) {
440
+ // All ops are UseDefaultBinaryOp (why oh why would someone call that?)
441
+ binary_op<T, T>(
442
+ a,
443
+ b,
444
+ out,
445
+ op,
446
+ DefaultScalarVector<T, T, Op>(op),
447
+ DefaultVectorScalar<T, T, Op>(op),
448
+ DefaultVectorVector<T, T, Op>(op));
449
+ } else {
450
+ // opsv and opvs were UseDefaultBinaryOp
451
+ binary_op<T, T>(
452
+ a,
453
+ b,
454
+ out,
455
+ op,
456
+ DefaultScalarVector<T, T, Op>(op),
457
+ DefaultVectorScalar<T, T, Op>(op),
458
+ opvv);
459
+ }
460
+ } else if (std::is_same<decltype(opvv), UseDefaultBinaryOp>::value) {
461
+ // opsv and opvv were UseDefaultBinaryOp
462
+ binary_op<T, T>(
463
+ a,
464
+ b,
465
+ out,
466
+ op,
467
+ DefaultScalarVector<T, T, Op>(op),
468
+ opvs,
469
+ DefaultVectorVector<T, T, Op>(op));
470
+ } else {
471
+ // opsv was UseDefaultBinaryOp
472
+ binary_op<T, T>(
473
+ a, b, out, op, DefaultScalarVector<T, T, Op>(op), opvs, opvv);
474
+ }
475
+ } else if (std::is_same<decltype(opvs), UseDefaultBinaryOp>::value) {
476
+ if (std::is_same<decltype(opvv), UseDefaultBinaryOp>::value) {
477
+ // opvs and opvv were UseDefaultBinaryOp
478
+ binary_op<T, T>(
479
+ a,
480
+ b,
481
+ out,
482
+ op,
483
+ opsv,
484
+ DefaultVectorScalar<T, T, Op>(op),
485
+ DefaultVectorVector<T, T, Op>(op));
486
+ } else {
487
+ // opvs was UseDefaultBinaryOp
488
+ binary_op<T, T>(
489
+ a, b, out, op, opsv, DefaultVectorScalar<T, T, Op>(op), opvv);
490
+ }
491
+ } else if (std::is_same<decltype(opvv), UseDefaultBinaryOp>::value) {
492
+ // opvv was UseDefaultBinaryOp
493
+ binary_op<T, T>(
494
+ a, b, out, op, opsv, opvs, DefaultVectorVector<T, T, Op>(op));
495
+ } else {
496
+ // All ops provided
497
+ binary_op<T, T>(a, b, out, op, opsv, opvs, opvv);
498
+ }
499
+ }
500
+
501
+ template <typename T, typename Op>
502
+ void binary_op(const array& a, const array& b, array& out, Op op) {
503
+ DefaultScalarVector<T, T, Op> opsv(op);
504
+ DefaultVectorScalar<T, T, Op> opvs(op);
505
+ DefaultVectorVector<T, T, Op> opvv(op);
506
+ binary_op<T, T>(a, b, out, op, opsv, opvs, opvv);
507
+ }
508
+
509
+ template <typename... Ops>
510
+ void binary(const array& a, const array& b, array& out, Ops... ops) {
511
+ switch (out.dtype()) {
512
+ case bool_:
513
+ binary_op<bool>(a, b, out, ops...);
514
+ break;
515
+ case uint8:
516
+ binary_op<uint8_t>(a, b, out, ops...);
517
+ break;
518
+ case uint16:
519
+ binary_op<uint16_t>(a, b, out, ops...);
520
+ break;
521
+ case uint32:
522
+ binary_op<uint32_t>(a, b, out, ops...);
523
+ break;
524
+ case uint64:
525
+ binary_op<uint64_t>(a, b, out, ops...);
526
+ break;
527
+ case int8:
528
+ binary_op<int8_t>(a, b, out, ops...);
529
+ break;
530
+ case int16:
531
+ binary_op<int16_t>(a, b, out, ops...);
532
+ break;
533
+ case int32:
534
+ binary_op<int32_t>(a, b, out, ops...);
535
+ break;
536
+ case int64:
537
+ binary_op<int64_t>(a, b, out, ops...);
538
+ break;
539
+ case float16:
540
+ binary_op<float16_t>(a, b, out, ops...);
541
+ break;
542
+ case float32:
543
+ binary_op<float>(a, b, out, ops...);
544
+ break;
545
+ case bfloat16:
546
+ binary_op<bfloat16_t>(a, b, out, ops...);
547
+ break;
548
+ case complex64:
549
+ binary_op<complex64_t>(a, b, out, ops...);
550
+ break;
551
+ }
552
+ }
553
+
554
+ } // namespace
555
+
556
+ } // namespace mlx::core
lib/python3.11/site-packages/mlx/include/mlx/backend/common/copy.h ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Copyright © 2023 Apple Inc.
2
+
3
+ #pragma once
4
+
5
+ #include "mlx/array.h"
6
+ #include "mlx/backend/common/utils.h"
7
+
8
+ namespace mlx::core {
9
+
10
+ enum class CopyType {
11
+ // Copy a raw scalar input into the full contiguous output
12
+ Scalar,
13
+
14
+ // Copy the raw input buffer contiguously into a raw output buffer of the same
15
+ // size
16
+ Vector,
17
+
18
+ // Copy the full virtual input to the full contiguous output
19
+ General,
20
+
21
+ // Copy the full virtual input to the full virtual output. We assume the
22
+ // input and output have the same shape.
23
+ GeneralGeneral
24
+ };
25
+
26
+ void copy(const array& src, array& dst, CopyType ctype);
27
+ void copy_inplace(const array& src, array& dst, CopyType ctype);
28
+
29
+ } // namespace mlx::core
lib/python3.11/site-packages/mlx/include/mlx/backend/common/erf.h ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Copyright © 2023 Apple Inc.
2
+
3
+ namespace mlx::core {
4
+
5
+ /* Approximation to the inverse error function.
6
+ * Based on code from:
7
+ * https://stackoverflow.com/questions/27229371/inverse-error-function-in-c#answer-49743348
8
+ */
9
+ float erfinv(float a);
10
+
11
+ } // namespace mlx::core
lib/python3.11/site-packages/mlx/include/mlx/backend/common/reduce.h ADDED
@@ -0,0 +1,366 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Copyright © 2023 Apple Inc.
2
+
3
+ #pragma once
4
+
5
+ #include "mlx/backend/common/utils.h"
6
+
7
+ namespace mlx::core {
8
+
9
+ namespace {
10
+
11
+ enum ReductionOpType {
12
+ // Self-explanatory. Read everything and produce 1 output.
13
+ ContiguousAllReduce,
14
+
15
+ // The input is contiguous and the last axis is reduced
16
+ // N1xR1xN2xR2x...xNnxRn
17
+ ContiguousReduce,
18
+
19
+ // The input is contiguous and the last axis is not reduced
20
+ // R1xN1xR2xN2x...xRnxNn
21
+ ContiguousStridedReduce,
22
+
23
+ // The input is not contiguous but the last axis is and it is reduced so we
24
+ // need to figure out the offsets but we can call the contiguous reduce after
25
+ // that.
26
+ // N3xR1xN1xR4x...xRn
27
+ GeneralContiguousReduce,
28
+
29
+ // The input is not contiguous but the last reduction axis and the last axis
30
+ // are so we need to figure out the offset but we can call the strided reduce
31
+ // after that.
32
+ GeneralStridedReduce,
33
+
34
+ // The input is not contiguous after the reduction axis and it may contain
35
+ // 0-stride axes or transpositions. We could copy the strides and produce a
36
+ // transposed outcome or we can read the input out of order and write the
37
+ // output in order.
38
+ GeneralReduce
39
+ };
40
+
41
+ // Helper for the ndimensional strided loop
42
+ // Should this be in utils?
43
+ inline void nd_loop(
44
+ std::function<void(int)> callback,
45
+ const std::vector<int>& shape,
46
+ const std::vector<size_t>& strides) {
47
+ std::function<void(int, int)> loop_inner;
48
+ loop_inner = [&](int dim, int offset) {
49
+ if (dim < shape.size() - 1) {
50
+ int size = shape[dim];
51
+ size_t stride = strides[dim];
52
+ for (int i = 0; i < size; i++) {
53
+ loop_inner(dim + 1, offset + i * stride);
54
+ }
55
+ } else {
56
+ int size = shape[dim];
57
+ size_t stride = strides[dim];
58
+ for (int i = 0; i < size; i++) {
59
+ callback(offset + i * stride);
60
+ }
61
+ }
62
+ };
63
+ loop_inner(0, 0);
64
+ }
65
+
66
+ std::pair<std::vector<int>, std::vector<size_t>> shapes_without_reduction_axes(
67
+ const array& x,
68
+ const std::vector<int>& axes) {
69
+ std::vector<int> shape = x.shape();
70
+ std::vector<size_t> strides = x.strides();
71
+
72
+ for (int i = axes.size() - 1; i >= 0; i--) {
73
+ int a = axes[i];
74
+ shape.erase(shape.begin() + a);
75
+ strides.erase(strides.begin() + a);
76
+ }
77
+
78
+ return std::make_pair(shape, strides);
79
+ }
80
+
81
+ template <typename T, typename U, typename Op>
82
+ struct DefaultStridedReduce {
83
+ Op op;
84
+
85
+ DefaultStridedReduce(Op op_) : op(op_) {}
86
+
87
+ void operator()(const T* x, U* accumulator, int size, size_t stride) {
88
+ for (int i = 0; i < size; i++) {
89
+ U* moving_accumulator = accumulator;
90
+ for (int j = 0; j < stride; j++) {
91
+ op(moving_accumulator, *x);
92
+ moving_accumulator++;
93
+ x++;
94
+ }
95
+ }
96
+ }
97
+ };
98
+
99
+ template <typename T, typename U, typename Op>
100
+ struct DefaultContiguousReduce {
101
+ Op op;
102
+
103
+ DefaultContiguousReduce(Op op_) : op(op_) {}
104
+
105
+ void operator()(const T* x, U* accumulator, int size) {
106
+ while (size-- > 0) {
107
+ op(accumulator, *x);
108
+ x++;
109
+ }
110
+ }
111
+ };
112
+
113
+ struct ReductionPlan {
114
+ ReductionOpType type;
115
+ std::vector<int> shape;
116
+ std::vector<size_t> strides;
117
+
118
+ ReductionPlan(
119
+ ReductionOpType type_,
120
+ std::vector<int> shape_,
121
+ std::vector<size_t> strides_)
122
+ : type(type_), shape(std::move(shape_)), strides(std::move(strides_)) {}
123
+ ReductionPlan(ReductionOpType type_) : type(type_) {}
124
+ };
125
+
126
+ ReductionPlan get_reduction_plan(const array& x, const std::vector<int> axes) {
127
+ // The data is all there and we are reducing over everything
128
+ if (x.size() == x.data_size() && axes.size() == x.ndim() &&
129
+ x.flags().contiguous) {
130
+ return ContiguousAllReduce;
131
+ }
132
+
133
+ // Row contiguous input so the output is row contiguous
134
+ if (x.flags().row_contiguous) {
135
+ // Merge consecutive axes
136
+ std::vector<int> shape = {x.shape(axes[0])};
137
+ std::vector<size_t> strides = {x.strides()[axes[0]]};
138
+ for (int i = 1; i < axes.size(); i++) {
139
+ if (axes[i] - 1 == axes[i - 1]) {
140
+ shape.back() *= x.shape(axes[i]);
141
+ strides.back() = x.strides()[axes[i]];
142
+ } else {
143
+ shape.push_back(x.shape(axes[i]));
144
+ strides.push_back(x.strides()[axes[i]]);
145
+ }
146
+ }
147
+
148
+ if (strides.back() == 1) {
149
+ return ReductionPlan(ContiguousReduce, shape, strides);
150
+ } else if (strides.back() > 1) {
151
+ return ReductionPlan(ContiguousStridedReduce, shape, strides);
152
+ }
153
+ }
154
+
155
+ // Let's check if we can optimize our access patterns
156
+ //
157
+ // 1. We have a reduction axis with stride 1. Simply call
158
+ // GeneralContiguousReduce and be done with it.
159
+ // 2. We have transpositions and we are not reducing over the axis with
160
+ // stride 1. However, we are reducing over an axis where everything is
161
+ // contiguous in memory to the right of that axis. We can call strided
162
+ // reduce and be done with it.
163
+ // 2. We have weird transpositions and expands. Copy the strides to the
164
+ // output, then call strided reduce.
165
+
166
+ // Sort reduction axes by stride in order to merge them and figure out if we
167
+ // have a contiguous reduction.
168
+ std::vector<std::pair<int, size_t>> reductions;
169
+ for (auto a : axes) {
170
+ reductions.push_back(std::make_pair(x.shape(a), x.strides()[a]));
171
+ }
172
+ std::sort(reductions.begin(), reductions.end(), [](auto a, auto b) {
173
+ return a.second > b.second;
174
+ });
175
+ // Extract the two smallest and try to merge them in case the contiguous
176
+ // reduction can be bigger than just the last axis.
177
+ for (int i = reductions.size() - 1; i >= 1; i--) {
178
+ auto a = reductions[i];
179
+ auto b = reductions[i - 1];
180
+
181
+ // b.stride = a.shape * a.stride then a and b are contiguous
182
+ if (b.second == a.first * a.second) {
183
+ reductions.erase(reductions.begin() + i);
184
+ reductions[i - 1] = std::make_pair(a.first * b.first, a.second);
185
+ }
186
+ }
187
+
188
+ std::vector<int> shape;
189
+ std::vector<size_t> strides;
190
+ for (auto r : reductions) {
191
+ shape.push_back(r.first);
192
+ strides.push_back(r.second);
193
+ }
194
+
195
+ // We can call the contiguous reduction op for every weird way the input is
196
+ // structured in the rest of the axes.
197
+ if (strides.back() == 1) {
198
+ return ReductionPlan(GeneralContiguousReduce, shape, strides);
199
+ }
200
+
201
+ // Delegate to the general strided reduction op if the axes after
202
+ // strides.back() are contiguous.
203
+ if (strides.back() > 1) {
204
+ int size = 1;
205
+ for (int i = x.ndim() - 1; i >= 0; i--) {
206
+ if (axes.back() == i) {
207
+ continue;
208
+ }
209
+ if (x.strides()[i] != size) {
210
+ break;
211
+ }
212
+ size *= x.shape(i);
213
+ }
214
+ if (size >= strides.back()) {
215
+ return ReductionPlan(GeneralStridedReduce, shape, strides);
216
+ }
217
+ }
218
+
219
+ return ReductionPlan(GeneralReduce, shape, strides);
220
+ }
221
+
222
+ template <typename T, typename U, typename OpS, typename OpC, typename Op>
223
+ void reduction_op(
224
+ const array& x,
225
+ array& out,
226
+ const std::vector<int>& axes,
227
+ U init,
228
+ OpS ops,
229
+ OpC opc,
230
+ Op op) {
231
+ out.set_data(allocator::malloc_or_wait(out.nbytes()));
232
+ ReductionPlan plan = get_reduction_plan(x, axes);
233
+
234
+ if (plan.type == ContiguousAllReduce) {
235
+ U* out_ptr = out.data<U>();
236
+ *out_ptr = init;
237
+ opc(x.data<T>(), out_ptr, x.size());
238
+ return;
239
+ }
240
+
241
+ std::vector<int> shape;
242
+ std::vector<size_t> strides;
243
+
244
+ if (plan.type == ContiguousReduce && plan.shape.size() == 1) {
245
+ int reduction_size = plan.shape[0];
246
+ const T* x_ptr = x.data<T>();
247
+ U* out_ptr = out.data<U>();
248
+ for (int i = 0; i < out.size(); i++, out_ptr++, x_ptr += reduction_size) {
249
+ *out_ptr = init;
250
+ opc(x_ptr, out_ptr, reduction_size);
251
+ }
252
+ return;
253
+ }
254
+
255
+ if (plan.type == GeneralContiguousReduce || plan.type == ContiguousReduce) {
256
+ int reduction_size = plan.shape.back();
257
+ plan.shape.pop_back();
258
+ plan.strides.pop_back();
259
+ const T* x_ptr = x.data<T>();
260
+ U* out_ptr = out.data<U>();
261
+ // Unrolling the following loop (and implementing it in order for
262
+ // ContiguousReduce) should hold extra performance boost.
263
+ std::tie(shape, strides) = shapes_without_reduction_axes(x, axes);
264
+ if (plan.shape.size() == 0) {
265
+ for (int i = 0; i < out.size(); i++, out_ptr++) {
266
+ int offset = elem_to_loc(i, shape, strides);
267
+ *out_ptr = init;
268
+ opc(x_ptr + offset, out_ptr, reduction_size);
269
+ }
270
+ } else {
271
+ for (int i = 0; i < out.size(); i++, out_ptr++) {
272
+ int offset = elem_to_loc(i, shape, strides);
273
+ *out_ptr = init;
274
+ nd_loop(
275
+ [&](int extra_offset) {
276
+ opc(x_ptr + offset + extra_offset, out_ptr, reduction_size);
277
+ },
278
+ plan.shape,
279
+ plan.strides);
280
+ }
281
+ }
282
+ return;
283
+ }
284
+
285
+ if (plan.type == ContiguousStridedReduce && plan.shape.size() == 1) {
286
+ int reduction_size = plan.shape.back();
287
+ size_t reduction_stride = plan.strides.back();
288
+ plan.shape.pop_back();
289
+ plan.strides.pop_back();
290
+ const T* x_ptr = x.data<T>();
291
+ U* out_ptr = out.data<U>();
292
+ for (int i = 0; i < out.size(); i += reduction_stride) {
293
+ std::fill_n(out_ptr, reduction_stride, init);
294
+ ops(x_ptr, out_ptr, reduction_size, reduction_stride);
295
+ x_ptr += reduction_stride * reduction_size;
296
+ out_ptr += reduction_stride;
297
+ }
298
+ return;
299
+ }
300
+
301
+ if (plan.type == GeneralStridedReduce ||
302
+ plan.type == ContiguousStridedReduce) {
303
+ int reduction_size = plan.shape.back();
304
+ size_t reduction_stride = plan.strides.back();
305
+ plan.shape.pop_back();
306
+ plan.strides.pop_back();
307
+ const T* x_ptr = x.data<T>();
308
+ U* out_ptr = out.data<U>();
309
+ std::tie(shape, strides) = shapes_without_reduction_axes(x, axes);
310
+ if (plan.shape.size() == 0) {
311
+ for (int i = 0; i < out.size(); i += reduction_stride) {
312
+ int offset = elem_to_loc(i, shape, strides);
313
+ std::fill_n(out_ptr, reduction_stride, init);
314
+ ops(x_ptr + offset, out_ptr, reduction_size, reduction_stride);
315
+ out_ptr += reduction_stride;
316
+ }
317
+ } else {
318
+ for (int i = 0; i < out.size(); i += reduction_stride) {
319
+ int offset = elem_to_loc(i, shape, strides);
320
+ std::fill_n(out_ptr, reduction_stride, init);
321
+ nd_loop(
322
+ [&](int extra_offset) {
323
+ ops(x_ptr + offset + extra_offset,
324
+ out_ptr,
325
+ reduction_size,
326
+ reduction_stride);
327
+ },
328
+ plan.shape,
329
+ plan.strides);
330
+ out_ptr += reduction_stride;
331
+ }
332
+ }
333
+ return;
334
+ }
335
+
336
+ if (plan.type == GeneralReduce) {
337
+ const T* x_ptr = x.data<T>();
338
+ U* out_ptr = out.data<U>();
339
+ std::tie(shape, strides) = shapes_without_reduction_axes(x, axes);
340
+ for (int i = 0; i < out.size(); i++, out_ptr++) {
341
+ int offset = elem_to_loc(i, shape, strides);
342
+ U val = init;
343
+ nd_loop(
344
+ [&](int extra_offset) { op(&val, *(x_ptr + offset + extra_offset)); },
345
+ plan.shape,
346
+ plan.strides);
347
+ *out_ptr = val;
348
+ }
349
+ }
350
+ }
351
+
352
+ template <typename T, typename U, typename Op>
353
+ void reduction_op(
354
+ const array& x,
355
+ array& out,
356
+ const std::vector<int>& axes,
357
+ U init,
358
+ Op op) {
359
+ DefaultStridedReduce<T, U, Op> ops(op);
360
+ DefaultContiguousReduce<T, U, Op> opc(op);
361
+ reduction_op<T, U>(x, out, axes, init, ops, opc, op);
362
+ }
363
+
364
+ } // namespace
365
+
366
+ } // namespace mlx::core
lib/python3.11/site-packages/mlx/include/mlx/backend/common/threefry.h ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Copyright © 2023 Apple Inc.
2
+
3
+ #pragma once
4
+
5
+ #include <cstdint>
6
+ #include <utility>
7
+
8
+ namespace mlx::core::random {
9
+
10
+ /** Applies the Threefry 2x32 hash function.
11
+ * This code is based on the Jax counter-based and splittable PRNG
12
+ * https://github.com/google/jax/blob/main/docs/jep/263-prng.md
13
+ *
14
+ * Original Threefry reference:
15
+ * http://www.thesalmons.org/john/random123/papers/random123sc11.pdf
16
+ */
17
+ std::pair<uint32_t, uint32_t> threefry2x32_hash(
18
+ const std::pair<uint32_t, uint32_t>& key,
19
+ std::pair<uint32_t, uint32_t> count);
20
+
21
+ } // namespace mlx::core::random
lib/python3.11/site-packages/mlx/include/mlx/backend/common/unary.h ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Copyright © 2023 Apple Inc.
2
+
3
+ #pragma once
4
+
5
+ #include "mlx/allocator.h"
6
+ #include "mlx/array.h"
7
+ #include "mlx/backend/common/utils.h"
8
+ #include "mlx/utils.h"
9
+
10
+ namespace mlx::core {
11
+
12
+ namespace {
13
+
14
+ struct AbsOp {
15
+ template <typename T>
16
+ T operator()(T x) {
17
+ return std::abs(x);
18
+ }
19
+ uint8_t operator()(uint8_t x) {
20
+ return x;
21
+ }
22
+ uint16_t operator()(uint16_t x) {
23
+ return x;
24
+ }
25
+ uint32_t operator()(uint32_t x) {
26
+ return x;
27
+ }
28
+ uint64_t operator()(uint64_t x) {
29
+ return x;
30
+ }
31
+ bool operator()(bool x) {
32
+ return x;
33
+ }
34
+ };
35
+
36
+ struct SignOp {
37
+ template <typename T>
38
+ T operator()(T x) {
39
+ return (x > T(0)) - (x < T(0));
40
+ }
41
+
42
+ uint8_t operator()(uint8_t x) {
43
+ return x != 0;
44
+ }
45
+ uint16_t operator()(uint16_t x) {
46
+ return x != 0;
47
+ }
48
+ uint32_t operator()(uint32_t x) {
49
+ return x != 0;
50
+ }
51
+ uint64_t operator()(uint64_t x) {
52
+ return x != 0;
53
+ }
54
+ };
55
+
56
+ struct RoundOp {
57
+ template <typename T>
58
+ T operator()(T x) {
59
+ return std::round(x);
60
+ }
61
+
62
+ complex64_t operator()(complex64_t x) {
63
+ return {std::round(x.real()), std::round(x.imag())};
64
+ }
65
+ };
66
+
67
+ template <typename T, typename Op>
68
+ void unary_op(const array& a, array& out, Op op) {
69
+ const T* a_ptr = a.data<T>();
70
+ if (a.flags().contiguous) {
71
+ out.set_data(
72
+ allocator::malloc_or_wait(a.data_size() * out.itemsize()),
73
+ a.data_size(),
74
+ a.strides(),
75
+ a.flags());
76
+ T* dst = out.data<T>();
77
+ for (size_t i = 0; i < a.data_size(); ++i) {
78
+ dst[i] = op(a_ptr[i]);
79
+ }
80
+ } else {
81
+ out.set_data(allocator::malloc_or_wait(out.nbytes()));
82
+ T* dst = out.data<T>();
83
+ for (size_t i = 0; i < out.size(); ++i) {
84
+ // TODO this is super inefficient, need to fix.
85
+ int a_idx = elem_to_loc(i, a.shape(), a.strides());
86
+ dst[i] = op(a_ptr[a_idx]);
87
+ }
88
+ }
89
+ }
90
+
91
+ template <typename Op>
92
+ void unary(const array& a, array& out, Op op) {
93
+ switch (out.dtype()) {
94
+ case bool_:
95
+ unary_op<bool>(a, out, op);
96
+ break;
97
+ case uint8:
98
+ unary_op<uint8_t>(a, out, op);
99
+ break;
100
+ case uint16:
101
+ unary_op<uint16_t>(a, out, op);
102
+ break;
103
+ case uint32:
104
+ unary_op<uint32_t>(a, out, op);
105
+ break;
106
+ case uint64:
107
+ unary_op<uint64_t>(a, out, op);
108
+ break;
109
+ case int8:
110
+ unary_op<int8_t>(a, out, op);
111
+ break;
112
+ case int16:
113
+ unary_op<int16_t>(a, out, op);
114
+ break;
115
+ case int32:
116
+ unary_op<int32_t>(a, out, op);
117
+ break;
118
+ case int64:
119
+ unary_op<int64_t>(a, out, op);
120
+ break;
121
+ case float16:
122
+ unary_op<float16_t>(a, out, op);
123
+ break;
124
+ case float32:
125
+ unary_op<float>(a, out, op);
126
+ break;
127
+ case bfloat16:
128
+ unary_op<bfloat16_t>(a, out, op);
129
+ break;
130
+ case complex64:
131
+ unary_op<complex64_t>(a, out, op);
132
+ break;
133
+ }
134
+ }
135
+
136
+ template <typename Op>
137
+ void unary_fp(const array& a, array& out, Op op) {
138
+ switch (out.dtype()) {
139
+ case bfloat16:
140
+ unary_op<bfloat16_t>(a, out, op);
141
+ break;
142
+ case float16:
143
+ unary_op<float16_t>(a, out, op);
144
+ break;
145
+ case float32:
146
+ unary_op<float>(a, out, op);
147
+ break;
148
+ case complex64:
149
+ unary_op<complex64_t>(a, out, op);
150
+ break;
151
+ default:
152
+ std::ostringstream err;
153
+ err << "[unary_fp] Does not support " << out.dtype();
154
+ throw std::runtime_error(err.str());
155
+ }
156
+ }
157
+
158
+ } // namespace
159
+
160
+ } // namespace mlx::core
lib/python3.11/site-packages/mlx/include/mlx/backend/common/utils.h ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Copyright © 2023 Apple Inc.
2
+
3
+ #pragma once
4
+
5
+ #include <vector>
6
+
7
+ #include "mlx/array.h"
8
+
9
+ namespace mlx::core {
10
+
11
+ inline size_t elem_to_loc(
12
+ int elem,
13
+ const std::vector<int>& shape,
14
+ const std::vector<size_t>& strides) {
15
+ size_t loc = 0;
16
+ for (int i = shape.size() - 1; i >= 0; --i) {
17
+ auto q_and_r = ldiv(elem, shape[i]);
18
+ loc += q_and_r.rem * strides[i];
19
+ elem = q_and_r.quot;
20
+ }
21
+ return loc;
22
+ }
23
+
24
+ inline size_t elem_to_loc(int elem, const array& a) {
25
+ if (a.flags().row_contiguous) {
26
+ return elem;
27
+ }
28
+ return elem_to_loc(elem, a.shape(), a.strides());
29
+ }
30
+
31
+ } // namespace mlx::core
lib/python3.11/site-packages/mlx/include/mlx/backend/metal/allocator.h ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Copyright © 2023 Apple Inc.
2
+
3
+ #pragma once
4
+
5
+ #include <map>
6
+ #include <mutex>
7
+ #include <vector>
8
+
9
+ #include "mlx/allocator.h"
10
+ #include "mlx/backend/metal/device.h"
11
+
12
+ namespace mlx::core::metal {
13
+
14
+ using allocator::Buffer;
15
+
16
+ namespace {
17
+
18
+ class BufferCache {
19
+ public:
20
+ BufferCache(MTL::Device* device);
21
+ ~BufferCache();
22
+ void clear();
23
+
24
+ MTL::Buffer* reuse_from_cache(size_t size);
25
+ void recycle_to_cache(MTL::Buffer* buf);
26
+ void release_cached_buffers(size_t min_bytes_to_free);
27
+
28
+ private:
29
+ struct BufferHolder {
30
+ public:
31
+ BufferHolder(MTL::Buffer* buf_) : buf(buf_), prev(nullptr), next(nullptr) {}
32
+
33
+ BufferHolder* prev;
34
+ BufferHolder* next;
35
+ MTL::Buffer* buf;
36
+ };
37
+
38
+ void add_at_head(BufferHolder* to_add);
39
+ void remove_from_list(BufferHolder* to_remove);
40
+
41
+ MTL::Device* device_;
42
+ std::mutex cache_mutex_;
43
+
44
+ std::multimap<size_t, BufferHolder*> buffer_pool_;
45
+ BufferHolder* head_;
46
+ BufferHolder* tail_;
47
+ size_t pool_size_;
48
+ };
49
+
50
+ } // namespace
51
+
52
+ class MetalAllocator : public allocator::Allocator {
53
+ /** Allocator for Metal GPUs. */
54
+ public:
55
+ virtual Buffer malloc(size_t size, bool allow_swap = false) override;
56
+ virtual void free(Buffer buffer) override;
57
+
58
+ private:
59
+ MTL::Device* device_;
60
+ MetalAllocator();
61
+ friend MetalAllocator& allocator();
62
+
63
+ // Caching allocator
64
+ BufferCache buffer_cache_;
65
+
66
+ // Allocation stats
67
+ size_t peak_allocated_size_;
68
+ size_t block_limit_;
69
+ size_t gc_limit_;
70
+ };
71
+
72
+ MetalAllocator& allocator();
73
+
74
+ } // namespace mlx::core::metal
lib/python3.11/site-packages/mlx/include/mlx/backend/metal/copy.h ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Copyright © 2023 Apple Inc.
2
+
3
+ #pragma once
4
+
5
+ #include "mlx/backend/common/copy.h"
6
+ #include "mlx/stream.h"
7
+
8
+ namespace mlx::core {
9
+
10
+ void copy_gpu(const array& src, array& out, CopyType ctype, const Stream& s);
11
+ void copy_gpu(const array& src, array& out, CopyType ctype);
12
+ void copy_gpu_inplace(
13
+ const array& src,
14
+ array& out,
15
+ CopyType ctype,
16
+ const Stream& s);
17
+
18
+ } // namespace mlx::core
lib/python3.11/site-packages/mlx/include/mlx/backend/metal/device.h ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Copyright © 2023 Apple Inc.
2
+
3
+ #pragma once
4
+
5
+ #include <Metal/Metal.hpp>
6
+ #include <functional>
7
+ #include <mutex>
8
+ #include <string>
9
+ #include <unordered_map>
10
+
11
+ #include <dlfcn.h>
12
+ #include <filesystem>
13
+
14
+ #include "mlx/device.h"
15
+
16
+ namespace fs = std::filesystem;
17
+
18
+ namespace mlx::core::metal {
19
+
20
+ inline std::string get_colocated_mtllib_path(const std::string& lib_name) {
21
+ Dl_info info;
22
+ std::string mtllib_path;
23
+ std::string lib_ext = lib_name + ".metallib";
24
+
25
+ int success = dladdr((void*)get_colocated_mtllib_path, &info);
26
+ if (success) {
27
+ auto mtllib = fs::path(info.dli_fname).remove_filename() / lib_ext;
28
+ mtllib_path = mtllib.c_str();
29
+ }
30
+
31
+ return mtllib_path;
32
+ }
33
+
34
+ class Device {
35
+ public:
36
+ Device();
37
+ Device(const Device&) = delete;
38
+ Device& operator=(const Device&) = delete;
39
+ ~Device();
40
+
41
+ MTL::Device* mtl_device() {
42
+ return device_;
43
+ };
44
+
45
+ void new_queue(int index);
46
+ MTL::CommandBuffer* new_command_buffer(int index);
47
+ MTL::CommandBuffer* get_command_buffer(int index);
48
+ int get_command_buffer_ops(int index);
49
+ void increment_command_buffer_ops(int index);
50
+ void commit_command_buffer(int index);
51
+ MTL::ComputeCommandEncoder* get_command_encoder(int index);
52
+ void end_encoding(int index);
53
+
54
+ void register_library(
55
+ const std::string& lib_name,
56
+ const std::string& lib_path);
57
+ void register_library(
58
+ const std::string& lib_name,
59
+ const std::function<std::string(const std::string&)>& lib_path_func =
60
+ get_colocated_mtllib_path);
61
+
62
+ MTL::ComputePipelineState* get_kernel(
63
+ const std::string& name,
64
+ const std::string& lib_name = "mlx");
65
+
66
+ MTL::ArgumentEncoder* argument_encoder(
67
+ const std::vector<MTL::ArgumentDescriptor*>& arg_descs) const;
68
+
69
+ private:
70
+ MTL::Device* device_;
71
+ std::unordered_map<int32_t, MTL::CommandQueue*> queue_map_;
72
+ std::unordered_map<int32_t, std::pair<int, MTL::CommandBuffer*>> buffer_map_;
73
+ std::unordered_map<int32_t, MTL::ComputeCommandEncoder*> encoder_map_;
74
+ std::unordered_map<std::string, MTL::ComputePipelineState*> kernel_map_;
75
+ std::unordered_map<std::string, MTL::Library*> library_map_;
76
+ std::mutex mtx_;
77
+ };
78
+
79
+ Device& device(mlx::core::Device);
80
+
81
+ } // namespace mlx::core::metal
lib/python3.11/site-packages/mlx/include/mlx/backend/metal/kernels/atomic.h ADDED
@@ -0,0 +1,322 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Copyright © 2023 Apple Inc.
2
+
3
+ #pragma once
4
+
5
+ #include <metal_atomic>
6
+ #include <metal_stdlib>
7
+ #include "mlx/backend/metal/kernels/bf16.h"
8
+
9
+ using namespace metal;
10
+
11
+ ///////////////////////////////////////////////////////////////////////////////
12
+ // Atomic utils
13
+ ///////////////////////////////////////////////////////////////////////////////
14
+
15
+ #pragma METAL internals : enable
16
+ template <typename T>
17
+ constexpr constant bool is_metal_atomic = _disjunction<
18
+ is_same<T, int>,
19
+ is_same<T, uint>,
20
+ is_same<T, ulong>,
21
+ is_same<T, float>>::value;
22
+
23
+ #pragma METAL internals : disable
24
+
25
+ template <typename T, typename = void>
26
+ struct mlx_atomic {
27
+ atomic<uint> val;
28
+ };
29
+
30
+ template <typename T>
31
+ struct mlx_atomic<T, enable_if_t<is_metal_atomic<T>>> {
32
+ atomic<T> val;
33
+ };
34
+
35
+ ///////////////////////////////////////////////////////////////////////////////
36
+ // Native metal atomics
37
+ ///////////////////////////////////////////////////////////////////////////////
38
+
39
+ template <typename T, enable_if_t<is_metal_atomic<T>, bool> = true>
40
+ METAL_FUNC T
41
+ mlx_atomic_load_explicit(device mlx_atomic<T>* object, int offset) {
42
+ return atomic_load_explicit(&(object[offset].val), memory_order_relaxed);
43
+ }
44
+
45
+ template <typename T, enable_if_t<is_metal_atomic<T>, bool> = true>
46
+ METAL_FUNC void
47
+ mlx_atomic_store_explicit(device mlx_atomic<T>* object, T val, int offset) {
48
+ atomic_store_explicit(&(object[offset].val), val, memory_order_relaxed);
49
+ }
50
+
51
+ template <typename T, enable_if_t<is_metal_atomic<T>, bool> = true>
52
+ METAL_FUNC void
53
+ mlx_atomic_fetch_and_explicit(device mlx_atomic<T>* object, T val, int offset) {
54
+ atomic_fetch_and_explicit(&(object[offset].val), val, memory_order_relaxed);
55
+ }
56
+
57
+ template <typename T, enable_if_t<is_metal_atomic<T>, bool> = true>
58
+ METAL_FUNC void
59
+ mlx_atomic_fetch_or_explicit(device mlx_atomic<T>* object, T val, int offset) {
60
+ atomic_fetch_or_explicit(&(object[offset].val), val, memory_order_relaxed);
61
+ }
62
+
63
+ template <typename T, enable_if_t<is_metal_atomic<T>, bool> = true>
64
+ METAL_FUNC void
65
+ mlx_atomic_fetch_min_explicit(device mlx_atomic<T>* object, T val, int offset) {
66
+ atomic_fetch_min_explicit(&(object[offset].val), val, memory_order_relaxed);
67
+ }
68
+
69
+ template <typename T, enable_if_t<is_metal_atomic<T>, bool> = true>
70
+ METAL_FUNC void
71
+ mlx_atomic_fetch_max_explicit(device mlx_atomic<T>* object, T val, int offset) {
72
+ atomic_fetch_max_explicit(&(object[offset].val), val, memory_order_relaxed);
73
+ }
74
+
75
+ template <typename T, enable_if_t<is_metal_atomic<T>, bool> = true>
76
+ METAL_FUNC void
77
+ mlx_atomic_fetch_add_explicit(device mlx_atomic<T>* object, T val, int offset) {
78
+ atomic_fetch_add_explicit(&(object[offset].val), val, memory_order_relaxed);
79
+ }
80
+
81
+ template <typename T, enable_if_t<is_metal_atomic<T>, bool> = true>
82
+ METAL_FUNC void
83
+ mlx_atomic_fetch_mul_explicit(device mlx_atomic<T>* object, T val, int offset) {
84
+ T expected = mlx_atomic_load_explicit(object, offset);
85
+ while (!mlx_atomic_compare_exchange_weak_explicit(
86
+ object, &expected, val * expected, offset)) {
87
+ }
88
+ }
89
+
90
+ template <typename T, enable_if_t<is_metal_atomic<T>, bool> = true>
91
+ METAL_FUNC bool mlx_atomic_compare_exchange_weak_explicit(
92
+ device mlx_atomic<T>* object,
93
+ thread T* expected,
94
+ T val,
95
+ int offset) {
96
+ return atomic_compare_exchange_weak_explicit(
97
+ &(object[offset].val),
98
+ expected,
99
+ val,
100
+ memory_order_relaxed,
101
+ memory_order_relaxed);
102
+ }
103
+
104
+ // Specialization for float since it does not atomic_fetch_min_explicit
105
+ template <>
106
+ METAL_FUNC void mlx_atomic_fetch_min_explicit<float>(
107
+ device mlx_atomic<float>* object,
108
+ float val,
109
+ int offset) {
110
+ float expected = mlx_atomic_load_explicit(object, offset);
111
+ while (val < expected) {
112
+ if (mlx_atomic_compare_exchange_weak_explicit(
113
+ object, &expected, val, offset)) {
114
+ return;
115
+ }
116
+ }
117
+ }
118
+
119
+ // Specialization for float since it does not atomic_fetch_max_explicit
120
+ template <>
121
+ METAL_FUNC void mlx_atomic_fetch_max_explicit<float>(
122
+ device mlx_atomic<float>* object,
123
+ float val,
124
+ int offset) {
125
+ float expected = mlx_atomic_load_explicit(object, offset);
126
+ while (val > expected) {
127
+ if (mlx_atomic_compare_exchange_weak_explicit(
128
+ object, &expected, val, offset)) {
129
+ return;
130
+ }
131
+ }
132
+ }
133
+
134
+ ///////////////////////////////////////////////////////////////////////////////
135
+ // Custom atomics
136
+ ///////////////////////////////////////////////////////////////////////////////
137
+
138
+ namespace {
139
+
140
+ template <typename T>
141
+ constexpr constant uint packing_size = sizeof(uint) / sizeof(T);
142
+
143
+ template <typename T>
144
+ union uint_or_packed {
145
+ T val[packing_size<T>];
146
+ uint bits;
147
+ };
148
+
149
+ template <typename T, typename Op>
150
+ struct mlx_atomic_update_helper {
151
+ uint operator()(uint_or_packed<T> init, T update, int elem_offset) {
152
+ Op op;
153
+ init.val[elem_offset] = op(update, init.val[elem_offset]);
154
+ return init.bits;
155
+ }
156
+ };
157
+
158
+ template <typename T, typename Op>
159
+ METAL_FUNC void mlx_atomic_update_and_store(
160
+ device mlx_atomic<T>* object,
161
+ T update,
162
+ int offset) {
163
+ int pack_offset = offset / packing_size<T>;
164
+ int elem_offset = offset % packing_size<T>;
165
+
166
+ mlx_atomic_update_helper<T, Op> helper;
167
+ uint_or_packed<T> expected;
168
+ expected.bits =
169
+ atomic_load_explicit(&(object[pack_offset].val), memory_order_relaxed);
170
+
171
+ while (Op::condition(update, expected.val[elem_offset]) &&
172
+ !mlx_atomic_compare_exchange_weak_explicit(
173
+ object,
174
+ &(expected.bits),
175
+ helper(expected, update, elem_offset),
176
+ pack_offset)) {
177
+ }
178
+ }
179
+
180
+ template <typename T>
181
+ struct __None {
182
+ static bool condition(T a, T b) {
183
+ #pragma unused(a)
184
+ #pragma unused(b)
185
+ return true;
186
+ }
187
+
188
+ T operator()(T a, T b) {
189
+ #pragma unused(b)
190
+ return a;
191
+ }
192
+ };
193
+
194
+ template <typename T>
195
+ struct __Add {
196
+ static bool condition(T a, T b) {
197
+ #pragma unused(a)
198
+ #pragma unused(b)
199
+ return true;
200
+ }
201
+
202
+ T operator()(T a, T b) {
203
+ return a + b;
204
+ }
205
+ };
206
+
207
+ template <typename T>
208
+ struct __Mul {
209
+ static bool condition(T a, T b) {
210
+ #pragma unused(a)
211
+ return b != 0;
212
+ }
213
+
214
+ T operator()(T a, T b) {
215
+ return a * b;
216
+ }
217
+ };
218
+
219
+ template <typename T>
220
+ struct __Max {
221
+ static bool condition(T a, T b) {
222
+ return a > b;
223
+ }
224
+
225
+ T operator()(T a, T b) {
226
+ return max(a, b);
227
+ }
228
+ };
229
+
230
+ template <typename T>
231
+ struct __Min {
232
+ static bool condition(T a, T b) {
233
+ return a < b;
234
+ }
235
+
236
+ T operator()(T a, T b) {
237
+ return min(a, b);
238
+ }
239
+ };
240
+
241
+ } // namespace
242
+
243
+ template <typename T, enable_if_t<!is_metal_atomic<T>, bool> = true>
244
+ METAL_FUNC T
245
+ mlx_atomic_load_explicit(device mlx_atomic<T>* object, int offset) {
246
+ int pack_offset = offset / sizeof(T);
247
+ int elem_offset = offset % sizeof(T);
248
+ uint_or_packed<T> packed_val;
249
+ packed_val.bits =
250
+ atomic_load_explicit(&(object[pack_offset].val), memory_order_relaxed);
251
+ return packed_val.val[elem_offset];
252
+ }
253
+
254
+ template <typename T, enable_if_t<!is_metal_atomic<T>, bool> = true>
255
+ METAL_FUNC void
256
+ mlx_atomic_store_explicit(device mlx_atomic<T>* object, T val, int offset) {
257
+ mlx_atomic_update_and_store<T, __None<T>>(object, val, offset);
258
+ }
259
+
260
+ template <typename T, enable_if_t<!is_metal_atomic<T>, bool> = true>
261
+ METAL_FUNC void
262
+ mlx_atomic_fetch_and_explicit(device mlx_atomic<T>* object, T val, int offset) {
263
+ int pack_offset = offset / packing_size<T>;
264
+ int elem_offset = offset % packing_size<T>;
265
+ uint_or_packed<T> identity;
266
+ identity.bits = __UINT32_MAX__;
267
+ identity.val[elem_offset] = val;
268
+
269
+ atomic_fetch_and_explicit(
270
+ &(object[pack_offset].val), identity.bits, memory_order_relaxed);
271
+ }
272
+
273
+ template <typename T, enable_if_t<!is_metal_atomic<T>, bool> = true>
274
+ METAL_FUNC void
275
+ mlx_atomic_fetch_or_explicit(device mlx_atomic<T>* object, T val, int offset) {
276
+ int pack_offset = offset / packing_size<T>;
277
+ int elem_offset = offset % packing_size<T>;
278
+ uint_or_packed<T> identity;
279
+ identity.bits = 0;
280
+ identity.val[elem_offset] = val;
281
+
282
+ atomic_fetch_or_explicit(
283
+ &(object[pack_offset].val), identity.bits, memory_order_relaxed);
284
+ }
285
+
286
+ template <typename T, enable_if_t<!is_metal_atomic<T>, bool> = true>
287
+ METAL_FUNC void
288
+ mlx_atomic_fetch_min_explicit(device mlx_atomic<T>* object, T val, int offset) {
289
+ mlx_atomic_update_and_store<T, __Min<T>>(object, val, offset);
290
+ }
291
+
292
+ template <typename T, enable_if_t<!is_metal_atomic<T>, bool> = true>
293
+ METAL_FUNC void
294
+ mlx_atomic_fetch_max_explicit(device mlx_atomic<T>* object, T val, int offset) {
295
+ mlx_atomic_update_and_store<T, __Max<T>>(object, val, offset);
296
+ }
297
+
298
+ template <typename T, enable_if_t<!is_metal_atomic<T>, bool> = true>
299
+ METAL_FUNC void
300
+ mlx_atomic_fetch_add_explicit(device mlx_atomic<T>* object, T val, int offset) {
301
+ mlx_atomic_update_and_store<T, __Add<T>>(object, val, offset);
302
+ }
303
+
304
+ template <typename T, enable_if_t<!is_metal_atomic<T>, bool> = true>
305
+ METAL_FUNC void
306
+ mlx_atomic_fetch_mul_explicit(device mlx_atomic<T>* object, T val, int offset) {
307
+ mlx_atomic_update_and_store<T, __Mul<T>>(object, val, offset);
308
+ }
309
+
310
+ template <typename T, enable_if_t<!is_metal_atomic<T>, bool> = true>
311
+ METAL_FUNC bool mlx_atomic_compare_exchange_weak_explicit(
312
+ device mlx_atomic<T>* object,
313
+ thread uint* expected,
314
+ uint val,
315
+ int offset) {
316
+ return atomic_compare_exchange_weak_explicit(
317
+ &(object[offset].val),
318
+ expected,
319
+ val,
320
+ memory_order_relaxed,
321
+ memory_order_relaxed);
322
+ }
lib/python3.11/site-packages/mlx/include/mlx/backend/metal/kernels/bf16.h ADDED
@@ -0,0 +1,317 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Copyright © 2023 Apple Inc.
2
+
3
+ #pragma once
4
+
5
+ #include <metal_stdlib>
6
+
7
+ using namespace metal;
8
+
9
+ #if defined(__HAVE_BFLOAT__)
10
+
11
+ typedef bfloat bfloat16_t;
12
+
13
+ #else
14
+
15
+ /////////////////////////////////////////////////////////////////////////////
16
+ // Helpers
17
+ /////////////////////////////////////////////////////////////////////////////
18
+
19
+ constexpr METAL_FUNC uint16_t float_to_bfloat_bits(float x) {
20
+ // Check for nan
21
+ if ((as_type<uint32_t>(x) & ~_fp_encoding_traits<float>::sign_mask) >
22
+ _fp_encoding_traits<float>::inf_mask) {
23
+ return uint16_t(as_type<uint32_t>(0x7FC0));
24
+ }
25
+ // Take bits
26
+ uint32_t float_bits = as_type<uint32_t>(x);
27
+
28
+ // Round to nearest even
29
+ float_bits += ((float_bits >> 16) & 1) + as_type<uint32_t>(0x7FFF);
30
+
31
+ // Take upper 16 bits
32
+ return float_bits >> 16;
33
+ }
34
+
35
+ constexpr METAL_FUNC float bfloat_bits_to_float(uint16_t x) {
36
+ // Upper 16 bits are the data and lower 16 bits are 0s
37
+ return as_type<float>((uint32_t)x << 16);
38
+ }
39
+
40
+ struct _MLX_BFloat16;
41
+
42
+ template <typename T>
43
+ static constexpr constant bool can_convert_to_bfloat =
44
+ !is_same_v<T, _MLX_BFloat16> && is_convertible_v<T, float>;
45
+
46
+ template <typename T>
47
+ static constexpr constant bool can_convert_from_bfloat =
48
+ !is_same_v<T, _MLX_BFloat16> && is_convertible_v<float, T>;
49
+
50
+ /////////////////////////////////////////////////////////////////////////////
51
+ // Bfloat struct
52
+ /////////////////////////////////////////////////////////////////////////////
53
+
54
+ struct _MLX_BFloat16 {
55
+ /////////////////////////////////////////////////////////////////////////////
56
+ // Constructors
57
+ uint16_t bits_;
58
+ _MLX_BFloat16() thread = default;
59
+ _MLX_BFloat16() threadgroup = default;
60
+ _MLX_BFloat16() device = default;
61
+ _MLX_BFloat16() constant = default;
62
+
63
+ struct bits_to_bfloat_struct {};
64
+ static constexpr METAL_FUNC bits_to_bfloat_struct bits_to_bfloat() {
65
+ return bits_to_bfloat_struct();
66
+ }
67
+ constexpr METAL_FUNC _MLX_BFloat16(uint16_t bits, bits_to_bfloat_struct)
68
+ : bits_(bits) {}
69
+
70
+ /////////////////////////////////////////////////////////////////////////////
71
+ // Conversions to bfloat
72
+
73
+ template <
74
+ typename T,
75
+ typename = typename enable_if<can_convert_to_bfloat<T>>::type>
76
+ constexpr METAL_FUNC _MLX_BFloat16(T x) thread
77
+ : bits_(float_to_bfloat_bits(static_cast<float>(x))) {}
78
+
79
+ template <
80
+ typename T,
81
+ typename = typename enable_if<can_convert_to_bfloat<T>>::type>
82
+ constexpr METAL_FUNC _MLX_BFloat16(T x) threadgroup
83
+ : bits_(float_to_bfloat_bits(static_cast<float>(x))) {}
84
+
85
+ template <
86
+ typename T,
87
+ typename = typename enable_if<can_convert_to_bfloat<T>>::type>
88
+ constexpr METAL_FUNC _MLX_BFloat16(T x) device
89
+ : bits_(float_to_bfloat_bits(static_cast<float>(x))) {}
90
+
91
+ template <
92
+ typename T,
93
+ typename = typename enable_if<can_convert_to_bfloat<T>>::type>
94
+ constexpr METAL_FUNC _MLX_BFloat16(T x) constant
95
+ : bits_(float_to_bfloat_bits(static_cast<float>(x))) {}
96
+
97
+ /////////////////////////////////////////////////////////////////////////////
98
+ // Conversions from bfloat
99
+
100
+ template <
101
+ typename T,
102
+ typename = typename enable_if<can_convert_from_bfloat<T>>::type>
103
+ constexpr METAL_FUNC operator T() const thread {
104
+ return static_cast<T>(bfloat_bits_to_float(bits_));
105
+ }
106
+
107
+ template <
108
+ typename T,
109
+ typename = typename enable_if<can_convert_from_bfloat<T>>::type>
110
+ constexpr METAL_FUNC operator T() const threadgroup {
111
+ return static_cast<T>(bfloat_bits_to_float(bits_));
112
+ }
113
+
114
+ template <
115
+ typename T,
116
+ typename = typename enable_if<can_convert_from_bfloat<T>>::type>
117
+ constexpr METAL_FUNC operator T() const device {
118
+ return static_cast<T>(bfloat_bits_to_float(bits_));
119
+ }
120
+
121
+ template <
122
+ typename T,
123
+ typename = typename enable_if<can_convert_from_bfloat<T>>::type>
124
+ constexpr METAL_FUNC operator T() const constant {
125
+ return static_cast<T>(bfloat_bits_to_float(bits_));
126
+ }
127
+ };
128
+
129
+ /////////////////////////////////////////////////////////////////////////////
130
+ // Bfloat operators
131
+ /////////////////////////////////////////////////////////////////////////////
132
+
133
+ /////////////////////////////////////////////////////////////////////////////
134
+ // Unary ops
135
+ constexpr METAL_FUNC _MLX_BFloat16 operator-(_MLX_BFloat16 x) {
136
+ return -static_cast<float>(x);
137
+ }
138
+
139
+ /////////////////////////////////////////////////////////////////////////////
140
+ // Binary operators
141
+ #define bfloat_binop_base(__op__, __operator__, otype, atype, btype, ctype) \
142
+ constexpr METAL_FUNC otype __operator__(atype lhs, btype rhs) { \
143
+ return static_cast<ctype>(lhs) __op__ static_cast<ctype>(rhs); \
144
+ }
145
+
146
+ #define bfloat_binop_helper(__op__, __operator__, otype, itype, ctype) \
147
+ constexpr METAL_FUNC otype __operator__(_MLX_BFloat16 lhs, itype rhs) { \
148
+ return static_cast<ctype>(lhs) __op__ static_cast<ctype>(rhs); \
149
+ } \
150
+ constexpr METAL_FUNC otype __operator__(itype lhs, _MLX_BFloat16 rhs) { \
151
+ return static_cast<ctype>(lhs) __op__ static_cast<ctype>(rhs); \
152
+ }
153
+
154
+ /////////////////////////////////////////////////////////////////////////////
155
+ // Arithmetic Operators
156
+ #define bfloat_binop(_op_, _operator_) \
157
+ bfloat_binop_base( \
158
+ _op_, _operator_, _MLX_BFloat16, _MLX_BFloat16, _MLX_BFloat16, float); \
159
+ bfloat_binop_helper(_op_, _operator_, float, float, float); \
160
+ bfloat_binop_helper(_op_, _operator_, float, half, float); \
161
+ bfloat_binop_helper(_op_, _operator_, _MLX_BFloat16, int32_t, float); \
162
+ bfloat_binop_helper(_op_, _operator_, _MLX_BFloat16, uint32_t, float); \
163
+ bfloat_binop_helper(_op_, _operator_, _MLX_BFloat16, int64_t, float); \
164
+ bfloat_binop_helper(_op_, _operator_, _MLX_BFloat16, uint64_t, float);
165
+
166
+ bfloat_binop(+, operator+);
167
+ bfloat_binop(-, operator-);
168
+ bfloat_binop(*, operator*);
169
+ bfloat_binop(/, operator/);
170
+
171
+ /////////////////////////////////////////////////////////////////////////////
172
+ // Comparison ops
173
+ #define bfloat_compop(__op__, __operator__) \
174
+ bfloat_binop_base( \
175
+ __op__, __operator__, bool, _MLX_BFloat16, _MLX_BFloat16, float); \
176
+ bfloat_binop_helper(__op__, __operator__, bool, float, float); \
177
+ bfloat_binop_helper(__op__, __operator__, bool, half, float); \
178
+ bfloat_binop_helper(__op__, __operator__, bool, int32_t, float); \
179
+ bfloat_binop_helper(__op__, __operator__, bool, uint32_t, float); \
180
+ bfloat_binop_helper(__op__, __operator__, bool, int64_t, float); \
181
+ bfloat_binop_helper(__op__, __operator__, bool, uint64_t, float);
182
+
183
+ bfloat_compop(>, operator>);
184
+ bfloat_compop(<, operator<);
185
+ bfloat_compop(>=, operator>=);
186
+ bfloat_compop(<=, operator<=);
187
+ bfloat_compop(==, operator==);
188
+ bfloat_compop(!=, operator!=);
189
+
190
+ #undef bfloat_compop
191
+ #undef bfloat_binop_base
192
+ #undef bfloat_binop_helper
193
+ #undef bfloat_binop
194
+
195
+ /////////////////////////////////////////////////////////////////////////////
196
+ // Inplace Operators
197
+ #define bfloat_inplace_op_helper(__op__, __operator__, itype, addr_space) \
198
+ constexpr METAL_FUNC addr_space _MLX_BFloat16& __operator__( \
199
+ addr_space _MLX_BFloat16& lhs, itype rhs) { \
200
+ lhs = static_cast<float>(lhs) __op__ static_cast<float>(rhs); \
201
+ return lhs; \
202
+ } \
203
+ constexpr METAL_FUNC addr_space itype& __operator__( \
204
+ addr_space itype& lhs, _MLX_BFloat16 rhs) { \
205
+ lhs = static_cast<float>(lhs) __op__ static_cast<float>(rhs); \
206
+ return lhs; \
207
+ }
208
+
209
+ #define bfloat_inplace_op_addr_space_helper(__op__, __operator__, itype) \
210
+ bfloat_inplace_op_helper(__op__, __operator__, itype, device); \
211
+ bfloat_inplace_op_helper(__op__, __operator__, itype, thread); \
212
+ bfloat_inplace_op_helper(__op__, __operator__, itype, threadgroup);
213
+
214
+ #define bfloat_inplace_op(itype) \
215
+ bfloat_inplace_op_addr_space_helper(+, operator+=, itype); \
216
+ bfloat_inplace_op_addr_space_helper(-, operator-=, itype); \
217
+ bfloat_inplace_op_addr_space_helper(*, operator*=, itype); \
218
+ bfloat_inplace_op_addr_space_helper(/, operator/=, itype);
219
+
220
+ bfloat_inplace_op(float);
221
+ bfloat_inplace_op(half);
222
+ bfloat_inplace_op(int16_t);
223
+ bfloat_inplace_op(int32_t);
224
+ bfloat_inplace_op(int64_t);
225
+ bfloat_inplace_op(uint16_t);
226
+ bfloat_inplace_op(uint32_t);
227
+ bfloat_inplace_op(uint64_t);
228
+
229
+ #undef bfloat_inplace_op_helper
230
+ #undef bfloat_inplace_op_addr_space_helper
231
+ #undef bfloat_inplace_op
232
+
233
+ #define bfloat_inplace_op_helper(__op__, __operator__, addr_space) \
234
+ constexpr METAL_FUNC addr_space _MLX_BFloat16& __operator__( \
235
+ addr_space _MLX_BFloat16& lhs, _MLX_BFloat16 rhs) { \
236
+ lhs = static_cast<float>(lhs) __op__ static_cast<float>(rhs); \
237
+ return lhs; \
238
+ }
239
+
240
+ #define bfloat_inplace_op_addr_space_helper(__op__, __operator__) \
241
+ bfloat_inplace_op_helper(__op__, __operator__, device); \
242
+ bfloat_inplace_op_helper(__op__, __operator__, thread); \
243
+ bfloat_inplace_op_helper(__op__, __operator__, threadgroup);
244
+
245
+ bfloat_inplace_op_addr_space_helper(+, operator+=);
246
+ bfloat_inplace_op_addr_space_helper(-, operator-=);
247
+ bfloat_inplace_op_addr_space_helper(*, operator*=);
248
+ bfloat_inplace_op_addr_space_helper(/, operator/=);
249
+
250
+ #undef bfloat_inplace_op_helper
251
+ #undef bfloat_inplace_op_addr_space_helper
252
+
253
+ /////////////////////////////////////////////////////////////////////////////
254
+ // Bfloat typedef
255
+ /////////////////////////////////////////////////////////////////////////////
256
+
257
+ typedef struct _MLX_BFloat16 bfloat16_t;
258
+
259
+ /////////////////////////////////////////////////////////////////////////////
260
+ // Bfloat numeric limits
261
+ /////////////////////////////////////////////////////////////////////////////
262
+
263
+ #pragma METAL internals : enable
264
+
265
+ namespace metal {
266
+
267
+ template <>
268
+ struct _numeric_limits_impl<bfloat16_t> : _fp_numeric_limits_impl_base {
269
+ static constexpr constant int digits = 8;
270
+ static constexpr constant int digits10 = 2;
271
+ static constexpr constant int max_digits10 = 4;
272
+ static constexpr constant int radix = 2;
273
+ static constexpr constant int min_exponent = -125;
274
+ static constexpr constant int min_exponent10 = -37;
275
+ static constexpr constant int max_exponent = 128;
276
+ static constexpr constant int max_exponent10 = 38;
277
+
278
+ static constexpr bfloat16_t min() {
279
+ return _MLX_BFloat16(0x0080, _MLX_BFloat16::bits_to_bfloat());
280
+ }
281
+ static constexpr bfloat16_t lowest() {
282
+ return _MLX_BFloat16(0xFF7F, _MLX_BFloat16::bits_to_bfloat());
283
+ }
284
+ static constexpr bfloat16_t max() {
285
+ return _MLX_BFloat16(0x7F7F, _MLX_BFloat16::bits_to_bfloat());
286
+ }
287
+ static constexpr bfloat16_t epsilon() {
288
+ return _MLX_BFloat16(0x3C00, _MLX_BFloat16::bits_to_bfloat());
289
+ }
290
+ static constexpr bfloat16_t round_error() {
291
+ return _MLX_BFloat16(0x3F00, _MLX_BFloat16::bits_to_bfloat());
292
+ }
293
+ static constexpr bfloat16_t infinity() {
294
+ return _MLX_BFloat16(0x7F80, _MLX_BFloat16::bits_to_bfloat());
295
+ }
296
+ static constexpr bfloat16_t quiet_NaN() {
297
+ return _MLX_BFloat16(0x7FC0, _MLX_BFloat16::bits_to_bfloat());
298
+ }
299
+ static constexpr bfloat16_t signaling_NaN() {
300
+ return _MLX_BFloat16(0x7F80, _MLX_BFloat16::bits_to_bfloat());
301
+ }
302
+ static constexpr bfloat16_t denorm_min() {
303
+ return _MLX_BFloat16(0x0001, _MLX_BFloat16::bits_to_bfloat());
304
+ }
305
+ };
306
+
307
+ METAL_FUNC bool isnan(_MLX_BFloat16 x) {
308
+ return x != x;
309
+ }
310
+
311
+ } // namespace metal
312
+
313
+ #pragma METAL internals : disable
314
+
315
+ #endif // defined(__HAVE_BFLOAT__)
316
+
317
+ #include "mlx/backend/metal/kernels/bf16_math.h"
lib/python3.11/site-packages/mlx/include/mlx/backend/metal/kernels/bf16_math.h ADDED
@@ -0,0 +1,394 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Copyright © 2023 Apple Inc.
2
+
3
+ #pragma once
4
+
5
+ #include "mlx/backend/metal/kernels/bf16.h"
6
+
7
+ ///////////////////////////////////////////////////////////////////////////////
8
+ // Metal math for bfloat16
9
+ ///////////////////////////////////////////////////////////////////////////////
10
+
11
+ /*
12
+
13
+ Following the Metal Shading Language Specification (Metal 3.1)
14
+
15
+ "bfloat is an extended itypeing point type that only allows implicit conversion
16
+ to a type of greater itypeing point rank. While bfloat can be implicitly
17
+ converted to itype, it cannot be implicitly converted to half, and neither
18
+ itype nor half can be implicitly converted to bfloat."
19
+
20
+ Further, as far as I can tell, the stdlib math/simd functions are not defined
21
+ for bfloat and calling with an argument of type bfloat will result in that
22
+ argument getting implicitly converted to itype which then returns an output
23
+ that is (likely) a itype which cannot be implicitly converted into a bfloat
24
+
25
+ This leads to situations where
26
+ bfloat a = 5.0bf;
27
+ bfloat b = metal::abs(a); // this will throw an error since abs return itype
28
+ bfloat c = static_cast<bfloat>(metal::abs(a)); // this is fine
29
+
30
+ For the moment, I will be adding overloaded instantiations of the math
31
+ functions to accordingly automatically handle the casting
32
+
33
+ */
34
+
35
+ #define instantiate_metal_math_funcs(itype, otype, ctype, mfast) \
36
+ \
37
+ METAL_FUNC otype abs(itype x) { \
38
+ return static_cast<otype>(__metal_fabs(static_cast<ctype>(x), mfast)); \
39
+ } \
40
+ METAL_FUNC otype acos(itype x) { \
41
+ return static_cast<otype>(__metal_acos(static_cast<ctype>(x), mfast)); \
42
+ } \
43
+ METAL_FUNC otype acosh(itype x) { \
44
+ return static_cast<otype>(__metal_acosh(static_cast<ctype>(x), mfast)); \
45
+ } \
46
+ METAL_FUNC otype asin(itype x) { \
47
+ return static_cast<otype>(__metal_asin(static_cast<ctype>(x), mfast)); \
48
+ } \
49
+ METAL_FUNC otype asinh(itype x) { \
50
+ return static_cast<otype>(__metal_asinh(static_cast<ctype>(x), mfast)); \
51
+ } \
52
+ METAL_FUNC otype atan(itype y_over_x) { \
53
+ return static_cast<otype>( \
54
+ __metal_atan(static_cast<ctype>(y_over_x), mfast)); \
55
+ } \
56
+ METAL_FUNC otype atan2(itype y, itype x) { \
57
+ return static_cast<otype>( \
58
+ __metal_atan2(static_cast<ctype>(y), static_cast<ctype>(x), mfast)); \
59
+ } \
60
+ METAL_FUNC otype atanh(itype x) { \
61
+ return static_cast<otype>(__metal_atanh(static_cast<ctype>(x), mfast)); \
62
+ } \
63
+ METAL_FUNC otype ceil(itype x) { \
64
+ return static_cast<otype>(__metal_ceil(static_cast<ctype>(x), mfast)); \
65
+ } \
66
+ METAL_FUNC otype cos(itype x) { \
67
+ return static_cast<otype>(__metal_cos(static_cast<ctype>(x), mfast)); \
68
+ } \
69
+ METAL_FUNC otype cosh(itype x) { \
70
+ return static_cast<otype>(__metal_cosh(static_cast<ctype>(x), mfast)); \
71
+ } \
72
+ METAL_FUNC otype cospi(itype x) { \
73
+ return static_cast<otype>(__metal_cospi(static_cast<ctype>(x), mfast)); \
74
+ } \
75
+ METAL_FUNC otype divide(itype x, itype y) { \
76
+ return static_cast<otype>( \
77
+ __metal_divide(static_cast<ctype>(x), static_cast<ctype>(y), mfast)); \
78
+ } \
79
+ METAL_FUNC otype exp(itype x) { \
80
+ return static_cast<otype>(__metal_exp(static_cast<ctype>(x), mfast)); \
81
+ } \
82
+ METAL_FUNC otype exp10(itype x) { \
83
+ return static_cast<otype>(__metal_exp10(static_cast<ctype>(x), mfast)); \
84
+ } \
85
+ METAL_FUNC otype exp2(itype x) { \
86
+ return static_cast<otype>(__metal_exp2(static_cast<ctype>(x), mfast)); \
87
+ } \
88
+ METAL_FUNC otype fabs(itype x) { \
89
+ return static_cast<otype>(__metal_fabs(static_cast<ctype>(x), mfast)); \
90
+ } \
91
+ METAL_FUNC otype fdim(itype x, itype y) { \
92
+ ctype t = static_cast<ctype>(x - y); \
93
+ return static_cast<otype>(select(t, ctype(0), t < ctype(0) || x == y)); \
94
+ } \
95
+ METAL_FUNC otype floor(itype x) { \
96
+ return static_cast<otype>(__metal_floor(static_cast<ctype>(x), mfast)); \
97
+ } \
98
+ METAL_FUNC otype fma(itype x, itype y, itype z) { \
99
+ return static_cast<otype>(__metal_fma( \
100
+ static_cast<ctype>(x), static_cast<ctype>(y), static_cast<ctype>(z))); \
101
+ } \
102
+ METAL_FUNC otype fmax(itype x, itype y) { \
103
+ return static_cast<otype>( \
104
+ __metal_fmax(static_cast<ctype>(x), static_cast<ctype>(y), mfast)); \
105
+ } \
106
+ METAL_FUNC otype fmax3(itype x, itype y, itype z) { \
107
+ return static_cast<otype>(__metal_fmax3( \
108
+ static_cast<ctype>(x), \
109
+ static_cast<ctype>(y), \
110
+ static_cast<ctype>(z), \
111
+ mfast)); \
112
+ } \
113
+ METAL_FUNC otype fmedian3(itype x, itype y, itype z) { \
114
+ return static_cast<otype>(__metal_fmedian3( \
115
+ static_cast<ctype>(x), \
116
+ static_cast<ctype>(y), \
117
+ static_cast<ctype>(z), \
118
+ mfast)); \
119
+ } \
120
+ METAL_FUNC otype fmin(itype x, itype y) { \
121
+ return static_cast<otype>( \
122
+ __metal_fmin(static_cast<ctype>(x), static_cast<ctype>(y), mfast)); \
123
+ } \
124
+ METAL_FUNC otype fmin3(itype x, itype y, itype z) { \
125
+ return static_cast<otype>(__metal_fmin3( \
126
+ static_cast<ctype>(x), \
127
+ static_cast<ctype>(y), \
128
+ static_cast<ctype>(z), \
129
+ mfast)); \
130
+ } \
131
+ METAL_FUNC otype fmod(itype x, itype y) { \
132
+ return static_cast<otype>( \
133
+ __metal_fmod(static_cast<ctype>(x), static_cast<ctype>(y), mfast)); \
134
+ } \
135
+ METAL_FUNC otype fract(itype x) { \
136
+ return static_cast<otype>(__metal_fract(static_cast<ctype>(x), mfast)); \
137
+ } \
138
+ METAL_FUNC otype frexp(itype x, thread int& exp) { \
139
+ return static_cast<otype>(__metal_frexp(static_cast<ctype>(x), &exp)); \
140
+ } \
141
+ METAL_FUNC otype ldexp(itype x, int k) { \
142
+ return static_cast<otype>(__metal_ldexp(static_cast<ctype>(x), k, mfast)); \
143
+ } \
144
+ METAL_FUNC otype log(itype x) { \
145
+ return static_cast<otype>(__metal_log(static_cast<ctype>(x), mfast)); \
146
+ } \
147
+ METAL_FUNC otype log10(itype x) { \
148
+ return static_cast<otype>(__metal_log10(static_cast<ctype>(x), mfast)); \
149
+ } \
150
+ METAL_FUNC otype log2(itype x) { \
151
+ return static_cast<otype>(__metal_log2(static_cast<ctype>(x), mfast)); \
152
+ } \
153
+ METAL_FUNC otype max(itype x, itype y) { \
154
+ return static_cast<otype>( \
155
+ __metal_fmax(static_cast<ctype>(x), static_cast<ctype>(y), mfast)); \
156
+ } \
157
+ METAL_FUNC otype max3(itype x, itype y, itype z) { \
158
+ return static_cast<otype>(__metal_fmax3( \
159
+ static_cast<ctype>(x), \
160
+ static_cast<ctype>(y), \
161
+ static_cast<ctype>(z), \
162
+ mfast)); \
163
+ } \
164
+ METAL_FUNC otype median3(itype x, itype y, itype z) { \
165
+ return static_cast<otype>(__metal_fmedian3( \
166
+ static_cast<ctype>(x), \
167
+ static_cast<ctype>(y), \
168
+ static_cast<ctype>(z), \
169
+ mfast)); \
170
+ } \
171
+ METAL_FUNC otype min(itype x, itype y) { \
172
+ return static_cast<otype>( \
173
+ __metal_fmin(static_cast<ctype>(x), static_cast<ctype>(y), mfast)); \
174
+ } \
175
+ METAL_FUNC otype min3(itype x, itype y, itype z) { \
176
+ return static_cast<otype>(__metal_fmin3( \
177
+ static_cast<ctype>(x), \
178
+ static_cast<ctype>(y), \
179
+ static_cast<ctype>(z), \
180
+ mfast)); \
181
+ } \
182
+ METAL_FUNC otype nextafter(itype x, itype y) { \
183
+ return static_cast<otype>( \
184
+ __metal_nextafter(static_cast<ctype>(x), static_cast<ctype>(y))); \
185
+ } \
186
+ METAL_FUNC otype pow(itype x, itype y) { \
187
+ return static_cast<otype>( \
188
+ __metal_pow(static_cast<ctype>(x), static_cast<ctype>(y), mfast)); \
189
+ } \
190
+ METAL_FUNC otype powr(itype x, itype y) { \
191
+ return static_cast<otype>( \
192
+ __metal_powr(static_cast<ctype>(x), static_cast<ctype>(y), mfast)); \
193
+ } \
194
+ METAL_FUNC otype rint(itype x) { \
195
+ return static_cast<otype>(__metal_rint(static_cast<ctype>(x), mfast)); \
196
+ } \
197
+ METAL_FUNC otype round(itype x) { \
198
+ return static_cast<otype>(__metal_round(static_cast<ctype>(x), mfast)); \
199
+ } \
200
+ METAL_FUNC otype rsqrt(itype x) { \
201
+ return static_cast<otype>(__metal_rsqrt(static_cast<ctype>(x), mfast)); \
202
+ } \
203
+ METAL_FUNC otype sin(itype x) { \
204
+ return static_cast<otype>(__metal_sin(static_cast<ctype>(x), mfast)); \
205
+ } \
206
+ METAL_FUNC otype sinh(itype x) { \
207
+ return static_cast<otype>(__metal_sinh(static_cast<ctype>(x), mfast)); \
208
+ } \
209
+ METAL_FUNC otype sinpi(itype x) { \
210
+ return static_cast<otype>(__metal_sinpi(static_cast<ctype>(x), mfast)); \
211
+ } \
212
+ METAL_FUNC otype sqrt(itype x) { \
213
+ return static_cast<otype>(__metal_sqrt(static_cast<ctype>(x), mfast)); \
214
+ } \
215
+ METAL_FUNC otype tan(itype x) { \
216
+ return static_cast<otype>(__metal_tan(static_cast<ctype>(x), mfast)); \
217
+ } \
218
+ METAL_FUNC otype tanh(itype x) { \
219
+ return static_cast<otype>(__metal_tanh(static_cast<ctype>(x), mfast)); \
220
+ } \
221
+ METAL_FUNC otype tanpi(itype x) { \
222
+ return static_cast<otype>(__metal_tanpi(static_cast<ctype>(x), mfast)); \
223
+ } \
224
+ METAL_FUNC otype trunc(itype x) { \
225
+ return static_cast<otype>(__metal_trunc(static_cast<ctype>(x), mfast)); \
226
+ }
227
+
228
+ namespace metal {
229
+
230
+ instantiate_metal_math_funcs(
231
+ bfloat16_t,
232
+ bfloat16_t,
233
+ float,
234
+ __METAL_MAYBE_FAST_MATH__);
235
+
236
+ namespace fast {
237
+
238
+ instantiate_metal_math_funcs(
239
+ bfloat16_t,
240
+ bfloat16_t,
241
+ float,
242
+ __METAL_FAST_MATH__);
243
+
244
+ } // namespace fast
245
+
246
+ namespace precise {
247
+
248
+ instantiate_metal_math_funcs(
249
+ bfloat16_t,
250
+ bfloat16_t,
251
+ float,
252
+ __METAL_PRECISE_MATH__);
253
+
254
+ } // namespace precise
255
+
256
+ } // namespace metal
257
+
258
+ ///////////////////////////////////////////////////////////////////////////////
259
+ // Metal simd for bfloat16
260
+ ///////////////////////////////////////////////////////////////////////////////
261
+
262
+ #define instantiate_metal_simd_comm_funcs( \
263
+ itype, otype, ctype, itype_to_ctype, ctype_to_otype) \
264
+ \
265
+ METAL_FUNC otype simd_broadcast(itype data, ushort broadcast_lane_id) { \
266
+ return ctype_to_otype( \
267
+ __metal_simd_broadcast(itype_to_ctype(data), broadcast_lane_id)); \
268
+ } \
269
+ \
270
+ METAL_FUNC otype simd_shuffle(itype data, ushort simd_lane_id) { \
271
+ return ctype_to_otype( \
272
+ __metal_simd_shuffle(itype_to_ctype(data), simd_lane_id)); \
273
+ } \
274
+ \
275
+ METAL_FUNC otype simd_shuffle_and_fill_down( \
276
+ itype data, itype filling_data, ushort delta, ushort modulo) { \
277
+ return ctype_to_otype(__metal_simd_shuffle_and_fill_down( \
278
+ itype_to_ctype(data), itype_to_ctype(filling_data), delta, modulo)); \
279
+ } \
280
+ \
281
+ METAL_FUNC otype simd_shuffle_and_fill_down( \
282
+ itype data, itype filling_data, ushort delta) { \
283
+ return ctype_to_otype(__metal_simd_shuffle_and_fill_down( \
284
+ itype_to_ctype(data), \
285
+ itype_to_ctype(filling_data), \
286
+ delta, \
287
+ __metal_get_simdgroup_size(ushort()))); \
288
+ } \
289
+ \
290
+ METAL_FUNC otype simd_shuffle_and_fill_up( \
291
+ itype data, itype filling_data, ushort delta, ushort modulo) { \
292
+ return ctype_to_otype(__metal_simd_shuffle_and_fill_up( \
293
+ itype_to_ctype(data), itype_to_ctype(filling_data), delta, modulo)); \
294
+ } \
295
+ \
296
+ METAL_FUNC otype simd_shuffle_and_fill_up( \
297
+ itype data, itype filling_data, ushort delta) { \
298
+ return ctype_to_otype(__metal_simd_shuffle_and_fill_up( \
299
+ itype_to_ctype(data), \
300
+ itype_to_ctype(filling_data), \
301
+ delta, \
302
+ __metal_get_simdgroup_size(ushort()))); \
303
+ } \
304
+ \
305
+ METAL_FUNC otype simd_shuffle_down(itype data, ushort delta) { \
306
+ return ctype_to_otype( \
307
+ __metal_simd_shuffle_down(itype_to_ctype(data), delta)); \
308
+ } \
309
+ \
310
+ METAL_FUNC otype simd_shuffle_rotate_down(itype data, ushort delta) { \
311
+ return ctype_to_otype( \
312
+ __metal_simd_shuffle_rotate_down(itype_to_ctype(data), delta)); \
313
+ } \
314
+ \
315
+ METAL_FUNC otype simd_shuffle_rotate_up(itype data, ushort delta) { \
316
+ return ctype_to_otype( \
317
+ __metal_simd_shuffle_rotate_up(itype_to_ctype(data), delta)); \
318
+ } \
319
+ \
320
+ METAL_FUNC otype simd_shuffle_up(itype data, ushort delta) { \
321
+ return ctype_to_otype( \
322
+ __metal_simd_shuffle_up(itype_to_ctype(data), delta)); \
323
+ } \
324
+ \
325
+ METAL_FUNC otype simd_shuffle_xor(itype data, ushort mask) { \
326
+ return ctype_to_otype( \
327
+ __metal_simd_shuffle_xor(itype_to_ctype(data), mask)); \
328
+ }
329
+
330
+ #define instantiate_metal_simd_reduction_funcs(itype, otype, ctype) \
331
+ \
332
+ METAL_FUNC otype simd_max(itype data) { \
333
+ return static_cast<otype>(__metal_simd_max(static_cast<ctype>(data))); \
334
+ } \
335
+ \
336
+ METAL_FUNC otype simd_min(itype data) { \
337
+ return static_cast<otype>(__metal_simd_min(static_cast<ctype>(data))); \
338
+ } \
339
+ \
340
+ METAL_FUNC otype simd_prefix_exclusive_product(itype data) { \
341
+ return static_cast<otype>( \
342
+ __metal_simd_prefix_exclusive_product(static_cast<ctype>(data))); \
343
+ } \
344
+ \
345
+ METAL_FUNC otype simd_prefix_exclusive_sum(itype data) { \
346
+ return static_cast<otype>( \
347
+ __metal_simd_prefix_exclusive_sum(static_cast<ctype>(data))); \
348
+ } \
349
+ \
350
+ METAL_FUNC otype simd_prefix_inclusive_product(itype data) { \
351
+ return static_cast<otype>( \
352
+ __metal_simd_prefix_inclusive_product(static_cast<ctype>(data))); \
353
+ } \
354
+ \
355
+ METAL_FUNC otype simd_prefix_inclusive_sum(itype data) { \
356
+ return static_cast<otype>( \
357
+ __metal_simd_prefix_inclusive_sum(static_cast<ctype>(data))); \
358
+ } \
359
+ \
360
+ METAL_FUNC otype simd_product(itype data) { \
361
+ return static_cast<otype>(__metal_simd_product(static_cast<ctype>(data))); \
362
+ } \
363
+ \
364
+ METAL_FUNC otype simd_sum(itype data) { \
365
+ return static_cast<otype>(__metal_simd_sum(static_cast<ctype>(data))); \
366
+ } \
367
+ \
368
+ METAL_FUNC otype simd_xor(itype data) { \
369
+ return static_cast<otype>(__metal_simd_xor(static_cast<ctype>(data))); \
370
+ }
371
+
372
+ #if defined(__HAVE_BFLOAT__)
373
+
374
+ #define bfloat16_to_uint16(x) as_type<uint16_t>(x)
375
+ #define uint16_to_bfloat16(x) as_type<bfloat16_t>(x)
376
+
377
+ #else
378
+
379
+ #define bfloat16_to_uint16(x) x.bits_
380
+ #define uint16_to_bfloat16(x) _MLX_BFloat16(x, _MLX_BFloat16::bits_to_bfloat())
381
+
382
+ #endif
383
+
384
+ namespace metal {
385
+
386
+ instantiate_metal_simd_comm_funcs(
387
+ bfloat16_t,
388
+ bfloat16_t,
389
+ uint16_t,
390
+ bfloat16_to_uint16,
391
+ uint16_to_bfloat16);
392
+ instantiate_metal_simd_reduction_funcs(bfloat16_t, bfloat16_t, float);
393
+
394
+ } // namespace metal
lib/python3.11/site-packages/mlx/include/mlx/backend/metal/kernels/complex.h ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Copyright © 2023 Apple Inc.
2
+
3
+ #pragma once
4
+
5
+ #include <metal_stdlib>
6
+
7
+ using namespace metal;
8
+
9
+ struct complex64_t;
10
+
11
+ template <typename T>
12
+ static constexpr constant bool can_convert_to_complex64 =
13
+ !is_same_v<T, complex64_t> && is_convertible_v<T, float>;
14
+
15
+ template <typename T>
16
+ static constexpr constant bool can_convert_from_complex64 =
17
+ !is_same_v<T, complex64_t> &&
18
+ (is_convertible_v<float, T> || is_convertible_v<bfloat16_t, T>);
19
+
20
+ struct complex64_t {
21
+ float real;
22
+ float imag;
23
+
24
+ // Constructors
25
+ constexpr complex64_t(float real, float imag) : real(real), imag(imag){};
26
+
27
+ // Conversions to complex64_t
28
+ template <
29
+ typename T,
30
+ typename = typename enable_if<can_convert_to_complex64<T>>::type>
31
+ constexpr complex64_t(T x) thread : real(x), imag(0) {}
32
+
33
+ template <
34
+ typename T,
35
+ typename = typename enable_if<can_convert_to_complex64<T>>::type>
36
+ constexpr complex64_t(T x) threadgroup : real(x), imag(0) {}
37
+
38
+ template <
39
+ typename T,
40
+ typename = typename enable_if<can_convert_to_complex64<T>>::type>
41
+ constexpr complex64_t(T x) device : real(x), imag(0) {}
42
+
43
+ template <
44
+ typename T,
45
+ typename = typename enable_if<can_convert_to_complex64<T>>::type>
46
+ constexpr complex64_t(T x) constant : real(x), imag(0) {}
47
+
48
+ // Conversions from complex64_t
49
+ template <
50
+ typename T,
51
+ typename = typename enable_if<can_convert_from_complex64<T>>::type>
52
+ constexpr operator T() const thread {
53
+ return static_cast<T>(real);
54
+ }
55
+
56
+ template <
57
+ typename T,
58
+ typename = typename enable_if<can_convert_from_complex64<T>>::type>
59
+ constexpr operator T() const threadgroup {
60
+ return static_cast<T>(real);
61
+ }
62
+
63
+ template <
64
+ typename T,
65
+ typename = typename enable_if<can_convert_from_complex64<T>>::type>
66
+ constexpr operator T() const device {
67
+ return static_cast<T>(real);
68
+ }
69
+
70
+ template <
71
+ typename T,
72
+ typename = typename enable_if<can_convert_from_complex64<T>>::type>
73
+ constexpr operator T() const constant {
74
+ return static_cast<T>(real);
75
+ }
76
+ };
77
+
78
+ constexpr complex64_t operator-(complex64_t x) {
79
+ return {-x.real, -x.imag};
80
+ }
81
+
82
+ constexpr bool operator>=(complex64_t a, complex64_t b) {
83
+ return (a.real > b.real) || (a.real == b.real && a.imag >= b.imag);
84
+ }
85
+
86
+ constexpr bool operator>(complex64_t a, complex64_t b) {
87
+ return (a.real > b.real) || (a.real == b.real && a.imag > b.imag);
88
+ }
89
+
90
+ constexpr bool operator<=(complex64_t a, complex64_t b) {
91
+ return operator>=(b, a);
92
+ }
93
+
94
+ constexpr bool operator<(complex64_t a, complex64_t b) {
95
+ return operator>(b, a);
96
+ }
97
+
98
+ constexpr bool operator==(complex64_t a, complex64_t b) {
99
+ return a.real == b.real && a.imag == b.imag;
100
+ }
101
+
102
+ constexpr complex64_t operator+(complex64_t a, complex64_t b) {
103
+ return {a.real + b.real, a.imag + b.imag};
104
+ }
105
+
106
+ constexpr complex64_t operator-(complex64_t a, complex64_t b) {
107
+ return {a.real - b.real, a.imag - b.imag};
108
+ }
109
+
110
+ constexpr complex64_t operator*(complex64_t a, complex64_t b) {
111
+ return {a.real * b.real - a.imag * b.imag, a.real * b.imag + a.imag * b.real};
112
+ }
113
+
114
+ constexpr complex64_t operator/(complex64_t a, complex64_t b) {
115
+ auto denom = b.real * b.real + b.imag * b.imag;
116
+ auto x = a.real * b.real + a.imag * b.imag;
117
+ auto y = a.imag * b.real - a.real * b.imag;
118
+ return {x / denom, y / denom};
119
+ }
120
+
121
+ constexpr complex64_t operator%(complex64_t a, complex64_t b) {
122
+ auto real = a.real - (b.real * static_cast<int64_t>(a.real / b.real));
123
+ auto imag = a.imag - (b.imag * static_cast<int64_t>(a.imag / b.imag));
124
+ return {real, imag};
125
+ }
lib/python3.11/site-packages/mlx/include/mlx/backend/metal/kernels/conv_params.h ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Copyright © 2023 Apple Inc.
2
+
3
+ #pragma once
4
+
5
+ template <int NDIM>
6
+ struct MLXConvParams {
7
+ const int N; // Batch size
8
+ const int C; // In channels
9
+ const int O; // Out channels
10
+ const int iS[NDIM]; // Input spatial dim
11
+ const int wS[NDIM]; // Weight spatial dim
12
+ const int oS[NDIM]; // Output spatial dim
13
+ const int str[NDIM]; // Kernel strides
14
+ const int pad[NDIM]; // Input padding
15
+ const int dil[NDIM]; // Kernel dilation
16
+ const size_t in_strides[NDIM + 2]; // In strides
17
+ const size_t wt_strides[NDIM + 2]; // Wt strides
18
+ const size_t out_strides[NDIM + 2]; // Out strides
19
+ };