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