gDPLoadTextureBlock [Macro]

Function

gDPLoadTextureBlock

Loads texture as a contiguous texture block

Syntax

#include <ultra64.h>        /* gbi.h */
gDPLoadTextureBlock(
        Gfx *gdl,
        u32 timg,
        u32 fmt,
        u32 siz,
        u32 width,
        u32 height,
        u32 pal,
        u32 cms,
        u32 cmt,
        u32 masks,
        u32 maskt,
        u32 shifts,
        u32 shiftt )
gsDPLoadTextureBlock(
        u32 timg,
        u32 fmt,
        u32 siz,
        u32 width,
        u32 height,
        u32 pal,
        u32 cms,
        u32 cmt,
        u32 masks,
        u32 maskt,
        u32 shifts,
        u32 shiftt ) 

Arguments

gdl
Display list pointer
 
timg
Address of the texture image (64-bit alignment)
 
fmt
Texture image format:
G_IM_FMT_RGBA (RGBA format)
G_IM_FMT_YUV (YUV format)
G_IM_FMT_CI (CI format)
G_IM_FMT_IA (IA format)
G_IM_FMT_I (I format)
 
siz
Pixel component size:
G_IM_SIZ_8b (8 bits/texel)
G_IM_SIZ_16b (16 bits/texel)
G_IM_SIZ_32b (32 bits/texel)
 
width
Texture image width
 
height
Texture image height
 
pal
Location of palette for 4-bit color index texture(4-bit precision, 0~15)
 
cms
s-axis mirror, no-mirror, wrap, and clamp flags
G_TX_MIRROR (enable mirror operations)
G_TX_NOMIRROR (disable mirror operations)
G_TX_WRAP (enable wrap operations)
G_TX_CLAMP (enable clamp operations)
 
cmt
t-axis mirror, no-mirror, wrap and clamp flags
G_TX_MIRROR (enable mirror operations)
G_TX_NOMIRROR (disable mirror operations)
G_TX_WRAP (enable wrap operations)
G_TX_CLAMP (enable clamp operations)
 
masks
s-axis mask (4-bit precision, 0~15)
G_TX_NOMASK (do not mask, 0)
numeric value n (mask, 1~15)
 
maskt
t-axis mask (4-bit precision, 0~15)
G_TX_NOMASK (do not mask, 0)
numeric value n (mask, 1~15)
 
shifts
s-coordinate shift value (4-bit precision, 0~15)
G_TX_NOLOD (do not shift, 0)
numeric value n (shift, 1~15)
 
shiftt
t-coordinate shift value (4-bit precision, 0~15)
G_TX_NOLOD (do not shift, 0)
numeric value n (shift, 1~15)

Description

Loads a texture from DRAM into texture memory (TMEM). Because this macro loads the texture image into a contiguous region in memory, it is the most efficient way to load a texture. DRAM transfers are also most efficient with large blocks.

This macro is actually comprised of a number of 64-bit GBI commands. Thus, if you need to find out the exact size of the display list, you need to consider how many GBI commands it is comprised of.

Regarding the fmt argument:

G_IM_FMT_RGBA
Each texel comprises four elements of information: RGB (red, green, blue) and alpha (opacity).
G_IM_FMT_YUV
Each texel comprises a Y (intensity) component and a UV (color difference) component.
G_IM_FMT_CI
Each texel is comprised of index information specifying palette data.
G_IM_FMT_IA
Each texel is comprised of I (intensity) information and alpha information.
G_IM_FMT_I
Each texel is a texture with only I information. Since this is extremely compact, it is useful when only a few colors are being used.
 
You can choose from among 7 different texture image formats. The table shows the valid combinations of format and size. Select the format that best suits the texture compression method and type.
 
  G_IM_SIZ_(Size)
8b 16b 32b
G_IM_FMT_
(Format)
RGBA          X
(5/5/5/1)
X
(8/8/8/8)
YUV          X  
 
CI X          
 
IA X
(4/4)
X
(8/8)
        
I X    
 

Regarding the cms and cmt arguments, multitple specifications can be made with a bit sum of the following flags:

G_TX_MIRROR
Enables mirroring. Mirror textures can be used for textures with axial symmetry, like a tree. Symmetric textures are an effective way to reduce texture volume.
G_TX_NOMIRROR
Disables mirroring.
G_TX_WRAP
Enables wrapping. A wrapped texture repeats a texel. The wrapping cycle can be specified by a mask.
G_TX_CLAMP
Enables clamping. A clamped texture repeats the edge texel color when sampling outside of the texture map. Clamping is performed at the boundary of the texture tile.

Regarding the masks and maskt arguments:

G_TX_NOMASK(0)
No mask is used.
numeric value n(1~15)
Specifies the wrap position with the value of n. The low-order n bits of the s,t texel coordinates are used for texture sampling.
 
Texture sampling utilizes the low-order n bits of the s,t texture coordinates. You would set to 5 to wrap a texture with a boundary of 32x32 (25 x 25). Set to 0 to perform clamping.

Regarding the shifts and shiftt arguments:

G_TX_NOLOD(0)
No shifting is performed.
numeric value n(1~15)
Shifts the s,t texel coordinate by n bits. This enables the sampling of low-level LOD maps and detail textures.
 
Normally, use G_TX_NOLOD. Also, numeric value n is used, see gDPSetTile for more information.

The values specified by shifts and shiftt (the shift parameter values) represent the amount by which the s,t coordinates are shifted to the left or to the right. This is used for the MIP-mapping, detail, and sharp mode settings. The values 0-10 are interpreted as right shifts, and the values 11-15 are interpreted as left shifts (see the table below).

Shift parameter value Shift amount
0 No shift
1 >> 1
2 >> 2
...
9 >> 9
10 >> 10
11 << 5
12 << 4
13 << 3
14 << 2
15 << 1

For details about each argument, see Section 13.4 "Tile Attributes" in the N64 Programming Manual. Also, for information about using this macro, see Section 13.5 "Tile Descriptor Loading" in the N64 Programming Manual.

Note

To load a 4-bit texture, use the gDPLoadTextureBlock4b macro, no matter what the type.

Also, note that operation is not currently guaranteed for G_IM_FMT_YUV (YUV format).

Comment

There are some restrictions regarding the loading of textures with this macro. To ignore the restrictions, use the gDPLoadTextureBlockS macro. However, that form of the macro requires that every 32 bits in the odd lines of the texture data be pre-swapped. This kind of texture data is created using rgb2c with the -S option. You enter a number after -S to indicate how many texels to swap at a time. That is to say, if the texture you are creating is 32bit or 16bit, you enter 2, 4 for 8bit, and 8 for 4bit. To learn about the restrictions on loading, see Section 13, Appendix A "LoadBlock Line Limits" and Section 13.8 "Texture Memory" in the N64 Programming Manual. Also, note that additional texture macros are defined in <gbi.h>

See Also

gDPLoadTextureBlock_4b, gDPLoadTextureTile, gDPLoadTextureTile_4b, gDPLoadTLUT_pal256, gDPSetTextureDetail, guLoadTextureBlockMipMap, and rgb2c

Revision History

02/01/99 Completely rewritten.
03/31/99 Modified the Description.