ATI 3D RAGE WHITE PAPERS

Contents:

3D Rage Chipset Features

3D Rage Graphics Pipeline

ATI 3D CIF API Overview

ATI 3D Rage Chipset Features

Introduction

The ATI 3D RAGE Family of chips is a highly integrated mach64 graphics accelerator with superior support for 3D and motion video. It is ideal for gaming, consumer PCs, and multimedia workstations. The 3D RAGE will lead the implementation of 3D functionality across the ATI product line over the next two years.

The core hardware accelerated 3D features of the 3D RAGE family of chips include:

This rich feature set was determined by researching the needs of the development community. These are the most common 3D features utilized in 3D games, web content and other applications. ATI also reviewed the needs of the major 3D API (Application Programming Interface) developers, such as Microsoft and their RealityLab and Direct3D APIs, Apple Computer and their QuickDraw3D API, Intel and their 3DR API, and others.

For accessing accelerated 3D features on the 3D RAGE under Windows 95, ATI provides a proprietary interface called ATI3DCIF (ATI 3D C InterFace). This low-level interface provides a set of functions for executing and managing 3D rendering operations such as primitive drawing, texture mapping, color shading, and color blending. Under Windows 95, applications may use Microsoft's DirectDraw to create the double buffer and texture map surfaces required by ATI3DCIF.

ATI3DCIF is a 3D-rendering interface. It does not perform 3D geometric transformations. It also does not implement any 2D blitting operations as these services are provided by the GDI and DirectDraw under Windows 95.

Please note that ATI3DCIF cannot be used with Direct3D within the same application (although ATI3DCIF may, and usually is, used with DirectDraw).

Enhanced Features of the 3D RAGE Pro

The 3D RAGE PRO is the third generation chipset in the 3D Rage product line. It is a highly integrated 64-bit graphics accelerator, which features full 2D acceleration, TV quality motion video and superior 3D acceleration. It incorporates comprehensive support for Intel's Accelerated Graphics Port (AGP) including 66 or 133 MHz fully pipelined operation with sideband.

Following are the features provided by the 3D RAGE PRO:

General Features

3D Acceleration


2D Acceleration

Motion Video Acceleration

ATI Multimedia Channel













ATI 3D Rage Graphics Pipeline

Introduction

ATI3DCIF is an ATI proprietary programming interface that exposes the 3D hardware rasterization functionality of the ATI 3D RAGE graphics accelerator. The focus of ATI3DCIF is to provide client applications with an interface for accelerating 3D rendering operations. Therefore, ATI3DCIF is a rendering interface, and as such, does not perform any 3D geometric transformations, 2D rendering operations, or memory management. Applications may use the DirectDraw component of Microsoft's DirectX or the GDI to perform memory management and 2D blitting operations.

3D Drawing Operations

ATI3DCIF accelerates the drawing of quadrangles, triangles, and lines. The 3D RAGE supports a rich set of orthogonal 3D drawing operations for texture mapping, shading, and alpha blending. The hardware can be conceived as a three-stage graphics pipeline with a Texture Mapper, Shader, and Alpha Blender stages, where each stage is dedicated to carrying out one of the rendering operations.

pipeline diagram

When all three components are on, the Shader is applied to texels fetched from the frame buffer by the Texture Mapper to simulate texture lighting effects, and the resulting pixels are passed on to the Alpha Blender. The operation of each element is described below.

Texture Mapper

Texels from the frame buffer are read into the pixel pipeline and filtered by one of the programmable filtering algorithms. The resulting texel may optionally be compared against a chroma key. If the texel matches the chroma key, it is discarded and the destination is left unaltered. Otherwise, the texel is passed on to the Shader stage of the pipe.

Shader

The Shader generates colors that can be applied to texels supplied by the Texture Mapper. If the Texture Mapper is off, these colors are passed to the Alpha Blender stage unaltered. The mechanism used to generate colors by the Shader is programmable, and allows for different shading methods such as solid, flat, and gouraud shading. If texture mapping is on, the method used to mix texels with the colors generated by the Shader (texture lighting) is also programmable. The resulting pixels from this stage are passed on to the Alpha Blending stage.

