MTLStageInputOutputDescriptor.hpp
1 //------------------------------------------------------------------------------------------------------------------------------------------------------------- 2 // 3 // Metal/MTLStageInputOutputDescriptor.hpp 4 // 5 // Copyright 2020-2024 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 }