Table of Contents Glide Programming Guide



Download 6.22 Mb.
Page71/106
Date03.02.2023
Size6.22 Mb.
#60547
1   ...   67   68   69   70   71   72   73   74   ...   106
GLIDEPGM

5Texture Memory


Each TMU has its own texture memory, which ranges in size from 2MB to 4MB depending on the system configuration. To download a texture into texture memory, one must complete the following steps:

  • Determine how much memory is required for the texture.

  • Determine the starting address and extent of free space. Is it adequate for the texture? Will a mipmap level straddle the 2Mbyte boundary in texture memory (thereby causing an error)?

  • Download the texture.

  • Identify the texture as the texel source for subsequent texture mapping operations.

Glide does no texture memory management; rather, it includes several functions that allow the application to manage it.

6Computing the Size of a Mipmap


The Glide functions grTexCalcMemRequired() and grTexTextureMemRequired() determine the storage requirements of a mipmap. Textures must start on an 8-byte boundary in memory. The size returned by these functions includes any bytes required to pad the texture to an 8-byte boundary, and may be added to the starting address of the texture to determine the next available location in texture memory.
Both routines use the texture format, aspect ratio, and range of LODs in the mipmap to compute the size. These values are arguments to grTexCalcMemRequired(); they are extracted from a GrTexInfo structure that is passed to grTexTextureMemRequired(). The other difference between the two routines is that grTexTextureMemRequired() has an evenOdd argument and can determine the memory requirements of a texture that will be split across two TMUs for trilinear filtering applications (see Example Texture Mapping.3 in the previous chapter).

  1. Table Managing Texture Memory.2 Glide constants that specify arguments to grTex functions.

The table below lists the constants used to name the values that can be specified as arguments to functions in the grTex family. The first column lists the argument names that are used in the function specifications. The second column gives the Glide type for the argument. The third column lists the constant name, and the fourth column gives a description.

If the function argument is named

and its type is

then these constants are valid values

and these are the consequences of choosing that value.

tmu

GrChipID_t

GR_TMU0
GR_TMU1
GR_TMU2

Selects the target TMU. The constant names it.

smallLOD
largeLOD
thisLOD

GrLOD_t

GR_LOD_256
GR_LOD_128
GR_LOD_64
GR_LOD_32
GR_LOD_16
GR_LOD_8
GR_LOD_4
GR_LOD_2
GR_LOD_1

The number in the constant is the largest of the texture. The aspect ratio determines the smaller dimension.

aspectRatio

GrAspectRatio_t

GR_ASPECT_8x1
GR_ASPECT_4x1
GR_ASPECT_2x1
GR_ASPECT_1x1
GR_ASPECT_1x2
GR_ASPECT_1x4
GR_ASPECT_1x8

The constant sets the aspect ratio of the textures in a mipmap.

format

GrTextureFormat_t

GR_TEXFMT_RGB_332
GR_TEXFMT_YIQ_422
GR_TEXFMT_ALPHA_8
GR_TEXFMT_INTENSITY_8
GR_TEXFMT_ALPHA_INTENSITY_44
GR_TEXFMT_P_8
GR_TEXFMT_ARGB_8332
GR_TEXFMT_AYIQ_8422
GR_TEXFMT_RGB_565
GR_TEXFMT_ARGB_1555
GR_TEXFMT_ARGB_4444
GR_TEXFMT_ ALPHA_INTENSITY_88
GR_TEXFMT_AP_88

See Table Managing Texture Memory.1 for a description of the texture formats.

evenOdd

FxU32

GR_MIPMAPLEVELMASK_EVEN
GR_MIPMAPLEVELMASK_ODD
GR_MIPMAPLEVELMASK_BOTH

Even LODs are GR_LOD_256, GR_LOD_64, GR_LOD_16, GR_LOD_4, and GR_LOD_1.
Odd LODs are GR_LOD_128, GR_LOD_32, GR_LOD_8, and GR_LOD_2.

range

GrTexBaseRange_t

GR_TEXBASE_256
GR_TEXBASE_128
GR_TEXBASE_64
GR_TEXBASE_32_TO_1

Specifies the base register when using more than one. A mipmap can be broken into four fragments. The number in the constant corresponds to the LOD number.

tableType
table

GrTexTable_t

GR_TEX_NCC0
GR_TEX_NCC1
GR_TEX_PALETTE

Each TMU can have two NCC tables and a palette. Load them one at a time with a general purpose routine.

mipmapMode
mode

GrMipMapMode_t

GR_MIPMAP_DISABLE
GR_MIPMAP_NEAREST
GR_MIPMAP_NEAREST_DITHER

Specifies the kind of mipmapping to perform.

FxU32 grTexCalcMemRequired( GrLOD_t smallLOD,
GrLOD_t largeLOD,
GrAspectRatio_t aspectRatio,
GrTextureFormat_t format

Download 6.22 Mb.

Share with your friends:
1   ...   67   68   69   70   71   72   73   74   ...   106




The database is protected by copyright ©ininet.org 2024
send message

    Main page