1 module metal.rendercommandencoder; 2 3 version(D_ObjectiveC): 4 extern(Objective-C): 5 import metal.metal; 6 import metal.texture; 7 8 ///The type of a top-level Metal Shading Language (MSL) function. 9 enum MTLFunctionType : NSUInteger 10 { 11 ///A vertex function you can use in a render pipeline state object. 12 Vertex = 1, 13 ///A fragment function you can use in a render pipeline state object. 14 Fragment = 2, 15 ///A kernel you can use in a compute pipeline state object. 16 Kernel = 3, 17 ///A function you can use in an intersection function table. 18 Intersection = 6, 19 ///A function you can use in a visible function table. 20 Visible = 5, 21 Mesh = 7, 22 Object = 8 23 } 24 25 ///An object representing a function that you can add to a visible function table. 26 extern interface MTLFunctionHandle 27 { 28 ///The device object that created the shader function. 29 @selector("device") 30 MTLDevice device(); 31 32 ///The shader function’s type. 33 @selector("functionType") 34 MTLFunctionType functionType(); 35 36 @selector("name") 37 NSString name(); 38 39 } 40 41 ///A collection of model data for GPU-accelerated intersection of rays with the model. 42 extern interface MTLAccelerationStructure 43 { 44 ///The size of the acceleration structure’s memory allocation, in bytes. 45 @selector("size") 46 NSUInteger size(); 47 48 // MTLResourceID gpuResourceID(); 49 } 50 51 ///A table of intersection functions that Metal calls to perform ray-tracing intersection tests. 52 extern interface MTLIntersectionFunctionTable 53 { 54 ///Sets an entry in the table. 55 @selector("setFunction:atIndex:") 56 void setFunction(MTLFunctionHandle, NSUInteger index); 57 } 58 59 ///A table of shader functions visible to your app that you can pass into compute commands to customize the behavior of a shader. 60 extern interface MTLVisibleFunctionTable 61 { 62 ///Sets a table entry to point to a callable function. 63 @selector("setFunction:atIndex:") 64 void setFunction(MTLFunctionHandle, NSUInteger index); 65 66 ///Sets a range of table entries to point to an array of callable functions. 67 @selector("setFunctions:withRange:") 68 void setFunctions(const(MTLFunctionHandle)*, NSRange range); 69 70 // MTLResourceID gpuResourceID(); 71 } 72 73 struct MTLVertexAmplificationViewMapping 74 { 75 ///An offset into the list of render targets. 76 uint renderTargetArrayIndexOffset; 77 ///An offset into the list of viewports. 78 uint viewportArrayIndexOffset; 79 } 80 81 extern interface MTLRenderCommandEncoder : MTLCommandEncoder 82 { 83 @selector("setViewport:") 84 void setViewport(MTLViewport); 85 86 ///Sets the current render pipeline state object. 87 @selector("setRenderPipelineState:") 88 void setRenderPipelineState(MTLRenderPipelineState pipelineState); 89 90 ///Sets how to rasterize triangle and triangle strip primitives. 91 @selector("setTriangleFillMode:") 92 void setTriangleFillMode(MTLTriangleFillMode); 93 94 ///Sets the winding order of front-facing primitives. 95 @selector("setFrontFaceWinding:") 96 void setFrontFaceWinding(MTLWinding); 97 98 ///Specifies whether to cull primitives when front- or back-facing. 99 @selector("setCullMode:") 100 void setCullMode(MTLCullMode); 101 102 ///Sets the depth and stencil test state. 103 @selector("setDepthStencilState:") 104 void setDepthStencilState(MTLDepthStencilState); 105 106 ///Sets a buffer for the vertex function. 107 @selector("setVertexBuffer:offset:atIndex:") 108 void setVertexBuffer(MTLBuffer vertexBuffer, NSUInteger offset, NSUInteger index); 109 110 ///Sets an array of buffers for the vertex function. 111 @selector("setVertexBuffers:offsets:withRange:") 112 void setVertexBuffers(const(MTLBuffer)* buffers, const(NSUInteger)* offsets, NSRange range); 113 114 ///Sets where the data begins in a buffer already bound to the vertex shader. 115 @selector("setVertexBufferOffset:atIndex:") 116 void setVertexBufferOffset(NSUInteger offset, NSUInteger index); 117 118 ///Sets a block of data for the vertex shader. 119 @selector("setVertexBytes:length:atIndex:") 120 void setVertexBytes(const(void)* bytes, NSUInteger length, NSUInteger index); 121 122 ///Sets a sampler for the vertex function. 123 // @selector("setVertexSamplerState:atIndex:") 124 // void setVertexSamplerState(MTLSamplerState sampler, NSUInteger index); 125 126 ///Sets a sampler for the vertex function, specifying clamp values for the level of detail. 127 @selector("setVertexSamplerState:lodMinClamp:lodMaxClamp:atIndex:") 128 void setVertexSamplerState(MTLSamplerState state, float lodMinClamp, float lodMaxClamp, NSUInteger index); 129 130 ///Sets multiple samplers for the vertex function. 131 @selector("setVertexSamplerStates:withRange:") 132 void setVertexSamplerStates(const(MTLSamplerState)* samplers, NSRange range); 133 134 ///Sets multiple samplers for the vertex function, specifying clamp values for the level of detail of each sampler. 135 @selector("setVertexSamplerStates:lodMinClamps:lodMaxClamps:withRange:") 136 void setVertexSamplerStates( 137 const(MTLSamplerState)* samplers, 138 const(float)* lodMinClamps, 139 const(float)* lodMaxClamps, 140 NSRange range 141 ); 142 143 ///Sets a texture for the vertex function. 144 @selector("setVertexTexture:atIndex:") 145 void setVertexTexture(MTLTexture texture, NSUInteger index); 146 147 ///Sets an array of textures for the vertex function. 148 @selector("setVertexTextures:withRange:") 149 void setVertexTextures(const(MTLTexture)* textures, NSRange range); 150 151 ///Sets a visible function table for the vertex function. 152 @selector("setVertexVisibleFunctionTable:atBufferIndex:") 153 void setVertexVisibleFunctionTable(MTLVisibleFunctionTable, NSUInteger bufferIndex); 154 155 ///Sets an array of visible function tables for the vertex function. 156 @selector("setVertexVisibleFunctionTables:withBufferRange:") 157 void setVertexVisibleFunctionTables(const(MTLVisibleFunctionTable)*, NSRange range); 158 159 ///Sets a intersection function table for the vertex function. 160 @selector("setVertexIntersectionFunctionTable:atBufferIndex:") 161 void setVertexIntersectionFunctionTable(MTLIntersectionFunctionTable, NSUInteger index); 162 163 ///Sets an array of intersection function tables for the vertex function. 164 @selector("setVertexIntersectionFunctionTables:withBufferRange:") 165 void setVertexIntersectionFunctionTables(const(MTLIntersectionFunctionTable)*, NSRange range); 166 167 ///Sets an acceleration structure for the vertex function. 168 @selector("setVertexAccelerationStructure:atBufferIndex:") 169 void setVertexAccelerationStructure(MTLAccelerationStructure, NSUInteger bufferIndex); 170 171 ///Sets a buffer for the fragment function. 172 @selector("setFragmentBuffer:offset:atIndex:") 173 void setFragmentBuffer(MTLBuffer, NSUInteger offset, NSUInteger index); 174 175 ///Sets an array of buffers for the fragment function in a range of indices in the buffer argument table. 176 @selector("setFragmentBuffers:offsets:withRange:") 177 void setFragmentBuffers(const(MTLBuffer)*, const(NSUInteger)* offsets, NSRange range); 178 179 ///Sets where the data begins in a buffer already bound to the fragment shader. 180 @selector("setFragmentBufferOffset:atIndex:") 181 void setFragmentBufferOffset(NSUInteger offset, NSInteger index); 182 183 ///Sets a block of data for the fragment shader. 184 @selector("setFragmentBytes:length:atIndex:") 185 void setFragmentBytes(const(void)* bytes, NSUInteger length, NSUInteger index); 186 187 ///Sets a sampler state for the fragment function at an index in the sampler state argument table. 188 @selector("setFragmentSamplerState:atIndex:") 189 void setFragmentSamplerState(MTLSamplerState, NSUInteger index); 190 191 ///Sets an array of sampler states for the fragment function in a range of indices in the sampler state argument table. 192 @selector("setFragmentSamplerStates:withRange:") 193 void setFragmentSamplerStates(const(MTLSamplerState)*, NSRange range); 194 195 ///Sets a sampler state for the fragment function at an index in the sampler state argument table, specifying clamp values for the minimum and maximum level of detail. 196 @selector("setFragmentSamplerState:lodMinClamp:lodMaxClamp:atIndex:") 197 void setFragmentSamplerState(MTLSamplerState, float lodMinClamp, float lodMaxClamp, NSUInteger index); 198 199 ///Sets sampler states for the fragment function in a range of indices in the sampler state argument table, specifying clamp values for levels of detail. 200 @selector("setFragmentSamplerStates:lodMinClamps:lodMaxClamps:withRange:") 201 void setFragmentSamplerStates( 202 const(MTLSamplerState)*, 203 const(float)* lodMinClamps, 204 const(float)* lodMaxClamps, 205 NSRange range 206 ); 207 208 ///Sets a texture for the fragment function at an index in the texture argument table. 209 @selector("setFragmentTexture:atIndex:") 210 void setFragmentTexture(MTLTexture, NSUInteger index); 211 212 ///Sets an array of textures for the fragment function in a range of indices in the texture argument table. 213 @selector("setFragmentTextures:withRange:") 214 void setFragmentTextures(const(MTLTexture)*, NSRange range); 215 216 ///Sets a visible function table for the fragment function. 217 @selector("setFragmentVisibleFunctionTable:atBufferIndex:") 218 void setFragmentVisibleFunctionTable(MTLVisibleFunctionTable, NSUInteger bufferIndex); 219 220 ///Sets an array of visible function tables for the fragment function. 221 @selector("setFragmentVisibleFunctionTables:withBufferRange:") 222 void setFragmentVisibleFunctionTables(const(MTLVisibleFunctionTable)*, NSRange range); 223 224 ///Sets a intersection function table for the fragment function. 225 @selector("setFragmentIntersectionFunctionTable:atBufferIndex:") 226 void setFragmentIntersectionFunctionTable(MTLIntersectionFunctionTable, NSUInteger bufferIndex); 227 228 ///Sets an array of intersection function tables for the fragment function. 229 @selector("setFragmentIntersectionFunctionTables:withBufferRange:") 230 void setFragmentIntersectionFunctionTables(const(MTLIntersectionFunctionTable*), NSRange range); 231 232 ///Sets an acceleration structure for the fragment function. 233 @selector("setFragmentAccelerationStructure:atBufferIndex:") 234 void setFragmentAccelerationStructure(MTLAccelerationStructure, NSUInteger bufferIndex); 235 236 ///Sets the per-patch tessellation factors buffer for the tessellator. 237 @selector("setTessellationFactorBuffer:offset:instanceStride:") 238 void setTessellationFactorBuffer(MTLBuffer, NSUInteger offset, NSUInteger instanceStride); 239 240 ///Sets the scale factor applied to the per-patch tessellation factors. 241 @selector("setTessellationFactorScale:") 242 void setTessellationFactorScale(float); 243 244 ///Sets the number of output vertices for each input vertex, along with offsets into the layer and viewport lists. 245 @selector("setVertexAmplificationCount:viewMappings:") 246 void setVertexAmplificationCount(NSUInteger count, const(MTLVertexAmplificationViewMapping)* viewMappings); 247 248 ///Encodes a command to render a number of instances of primitives using vertex data in contiguous array elements, starting from the base instance. 249 @selector("drawPrimitives:vertexStart:vertexCount:instanceCount:baseInstance:") 250 void drawPrimitives(MTLPrimitiveType, NSUInteger vertexStart, NSUInteger vertexCount, NSUInteger instanceCount, NSUInteger baseInstance); 251 252 ///Encodes a command to render a number of instances of primitives using vertex data in contiguous array elements. 253 @selector("drawPrimitives:vertexStart:vertexCount:instanceCount:") 254 void drawPrimitives(MTLPrimitiveType, NSUInteger vertexStart, NSUInteger vertexCount, NSUInteger instanceCount); 255 256 ///Encodes a command to render one instance of primitives using vertex data in contiguous array elements. 257 @selector("drawPrimitives:vertexStart:vertexCount:") 258 void drawPrimitives(MTLPrimitiveType, NSUInteger vertexStart, NSUInteger vertexCount); 259 260 261 ///Encodes a command to render a number of instances of primitives using an index list specified in a buffer, starting from the base vertex of the base instance. 262 @selector("drawIndexedPrimitives:indexCount:indexType:indexBuffer:indexBufferOffset:instanceCount:baseVertex:baseInstance:") 263 void drawIndexedPrimitives( 264 MTLPrimitiveType, 265 NSUInteger indexCount, 266 MTLIndexType indexType, 267 MTLBuffer indexBuffer, 268 NSUInteger indexBufferOffset, 269 NSUInteger instanceCount, 270 NSInteger baseVertex, 271 NSUInteger baseInstance, 272 ); 273 274 ///Encodes a command to render a number of instances of primitives using an index list specified in a buffer. 275 @selector("drawIndexedPrimitives:indexCount:indexType:indexBuffer:indexBufferOffset:instanceCount:") 276 void drawIndexedPrimitives( 277 MTLPrimitiveType, 278 NSUInteger indexCount, 279 MTLIndexType indexType, 280 MTLBuffer indexBuffer, 281 NSUInteger indexBufferOffset, 282 NSUInteger instanceCount, 283 ); 284 285 ///Encodes a command to render one instance of primitives using an index list specified in a buffer. 286 @selector("drawIndexedPrimitives:indexCount:indexType:indexBuffer:indexBufferOffset:") 287 void drawIndexedPrimitives( 288 MTLPrimitiveType, 289 NSUInteger indexCount, 290 MTLIndexType indexType, 291 MTLBuffer indexBuffer, 292 NSUInteger indexBufferOffset, 293 ); 294 295 ///Encodes a command to render a number of instances of tessellated patches. 296 @selector("drawPatches:patchStart:patchCount:patchIndexBuffer:patchIndexBufferOffset:instanceCount:baseInstance:") 297 void drawPatches( 298 NSUInteger numberOfPatchControlPoints, 299 NSUInteger patchStart, 300 NSUInteger patchCount, 301 MTLBuffer patchIndexBuffer, 302 NSUInteger patchIndexBufferOffset, 303 NSUInteger instanceCount, 304 NSUInteger baseInstance, 305 ); 306 307 ///Encodes a command to render a number of instances of tessellated patches, using a control point index buffer. 308 @selector("drawIndexedPatches:patchStart:patchCount:patchIndexBuffer:patchIndexBufferOffset:controlPointIndexBuffer:controlPointIndexBufferOffset:instanceCount:baseInstance:") 309 void drawIndexedPatches( 310 NSUInteger numberOfPatchControlPoints, 311 NSUInteger patchStart, 312 NSUInteger patchCount, 313 MTLBuffer patchIndexBuffer, 314 NSUInteger patchIndexBufferOffset, 315 MTLBuffer controlPointIndexBuffer, 316 NSUInteger controlPointIndexBufferOffset, 317 NSUInteger instanceCount, 318 NSUInteger baseInstance, 319 ); 320 ///Declares that all command generation from the encoder is completed. 321 @selector("endEncoding") 322 void endEncoding(); 323 }