gDPLoadTexture.3p
6.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
.TH gDPLoadTexture 3P local "Silicon Graphics, Inc."
.SH NAME
.upperok
gDPLoadTexture,
gDPLoadTextureBlock, gsDPLoadTextureBlock,
gDPLoadTextureBlock_4b, gsDPLoadTextureBlock_4b,
gDPLoadTextureTile, gsDPLoadTextureTile,
gDPLoadTextureTile_4b, gsDPLoadTextureTile_4b,
gDPLoadBlock, gsDPLoadBlock
\- load a contiguous texture block or a subtile of a larger texture image into the RDP texture memory.
.SH C SPECIFICATION
.nf
\f3#include "gbi.h"
gDPLoadTextureBlock(Gfx *gdl,
unsigned int timg,
unsigned int fmt,
unsigned int siz,
unsigned int width, height,
unsigned int pal,
unsigned int cms, cmt,
unsigned int masks, maskt,
unsigned int shifts, shiftt )
gDPLoadTextureBlock_4b(Gfx *gdl,
unsigned int timg,
unsigned int fmt,
unsigned int width, height,
unsigned int pal,
unsigned int cms, cmt,
unsigned int masks, maskt,
unsigned int shifts, shiftt )
gDPLoadTextureTile(Gfx *gdl,
unsigned int timg,
unsigned int fmt,
unsigned int siz,
unsigned int width, height,
unsigned int uls, ult, lrs, lrt,
unsigned int pal,
unsigned int cms, cmt,
unsigned int masks, maskt,
unsigned int shifts, shiftt )
gDPLoadTextureTile_4b(Gfx *gdl,
unsigned int timg,
unsigned int fmt,
unsigned int width, height,
unsigned int uls, ult, lrs, lrt,
unsigned int pal,
unsigned int cms, cmt,
unsigned int masks, maskt,
unsigned int shifts, shiftt )
gDPLoadBlock(Gfx *gdl,
unsigned int tile,
unsigned int uls,
unsigned int ult,
unsigned int lrs,
unsigned int dxt)
\fP
.fi
.SH PARAMETERS
.TP 10
.I *gdl
graphics display list pointer.
.TP
.I timg
Location of the texture image in dram.
Must be 64 bit aligned.
.TP
.I fmt
Texture image format.
\fBG_IM_FMT_RGBA, G_IM_FMT_YUV, G_IM_FMT_CI, G_IM_FMT_IA, G_IM_FMT_I\fP
.TP
.I siz
Texel size.
\fBG_IM_SIZ_4b, G_IM_SIZ_8b, G_IM_SIZ_16b, G_IM_SIZ_32b\fP
.TP
.I width, height
Texture image width and height in texels.
When loading a texture tile, specify the width and height of the original larger texture image in dram.
.TP
.I uls, ult, lrs, lrt
Upper left s and t, lower right s and t coordinates of a texture tile in the source image.
.TP
.I pal
For indexed textures, indicate which texture lookup table palette to use.
.TP
.I cms, cmt
Clamp, wrap and mirror flag for s and t axis.
\f3G_TX_NOMIRROR, G_TX_WRAP, G_TX_MIRROR, G_TX_CLAMP\fP
.TP
.I masks, maskt
Mask for s and t axis.
\f3G_TX_NOMASK\fP or a number specifing where to wrap.
.TP
.I shifts, shiftt
Shift value for s and t coordinates.
For lower level of detail textures.
If no shifts, use \fBG_TX_NOLOD\fP.
.TP
.I tile
the tile number for
.B g*DPLoadBlock().
.TP
.I dxt
the
.B t
increment value, per scanline for
.B g*DPLoadBlock().
.SH DESCRIPTION
These commands load texture from dram to on chip texture memory (TMEM) in the RDP.
gDPLoadBlock* commands load a texture image contiguous in memory.
This is the most efficient loading mechanism.
DRAM transfers are most efficient in large blocks.
gDPLoadTile* commands load a subtile of a larger texture image from memory.
.PP
If you are counting gbi display list size to understand memory requirements.
Each of these commands is actually made up of several gbi 64 commands.
.PP
There are many texture image formats. The best choice depends upon the desired
compression and on the content of the texture image.
4/8/16/32 bit texel sizes are supported.
Indexed, 1/2/4 component textures are supported.
I is intensity textures.
IA is intensity alpha textures.
RGBA is true color textures.
CI is color indexed textures.
.PP
When loading 4-bit textures, regardless of the type, use the macros
that have the suffix
.B _4b.
When using these macros, the size is implied and
is not included in the parameter list. 4-bit textures should be aligned
on byte boundaries.
.PP
The width and height are in texel space,
indicating the size of the source texture image in dram.
.PP
The upper left and lower right (s,t) coordinates are only used for tiled texture loads.
They specify in texel space the corners of the subtile to load into TMEM.
.PP
cms and cmt set clamp, mirror, and wrap flags for the s and t axes.
These flags are bit ORed together to specify the desired texture properties.
Mirrored textures are useful on axial aligned textures like a tree.
Clamped textures replicates the edge texel color when sampling outside of the texture map.
Wraped textures require the proper mask be set for wrapping.
A number n in masks or maskt indicates (n) LSBs of the s or t texel coordinate are used to sample the textures.
If you have a 32x32 texture and want to wrap at the edge, use 5 for masks and maskt.
.PP
The shift values are used to shift s or t texel coordinates left or right.
This enables the proper sampling of lower LOD maps and detail textures.
There are many other steps necessary in making a mipmaped textures.
Therefore, the shift values are often not used in these commands.
.PP
There are alternative forms of the gDPLoadTextureBlock macros
to support the full range of possible widths and heights.
These forms end in "S" to indicate that the texture has
been pre-swapped (that is, odd lines of textures have been
word swapped). See rgb2c(1) for more info on the "-S" flag.
.PP
When loading a texture tile, the addresses of the four corner pixels of the tile only need to be byte aligned.
However, if the row width of the tile is not 64 bit aligned, the hardware will automatically pad to 64 bit alignment on the right of each row in the RDP onchip texture memory (this is only true for LoadTextureTile commands).
.PP
.B gDPLoadBlock()
and
.B gsDPLoadBlock()
are low-level macros which should not normally be used in programs.
They load TMEM in a single transfer, but have some restrictions.
The maximum number of texels that can be loaded using this command is
2048. In order to load all 4K of TMEM, you might need to load the texture
as G_IM_SIZ_16b, then change the tile to the proper texel size after the
load. The
.B g*DPLoadTextureBlock()
macros already do this, but if you use this low-level macro directly,
you will need to handle the tile manipulation yourself.
.PP
LoadBlock commands do not do any padding for you. You must pad the
data before doing the load block.
.PP
Additional texture macros are defined in gbi.h; examine that file for details.
.SH BUGS
Also see Appendix A of the Texture Mapping chapter in the
Developers Document for a list of restrictions on gDPLoadTextureBlock
that can be worked around by using the "S" form of these macros.
.SH SEE ALSO
.IR gDPLoadTLUT (3P)
.IR guLoadTextureBlockMipMap (3P)
.IR rgb2c (1)