Alpha Blender

The alpha blender simply blends the output of the Shader stage with the pixel at the destination address in the frame buffer. Various source and destination alpha blending methods are available on the 3D RAGE. Alpha blending may be used to achieve special effects such as translucency and transparency.

The ATI3DCIF interface is composed of the following functional groups:

Library initialization functions allow the client application to load and unload the ATI3DCIF module. Library initialization must be performed prior to using any other library functions, and library termination must be performed after the client application has finished using the interface to free resources.

Texture Management functions are used by ATI3DCIF to manage the use of textures. Textures are registered with ATI3DCIF and given a unique handle. This handle is used to select the texture for rasterization during the texture mapping process.

Context Management functions allow the client application to create and modify a rendering context. A rendering context represents the collection of rendering states currently set for the 3D RAGE accelerator. The Rendering functions allow the application to render line, triangle, or quadrilateral primitives in primitive lists or strips.









ATI 3D CIF API Overview

Basic ATI3DCIF Operations

This section describes the basic operations for setting up and using ATI3DCIF. It covers ATI3DCIF initialization and describes the fundamentals of the ATI3DCIF rendering model, introducing concepts such as the rendering context and 3D rendering blocks. Finally, it demonstrates how an application can retrieve ATI3DCIF module and graphics subsystem information.

Initializing ATI3DCIF

The first step to use ATI3DCIF is to load and initialize the ATI3DCIF.DLL module. This is done by calling ATI3DCIF_Init(). This DLL must be loaded before any ATI3DCIF functions are called. Before the application terminates, it must unload ATI3DCIF.DLL by calling ATI3DCIF_Term().

Creating a Rendering Context

After the ATI3DCIF module is loaded, the application must create a rendering context to use the 3D features of the 3D RAGE. A rendering context is created by calling ATI3DCIF_ContextCreate(). When a rendering context is created, the RAGE's 3D rendering components are configured into a default state. A unique handle identifies this rendering context, and the application must pass this handle to ATI3DCIF functions whenever referencing or modifying the rendering context. For example, to change the context shading mode, the application must call ATI3DCIF_ContextSetState() with the context handle as the first argument, and the appropriate state modification flag and data as the other arguments.

When the application no longer needs the rendering context, it may destroy it by calling ATI3DCIF_ContextDestroy(). An application must destroy the rendering context before terminating. The application must then call ATI3DCIF_Term() to unload the ATI3DCIF module.

Rendering 3D Primitives

When an application is ready to render 3D primitives, it must set the 3D RAGE into a 3D operating mode. While in this mode, the application will not be able to perform 2D operations, such as blitting, rectangle fills, or page flipping. The application should perform all 3D rendering operations while in 3D mode and switch back to 2D mode to perform 2D operations.

To switch to 3D mode, the application must call ATI3DCIF_RenderBegin(). While in this mode, primitive lists and strips may be rendered by calling ATI3DCIF_RenderPrimList() or ATI3DCIF_RenderPrimStrip(), respectively. To switch back to 2D rendering mode after rendering all the 3D primitives, the application must call ATI3DCIF_RenderEnd().

When switching between 2D and 3D modes, ATI3DCIF_RenderBegin() saves the state of the 2D engine, and ATI3DCIF_RenderEnd() restores the state of the 2D engine. To minimize the overhead incurred while saving and restoring, the applications should minimize the number of ATI3DCIF_RenderBegin() - ATI3DCIF_RenderEnd() blocks (3D rendering blocks) in each frame update. Ideally, there should be only one 3D rendering block per frame update, and all 3D primitive lists or strips should be rendered within this block. To accomplish this, the application may need to reorganize the order in which rendering operations are performed. 2D and 3D operations should be separated, and all 3D operations should be performed within one 3D rendering block whenever possible.

Modifying the Rendering Context

