GX State

State Issuing vs. the Display List

In this document we describe the following items:

This information is useful for various purposes: constructing display lists, optimizing function call patterns, etc.

The register types in the tables below are as follows:

Register Type Description
CP Command Processor
XF Transform unit
RS Raster pipe state

Note: In the Revolution SDK, the order in which the GX Library issues commands is different from that of the GAMECUBE SDK. This is to improve the internal processing efficiency of the graphics processor. Specifically, most states due to the XF command will be delayed (apart from a few exceptions, such as loading a matrix).

Nice GX Functions

We begin by describing the "nice" GX functions. These functions each affect unique registers, and they insert their command tokens immediately (leaving no pending state). They are easy to put into display lists. 

Functions Register Type
GXSetArray CP
GXInvalidateVtxCache CP
GXLoadPosMtxImm/Indx XF
GXLoadNrmMtxImm/Imm3x3/Indx3x3 XF
GXLoadTexMtxImm/Indx XF
GXSetClipMode XF
GXLoadLightObjImm XF
GXLoadLightObjIndx XF
GXSetTevInd* (all the various functions to set indirect modes) RS
GXSetTevDirect RS
GXSetIndTexMtx RS
GXPixModeSync RS
GXTexModeSync RS
GXSetDrawSync RS
GXSetCopyClear RS
GXSetCopyFilter RS
GXClearBoundingBox RS
GXSetZMode RS
GXSetDstAlpha RS
GXSetFieldMask RS
GXSetScissor RS
GXSetScissorBoxOffset RS
GXSetTevColor RS
GXSetTevColorS10 RS
GXSetTevKColor RS
GXSetAlphaCompare RS
GXSetZTexture RS
GXSetFog RS
GXSetFogRangeAdj RS

Functions with Register Conflicts

These functions conflict with others that use the same registers. They can be put into display lists carefully as long as you understand that doing so will affect all settings sharing the same registers. 

Note: Some of the register conflicts are also listed in the next section.

It is possible to work around any RS register conflict (it is not possible for CP or XF registers). There is a mask register that can be used to write only certain bits within a RS register. Given that it takes time to set the mask register, none of the current GX functions use this feature. The one exception is GXSetCoPlanar (which would otherwise conflict with the genmode register). Future revisions of GX may include functions that utilize the mask register. If you think you can greatly benefit from using the mask register, please contact Developer Support with your reasons.

