MTLRasterizationRateMap
A compiled read-only instance that determines how to apply variable rasterization rates when rendering.
Declaration
protocol MTLRasterizationRateMap : NSObjectProtocol, SendableMentioned in
Overview
Use a rasterization rate map to reduce rendering quality in less-important or less-sampled regions of the render target, such as areas affected by blur effects or a far-away cascade of a shadow map.
By default, a render pass doesn’t have a rasterization rate map, and the viewport coordinate system maps exactly to physical pixels in the targeted textures. If you apply a rasterization rate map to a render pass, the viewport coordinate system becomes a logical coordinate system, and the rate map describes how to map logical coordinates to physical pixels in the render pass’s targets. You can specify different rasterization rates in different regions of the logical coordinate system. When you do, those logical units map to fewer physical pixels, which means you can use smaller render targets and render fewer pixels, saving both memory and processing time. For more information, see Rendering at different rasterization rates.
Don’t implement this protocol yourself; instead, create an MTLRasterizationRateMapDescriptor instance, configure it, and then call the makeRasterizationRateMap(descriptor:) on a device instance.
To apply a rasterization rate map to a render pass, set the render pass descriptor’s rasterizationRateMap property.
Configuring the rate map
A rasterization rate map specifies the size of the viewport coordinate space in logical units and one or more layer maps. A layer map partitions the viewport coordinate space into a 2D grid of cells and defines the rasterization rate for each cell. If you aren’t using layered rendering, provide a single layer map; otherwise, provide one layer map for each layer. For more information about layered rendering, see Rendering to multiple texture slices in a draw command.
You can query the physical size requirements for each layer in the render pass by calling the physicalSize(layer:) method. Your render targets need to be at least this large.