MTLLibrary.hpp
1 //------------------------------------------------------------------------------------------------------------------------------------------------------------- 2 // 3 // Metal/MTLLibrary.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 "MTLArgument.hpp" 30 #include "MTLFunctionDescriptor.hpp" 31 #include "MTLLibrary.hpp" 32 #include <functional> 33 34 namespace MTL 35 { 36 _MTL_ENUM(NS::UInteger, PatchType) { 37 PatchTypeNone = 0, 38 PatchTypeTriangle = 1, 39 PatchTypeQuad = 2, 40 }; 41 42 class VertexAttribute : public NS::Referencing<VertexAttribute> 43 { 44 public: 45 static class VertexAttribute* alloc(); 46 47 class VertexAttribute* init(); 48 49 NS::String* name() const; 50 51 NS::UInteger attributeIndex() const; 52 53 MTL::DataType attributeType() const; 54 55 bool active() const; 56 57 bool patchData() const; 58 59 bool patchControlPointData() const; 60 }; 61 62 class Attribute : public NS::Referencing<Attribute> 63 { 64 public: 65 static class Attribute* alloc(); 66 67 class Attribute* init(); 68 69 NS::String* name() const; 70 71 NS::UInteger attributeIndex() const; 72 73 MTL::DataType attributeType() const; 74 75 bool active() const; 76 77 bool patchData() const; 78 79 bool patchControlPointData() const; 80 }; 81 82 _MTL_ENUM(NS::UInteger, FunctionType) { 83 FunctionTypeVertex = 1, 84 FunctionTypeFragment = 2, 85 FunctionTypeKernel = 3, 86 FunctionTypeVisible = 5, 87 FunctionTypeIntersection = 6, 88 FunctionTypeMesh = 7, 89 FunctionTypeObject = 8, 90 }; 91 92 class FunctionConstant : public NS::Referencing<FunctionConstant> 93 { 94 public: 95 static class FunctionConstant* alloc(); 96 97 class FunctionConstant* init(); 98 99 NS::String* name() const; 100 101 MTL::DataType type() const; 102 103 NS::UInteger index() const; 104 105 bool required() const; 106 }; 107 108 using AutoreleasedArgument = class Argument*; 109 110 class Function : public NS::Referencing<Function> 111 { 112 public: 113 NS::String* label() const; 114 void setLabel(const NS::String* label); 115 116 class Device* device() const; 117 118 MTL::FunctionType functionType() const; 119 120 MTL::PatchType patchType() const; 121 122 NS::Integer patchControlPointCount() const; 123 124 NS::Array* vertexAttributes() const; 125 126 NS::Array* stageInputAttributes() const; 127 128 NS::String* name() const; 129 130 NS::Dictionary* functionConstantsDictionary() const; 131 132 class ArgumentEncoder* newArgumentEncoder(NS::UInteger bufferIndex); 133 134 class ArgumentEncoder* newArgumentEncoder(NS::UInteger bufferIndex, const MTL::AutoreleasedArgument* reflection); 135 136 MTL::FunctionOptions options() const; 137 }; 138 139 _MTL_ENUM(NS::UInteger, LanguageVersion) { 140 LanguageVersion1_0 = 65536, 141 LanguageVersion1_1 = 65537, 142 LanguageVersion1_2 = 65538, 143 LanguageVersion2_0 = 131072, 144 LanguageVersion2_1 = 131073, 145 LanguageVersion2_2 = 131074, 146 LanguageVersion2_3 = 131075, 147 LanguageVersion2_4 = 131076, 148 LanguageVersion3_0 = 196608, 149 LanguageVersion3_1 = 196609, 150 LanguageVersion3_2 = 196610, 151 }; 152 153 _MTL_ENUM(NS::Integer, LibraryType) { 154 LibraryTypeExecutable = 0, 155 LibraryTypeDynamic = 1, 156 }; 157 158 _MTL_ENUM(NS::Integer, LibraryOptimizationLevel) { 159 LibraryOptimizationLevelDefault = 0, 160 LibraryOptimizationLevelSize = 1, 161 }; 162 163 _MTL_ENUM(NS::Integer, CompileSymbolVisibility) { 164 CompileSymbolVisibilityDefault = 0, 165 CompileSymbolVisibilityHidden = 1, 166 }; 167 168 _MTL_ENUM(NS::Integer, MathMode) { 169 MathModeSafe = 0, 170 MathModeRelaxed = 1, 171 MathModeFast = 2, 172 }; 173 174 _MTL_ENUM(NS::Integer, MathFloatingPointFunctions) { 175 MathFloatingPointFunctionsFast = 0, 176 MathFloatingPointFunctionsPrecise = 1, 177 }; 178 179 class CompileOptions : public NS::Copying<CompileOptions> 180 { 181 public: 182 static class CompileOptions* alloc(); 183 184 class CompileOptions* init(); 185 186 NS::Dictionary* preprocessorMacros() const; 187 void setPreprocessorMacros(const NS::Dictionary* preprocessorMacros); 188 189 bool fastMathEnabled() const; 190 void setFastMathEnabled(bool fastMathEnabled); 191 192 MTL::MathMode mathMode() const; 193 void setMathMode(MTL::MathMode mathMode); 194 195 MTL::MathFloatingPointFunctions mathFloatingPointFunctions() const; 196 void setMathFloatingPointFunctions(MTL::MathFloatingPointFunctions mathFloatingPointFunctions); 197 198 MTL::LanguageVersion languageVersion() const; 199 void setLanguageVersion(MTL::LanguageVersion languageVersion); 200 201 MTL::LibraryType libraryType() const; 202 void setLibraryType(MTL::LibraryType libraryType); 203 204 NS::String* installName() const; 205 void setInstallName(const NS::String* installName); 206 207 NS::Array* libraries() const; 208 void setLibraries(const NS::Array* libraries); 209 210 bool preserveInvariance() const; 211 void setPreserveInvariance(bool preserveInvariance); 212 213 MTL::LibraryOptimizationLevel optimizationLevel() const; 214 void setOptimizationLevel(MTL::LibraryOptimizationLevel optimizationLevel); 215 216 MTL::CompileSymbolVisibility compileSymbolVisibility() const; 217 void setCompileSymbolVisibility(MTL::CompileSymbolVisibility compileSymbolVisibility); 218 219 bool allowReferencingUndefinedSymbols() const; 220 void setAllowReferencingUndefinedSymbols(bool allowReferencingUndefinedSymbols); 221 222 NS::UInteger maxTotalThreadsPerThreadgroup() const; 223 void setMaxTotalThreadsPerThreadgroup(NS::UInteger maxTotalThreadsPerThreadgroup); 224 225 bool enableLogging() const; 226 void setEnableLogging(bool enableLogging); 227 }; 228 229 _MTL_ENUM(NS::UInteger, LibraryError) { 230 LibraryErrorUnsupported = 1, 231 LibraryErrorInternal = 2, 232 LibraryErrorCompileFailure = 3, 233 LibraryErrorCompileWarning = 4, 234 LibraryErrorFunctionNotFound = 5, 235 LibraryErrorFileNotFound = 6, 236 }; 237 238 class Library : public NS::Referencing<Library> 239 { 240 public: 241 void newFunction(const NS::String* pFunctionName, const class FunctionConstantValues* pConstantValues, const std::function<void(Function* pFunction, NS::Error* pError)>& completionHandler); 242 243 void newFunction(const class FunctionDescriptor* pDescriptor, const std::function<void(Function* pFunction, NS::Error* pError)>& completionHandler); 244 245 void newIntersectionFunction(const class IntersectionFunctionDescriptor* pDescriptor, const std::function<void(Function* pFunction, NS::Error* pError)>& completionHandler); 246 247 NS::String* label() const; 248 void setLabel(const NS::String* label); 249 250 class Device* device() const; 251 252 class Function* newFunction(const NS::String* functionName); 253 254 class Function* newFunction(const NS::String* name, const class FunctionConstantValues* constantValues, NS::Error** error); 255 256 void newFunction(const NS::String* name, const class FunctionConstantValues* constantValues, void (^completionHandler)(MTL::Function*, NS::Error*)); 257 258 void newFunction(const class FunctionDescriptor* descriptor, void (^completionHandler)(MTL::Function*, NS::Error*)); 259 260 class Function* newFunction(const class FunctionDescriptor* descriptor, NS::Error** error); 261 262 void newIntersectionFunction(const class IntersectionFunctionDescriptor* descriptor, void (^completionHandler)(MTL::Function*, NS::Error*)); 263 264 class Function* newIntersectionFunction(const class IntersectionFunctionDescriptor* descriptor, NS::Error** error); 265 266 NS::Array* functionNames() const; 267 268 MTL::LibraryType type() const; 269 270 NS::String* installName() const; 271 }; 272 273 } 274 275 // static method: alloc 276 _MTL_INLINE MTL::VertexAttribute* MTL::VertexAttribute::alloc() 277 { 278 return NS::Object::alloc<MTL::VertexAttribute>(_MTL_PRIVATE_CLS(MTLVertexAttribute)); 279 } 280 281 // method: init 282 _MTL_INLINE MTL::VertexAttribute* MTL::VertexAttribute::init() 283 { 284 return NS::Object::init<MTL::VertexAttribute>(); 285 } 286 287 // property: name 288 _MTL_INLINE NS::String* MTL::VertexAttribute::name() const 289 { 290 return Object::sendMessage<NS::String*>(this, _MTL_PRIVATE_SEL(name)); 291 } 292 293 // property: attributeIndex 294 _MTL_INLINE NS::UInteger MTL::VertexAttribute::attributeIndex() const 295 { 296 return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(attributeIndex)); 297 } 298 299 // property: attributeType 300 _MTL_INLINE MTL::DataType MTL::VertexAttribute::attributeType() const 301 { 302 return Object::sendMessage<MTL::DataType>(this, _MTL_PRIVATE_SEL(attributeType)); 303 } 304 305 // property: active 306 _MTL_INLINE bool MTL::VertexAttribute::active() const 307 { 308 return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(isActive)); 309 } 310 311 // property: patchData 312 _MTL_INLINE bool MTL::VertexAttribute::patchData() const 313 { 314 return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(isPatchData)); 315 } 316 317 // property: patchControlPointData 318 _MTL_INLINE bool MTL::VertexAttribute::patchControlPointData() const 319 { 320 return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(isPatchControlPointData)); 321 } 322 323 // static method: alloc 324 _MTL_INLINE MTL::Attribute* MTL::Attribute::alloc() 325 { 326 return NS::Object::alloc<MTL::Attribute>(_MTL_PRIVATE_CLS(MTLAttribute)); 327 } 328 329 // method: init 330 _MTL_INLINE MTL::Attribute* MTL::Attribute::init() 331 { 332 return NS::Object::init<MTL::Attribute>(); 333 } 334 335 // property: name 336 _MTL_INLINE NS::String* MTL::Attribute::name() const 337 { 338 return Object::sendMessage<NS::String*>(this, _MTL_PRIVATE_SEL(name)); 339 } 340 341 // property: attributeIndex 342 _MTL_INLINE NS::UInteger MTL::Attribute::attributeIndex() const 343 { 344 return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(attributeIndex)); 345 } 346 347 // property: attributeType 348 _MTL_INLINE MTL::DataType MTL::Attribute::attributeType() const 349 { 350 return Object::sendMessage<MTL::DataType>(this, _MTL_PRIVATE_SEL(attributeType)); 351 } 352 353 // property: active 354 _MTL_INLINE bool MTL::Attribute::active() const 355 { 356 return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(isActive)); 357 } 358 359 // property: patchData 360 _MTL_INLINE bool MTL::Attribute::patchData() const 361 { 362 return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(isPatchData)); 363 } 364 365 // property: patchControlPointData 366 _MTL_INLINE bool MTL::Attribute::patchControlPointData() const 367 { 368 return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(isPatchControlPointData)); 369 } 370 371 // static method: alloc 372 _MTL_INLINE MTL::FunctionConstant* MTL::FunctionConstant::alloc() 373 { 374 return NS::Object::alloc<MTL::FunctionConstant>(_MTL_PRIVATE_CLS(MTLFunctionConstant)); 375 } 376 377 // method: init 378 _MTL_INLINE MTL::FunctionConstant* MTL::FunctionConstant::init() 379 { 380 return NS::Object::init<MTL::FunctionConstant>(); 381 } 382 383 // property: name 384 _MTL_INLINE NS::String* MTL::FunctionConstant::name() const 385 { 386 return Object::sendMessage<NS::String*>(this, _MTL_PRIVATE_SEL(name)); 387 } 388 389 // property: type 390 _MTL_INLINE MTL::DataType MTL::FunctionConstant::type() const 391 { 392 return Object::sendMessage<MTL::DataType>(this, _MTL_PRIVATE_SEL(type)); 393 } 394 395 // property: index 396 _MTL_INLINE NS::UInteger MTL::FunctionConstant::index() const 397 { 398 return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(index)); 399 } 400 401 // property: required 402 _MTL_INLINE bool MTL::FunctionConstant::required() const 403 { 404 return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(required)); 405 } 406 407 // property: label 408 _MTL_INLINE NS::String* MTL::Function::label() const 409 { 410 return Object::sendMessage<NS::String*>(this, _MTL_PRIVATE_SEL(label)); 411 } 412 413 _MTL_INLINE void MTL::Function::setLabel(const NS::String* label) 414 { 415 Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setLabel_), label); 416 } 417 418 // property: device 419 _MTL_INLINE MTL::Device* MTL::Function::device() const 420 { 421 return Object::sendMessage<MTL::Device*>(this, _MTL_PRIVATE_SEL(device)); 422 } 423 424 // property: functionType 425 _MTL_INLINE MTL::FunctionType MTL::Function::functionType() const 426 { 427 return Object::sendMessage<MTL::FunctionType>(this, _MTL_PRIVATE_SEL(functionType)); 428 } 429 430 // property: patchType 431 _MTL_INLINE MTL::PatchType MTL::Function::patchType() const 432 { 433 return Object::sendMessage<MTL::PatchType>(this, _MTL_PRIVATE_SEL(patchType)); 434 } 435 436 // property: patchControlPointCount 437 _MTL_INLINE NS::Integer MTL::Function::patchControlPointCount() const 438 { 439 return Object::sendMessage<NS::Integer>(this, _MTL_PRIVATE_SEL(patchControlPointCount)); 440 } 441 442 // property: vertexAttributes 443 _MTL_INLINE NS::Array* MTL::Function::vertexAttributes() const 444 { 445 return Object::sendMessage<NS::Array*>(this, _MTL_PRIVATE_SEL(vertexAttributes)); 446 } 447 448 // property: stageInputAttributes 449 _MTL_INLINE NS::Array* MTL::Function::stageInputAttributes() const 450 { 451 return Object::sendMessage<NS::Array*>(this, _MTL_PRIVATE_SEL(stageInputAttributes)); 452 } 453 454 // property: name 455 _MTL_INLINE NS::String* MTL::Function::name() const 456 { 457 return Object::sendMessage<NS::String*>(this, _MTL_PRIVATE_SEL(name)); 458 } 459 460 // property: functionConstantsDictionary 461 _MTL_INLINE NS::Dictionary* MTL::Function::functionConstantsDictionary() const 462 { 463 return Object::sendMessage<NS::Dictionary*>(this, _MTL_PRIVATE_SEL(functionConstantsDictionary)); 464 } 465 466 // method: newArgumentEncoderWithBufferIndex: 467 _MTL_INLINE MTL::ArgumentEncoder* MTL::Function::newArgumentEncoder(NS::UInteger bufferIndex) 468 { 469 return Object::sendMessage<MTL::ArgumentEncoder*>(this, _MTL_PRIVATE_SEL(newArgumentEncoderWithBufferIndex_), bufferIndex); 470 } 471 472 // method: newArgumentEncoderWithBufferIndex:reflection: 473 _MTL_INLINE MTL::ArgumentEncoder* MTL::Function::newArgumentEncoder(NS::UInteger bufferIndex, const MTL::AutoreleasedArgument* reflection) 474 { 475 return Object::sendMessage<MTL::ArgumentEncoder*>(this, _MTL_PRIVATE_SEL(newArgumentEncoderWithBufferIndex_reflection_), bufferIndex, reflection); 476 } 477 478 // property: options 479 _MTL_INLINE MTL::FunctionOptions MTL::Function::options() const 480 { 481 return Object::sendMessage<MTL::FunctionOptions>(this, _MTL_PRIVATE_SEL(options)); 482 } 483 484 // static method: alloc 485 _MTL_INLINE MTL::CompileOptions* MTL::CompileOptions::alloc() 486 { 487 return NS::Object::alloc<MTL::CompileOptions>(_MTL_PRIVATE_CLS(MTLCompileOptions)); 488 } 489 490 // method: init 491 _MTL_INLINE MTL::CompileOptions* MTL::CompileOptions::init() 492 { 493 return NS::Object::init<MTL::CompileOptions>(); 494 } 495 496 // property: preprocessorMacros 497 _MTL_INLINE NS::Dictionary* MTL::CompileOptions::preprocessorMacros() const 498 { 499 return Object::sendMessage<NS::Dictionary*>(this, _MTL_PRIVATE_SEL(preprocessorMacros)); 500 } 501 502 _MTL_INLINE void MTL::CompileOptions::setPreprocessorMacros(const NS::Dictionary* preprocessorMacros) 503 { 504 Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setPreprocessorMacros_), preprocessorMacros); 505 } 506 507 // property: fastMathEnabled 508 _MTL_INLINE bool MTL::CompileOptions::fastMathEnabled() const 509 { 510 return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(fastMathEnabled)); 511 } 512 513 _MTL_INLINE void MTL::CompileOptions::setFastMathEnabled(bool fastMathEnabled) 514 { 515 Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setFastMathEnabled_), fastMathEnabled); 516 } 517 518 // property: mathMode 519 _MTL_INLINE MTL::MathMode MTL::CompileOptions::mathMode() const 520 { 521 return Object::sendMessage<MTL::MathMode>(this, _MTL_PRIVATE_SEL(mathMode)); 522 } 523 524 _MTL_INLINE void MTL::CompileOptions::setMathMode(MTL::MathMode mathMode) 525 { 526 Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setMathMode_), mathMode); 527 } 528 529 // property: mathFloatingPointFunctions 530 _MTL_INLINE MTL::MathFloatingPointFunctions MTL::CompileOptions::mathFloatingPointFunctions() const 531 { 532 return Object::sendMessage<MTL::MathFloatingPointFunctions>(this, _MTL_PRIVATE_SEL(mathFloatingPointFunctions)); 533 } 534 535 _MTL_INLINE void MTL::CompileOptions::setMathFloatingPointFunctions(MTL::MathFloatingPointFunctions mathFloatingPointFunctions) 536 { 537 Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setMathFloatingPointFunctions_), mathFloatingPointFunctions); 538 } 539 540 // property: languageVersion 541 _MTL_INLINE MTL::LanguageVersion MTL::CompileOptions::languageVersion() const 542 { 543 return Object::sendMessage<MTL::LanguageVersion>(this, _MTL_PRIVATE_SEL(languageVersion)); 544 } 545 546 _MTL_INLINE void MTL::CompileOptions::setLanguageVersion(MTL::LanguageVersion languageVersion) 547 { 548 Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setLanguageVersion_), languageVersion); 549 } 550 551 // property: libraryType 552 _MTL_INLINE MTL::LibraryType MTL::CompileOptions::libraryType() const 553 { 554 return Object::sendMessage<MTL::LibraryType>(this, _MTL_PRIVATE_SEL(libraryType)); 555 } 556 557 _MTL_INLINE void MTL::CompileOptions::setLibraryType(MTL::LibraryType libraryType) 558 { 559 Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setLibraryType_), libraryType); 560 } 561 562 // property: installName 563 _MTL_INLINE NS::String* MTL::CompileOptions::installName() const 564 { 565 return Object::sendMessage<NS::String*>(this, _MTL_PRIVATE_SEL(installName)); 566 } 567 568 _MTL_INLINE void MTL::CompileOptions::setInstallName(const NS::String* installName) 569 { 570 Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setInstallName_), installName); 571 } 572 573 // property: libraries 574 _MTL_INLINE NS::Array* MTL::CompileOptions::libraries() const 575 { 576 return Object::sendMessage<NS::Array*>(this, _MTL_PRIVATE_SEL(libraries)); 577 } 578 579 _MTL_INLINE void MTL::CompileOptions::setLibraries(const NS::Array* libraries) 580 { 581 Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setLibraries_), libraries); 582 } 583 584 // property: preserveInvariance 585 _MTL_INLINE bool MTL::CompileOptions::preserveInvariance() const 586 { 587 return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(preserveInvariance)); 588 } 589 590 _MTL_INLINE void MTL::CompileOptions::setPreserveInvariance(bool preserveInvariance) 591 { 592 Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setPreserveInvariance_), preserveInvariance); 593 } 594 595 // property: optimizationLevel 596 _MTL_INLINE MTL::LibraryOptimizationLevel MTL::CompileOptions::optimizationLevel() const 597 { 598 return Object::sendMessage<MTL::LibraryOptimizationLevel>(this, _MTL_PRIVATE_SEL(optimizationLevel)); 599 } 600 601 _MTL_INLINE void MTL::CompileOptions::setOptimizationLevel(MTL::LibraryOptimizationLevel optimizationLevel) 602 { 603 Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setOptimizationLevel_), optimizationLevel); 604 } 605 606 // property: compileSymbolVisibility 607 _MTL_INLINE MTL::CompileSymbolVisibility MTL::CompileOptions::compileSymbolVisibility() const 608 { 609 return Object::sendMessage<MTL::CompileSymbolVisibility>(this, _MTL_PRIVATE_SEL(compileSymbolVisibility)); 610 } 611 612 _MTL_INLINE void MTL::CompileOptions::setCompileSymbolVisibility(MTL::CompileSymbolVisibility compileSymbolVisibility) 613 { 614 Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setCompileSymbolVisibility_), compileSymbolVisibility); 615 } 616 617 // property: allowReferencingUndefinedSymbols 618 _MTL_INLINE bool MTL::CompileOptions::allowReferencingUndefinedSymbols() const 619 { 620 return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(allowReferencingUndefinedSymbols)); 621 } 622 623 _MTL_INLINE void MTL::CompileOptions::setAllowReferencingUndefinedSymbols(bool allowReferencingUndefinedSymbols) 624 { 625 Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setAllowReferencingUndefinedSymbols_), allowReferencingUndefinedSymbols); 626 } 627 628 // property: maxTotalThreadsPerThreadgroup 629 _MTL_INLINE NS::UInteger MTL::CompileOptions::maxTotalThreadsPerThreadgroup() const 630 { 631 return Object::sendMessage<NS::UInteger>(this, _MTL_PRIVATE_SEL(maxTotalThreadsPerThreadgroup)); 632 } 633 634 _MTL_INLINE void MTL::CompileOptions::setMaxTotalThreadsPerThreadgroup(NS::UInteger maxTotalThreadsPerThreadgroup) 635 { 636 Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setMaxTotalThreadsPerThreadgroup_), maxTotalThreadsPerThreadgroup); 637 } 638 639 // property: enableLogging 640 _MTL_INLINE bool MTL::CompileOptions::enableLogging() const 641 { 642 return Object::sendMessage<bool>(this, _MTL_PRIVATE_SEL(enableLogging)); 643 } 644 645 _MTL_INLINE void MTL::CompileOptions::setEnableLogging(bool enableLogging) 646 { 647 Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setEnableLogging_), enableLogging); 648 } 649 650 _MTL_INLINE void MTL::Library::newFunction(const NS::String* pFunctionName, const FunctionConstantValues* pConstantValues, const std::function<void(Function* pFunction, NS::Error* pError)>& completionHandler) 651 { 652 __block std::function<void(Function * pFunction, NS::Error * pError)> blockCompletionHandler = completionHandler; 653 654 newFunction(pFunctionName, pConstantValues, ^(Function* pFunction, NS::Error* pError) { blockCompletionHandler(pFunction, pError); }); 655 } 656 657 _MTL_INLINE void MTL::Library::newFunction(const FunctionDescriptor* pDescriptor, const std::function<void(Function* pFunction, NS::Error* pError)>& completionHandler) 658 { 659 __block std::function<void(Function * pFunction, NS::Error * pError)> blockCompletionHandler = completionHandler; 660 661 newFunction(pDescriptor, ^(Function* pFunction, NS::Error* pError) { blockCompletionHandler(pFunction, pError); }); 662 } 663 664 _MTL_INLINE void MTL::Library::newIntersectionFunction(const IntersectionFunctionDescriptor* pDescriptor, const std::function<void(Function* pFunction, NS::Error* pError)>& completionHandler) 665 { 666 __block std::function<void(Function * pFunction, NS::Error * pError)> blockCompletionHandler = completionHandler; 667 668 newIntersectionFunction(pDescriptor, ^(Function* pFunction, NS::Error* pError) { blockCompletionHandler(pFunction, pError); }); 669 } 670 671 // property: label 672 _MTL_INLINE NS::String* MTL::Library::label() const 673 { 674 return Object::sendMessage<NS::String*>(this, _MTL_PRIVATE_SEL(label)); 675 } 676 677 _MTL_INLINE void MTL::Library::setLabel(const NS::String* label) 678 { 679 Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(setLabel_), label); 680 } 681 682 // property: device 683 _MTL_INLINE MTL::Device* MTL::Library::device() const 684 { 685 return Object::sendMessage<MTL::Device*>(this, _MTL_PRIVATE_SEL(device)); 686 } 687 688 // method: newFunctionWithName: 689 _MTL_INLINE MTL::Function* MTL::Library::newFunction(const NS::String* functionName) 690 { 691 return Object::sendMessage<MTL::Function*>(this, _MTL_PRIVATE_SEL(newFunctionWithName_), functionName); 692 } 693 694 // method: newFunctionWithName:constantValues:error: 695 _MTL_INLINE MTL::Function* MTL::Library::newFunction(const NS::String* name, const MTL::FunctionConstantValues* constantValues, NS::Error** error) 696 { 697 return Object::sendMessage<MTL::Function*>(this, _MTL_PRIVATE_SEL(newFunctionWithName_constantValues_error_), name, constantValues, error); 698 } 699 700 // method: newFunctionWithName:constantValues:completionHandler: 701 _MTL_INLINE void MTL::Library::newFunction(const NS::String* name, const MTL::FunctionConstantValues* constantValues, void (^completionHandler)(MTL::Function*, NS::Error*)) 702 { 703 Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(newFunctionWithName_constantValues_completionHandler_), name, constantValues, completionHandler); 704 } 705 706 // method: newFunctionWithDescriptor:completionHandler: 707 _MTL_INLINE void MTL::Library::newFunction(const MTL::FunctionDescriptor* descriptor, void (^completionHandler)(MTL::Function*, NS::Error*)) 708 { 709 Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(newFunctionWithDescriptor_completionHandler_), descriptor, completionHandler); 710 } 711 712 // method: newFunctionWithDescriptor:error: 713 _MTL_INLINE MTL::Function* MTL::Library::newFunction(const MTL::FunctionDescriptor* descriptor, NS::Error** error) 714 { 715 return Object::sendMessage<MTL::Function*>(this, _MTL_PRIVATE_SEL(newFunctionWithDescriptor_error_), descriptor, error); 716 } 717 718 // method: newIntersectionFunctionWithDescriptor:completionHandler: 719 _MTL_INLINE void MTL::Library::newIntersectionFunction(const MTL::IntersectionFunctionDescriptor* descriptor, void (^completionHandler)(MTL::Function*, NS::Error*)) 720 { 721 Object::sendMessage<void>(this, _MTL_PRIVATE_SEL(newIntersectionFunctionWithDescriptor_completionHandler_), descriptor, completionHandler); 722 } 723 724 // method: newIntersectionFunctionWithDescriptor:error: 725 _MTL_INLINE MTL::Function* MTL::Library::newIntersectionFunction(const MTL::IntersectionFunctionDescriptor* descriptor, NS::Error** error) 726 { 727 return Object::sendMessage<MTL::Function*>(this, _MTL_PRIVATE_SEL(newIntersectionFunctionWithDescriptor_error_), descriptor, error); 728 } 729 730 // property: functionNames 731 _MTL_INLINE NS::Array* MTL::Library::functionNames() const 732 { 733 return Object::sendMessage<NS::Array*>(this, _MTL_PRIVATE_SEL(functionNames)); 734 } 735 736 // property: type 737 _MTL_INLINE MTL::LibraryType MTL::Library::type() const 738 { 739 return Object::sendMessage<MTL::LibraryType>(this, _MTL_PRIVATE_SEL(type)); 740 } 741 742 // property: installName 743 _MTL_INLINE NS::String* MTL::Library::installName() const 744 { 745 return Object::sendMessage<NS::String*>(this, _MTL_PRIVATE_SEL(installName)); 746 }