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