1 module metal.vertexdescriptor; 2 import objc.runtime; 3 import objc.meta : selector, ObjcExtend; 4 5 @ObjectiveC final extern(C++): 6 @nogc nothrow: 7 8 9 enum MTLVertexFormat : uint 10 { 11 ///An invalid vertex format. 12 invalid, 13 ///One unsigned 8-bit value. 14 uchar = 45, 15 ///Two unsigned 8-bit values. 16 uchar2 = 1, 17 ///Three unsigned 8-bit values. 18 uchar3 = 2, 19 ///Four unsigned 8-bit values. 20 uchar4 = 3, 21 ///One signed 8-bit two's complement value. 22 char1 = 46, 23 ///Two signed 8-bit two's complement values. 24 char2 = 4, 25 ///Three signed 8-bit two's complement values. 26 char3 = 5, 27 ///Four signed 8-bit two's complement values. 28 char4 = 6, 29 ///One unsigned normalized 8-bit value. 30 ucharNormalized = 47, 31 ///Two unsigned normalized 8-bit values. 32 uchar2Normalized = 7, 33 ///Three unsigned normalized 8-bit values. 34 uchar3Normalized = 8, 35 ///Four unsigned normalized 8-bit values. 36 uchar4Normalized = 9, 37 ///One signed normalized 8-bit two's complement value. 38 charNormalized = 48, 39 ///Two signed normalized 8-bit two's complement values. 40 char2Normalized = 10, 41 ///Three signed normalized 8-bit two's complement values. 42 char3Normalized = 11, 43 ///Four signed normalized 8-bit two's complement values. 44 char4Normalized = 12, 45 ///One unsigned 16-bit value. 46 ushort1 = 49, 47 ///Two unsigned 16-bit values. 48 ushort2 = 13, 49 ///Three unsigned 16-bit values. 50 ushort3 = 14, 51 ///Four unsigned 16-bit values. 52 ushort4 = 15, 53 ///One signed 16-bit two's complement value. 54 short1 = 50, 55 ///Two signed 16-bit two's complement values. 56 short2 = 16, 57 ///Three signed 16-bit two's complement values. 58 short3 = 17, 59 ///Four signed 16-bit two's complement values. 60 short4 = 18, 61 ///One unsigned normalized 16-bit value. 62 ushortNormalized = 51, 63 ///Two unsigned normalized 16-bit values. 64 ushort2Normalized = 19, 65 ///Three unsigned normalized 16-bit values. 66 ushort3Normalized = 20, 67 ///Four unsigned normalized 16-bit values. 68 ushort4Normalized = 21, 69 ///One signed normalized 16-bit two's complement value. 70 shortNormalized = 52, 71 ///Two signed normalized 16-bit two's complement values. 72 short2Normalized = 22, 73 ///Three signed normalized 16-bit two's complement values. 74 short3Normalized = 23, 75 ///Four signed normalized 16-bit two's complement values. 76 short4Normalized = 24, 77 ///One half-precision floating-point value. 78 half1 = 53, 79 ///Two half-precision floating-point values. 80 half2 = 25, 81 ///Three half-precision floating-point values. 82 half3 = 26, 83 ///Four half-precision floating-point values. 84 half4 = 27, 85 ///One single-precision floating-point value. 86 float1 = 28, 87 ///Two single-precision floating-point values. 88 float2 = 29, 89 ///Three single-precision floating-point values. 90 float3 = 30, 91 ///Four single-precision floating-point values. 92 float4 = 31, 93 ///One unsigned 32-bit value. 94 uint1 = 36, 95 ///Two unsigned 32-bit values. 96 uint2 = 37, 97 ///Three unsigned 32-bit values. 98 uint3 = 38, 99 ///Four unsigned 32-bit values. 100 uint4 = 39, 101 ///One signed 32-bit two's complement value. 102 int1 = 32, 103 ///Two signed 32-bit two's complement values. 104 int2 = 33, 105 ///Three signed 32-bit two's complement values. 106 int3 = 34, 107 ///Four signed 32-bit two's complement values. 108 int4 = 35, 109 ///One packed 32-bit value with four normalized signed two's complement integer values, arranged as 10 bits, 10 bits, 10 bits, and 2 bits. 110 int1010102Normalized = 40, 111 ///One packed 32-bit value with four normalized unsigned integer values, arranged as 10 bits, 10 bits, 10 bits, and 2 bits. 112 uint1010102Normalized = 41, 113 ///Four unsigned normalized 8-bit values, arranged as blue, green, red, and alpha components. 114 uchar4Normalized_bgra = 42, 115 } 116 117 118 ///An object that determines how to store attribute data in memory and map it to the arguments of a vertex function. 119 class MTLVertexAttributeDescriptor 120 { 121 @nogc nothrow: 122 123 mixin ObjcExtend!NSObject; 124 ///The format of the vertex attribute. 125 @selector("format") 126 MTLVertexFormat format(); 127 128 @selector("setFormat:") 129 MTLVertexFormat format(MTLVertexFormat); 130 131 ///The location of an attribute in vertex data, determined by the byte offset from the start of the vertex data. 132 @selector("offset") 133 NSUInteger offset(); 134 @selector("setOffset:") 135 NSUInteger offset(NSUInteger); 136 137 ///The index in the argument table for the associated vertex buffer. 138 @selector("bufferIndex") 139 NSUInteger bufferIndex(); 140 @selector("setBufferIndex:") 141 NSUInteger bufferIndex(NSUInteger); 142 } 143 144 class MTLVertexAttributeDescriptorArray 145 { 146 @nogc nothrow: 147 148 mixin ObjcExtend!NSObject; 149 ///Returns the state of the specified vertex attribute. 150 @selector("objectAtIndexedSubscript:") 151 MTLVertexAttributeDescriptor objectAtIndexedSubscript(NSUInteger index); 152 153 ///Sets state for the specified vertex attribute. 154 @selector("setObject:atIndexedSubscript:") 155 void setObjectAtIndexedSubscript(MTLVertexAttributeDescriptor descriptor, NSUInteger index); 156 157 extern(D) final MTLVertexAttributeDescriptor opIndex(NSUInteger index) 158 { 159 return objectAtIndexedSubscript(index); 160 } 161 extern(D) final void opIndexAssign(MTLVertexAttributeDescriptor v, NSUInteger index) 162 { 163 setObjectAtIndexedSubscript(v, index); 164 } 165 } 166 167 ///The frequency with which the vertex function or post-tessellation vertex function fetches attribute data. 168 enum MTLVertexStepFunction : NSUInteger 169 { 170 ///The vertex function fetches attribute data once and uses that data for every vertex. 171 Constant = 0, 172 ///The vertex function fetches and uses new attribute data for every vertex. 173 PerVertex = 1, 174 ///The vertex function regularly fetches new attribute data for a number of instances that is determined by stepRate. 175 PerInstance = 2, 176 ///The post-tessellation vertex function fetches data based on the patch index of the patch. 177 PerPatch = 3, 178 ///The post-tessellation vertex function fetches data based on the control-point indices associated with the patch. 179 PerPatchControlPoint = 4 180 } 181 182 ///An object that configures how a render pipeline fetches data to send to the vertex function. 183 class MTLVertexBufferLayoutDescriptor 184 { 185 @nogc nothrow: 186 187 mixin ObjcExtend!NSObject; 188 ///The circumstances under which the vertex and its attributes are presented to the vertex function. 189 @selector("stepFunction") 190 MTLVertexStepFunction stepFunction(); 191 @selector("setStepFunction:") 192 MTLVertexStepFunction stepFunction(MTLVertexStepFunction); 193 194 ///The interval at which the vertex and its attributes are presented to the vertex function. 195 @selector("stepRate") 196 NSUInteger stepRate(); 197 @selector("setStepRate:") 198 NSUInteger stepRate(NSUInteger); 199 200 ///The distance, in bytes, between the attribute data of two vertices in the buffer. 201 @selector("stride") 202 NSUInteger stride(); 203 @selector("setStride:") 204 NSUInteger stride(NSUInteger); 205 } 206 207 class MTLVertexBufferLayoutDescriptorArray 208 { 209 @nogc nothrow: 210 211 mixin ObjcExtend!NSObject; 212 ///Returns the state of the specified vertex buffer layout. 213 @selector("objectAtIndexedSubscript:") 214 MTLVertexBufferLayoutDescriptor objectAtIndexedSubscript(NSUInteger index); 215 216 ///Sets the state of the specified vertex buffer layout. 217 @selector("setObject:atIndexedSubscript:") 218 void setObjectAtIndexedSubscript(MTLVertexBufferLayoutDescriptor bufferDesc, NSUInteger index); 219 220 extern(D) final MTLVertexBufferLayoutDescriptor opIndex(NSUInteger index) 221 { 222 return objectAtIndexedSubscript(index); 223 } 224 extern(D) final void opIndexAssign(MTLVertexBufferLayoutDescriptor value, NSUInteger index) 225 { 226 setObjectAtIndexedSubscript(value, index); 227 } 228 } 229 230 class MTLVertexDescriptor 231 { 232 @nogc nothrow: 233 234 mixin ObjcExtend!NSObject; 235 ///Creates and returns a new vertex descriptor. 236 static MTLVertexDescriptor vertexDescriptor() @selector("vertexDescriptor"); 237 ///Resets the default state for the vertex descriptor. 238 void reset() @selector("reset"); 239 240 ///An array of state data that describes how vertex attribute data is stored in memory and is mapped to arguments for a vertex shader function. 241 MTLVertexAttributeDescriptorArray attributes() @selector("attributes"); 242 243 ///An array of state data that describes how data are fetched by a vertex shader function when rendering primitives. 244 MTLVertexBufferLayoutDescriptorArray layouts() @selector("layouts"); 245 }