Instance Method

setScissorRects(_:)

Sets an array of scissor rectangles.

Declaration

func setScissorRects(_ scissorRects: [MTLScissorRect])

Parameters

scissorRects

An array of scissor rectangles.

Discussion

The maximum number of supported viewports and scissor rectangles varies by device. For more information, see Using Metal Feature Set Tables.

The rendering pipeline uses only one of the scissor rects to clip vertices. You select this scissor rect per primitive by specifying a [[viewport_array_index]] attribute on an output value from your vertex function.

Calling this method with an array of length 1 is equivalent to calling the setScissorRect(_:) method. Calling setScissorRect(_:) after calling setScissorRects(_:), and vice versa, overrides previously set scissor rectangles.

The number of scissor rectangles must match the number of viewports set by the setViewports(_:) method. If you want to use the same scissor rectangle for all viewports, call the setScissorRect(_:) method instead.

See Also

Setting Viewport and Scissor Behavior

Rendering to Multiple Viewports in a Draw Command

Select viewports and their corresponding scissor rectangles in your vertex shader.

func setViewport(MTLViewport)

Sets the viewport used for transformations and clipping.

Required.

func setViewports([MTLViewport])

Sets an array of viewports.

func setScissorRect(MTLScissorRect)

Sets the scissor rectangle for a fragment scissor test.

Required.

struct MTLViewport

A 3D rectangular region for the viewport clipping.

struct MTLScissorRect

A rectangle for the scissor fragment test.