Contents

drawPatches(numberOfPatchControlPoints:patchStart:patchCount:patchIndexBuffer:patchIndexBufferOffset:instanceCount:baseInstance:)

Encodes a draw command that renders multiple instances of tessellated patches.

Declaration

func drawPatches(numberOfPatchControlPoints: Int, patchStart: Int, patchCount: Int, patchIndexBuffer: (any MTLBuffer)?, patchIndexBufferOffset: 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 first patch the command draws.

  • patchCount:

    The number of patches the command draws for 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 patchIndexBuffer where the patch indices begin.

  • instanceCount:

    The number of times the command draws patchCount patches.

  • baseInstance:

    The lowest value the command passes to your vertex shader’s parameter with the instance_id attribute.

    The command assigns each drawing instance a unique instance_id value that increases from baseInstance through (baseInstance + instanceCount - 1). Your shader can use that value to identify which instance the vertex belongs to.

    For more information about the instance_id argument 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.

See Also

Drawing with tessellation patches