Rendering states within the rendering context may be modified by calling ATI3DCIF_ContextSetState(). The first argument to this function is the handle of the rendering context to be modified. The second argument specifies which rendering state or property will be modified and the last argument specifies a pointer to the new state or property.

Getting ATI3DCIF Module and Graphics Subsystem Information

An application may retrieve information about ATI3DCIF capabilities and the graphics subsystem by calling ATI3DCIF_GetInfo(). This function takes a pointer to a C3D_3DCIFINFO structure as its only argument. Upon return, this structure contains various information regarding the module and graphics subsystem, including the ASIC identification number, ASIC revision, pointer to the frame buffer, and total RAM on the accelerator card.

ATI3DCIF Primitive Types

ATI3DCIF supports line, triangle, rectangle, point, and quadrilateral primitive types. The primitive type specifies the geometric interpretation of a vertex set during rasterization. For example, if the primitive type is set to triangle, subsequent calls to ATI3DCIF_RenderPrimList() will interpret the list of vertices as triangles and will consume three vertices for each triangle drawn.

The possible primitive types are: Line Primitive, Triangle List or Strip Primitive (default), Quadrilateral List or Strip Primitive, screen aligned Rectangle List or Strip Primitive, Point List or Strip Primitive.

Vertex Data Formats

ATI3DCIF offers a number of vertex data formats to represent vertices. The choice of which format to use depends on the vertex information needed. For example, if an application does not perform texture mapping, it can represent vertices in a format that does not hold texture coordinate data. The vertex data type may be changed by calling ATI3DCIF_ContextSetState().

Shading Modes

Primitives can be rendered in solid, flat, or gouraud shading under ATI3DCIF. When solid shading is enabled, all primitives are rendered in the rendering context's current solid color. This color is set to black on context creation. It may be changed by calling ATI3DCIF_ContextSetState().

ATI3DCIF performs shading according to the following:

None: the shading color is undefined

Solid: shade using the solid color from the rendering context

Flat: shade using the color of the last vertex in the primitive to color the primitive

Smooth: shade the primitive by linearly interpolating the color of its vertices from vertex to vertex

Flat shading renders the entire primitive in the color of the last vertex in the primitive. Gouraud shading interpolates the color of each vertex in the primitive from vertex to vertex, resulting in a smooth gradation of color across the face of the primitive. It is the default shading mode set on context creation.

Texture Mapping

The texture mapping operations supported by ATI3DCIF are perspective correction, texture lighting, texture filtering, texture transparency using either a chroma key in the RGB channel or a bit mask in the alpha channel, and mip-mapping. All of these operations are performed by the 3D RAGE hardware.

There are a number of requirements for texture mapping with the 3D RAGE. On non-AGP accelerator cards, textures must be placed in video memory. For this reason, ATI3DCIF does not support textures stored in system memory on PCI 3D Rage cards. Also, The width and height of each texture must be a power of two and cannot exceed 1024x1024.

Registering a Texture

The first step in using a texture is to load it into a region of video memory. The next step is to register the texture with ATI3DCIF. Registration provides ATI3DCIF with important information about the texture, such as its location in video memory, width, height, pixel format and bit depth, chroma key color, and whether it is a mipmap or not. When registered, the texture is assigned a unique handle, which is used to select it during rendering operations.

The registration information for a texture is contained within a structure defined by ATI3DCIF. The fields of the structure must be filled out prior to texture registration. For instance, ApvLevels[ ] is an array of host pointers to the individual maps which compose a mipmap texture. If mip-mapping is turned on within the application, apvLevels contains one or more valid elements. The first element (index 0) points at the base map and subsequent elements point at sequentially smaller maps.

This structure also defines the texel format used by the texture. The 3D RAGE supports the following texel formats:

Applying a Texture

Mapping a texture onto primitives takes two steps: (1) select the texture, and (2) enable texture mapping in the rendering context. Any primitives rendered with ATI3DCIF_RenderPrimList() or ATI3DCIF_RenderPrimStrip() will subsequently be textured until texture mapping is disabled again in the rendering context. By default, texture mapping is disabled when a rendering context is created.