Functions Shared Register Name Register Type
GXSetBlendMode cmode0 RS
GXSetColorUpdate cmode0 RS
GXSetAlphaUpdate cmode0 RS
GXSetDither cmode0 RS
GXSetZCompLoc peCtrl RS
GXSetPixelFmt peCtrl RS
GXSetTevOp (invokes the following four functions) RS
GXSetTevColorIn (shares register with TevColorOp[stage]) RS
GXSetTevAlphaIn (shares register with TevAlphaOp[stage]) RS
GXSetTevColorOp (see above) RS
GXSetTevAlphaOp (see above and below) RS
GXSetTevSwapMode (shares register with TevAlphaOp[stage]) RS
GXSetTevKColorSel (Two stages per register, also SwapTable) RS
GXSetTevKAlphaSel (Two stages per register, also SwapTable) RS
GXSetTevSwapModeTable (shares reg's with Ksel's; 1st table in 1st 2 reg's, etc.) RS
GXSetIndTexCoordScale (Two stages per register) RS
GXSetTexCoordScaleManually suTs0[coord], suTs1[coord] RS
GXSetTexCoordCylWrap suTs0[coord], suTs1[coord] RS
GXSetTexCoordBias suTs0[coord], suTs1[coord] RS
GXEnableTexOffsets suTs0[coord] RS
GXSetLineWidth lpsize RS
GXSetPointSize lpsize RS
GXSetFieldMode lpsize (also texture flush; see below) RS
GXInvalidateTexRegion (texture flush issue; see below) RS
GXInvalidateTexAll (texture flush issue) RS
GXPreLoadEntireTexture (texture flush issue) RS

The "texture flush issue" means that a certain texture register must be written in order to force a texture system flush.
That register (imask) also happens to control which textures are direct and which are indirect. Refer to the next section (Note: information on imask is not included).

Functions that Set Pending State

These functions can usually be placed in a display list, but there are various issues involved since these functions are not necessarily straightforward in their operation. 'Lazy' means that the register value is not sent right away, but only at the last moment. The following functions will flush any lazy (pending) state before they execute their intended task:

The scaling of texture coordinates is something that also occurs in a lazy fashion. The texture scale registers (suTs0 and suTs1) are per texture coordinate, not per texture. They are set based upon which texture coordinates are associated with which textures. Functions that can possibly affect this mapping thus trigger a flag to set these registers at the last moment, and this is indicated by 'scale issue' in the list below. This issue can be avoided by setting all of the scale values manually. GX allows this by calling GXSetTexCoordScaleManually.

The 'tmem region issue' means that these functions call the appropriate TMEM region allocator in order to know what region of TMEM to use. Putting these functions into display lists 'fixes' the region of TMEM that is used, and thus you must deal with TMEM allocation carefully.

Functions Shared Register Name (or issue) Register Type
GXSetNumTexGens genmode (lazy) RS
GXSetNumChans   genmode (lazy) RS
GXSetCullMode genmode (lazy) RS
GXSetNumTevStages genmode (lazy) (scale issue) RS
GXSetNumIndStages genmode (lazy) imask (lazy) (scale issue) RS
GXSetIndTexOrder imask (lazy) (scale issue) (all four stages in one register) RS
GXSetTevOrder (scale issue) (two stages per register) RS
GXLoadTexObjPreLoaded (scale issue) RS
GXLoadTexObj (scale issue) (tmem region issue) RS
GXLoadTlut (tmem region issue) RS
GXSetCurrentMtx (current matrix registers) CP, XF
GXSetTexCoordGen (current matrix registers) CP, XF
GXSetTexCoordGen2 (current matrix registers) CP, XF
GXSetChanAmbColor (writes whole register: COLOR0A0 or COLOR1A1) XF
GXSetChanMatColor (writes whole register: COLOR0A0 or COLOR1A1) XF
GXSetChanCtrl (delayed to improve processing efficiency) XF
GXSetProjection/v (delayed to improve processing efficiency) XF
GXSetViewport/Jitter (delayed to improve processing efficiency) XF
GXSetVtxDesc/v VCD registers, invertexspec (lazy) CP
GXClearVtxDesc VCD registers, invertexspec (lazy) CP
GXSetVtxAttrFmt/v VAT[vat] registers (lazy) CP
GXSetDispCopySrc (does not send any registers itself; stores to GX) RS
GXSetTexCopySrc (does not send any registers itself; stores to GX) RS
GXSetDispCopyDst (does not send any registers itself; stores to GX) RS
GXSetTexCopyDst (does not send any registers itself; stores to GX) RS
GXSetDispCopyFrame2Field (does not send any registers itself; stores to GX) RS
GXSetCopyClamp (does not send any registers itself; stores to GX) RS
GXSetDispCopyYScale (does not send any registers itself; stores to GX) RS
GXSetDispCopyGamma (does not send any registers itself; stores to GX) RS
GXCopyDisp (sends registers set by above) RS
GXCopyTex (sends registers set by above) RS

Note: GXCopyDisp and GXCopyTex may possibly change various other registers (including pectrl, zmode, and cmode0) depending upon the operation and what the register (shadow) was were before the operation. The old register shadow values are restored after the copy operation.

Other

The GXDraw* functions all get and restore the current VCD/VAT (based upon the GX shadow copies).

If a GX function was not mentioned in any of the above sections, then it probably has no business being in a display list.

Revision History

03/01/2006 Initial version.