Article

About Enhanced MSAA and Imageblock Sample Coverage Control

Learn about accessing multisample tracking data within a tile shader, enabling development of custom MSAA resolve algorithms, and more.

Overview

Multisample antialiasing (MSAA) is a technique used to improve the appearance of primitive edges by using multiple depth and color samples for each pixel. Figure 1 shows a triangle rendered without MSAA. Because each pixel has a single sample position, it’s either covered or not covered by the triangle, leading to jagged edges.

Figure 1

Antialiasing using a single sample per pixel

Antialiasing using a single sample per pixel

Figure 2 shows the same triangle rendered using 4x MSAA; that is, each pixel has four sampling positions. The graphics processing unit (GPU) averages the colors of each sample within the pixel to determine a final color. This process results in a smoother appearance and reduces the jagged edges.

Figure 2

Antialiasing using four samples per pixel

Antialiasing using four samples per pixel

Apple’s A-Series GPUs have an efficient MSAA implementation. The hardware tracks whether each pixel contains a primitive edge so that your blending executes per sample only when necessary. If all samples in a pixel are covered by a single primitive, the GPU blends only once for the entire pixel.

Imageblock Sample Coverage Control

Metal 2 on A11 tracks the number of unique samples (or colors) for each pixel, updating this information as new primitives are rendered. For example, the pixel in Figure 3 contains the edges of two overlapping triangles, and the sample positions are covered by three unique colors. In current A-Series GPUs, this pixel blends each of the three covered samples. On the A11 GPU, this pixel blends only twice because two of the covered samples share the same color. In this case, the color at index 1 is a blend of green and pink, and the color at index 2 is pink.

Figure 3

One pixel that contains three unique samples

One pixel that contains three unique samples

Metal 2 on A11 can reduce the number of unique colors in a pixel. In Figure 4, an additional opaque triangle is rendered on top of the earlier primitives. Because all of the samples are covered by the new triangle and can be represented by a single color, the A11 GPU merges the three colors into one.

Figure 4

One pixel that contains one unique sample

One pixel that contains one unique sample

Additionally, you can access and modify sample coverage data in tile shaders to implement custom resolve algorithms. For example, given a complex scene containing separate render phases for opaque and translucent geometry, you can add a tile shader to resolve the sample data for the opaque geometry before blending the translucent geometry. With Metal 2 on A11, this tile shader works on data in local memory and can be part of the opaque geometry phase, as shown in Figure 5.

Figure 5

Using a tile shader to implement a custom resolve algorithm

Using a tile shader to implement a custom resolve algorithm.

See Also

GPU Family 4 Features

About Imageblocks

Learn how imageblocks allow you to define and manipulate custom per-pixel data structures in high-bandwidth tile memory.

About Tile Shading

Learn about combining rendering and compute operations into a single render pass while sharing local memory.

About Raster Order Groups

Learn about precisely controlling the order of parallel fragment shader threads accessing the same pixel coordinates.

About Threadgroup Sharing

Learn about the enhanced memory model that allows for flexible and efficient sharing of data between threads.