ATI3DCIF will scale, orient, and apply perspective correction to the texture as it is rendered based on the texture coordinates set for the primitive vertices. These coordinates are represented by the s, t, and w members of the vertex structures. The application is responsible for setting these coordinates correctly to map the texture in the manner intended.

Setting Texture Filtering, Lighting, and Perspective Correction Levels

All rendering states in the rendering context related to texture mapping, such as texture filtering, lighting, and perspective correction level, may be modified by calling ATI3DCIF_ContextSetState(). ATI3DCIF allows different filtering to be performed on texture minification and magnification. When mipmapping, it supports filtering modes which filter within maps and blend the results of two maps. The filtering modes supported are as follows:

The following lists the supported lighting modes:

The perspective correction level is set by calling ATI3DCIF_ContextSetState(). ATI3DCIF provides ten perspective correction levels, from C3D_ETPC_NONE, which provides no correction, to C3D_ETPC_NINE, which provides full correction. The frame rate decreases with increased levels of perspective correction. No correction offers the best frame rate, while full correction offers the worst. The default level set on context creation is C3D_ETCP_THREE, which offers a good compromise between frame rate and the level of perspective correction.

Transparent Texture Mapping

ATI3DCIF provides two ways for a client application to perform texture transparency. The first method is to use a chroma key color in the texel's RGB data. The second method is to use a bit mask in the texel's alpha data (needless to say, this method only works for texel formats which have an alpha channel, such as RGB 4444, RGB 1555, and RGB 8888). Both methods are termed as texel operations, and either may be selected by calling ATI3DCIF_ContextSetState().

Palletized Textures

In addition to the texture formats supported by the 3D RAGE, the 3D RAGE II and RAGE Pro support CI8 and CI4 palettized textures. In the CI8 format, each texel is an 8-bit packed value which represents an index into a 256 color palette. In the CI4 format, each texel is a 4-bit packed index into a 16 color palette. The four bit texel values must be byte aligned and may be packed in either the low or high nibble. It is possible to compress two CI4 textures into the space of one CI8 texture by loading one into the low nibble and the other into the high nibble of each byte.

The 3D RAGE II and RAGE Pro support Z buffers for sorting primitives by their z values while rendering. Z buffers must be allocated in video memory and must be aligned on eight byte boundaries. An application can ensure Z buffers are aligned properly by using DirectDraw surfaces for the buffers, as DirectDraw surfaces are aligned on eight byte boundaries. Z buffers on the 3D RAGE II and RAGE Pro are 16 bits deep. This gives a resolution of 216 for z values. Applications should ensure that the range of z values used can be scaled within this resolution (for example 0 to 216 - 1) to avoid inaccuracies due to truncation error.

Under ATI3DCIF, the Z buffer is always associated with the drawing surface. For example, in a double buffer configuration where ATI3DCIF is only rendering to the back surface, the Z buffer will always be associated with the back surface. Therefore, the Z buffer must have the same pitch in pixels and height in scan lines as the drawing surface.

The following Z value comparisons are supported:

The following features have been added to ATI3DCIF to support the RAGE Pro:

Texture Compositing

Texture compositing is the process of combining two textures into one composite texture. This process may be used to apply a light map to a texture or to dissolve from one texture into another. Texture compositing allows an application to get more mileage out of its textures by combining and modifying them in unlimited ways. For example, multiple light maps may be applied to a single texture, eliminating the need to create unique, modified versions of the same texture. The two texture maps may have different dimensions. They may also have different texel formats, but with three restrictions:

1) A YUV or Y8 texture may not be mixed with any RGB formats.

2) An 8-bpp texture or 4-bpp texture may not be mixed with a 16-bpp or 32-bpp texture.

3) Paletted textures must share the same palette.

There are three possible texture composting functions in ATI3DCIF: blend, modulation, and specular-addition.

Blend

This is the default texture composite function. The two textures are combined by a blending factor

The blending factor may be any integer value between 0 and 15, giving 16 blending levels. By progressively increasing or decreasing the blending factor, the two texture maps may be gradually dissolved into one another.

