Multisampling is a mechanism to antialias all Vulkan primitives: points, lines, and polygons. The technique is to sample all primitives multiple times at each pixel. Each sample in each framebuffer attachment has storage for a color, depth, and/or stencil value, such that per-fragment operations apply to each sample independently. The color sample values can be later resolved to a single color (see Resolving Multisample Images and the Render Pass chapter for more details on how to resolve multisample images to non-multisample images).
Vulkan defines rasterization rules for single-sample modes in a way that is equivalent to a multisample mode with a single sample in the center of each pixel.
Each fragment includes a coverage value with rasterizationSamples
bits
(see Sample Mask).
Each fragment includes rasterizationSamples
depth values and sets of
associated data.
An implementation may choose to assign the same associated data to more
than one sample.
The location for evaluating such associated data may be anywhere within the
pixel including the pixel center or any of the sample locations.
When rasterizationSamples
is VK_SAMPLE_COUNT_1_BIT
, the pixel
center must be used.
The different associated data values need not all be evaluated at the same
location.
Each pixel fragment thus consists of integer x and y grid coordinates,
rasterizationSamples
depth values and sets of associated data, and a
coverage value with rasterizationSamples
bits.
It is understood that each pixel has rasterizationSamples
locations
associated with it.
These locations are exact positions, rather than regions or areas, and each
is referred to as a sample point.
The sample points associated with a pixel must be located inside or on the
boundary of the unit square that is considered to bound the pixel.
Furthermore, the relative locations of sample points may be identical for
each pixel in the framebuffer, or they may differ.
If the current pipeline includes a fragment shader with one or more
variables in its interface decorated with Sample
and Input
, the
data associated with those variables will be assigned independently for each
sample.
The values for each sample must be evaluated at the location of the sample.
The data associated with any other variables not decorated with Sample
and Input
need not be evaluated independently for each sample.
If the standardSampleLocations
member of VkPhysicalDeviceLimits
is VK_TRUE
, then the sample counts VK_SAMPLE_COUNT_1_BIT
,
VK_SAMPLE_COUNT_2_BIT
, VK_SAMPLE_COUNT_4_BIT
,
VK_SAMPLE_COUNT_8_BIT
, and VK_SAMPLE_COUNT_16_BIT
have sample
locations as listed in the following table, with the ith entry in
the table corresponding to bit i in the sample masks.
VK_SAMPLE_COUNT_32_BIT
and VK_SAMPLE_COUNT_64_BIT
do not have
standard sample locations.
Locations are defined relative to an origin in the upper left corner of the
pixel.
Table 24.1. Standard sample locations
|
|
|
|
|
(0.5,0.5) | (0.25,0.25) (0.75,0.75) | (0.375, 0.125) (0.875, 0.375) (0.125, 0.625) (0.625, 0.875) | (0.5625, 0.3125) (0.4375, 0.6875) (0.8125, 0.5625) (0.3125, 0.1875) (0.1875, 0.8125) (0.0625, 0.4375) (0.6875, 0.9375) (0.9375, 0.0625) | (0.5625, 0.5625) (0.4375, 0.3125) (0.3125, 0.625) (0.75, 0.4375) (0.1875, 0.375) (0.625, 0.8125) (0.8125, 0.6875) (0.6875, 0.1875) (0.375, 0.875) (0.5, 0.0625) (0.25, 0.125) (0.125, 0.75) (0.0, 0.5) (0.9375, 0.25) (0.875, 0.9375) (0.0625, 0.0) |