AA down-filter introduction
Preface
Part of AMD's presentation materials that accompanied the release of R600 was a set of slides that outlined their new Custom Filter AA (CFAA) method. As well as an implementation of the traditional box down-filter for multisample resolve, as a post-filter, AMD also implemented programmable filtering for that stage in the modern real-time graphics pipeline.
The slides that outlined the new method were titled: Building a better filter. This investigation analyses that premise in more detail, in order to look at whether their initial CFAA filters are better than the traditional box filter alternative, where better is defined as improving overall image quality.
Introduction
In order to better understand how multisample antialiasing (MSAA) in modern graphics hardware works, this part of the article will quickly discuss pre- and post-filtering as means to remove geometry aliasing from an image.
We assume the reader realises that almost all the aliasing problems inherent to 3D rendering are a property of signal sampling, where the original data is sampled discretely and used to construct a new signal, the one that you see. Aliasing because of that can take many forms, and this article discusses just one.
Pre-filtering
Pre-filtering as applied to 3D graphics antialiasing determines final pixel colour as a function of the area of the subpixel covered by object geometries. Consider the simple case where for the target pixel, its internal area is covered 26% by a fully red triangle and 74% by a fully green triangle. The pixel colour is therefore determined by the exact area contribution of those two geometries and their colours.
The downside to pre-filtering antialiasing is the subpixel coverage is expensive to compute, and for high quality it requires integration over the subpixel area for each geometry contribution. The precision required for accurate subpixel area calculation can be formidable too, especially as screen size rises. So the per-pixel cost for exact area coverage for pre-filtered subpixel AA is considered too high to implement in real-time graphics hardware.
Post-filtering
Post-filtering is therefore the desired method for modern 3D graphics antialiasing. Sampling frequency is met by taking numbers of subpixel samples which approximate pixel coverage, and it's the chosen down-filter to combine the sample contributions that determines final pixel colour and therefore overall image quality.
We mentioned the box down-filter at the beginning of the article, and it's that which all modern 3D graphics hardware has implemented as its main post-filter recent years, when applied to the aliasing problem the hardware looks to solve with multisampling.
Multisampling
Multisampling takes discrete colour, depth (Z) and stencil samples at locations in the subpixel. For any given surface the hardware wants to apply AA to, a buffer the same size of the surface is created for the multisamples to be stored. Storage required for the multisample buffer is therefore a product of the number of samples, colour buffer depth and Z and stencil buffer depth.
For each sample contribution, depth and stencil are tested (usually in the pixel ROP) to determine pixel coverage by object geometry, and if the test passes, the colour of the fragment at that subpixel location is stored for that multisample.
NVIDIA Coverage Sampling
NVIDIA coverage sampling is the most recent departure from the norm in terms of sample contributions used for the down-filter, so we quickly mention it here. The hardware still takes discrete multisamples as outlined above, but also a number of extra depth tests are taken at subpixel locations in order to better determine geometry coverage.
The tests return a coverage mask for the subpixel, which is then used in the down-filter kernel to weight the colour data from the multisamples, to compute final pixel colour.