GX Default TMEM configuration

Description

GXInit defines the default memory map for the TMEM (embedded texture memory) and allocates areas for the texture cache and texture look up table (TLUT). After that, unless the user changes the mapping method, the region for cache used for texture mapping called by the GXLoadTexObj function will be decided according to this default memory map. 

This default memory map uses the first half of the 1MB TMEM (the address of which corresponds to 0x00000-0x7FFFF, known as the Low Memory Bank) as sixteen 32KB cache areas. The region that corresponds to the second half of the address 0x80000-0xFFFFF is divided into two parts; 0x80000-0xBFFFF is used as eight 32-KB cache areas whereas 0xC0000-0xFFFFF is used as TLUT area for CI texture.

When a texture is used, one of these cache areas will be allocated. There are three factors that decide how to allocate the areas.

There are three types of texture formats: CI textures, RGBA8(32b) textures and others (normal). The following indicates how the area would be used in each case:

Normal, non-mipmapped:

As for normal textures (non CI, non RGBA8), only one area that corresponds to each map ID in the Low Memory Bank will be used for each texture.

 
0x00000-0x07FFF
0x08000-0x0FFFF
0x10000-0x17FFF
0x18000-0x1FFFF
0x20000-0x27FFF
0x28000-0x2FFFF
0x30000-0x37FFF
0x38000-0x3FFFF
0x40000-0x47FFF
0x48000-0x4FFFF
0x50000-0x57FFF
0x58000-0x5FFFF
0x60000-0x67FFF
0x68000-0x6FFFF
0x70000-0x77FFF
0x78000-0x7FFFF
Low Memory Bank
GX_TEXMAP0
 
GX_TEXMAP1
 
GX_TEXMAP2
 
GX_TEXMAP3
 
GX_TEXMAP4
 
GX_TEXMAP5
 
GX_TEXMAP6
 
GX_TEXMAP7
 
High Memory Bank
 
 
 
 
 
 
 
 
TLUT
0x80000-0x87FFF
0x88000-0x8FFFF
0x90000-0x97FFF
0x98000-0x9FFFF
0xA0000-0xA7FFF
0xA8000-0xAFFFF
0xB0000-0xB7FFF
0xB8000-0xBFFFF
0xC0000-0xFFFFF

Normal, Mimap ON:

For a normal mipmapped texture, two cache areas for the even and odd LODs need to be allocated. Each needs to be located in Low and High Memory Banks separately, so they will be allocated like the following:

 
0x00000-0x07FFF
0x08000-0x0FFFF
0x10000-0x17FFF
0x18000-0x1FFFF
0x20000-0x27FFF
0x28000-0x2FFFF
0x30000-0x37FFF
0x38000-0x3FFFF
0x40000-0x47FFF
0x48000-0x4FFFF
0x50000-0x57FFF
0x58000-0x5FFFF
0x60000-0x67FFF
0x68000-0x6FFFF
0x70000-0x77FFF
0x78000-0x7FFFF
Low Memory Bank
GX_TEXMAP0(EVEN)
 
GX_TEXMAP1 (ODD)
 
GX_TEXMAP2(EVEN)
 
GX_TEXMAP3 (ODD)
 
GX_TEXMAP4(EVEN)
 
GX_TEXMAP5 (ODD)
 
GX_TEXMAP6(EVEN)
 
GX_TEXMAP7 (ODD)
 
High Memory Bank
GX_TEXMAP0 (ODD)
GX_TEXMAP4 (ODD)
GX_TEXMAP1(EVEN)
GX_TEXMAP5(EVEN)
GX_TEXMAP2 (ODD)
GX_TEXMAP6 (ODD)
GX_TEXMAP3(EVEN)
GX_TEXMAP7(EVEN)
TLUT
0x80000-0x87FFF
0x88000-0x8FFFF
0x90000-0x97FFF
0x98000-0x9FFFF
0xA0000-0xA7FFF
0xA8000-0xAFFFF
0xB0000-0xB7FFF
0xB8000-0xBFFFF
0xC0000-0xFFFFF

