252 AMD Geode™ LX Processors Data Book
Graphics Processor
33234H
6.3.11 Image Compositing Using Alpha
Whereas the raster operation allows different streams of
data to be logically combined, alpha channel composition
allows two streams of data to be mathematically combined
based on the contents of their alpha channel, which is an
additional channel to the red, blue, and green data con-
tained in the stream. The use of alpha channel composition
allows the streams of data to be combined in more com-
plex functions than that available from the raster operation.
For example, assume that image A, containing a blue trian-
gle, is to be combined with image B, containing a red trian-
gle. These images can be combined such that image A sits
on top of image B or vice versa. The alpha values in these
images reflect the percentage of a given pixel that is cov-
ered by the image. In image A, for instance, a pixel com-
pletely within the triangle has an alpha value of 1, while a
pixel completely outside of the triangle has an alpha value
of 0. A pixel on the edge of the triangle has a value
between 0 and 1 depending on how much of it is covered
by the triangle. When combining these images such that A
appears over B, pixels within the blue triangle appear blue,
pixels outside the blue triangle but within the red triangle
appear red, and pixels entirely outside of both triangles are
black. Pixels on the edge of either triangle have their color
scaled by the percentage of the pixel that lies within the tri-
angle.
When working with images using alpha channels, it is
assumed that each pixel of the entire image is premulti-
plied by the alpha values at that pixel. This is assumed
since every compositing operation on the data stream
requires this multiplication. If an image has not been pre-
multiplied, the Graphics Processor can perform this multi-
plication in a single pass prior to setting up the composition
operation. By setting up the Graphics Processor to fetch
destination data, this operation can be done in-place with-
out requiring a temporary storage location to hold the multi-
plied image. Once the image is premultiplied, it can be
manipulated through alpha composition without ever hav-
ing to perform this multiplication step again.
Table 6-27 describes the various ways that the two images
can be composited using the alpha blender. For some of
these cases, a third alpha value, in addition to the image
stream data alphas is needed. This alpha, αR, is specified
in the GP_RASTER_MODE register (GP Memory Offset
38h). The two channels specified, A and B, represent the
two streams of image data being fetched by the Graphics
Processor as source and destination data. Use the CS bit
to select whether channel A gets source data or destination
data. Channel B always gets the data not selected on
channel A. Note that if the combination of OS and AS bits
in the GP_RASTER_MODE register select data from one
channel and α from another, then both source and destina-
tion data are required to correctly perform the BLT. It is up
to software to assure that the appropriate controls are set
in the GP_BLT_MODE register (GP Memory Offset 40h) to
fetch the required data. See Section 6.3.10 "Raster Opera-
tions (ROP)" on page 251 for details on how to program
these functions.
Alpha blending is NOT supported for 8-bpp color depth. For
16 and 32-bpp, the alpha unit supports all of the formats.
Note that the 0:5:6:5 format does not support an alpha
channel with the data. When using 0:5:6:5, alpha must
always be selected from the register or else it is the con-
stant 1 (100%) and selecting αA or αB yields indeterminate
results.
To perform the premultiply of a given data stream, use the
“A” operation in Table 6-27, but set the alpha select to αA
(AS = 00) instead of 1. In this case, the enable bits should
be set so that the operation only applies to the RGB values
(EN = 01).
The operation “A stop B” requires two passes through the
alpha unit. The first pass creates an “A in B” image and the
second pass uses this intermediate image and performs an
“A over B” operation.
The operation “A xor B” requires three passes through the
alpha unit. The first two perform “B held out by A” on each
image independently, and the final pass adds the two
images together using “A plus B.”
The result of an alpha calculation is clamped at the maxi-
mum pixel value. Thus, if the result of A + (1-α)B (the only
calculation that could possibly overflow) does overflow in a
given color channel, then the result for that channel is all
1s.
Table 6-27. Alpha Blending Modes
Operation Diagram FAFBDescription AS Bits OS Bits
CLEAR 0 0 Resulting image is clear.
A1
Α)
0 Display only one of the images (or
multiply an image by its alpha).
011
(00)
00
(00)