1 module metal.library; 2 public import objc.runtime; 3 import objc.meta : selector, ObjcExtend; 4 import metal.metal; 5 6 @ObjectiveC final extern(C++): 7 @nogc nothrow: 8 enum MTLLanguageVersion : NSUInteger 9 { 10 ///Deprecated 11 _1_0 = (1 << 16) + 0, 12 _1_1 = (1 << 16) + 1, 13 _1_2 = (1 << 16) + 2, 14 _2_0 = (2 << 16) + 0, 15 _2_1 = (2 << 16) + 1, 16 _2_2 = (2 << 16) + 2, 17 _2_3 = (2 << 16) + 3, 18 _2_4 = (2 << 16) + 4, 19 _3_0 = (3 << 16) + 0, 20 } 21 22 enum MTLLibraryOptimizationLevel : NSInteger 23 { 24 ///An optimization option for the Metal compiler that prioritizes runtime performance. 25 Default = 0, 26 ///An optimization option for the Metal compiler that prioritizes minimizing the size of its output binaries, which may also reduce compile time. 27 Size = 1 28 } 29 30 enum MTLLibraryType : NSInteger 31 { 32 ///A library that can create pipeline state objects. 33 Executable = 0, 34 ///A library that you can dynamically link to from other libraries. 35 Dynamic = 1 36 } 37 38 39 class MTLCompileOptions 40 { 41 @nogc nothrow: 42 43 mixin ObjcExtend!NSObject; 44 @selector("alloc") 45 static MTLCompileOptions alloc(); 46 47 @selector("init") 48 MTLCompileOptions initialize(); 49 50 alias ini = initialize; 51 52 ///A Boolean value that indicates whether the compiler can perform optimizations for floating-point arithmetic that may violate the IEEE 754 standard. 53 @selector("fastMathEnabled") 54 BOOL fastMathEnabled(); 55 @selector("setFastMathEnabled:") 56 BOOL fastMathEnabled(BOOL); 57 58 ///A Boolean value that indicates whether the compiler should compile vertex shaders conservatively to generate consistent position calculations. 59 @selector("preserveInvariance") 60 BOOL preserveInvariance(); 61 @selector("setPreserveInvariance:") 62 BOOL preserveInvariance(BOOL); 63 64 ///The language version used to interpret the library source code. 65 @selector("languageVersion") 66 MTLLanguageVersion languageVersion(); 67 @selector("setLanguageVersion:") 68 MTLLanguageVersion languageVersion(MTLLanguageVersion); 69 70 ///A list of preprocessor macros to apply when compiling the library source. 71 @selector("preprocessorMacros") 72 NSDictionary preprocessorMacros(); 73 @selector("setPreprocessorMacros:") 74 NSDictionary preprocessorMacros(NSDictionary); 75 76 ///An option that tells the compiler what to prioritize when it compiles Metal shader code. 77 @selector("optimizationLevel") 78 MTLLibraryOptimizationLevel optimizationLevel(); 79 @selector("setOptimizationLevel:") 80 MTLLibraryOptimizationLevel optimizationLevel(MTLLibraryOptimizationLevel); 81 82 ///An array of dynamic libraries the Metal compiler links against. 83 @selector("libraries") 84 NSArray libraries(); 85 @selector("setLibraries:") 86 NSArray libraries(NSArray); 87 88 ///The kind of library to create. 89 @selector("libraryType") 90 MTLLibraryType libraryType(); 91 @selector("setLibraryType:") 92 MTLLibraryType libraryType(MTLLibraryType); 93 94 ///For a dynamic library, the name to use when installing the library. 95 @selector("installName") 96 NSString installName(); 97 @selector("setInstallName:") 98 NSString installName(NSString); 99 } 100 101 interface MTLLibrary 102 { 103 @nogc nothrow: 104 105 ///The installation name for a dynamic library. 106 @selector("installName") 107 NSString installName(); 108 ///The library’s basic type. 109 @selector("type") 110 MTLLibraryType type(); 111 112 @selector("functionNames") 113 NSArray_!NSString _functionNames(); 114 ///The names of all public functions in the library. 115 116 extern(D) final NSArrayD!NSString functionNames() 117 { 118 return NSArrayD!(NSString)(_functionNames); 119 } 120 121 @selector("newFunctionWithName:") 122 MTLFunction newFunctionWithName(NSString); 123 }