#include <revolution/gx.h> void GXSetArray( GXAttr attr, const void* base_ptr, u8 stride );
| attr | Specifies the attribute array name. Accepted values are:
|
||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| base_ptr | Pointer to the first element in the attribute data array. | ||||||||||||||||||||||||||||||||||
| stride | Stride in bytes between the attribute data elements. |
None.
This function sets the array base pointer and stride for a single attribute. The array base and stride are used to calculate the address of the indexed attribute data using the following equation:
attr_addr = base_ptr + attr_idx * stride
When drawing a graphics primitive that has been enabled to use indexed attributes (see the GXSetVtxDesc function), attr_idx is supplied in the vertex data. The format and size of the data in the array must also be described in the GXSetVtxAttrFmt function.
You can also index other data, such as matrices (see the GXLoadPosMtxIndx,GXLoadNrmMtxIndx3x3 andGXLoadTexMtxIndx functions), and light objects (see the GXLoadLightObjIndx function). For matrices and light objects, the size and format of the data to be loaded is implied by the function call.
There is a base pointer, base_ptr, for each type of attribute as well as for light data and matrices. Each attribute can be stored in its own array for maximum data compression (i.e., removal of redundant attribute data). The stride is in byte units and indicates the distance between attributes in the array.
Indexed data is loaded into a vertex cache in the graphics processor. The vertex cache fetches 32 bytes of data for each cache miss. As a result, there is a small performance benefit in aligning attribute arrays to 32 bytes, and in arranging vertex data so that it doesn't span 32-byte boundaries. Conveniently enough, the OSAlloc function returns 32-byte aligned pointers. For static data arrays, the ATTRIBUTE_ALIGN(32) macro (for the MetroWerks compiler) can be used to align base_ptr to 32 bytes, as in:
u32 mydata[] ATTRIBUTE_ALIGN(32) = {
// initialize data
};
2006/08/10 Corrected mistake with enum type.
2006/03/01 Initial version.
CONFIDENTIAL