CI, Mipmap OFF:

Color index textures will be treated in the same way as the normal non-mipmapped textures. TLUT information located in High Memory Bank will also be used.

 
0x00000-0x07FFF
0x08000-0x0FFFF
0x10000-0x17FFF
0x18000-0x1FFFF
0x20000-0x27FFF
0x28000-0x2FFFF
0x30000-0x37FFF
0x38000-0x3FFFF
0x40000-0x47FFF
0x48000-0x4FFFF
0x50000-0x57FFF
0x58000-0x5FFFF
0x60000-0x67FFF
0x68000-0x6FFFF
0x70000-0x77FFF
0x78000-0x7FFFF
Low Memory Bank
GX_TEXMAP0
 
GX_TEXMAP1
 
GX_TEXMAP2
 
GX_TEXMAP3
 
GX_TEXMAP4
 
GX_TEXMAP5
 
GX_TEXMAP6
 
GX_TEXMAP7
 
High Memory Bank
 
 
 
 
 
 
 
 
TLUT
0x80000-0x87FFF
0x88000-0x8FFFF
0x90000-0x97FFF
0x98000-0x9FFFF
0xA0000-0xA7FFF
0xA8000-0xAFFFF
0xB0000-0xB7FFF
0xB8000-0xBFFFF
0xC0000-0xFFFFF

CI, Mipmap ON:

For color index mipmapped textures, since the High Memory Bank will be used as the look up for TLUT, caches for both even and odd LODs need to be allocated in the Low Memory Bank. Hence, they will be allocated like the following:

 
0x00000-0x07FFF
0x08000-0x0FFFF
0x10000-0x17FFF
0x18000-0x1FFFF
0x20000-0x27FFF
0x28000-0x2FFFF
0x30000-0x37FFF
0x38000-0x3FFFF
0x40000-0x47FFF
0x48000-0x4FFFF
0x50000-0x57FFF
0x58000-0x5FFFF
0x60000-0x67FFF
0x68000-0x6FFFF
0x70000-0x77FFF
0x78000-0x7FFFF
Low Memory Bank
GX_TEXMAP0(EVEN)
GX_TEXMAP0 (ODD)
GX_TEXMAP1(EVEN)
GX_TEXMAP1 (ODD)
GX_TEXMAP2(EVEN)
GX_TEXMAP2 (ODD)
GX_TEXMAP3(EVEN)
GX_TEXMAP3 (ODD)
GX_TEXMAP4(EVEN)
GX_TEXMAP4 (ODD)
GX_TEXMAP5(EVEN)
GX_TEXMAP5 (ODD)
GX_TEXMAP6(EVEN)
GX_TEXMAP6 (ODD)
GX_TEXMAP7(EVEN)
GX_TEXMAP7 (ODD)
High Memory Bank
 
 
 
 
 
 
 
 
TLUT
0x80000-0x87FFF
0x88000-0x8FFFF
0x90000-0x97FFF
0x98000-0x9FFFF
0xA0000-0xA7FFF
0xA8000-0xAFFFF
0xB0000-0xB7FFF
0xB8000-0xBFFFF
0xC0000-0xFFFFF

RGBA8, Mipmap OFF:

RGBA8(32bit) textures are a special case; even the non-mipmapped textures need cache areas in both the Low and High Memory Banks. So the memory allocation is similar to the mipmapped normal texture case.

 
0x00000-0x07FFF
0x08000-0x0FFFF
0x10000-0x17FFF
0x18000-0x1FFFF
0x20000-0x27FFF
0x28000-0x2FFFF
0x30000-0x37FFF
0x38000-0x3FFFF
0x40000-0x47FFF
0x48000-0x4FFFF
0x50000-0x57FFF
0x58000-0x5FFFF
0x60000-0x67FFF
0x68000-0x6FFFF
0x70000-0x77FFF
0x78000-0x7FFFF
Low Memory Bank
GX_TEXMAP0
 
GX_TEXMAP1
 
