setScissorRects(_:)
Configures multiple rectangles for the fragment scissor test.
Declaration
func setScissorRects(_ scissorRects: [MTLScissorRect])Parameters
- scissorRects:
An array of Mtlscissorrect instances the command applies to the render pipeline for clipping.
Mentioned in
Discussion
The rendering pipeline discards any fragments that lie outside the scissor rectangle. The default scissor rectangle is the same size as the current render attachment, with its origin coordinates in the upper-left corner at (0, 0).
Use this method to configure a different scissor rectangle for multiple viewports you configure with the setViewports(_:) method. Multiple viewports give your app the ability to draw into separate areas of an image with a single draw call. You can either set a single scissor rectangle for all viewports with the setScissorRect(_:) method, or set each viewport’s rectangle with this method.
The maximum number of viewports and scissor rectangles a GPU supports varies by device family. For more information, see MTLGPUFamily and Detecting GPU features and Metal software versions.
The rendering pipeline sends each primitive to a single viewport and its associated scissor rectangle. You can select which viewport each primitive uses in your vertex shader by adding the [[viewport_array_index]] attribute to an output value.
The setScissorRect(_:) method is equivalent to calling this method with a single element in the scissorRects array.