drawIndexedPatches(numberOfPatchControlPoints:patchStart:patchCount:patchIndexBuffer:patchIndexBufferOffset:controlPointIndexBuffer:controlPointIndexBufferOffset:instanceCount:baseInstance:)
Encodes a draw command that renders multiple instances of tessellated patches with a control point index buffer.
Declaration
func drawIndexedPatches(numberOfPatchControlPoints: Int, patchStart: Int, patchCount: Int, patchIndexBuffer: (any MTLBuffer)?, patchIndexBufferOffset: Int, controlPointIndexBuffer: any MTLBuffer, controlPointIndexBufferOffset: Int, instanceCount: Int, baseInstance: Int)Parameters
- numberOfPatchControlPoints:
The number of control points for each patch, which needs to be in the range
[0, 32]. - patchStart:
The patch start index.
- patchCount:
The number of patches in each instance.
- patchIndexBuffer:
An Mtlbuffer instance that contains the indices to patches.
- patchIndexBufferOffset:
An integer that represents the location, in bytes, from the start of
patchIndexBufferwhere the patch indices begin. - controlPointIndexBuffer:
An Mtlbuffer instance that contains the indices to control points.
- controlPointIndexBufferOffset:
An integer that represents the location, in bytes, from the start of
controlPointIndexBufferwhere the control point indices begin. - instanceCount:
The number of times the command draws
patchCountpatches. - baseInstance:
The lowest value the command passes to your vertex shader’s parameter with the
instance_idattribute.The command assigns each drawing instance a unique
instance_idvalue that increases frombaseInstancethrough(baseInstance + instanceCount - 1). Your shader can use that value to identify which instance the vertex belongs to.For more information about the
instance_idargument attribute for vertex shaders, see the Metal Shading Language Specification.
Discussion
The method records the encoder’s current rendering state and resources the command needs as it runs. You can safely change the encoder’s render pipeline state to encode other commands after calling this method. Subsequent changes to the state don’t affect the commands already in the encoder’s MTLCommandBuffer.