GX_TEXMAP2
 
GX_TEXMAP3
 
GX_TEXMAP4
 
GX_TEXMAP5
 
GX_TEXMAP6
 
GX_TEXMAP7
 
High Memory Bank
GX_TEXMAP0
GX_TEXMAP4
GX_TEXMAP1
GX_TEXMAP5
GX_TEXMAP2
GX_TEXMAP6
GX_TEXMAP3
GX_TEXMAP7
TLUT
0x80000-0x87FFF
0x88000-0x8FFFF
0x90000-0x97FFF
0x98000-0x9FFFF
0xA0000-0xA7FFF
0xA8000-0xAFFFF
0xB0000-0xB7FFF
0xB8000-0xBFFFF
0xC0000-0xFFFFF

RGBA8, Mipmap ON:

RGBA8 (32b) format mipmapped textures are even more special. Two consecutive cache areas are necessary in both the Low and High Memory Banks. Because of this reason, it is not possible to allocate independent areas for all texture IDs in the High Memory Bank, therefore the same cache area is shared by GX_TEXMAP0 and GX_TEXMAP4. Be careful to avoid cache collision.

 
0x00000-0x07FFF
0x08000-0x0FFFF
0x10000-0x17FFF
0x18000-0x1FFFF
0x20000-0x27FFF
0x28000-0x2FFFF
0x30000-0x37FFF
0x38000-0x3FFFF
0x40000-0x47FFF
0x48000-0x4FFFF
0x50000-0x57FFF
0x58000-0x5FFFF
0x60000-0x67FFF
0x68000-0x6FFFF
0x70000-0x77FFF
0x78000-0x7FFFF
Low Memory Bank
GX_TEXMAP0(EVEN)
GX_TEXMAP1 (ODD)
GX_TEXMAP2(EVEN)
GX_TEXMAP3 (ODD)
GX_TEXMAP4(EVEN)
GX_TEXMAP5 (ODD)
GX_TEXMAP6(EVEN)
GX_TEXMAP7 (ODD)
High Memory Bank
GX_TEXMAP0 (ODD)
GX_TEXMAP4 (ODD)
GX_TEXMAP1(EVEN)
GX_TEXMAP5(EVEN)
GX_TEXMAP2 (ODD)
GX_TEXMAP6 (ODD)
GX_TEXMAP3(EVEN)
GX_TEXMAP7(EVEN)
TLUT
0x80000-0x87FFF
0x88000-0x8FFFF
0x90000-0x97FFF
0x98000-0x9FFFF
0xA0000-0xA7FFF
0xA8000-0xAFFFF
0xB0000-0xB7FFF
0xB8000-0xBFFFF
0xC0000-0xFFFFF

Cache Conflicts and Avoidance

As noted above, cache conflicts can occur with RGBA8 (32bit) mipmapped textures. There's also a possibility that RGBA8 texture affects caches for other types of texture. Here's an example:

GX_TEXMAP0 GX_TF_RGBA8, Mipmap ON.
GX_TEXMAP1 GX_TF_I8, Mipmap ON.
GX_TEXMAP2 GX_TF_C8, Mipmap ON.
GX_TEXMAP3 GX_TF_RGB565, Mipmap OFF.
GX_TEXMAP4 GX_TF_RGBA8, Mipmap OFF.
GX_TEXMAP5 GX_TF_RGBA8, Mipmap ON.

If multi-texturing is performed under this environment, cache conflicts may occur in the shared area for GX_TEXMAP0 and GX_TEXMAP4 and also in the shared area for GX_TEXMAP1 and GX_TEXMAP5. (Corresponding to the red areas in the figure below.)

 
0x00000-0x07FFF
0x08000-0x0FFFF
0x10000-0x17FFF
0x18000-0x1FFFF
0x20000-0x27FFF
0x28000-0x2FFFF
0x30000-0x37FFF
0x38000-0x3FFFF
0x40000-0x47FFF
0x48000-0x4FFFF
0x50000-0x57FFF
0x58000-0x5FFFF
0x60000-0x67FFF
0x68000-0x6FFFF
0x70000-0x77FFF
0x78000-0x7FFFF
Low Memory Bank
GX_TEXMAP0(EVEN)
GX_TEXMAP1 (ODD)
 
