General Information about PEXlib Accumulation Buffers


See Accumulation Buffers for a list of PEXlib Accumulation Buffer function and related topics.

The accumulation buffer is an ancillary buffer useful in advanced rendering techniques that generally require rendering the entire scene, or some portion of it, multiple times and "accumulating" the resulting images. Such techniques include, but need not be limited to: antialiasing, motion blur, depth of field, and transparency. For more information on techniques which take advantage of the accumulation buffer, see the paper, "The Accumulation Buffer: Hardware Support for High-Quality Rendering", Computer Graphics, Volume 24, Number 4, August, 1990, pp. 309-318, written by Paul Haeberli and Kurt Akeley.

Accumulation is performed by adding the contents of an image (and possibly ancillary components of an image such as alpha values) to the buffer. Accumulation occurs using one of the following techniques, or by some combination:

At the end of accumulation, the buffer is typically transferred to a drawable to display the resulting image.

Accumulation buffers are not drawables; renderers cannot render directly to accumulation buffers. The images used during accumulation may consist of pixels that are the result from PEX rendering, so that in fact the accumulation buffers are "indirectly rendered". Both the accumulation buffers and the accumulated images must contain colors which are the result of the application of the color approximation steps. Therefore, accumulation is defined only for component visuals, i.e. those visuals which have X11 pixel values that directly specify each of the red, green and blue components. See the definition of DirectColor and TrueColor visuals in the core X11 specification for more detail on visual types.

Since accumulation is performed on images, the accumulation buffer is originally loaded from a drawable and has drawables accumulated into it. Core X11 semantics provide no mechanism to specify the existence of ancillary buffers such as the accumulation buffer or alpha buffer. These ancillary buffers may be described by the PEXGetAncillaryBufferInfo function which the client uses to determine capabilities of a drawable. If the implementation supports drawables with an alpha buffer capability, then a PEX implementation supporting accumulation buffers must support the drawables with sufficient alpha planes to allow for accumulation of the ancillary alpha values. Additionally, the total depth of the accumulation buffer must be equal to or greater than the total depth of the drawable to which it is associated, and the depth of each component (red, green, blue, and if supported, alpha) must also be equal to or greater than the depth of each component. Also, since the accumulation buffer is an ancillary buffer to the drawable, it has the same width and height as the drawable.

If the drawable with which an accumulation buffer is associated is resized, all subsequent PEXAccumulateBuffer and PEXReturnAccumulationBuffer requests are ignored until the client makes a PEXLoadAccumulationBuffer or PEXFreeAccumulationBuffer request. The ignored accumulation buffer requests cause no further action and generate no errors. However, a PEXLoadAccumulationBuffer request may generate a BadAlloc error if the implementation attempts to resize the accumulation buffer due to its associated drawable being resized.

If the drawable with which an accumulation buffer is associated is destroyed, the implementation performs an implicit PEXFreeAccumulationBuffer.

If the drawable associated with an accumulation buffer is moved, exposed, or occuluded, the implementation continues processing subsequent accumulation buffer requests using the newly modified drawable.

Typical methods of using the accumulation buffer are as follows:

  1. Accumulate source images with source weights between 0.0 and 1.0, a destination weight of 1.0, and return without scaling. One application of this approach is for the blending of images into an accumulation buffer which has a depth that is not sufficiently deeper than the source image to allow for overflow, also known as pixel saturation, on addition. The final image returned is the non-normalized result of the multiple accumulations.

  2. Accumulate source images with source and destination weights of 1.0, and return after scaling by 1/n, where n is the number of accumulations. For sufficiently deep accumulation buffers where overflow is generally not a problem, the image is added to the accumulation buffer. When the image is returned, it is averaged by the number of accumulations. Some implementations may recognize the 1.0 source weight and skip the multiplication on each accumulation of each pixel.

  3. If the accumulation buffer is not sufficiently deep to avoid the posibility of overflow, and the number of accumulations is not known until all the accumulations are complete, then it is possible to adjust the running average by using both the source and destination weight factors. The return is then done without scaling.