Useful Resolves
We know that the use of MSAA render
targets is only helpful when draw calls produce visible "jaggies".
In an ideal world the main geometry pass would be rendered in MSAA mode,
and then resolved to a non-MSAA render target. Any subsequent post-processing
passes would all be completed in non-MSAA mode. This would therefore
give rise to just a single resolve per frame.
However there are two reasons why a
post-processing technique may need to be performed in MSAA mode:
- If a post-processing technique
enables subsample based depth testing, it can result in an update to
some of the subsamples of a pixel.
- In a similar way, if alpha
blending is enabled, then subsample data is preserved through the blend
operation.
In these two cases it may indeed make
sense to resolve the render target for further passes. However these
two examples are the exception and it should be noted that for full
screen passes that do not enable depth testing or alpha blending, there
is precious little point in using MSAA mode.
Redundant Resolves
A technique that does not actually
draw any geometry, other than a full screen quad, will usually write
the same color to all subsamples in a MSAA render target (Figure 2).
The reason for this is that the pixel shader is only run once per pixel
and the whole pixel is covered. Effectively the MSAA buffer has been
turned into a non-MSAA buffer, and every further resolve operation on
this surface is redundant.
Aside from the obvious redundancy, once the
same color has been written to all subsamples of the corresponding pixels,
it should be noted that the MSAA depth buffer does not actually match
the silhouettes of the objects anymore.
Clearly the solution is to render these
passes in non-MSAA mode, thus completely avoiding the need to perform
resolves. The recommended way to avoid these unnecessary resolves is
as follows:
- Create the main frame buffer
(swap chain) in non-MSAA mode.
- Create an intermediate MSAA
render target where the main scene geometry is rendered, and anything
else that would result in "jaggies".
- Perform a resolve of the
intermediate MSAA render target to a non-MSAA surface.
- Ping pong between non-MSAA
render targets for the remaining passes (Figure 3).
To add a real world example to this
discussion, the following sequence of passes was uncovered during the
analysis of a recently released PC title:
- Render the geometry pass
into the main MSAA render target M
- Resolve M into a non-MSAA
render target A
- Render A on to M using a
full-screen quad
- Resolve M into A
- Render water to M
- Resolve M into A for further
post-processing
It is fairly obvious from an initial
glance at this sequence, that steps two through four are totally redundant.
In fact step three is actually harmful from a quality standpoint, as
it destroys the subsample color information.
|