Graphics Reference
In-Depth Information
memory footprint to increase by the MSAA factor. The same applies to the render target,
since it must store individual color values for each sample before they can be resolved to
a single value. Because of this, the MSAA sample count must be explicitly specified when
creating the render target and depth stencil resources, so that the runtime can allocate a
sufficient amount of memory. Also, the MSAA sample count must be exactly the same
for render targets and depth-stencil buffers that are simultaneously used for rendering.
Additional details for creating the resources needed for MSAA can be found in Chapter 2.
Rasterizer interaction with MSAA. When MSAA is enabled for rendering, the first modi-
fication to the pipeline is in the rasterization stage. Normally, during rasterization a triangle
is tested for coverage using a single point for each pixel as outlined above. In Direct3D 11,
this point is located in the exact center of the pixel, or 0.5 units from the upper-left corner
in both the X and Y directions. This point is also used for interpolating all vertex attri-
butes output from the previous stage (either the vertex shader, domain shader, or geometry
shader, depending on which stages are in use), including the depth used for performing
the depth test. When MSAA is enabled, multiple sample points within a pixel are used to
test for coverage. The location of these sample points is implementation-specific, although
typically these samples are arranged in a rotated grid pattern. An example of the sampling
points for MSAA and non-MSAA rasterization are shown in Figure 3.65.
When a depth stencil target and MSAA render target have been bound to the pipeline,
the rasterizer behavior is determined by the multisampleEnable member of the rasterizer
state. This parameter essentially toggles whether the rasterizer performs multiple coverage
tests for MSAA render targets. If it is disabled and an MSAA target is bound, then only a
single coverage test is performed at the pixel center. If the coverage test passes, the pixel
shader result is written to all subsamples. If it does not pass, then none of them are writ-
ten to. This selectable MSAA operation allows a portion of a scene to be rendered using
the multi-sampling functionality, while other portions of the scene that don't require anti-
aliasing (such as 2D sprites for a user interface) can be rendered in the normal fashion.
This produces a consistent appearance for these scene elements that don't use anti-aliasing,
and also improves performance by reducing the number of coverage tests that are needed.
Figure 3.66. The difference between a rendering with and without MSAA enabled.
Search WWH ::




Custom Search