GX_TEXMAP2(EVEN)
GX_TEXMAP2 (ODD)
GX_TEXMAP3
 
GX_TEXMAP4
 
GX_TEXMAP5 (ODD)
 
 
High Memory Bank
GX_TEXMAP0 (ODD)
GX_TEXMAP4
GX_TEXMAP1(EVEN)
GX_TEXMAP5(EVEN)
 
 
TLUT
0x80000-0x87FFF
0x88000-0x8FFFF
0x90000-0x97FFF
0x98000-0x9FFFF
0xA0000-0xA7FFF
0xA8000-0xAFFFF
0xB0000-0xB7FFF
0xB8000-0xBFFFF
0xC0000-0xFFFFF

Even though a cache collision occurs, corrupt graphics will not occur. However, performance may be affected. So it's best to avoid the collision if possible. In this example, by switching the use of GX_TEXMAP1 and GX_TEXMAP2, and also switching GX_TEXMAP3 and GX_TEXMAP4, the sections will not be reused as shown in the table below. It also prevents the possibility of cache collision.

 
0x00000-0x07FFF
0x08000-0x0FFFF
0x10000-0x17FFF
0x18000-0x1FFFF
0x20000-0x27FFF
0x28000-0x2FFFF
0x30000-0x37FFF
0x38000-0x3FFFF
0x40000-0x47FFF
0x48000-0x4FFFF
0x50000-0x57FFF
0x58000-0x5FFFF
0x60000-0x67FFF
0x68000-0x6FFFF
0x70000-0x77FFF
0x78000-0x7FFFF
Low Memory Bank
GX_TEXMAP0(EVEN)
GX_TEXMAP1(EVEN)
GX_TEXMAP1 (ODD)
GX_TEXMAP2(EVEN)
 
GX_TEXMAP3
 
GX_TEXMAP4
 
GX_TEXMAP5 (ODD)
 
 
High Memory Bank
GX_TEXMAP0 (ODD)
GX_TEXMAP5(EVEN)
GX_TEXMAP2 (ODD)
GX_TEXMAP3
TLUT
0x80000-0x87FFF
0x88000-0x8FFFF
0x90000-0x97FFF
0x98000-0x9FFFF
0xA0000-0xA7FFF
0xA8000-0xAFFFF
0xB0000-0xB7FFF
0xB8000-0xBFFFF
0xC0000-0xFFFFF

The use of a four multi-texture environment (only GX_TEXMAP0 through GX_TEXMAP3) eliminates conflict concerns. Concerns therefore arise when more than five textures are used and there's an RGBA8 mipmapped texture.

TLUT

The addresses 0xC0000-0xFFFFF in the High Memory Bank are allocated as TLUT for color index textures, sixteen 256-entry tables (using eight kilobytes each), and four 1024-entry tables (using 32 KB each), as shown in the following table:

 
0xC0000-0xC1FFF
0xC2000-0xC3FFF
0xC4000-0xC5FFF
0xC6000-0xC7FFF
 
0xDA000-0xDBFFF
0xDC000-0xDDFFF
0xDE000-0xDFFFF
0xE0000-0xE7FFF
 
0xE8000-0xEFFFF
 
0xF0000-0xF7FFF
 
0xF8000-0xFFFFF
 
TLUT
GX_TLUT0
GX_TLUT1
GX_TLUT2
GX_TLUT3
:
GX_TLUT13
GX_TLUT14
GX_TLUT15
GX_BIGTLUT0
GX_BIGTLUT1
  GX_BIGTLUT2
 GX_BIGTLUT3

See Also

GXInit
GXLoadTexObj
GXInitTexCacheRegion
GXInitTlutRegion
GXSetTexRegionCallBack
GXSetTlutRegionCallBack

Revision History

03/01/2006 Initial version.