Modulation

The two textures are combined according to the following equation:

final texel = primary texel x secondary texel

The two textures are simply multiplied together for the final texel. There is no blending factor affecting the modulation.

Specular-Addition

The two textures are combined according to the following equation:

final texel = primary texel x diffuse color + secondary texel

LOD Biasing

LOD (Level of Detail) biasing controls level switching during mipmapping. The LOD bias is an integer value between 0 and 15 which modifies the threshold stride at which the switch is made to the next smallest map.

Texture Clamping

Texture clamping allows a texture's S and T coordinates to each be clamped at 1.0. This prevents texture tiling, instead causing the texel at coordinate 1.0 to be replicated towards the edge of the primitive. The effect is that of smearing, and can be used to extend the edges of the texture to fill in the gaps when tiling is not desired.

Texture Coordinates

ATI3DCIF accepts homogeneous texture coordinates (s, t, and inverse w).

Alpha Blending

The RAGE's alpha blender may be used to combine source and destination pixels in accordance to source and destination blending factors which are functions of vertex alpha or RGB values. The equation used to determine the output destination pixel is the following:

output destination color = (source color x source blending factor) +

(current destination color x destination blending factor)

The source blending factor can be set to any of the following:

The destination blending factor can be set to any of the following:

CAUTION: Enabling alpha blending adds another process to the graphics pipeline, causing rendering performance to decrease. For the trivial case of source blending factor = (1, 1, 1) and destination blending factor = (0, 0, 0), the alpha blender is disabled and removed from the graphics pipeline. If the application does not intend to use alpha blending, it should disable this operation by forcing the source and destination blending factors to these states (which are set by default during context creation).

Destination Alpha Testing

Destination alpha testing is a mechanism for selectively writing source data to the destination buffer. This process compares the alpha value from one of six selectable sources to a reference value maintained in the rendering context. If the comparison passes, the RGB data of the primitive being rendered is written to the destination RGB channels, and the alpha from the selected source is written to the destination alpha channel. Otherwise, the destination remains unchanged. Conceptually, the process is similar to Z-buffering in that a decision is made to render a pixel based on the comparison of two values. But unlike Z-buffering, the alpha comparison reference is not the target destination pixel's alpha value, but a single reference value in the rendering context which is compared against for all pixels. Also, as mentioned, there are six sources of alpha test values, as opposed to one source of z data (the vertex z value).

Applying Fog

Fog is applied through a two step process. The first step is to set a fog color, and the next step is to enable fogging. Once enabled, the fog blending factor for each vertex is determined from its alpha value. This does not cause a conflict between fogging and alpha blending because the two operations are mutually exclusive. The manner in which the fog color is applied to the primitive depends on the current shading mode. For example, to interpolate the fog across the primitive, the shading mode should be set to smooth.

ATI3DCIF Viewport

ATI3DCIF renders primitives relative to a rectangular region called the viewport. Its top left corner defines the origin of the screen coordinate system in which primitives are drawn, and its width and height extents define the non-clipped rendering area. Parts of primitives which lie outside of this area are clipped by hardware during rendering. In addition, the viewport can be moved to change the logical origin of the screen coordinate system.

CAUTION: Pixels are clipped at the edges of the viewport during the last stage of the rendering process. Prior to reaching this stage, these pixels are still processed through the graphics pipeline although they are not rendered. If vertex coordinates extend beyond the viewport boundaries by a large amount, the graphics engine will end up processing a large number of pixels, which will never be rendered. This may have a detrimental effect on performance. For this reason, it may be necessary to pre-clip primitives in software if the clipping overhead proves to be less costly than the time spent processing unrendered pixels.

In addition, the viewport width cannot be extended past the current screen width.

ATI3DCIF Clipping Scissors

The ATI3DCIF clipping scissors define a rectangular region outside of which primitives are clipped. The behavior and performance constraints are the same as for the viewport described in the last section, except the origin is always fixed at the top left corner of the drawing surface.