change PAD_ScanPads()s behaviour. the return value now contains a bitmask of the...
[libogc.git] / gc / ogc / gx.h
blobbcb118abee60cd78b0806050966717d501564c0e
1 #ifndef __GX_H__
2 #define __GX_H__
4 /*!
5 * \file gx.h
6 * \brief GX subsystem
8 */
10 #include <gctypes.h>
11 #include "lwp.h"
12 #include "gx_struct.h"
13 #include "gu.h"
15 #define GX_FALSE 0
16 #define GX_TRUE 1
17 #define GX_DISABLE 0
18 #define GX_ENABLE 1
20 /*! \addtogroup clipmode Clipping mode
21 * @{
23 #define GX_CLIP_DISABLE 1
24 #define GX_CLIP_ENABLE 0
25 /*! @} */
27 #define GX_FIFO_MINSIZE (64*1024) /*!< Smallest usable graphics FIFO size. */
28 #define GX_FIFO_HIWATERMARK (16*1024) /*!< Default hi watermark for FIFO buffer control. */
29 #define GX_FIFO_OBJSIZE 128
31 #define GX_PERSPECTIVE 0
32 #define GX_ORTHOGRAPHIC 1
34 #define GX_MT_NULL 0
35 #define GX_MT_XF_FLUSH 1
36 #define GX_MT_DL_SAVE_CTX 2
38 #define GX_XF_FLUSH_NONE 0
39 #define GX_XF_FLUSH_SAFE 1
41 /*! \addtogroup channelid Color channel ID
42 * @{
44 #define GX_COLOR0 0
45 #define GX_COLOR1 1
46 #define GX_ALPHA0 2
47 #define GX_ALPHA1 3
48 #define GX_COLOR0A0 4
49 #define GX_COLOR1A1 5
50 #define GX_COLORZERO 6
51 #define GX_ALPHA_BUMP 7
52 #define GX_ALPHA_BUMPN 8
53 #define GX_COLORNULL 0xff
54 /*! @} */
56 /*! \addtogroup mtxtype Matrix type
57 * @{
59 #define GX_MTX2x4 0
60 #define GX_MTX3x4 1
61 /*! @} */
63 /*! \addtogroup vtxfmt Vertex format index
64 * @{
66 #define GX_VTXFMT0 0
67 #define GX_VTXFMT1 1
68 #define GX_VTXFMT2 2
69 #define GX_VTXFMT3 3
70 #define GX_VTXFMT4 4
71 #define GX_VTXFMT5 5
72 #define GX_VTXFMT6 6
73 #define GX_VTXFMT7 7
74 #define GX_MAXVTXFMT 8
76 /*! @} */
79 /*! \addtogroup vtxattrin Vertex data input type
80 * @{
82 #define GX_NONE 0 /*!< Input data is not used */
83 #define GX_DIRECT 1 /*!< Input data is set direct */
84 #define GX_INDEX8 2 /*!< Input data is set by a 8bit index */
85 #define GX_INDEX16 3 /*!< Input data is set by a 16bit index */
87 /*! @} */
90 /*! \addtogroup compsize Number of components in an attribute
91 * @{
93 #define GX_U8 0 /*!< Unsigned 8-bit integer */
94 #define GX_S8 1 /*!< Signed 8-bit integer */
95 #define GX_U16 2 /*!< Unsigned 16-bit integer */
96 #define GX_S16 3 /*!< Signed 16-bit integer */
97 #define GX_F32 4 /*!< 32-bit floating-point */
98 #define GX_RGB565 0 /*!< 16-bit RGB */
99 #define GX_RGB8 1 /*!< 24-bit RGB */
100 #define GX_RGBX8 2 /*!< 32-bit RGBX */
101 #define GX_RGBA4 3 /*!< 16-bit RGBA */
102 #define GX_RGBA6 4 /*!< 24-bit RGBA */
103 #define GX_RGBA8 5 /*!< 32-bit RGBA */
104 /*! @} */
106 /*! \addtogroup comptype Attribute component type
107 * @{
109 #define GX_POS_XY 0 /*!< X,Y position */
110 #define GX_POS_XYZ 1 /*!< X,Y,Z position */
111 #define GX_NRM_XYZ 0 /*!< X,Y,Z normal */
112 #define GX_NRM_NBT 1
113 #define GX_NRM_NBT3 2
114 #define GX_CLR_RGB 0 /*!< RGB color */
115 #define GX_CLR_RGBA 1 /*!< RGBA color */
116 #define GX_TEX_S 0 /*!< One texture dimension */
117 #define GX_TEX_ST 1 /*!< Two texture dimensions */
118 /*! @} */
120 /*! \addtogroup vtxattr Vertex attribute array type
121 * @{
123 #define GX_VA_PTNMTXIDX 0
124 #define GX_VA_TEX0MTXIDX 1
125 #define GX_VA_TEX1MTXIDX 2
126 #define GX_VA_TEX2MTXIDX 3
127 #define GX_VA_TEX3MTXIDX 4
128 #define GX_VA_TEX4MTXIDX 5
129 #define GX_VA_TEX5MTXIDX 6
130 #define GX_VA_TEX6MTXIDX 7
131 #define GX_VA_TEX7MTXIDX 8
132 #define GX_VA_POS 9
133 #define GX_VA_NRM 10
134 #define GX_VA_CLR0 11
135 #define GX_VA_CLR1 12
136 #define GX_VA_TEX0 13
137 #define GX_VA_TEX1 14
138 #define GX_VA_TEX2 15
139 #define GX_VA_TEX3 16
140 #define GX_VA_TEX4 17
141 #define GX_VA_TEX5 18
142 #define GX_VA_TEX6 19
143 #define GX_VA_TEX7 20
144 #define GX_POSMTXARRAY 21
145 #define GX_NRMMTXARRAY 22
146 #define GX_TEXMTXARRAY 23
147 #define GX_LIGHTARRAY 24
148 #define GX_VA_NBT 25
149 #define GX_VA_MAXATTR 26
150 #define GX_VA_NULL 0xff
151 /*! @} */
153 /*! \addtogroup primtype Primitive type
154 * \brief Collection of primitive types that can be drawn by the GP.
156 * \note Which type you use depends on your needs; however, performance can increase by using triangle strips or fans instead of discrete triangles.
157 * @{
159 #define GX_POINTS 0xB8 /*!< Draws a series of points. Each vertex is a single point. */
160 #define GX_LINES 0xA8 /*!< Draws a series of unconnected line segments. Each pair of vertices makes a line. */
161 #define GX_LINESTRIP 0xB0 /*!< Draws a series of lines. Each vertex (besides the first) makes a line between it and the previous. */
162 #define GX_TRIANGLES 0x90 /*!< Draws a series of unconnected triangles. Three vertices make a single triangle. */
163 #define GX_TRIANGLESTRIP 0x98 /*!< Draws a series of triangles. Each triangle (besides the first) shares a side with the previous triangle.
164 * Each vertex (besides the first two) completes a triangle. */
165 #define GX_TRIANGLEFAN 0xA0 /*!< Draws a single triangle fan. The first vertex is the "centerpoint". The second and third vertex complete
166 * the first triangle. Each subsequent vertex completes another triangle which shares a side with the previous
167 * triangle (except the first triangle) and has the centerpoint vertex as one of the vertices. */
168 #define GX_QUADS 0x80 /*!< Draws a series of unconnected quads. Every four vertices completes a quad. Internally, each quad is
169 * translated into a pair of triangles. */
170 /*! @} */
172 #define GX_SRC_REG 0
173 #define GX_SRC_VTX 1
175 /*! \addtogroup lightid Light ID
176 * @{
178 #define GX_LIGHT0 0x001 /*!< Light 0 */
179 #define GX_LIGHT1 0x002 /*!< Light 2 */
180 #define GX_LIGHT2 0x004 /*!< Light 3 */
181 #define GX_LIGHT3 0x008 /*!< Light 4 */
182 #define GX_LIGHT4 0x010 /*!< Light 5 */
183 #define GX_LIGHT5 0x020 /*!< Light 6 */
184 #define GX_LIGHT6 0x040 /*!< Light 7 */
185 #define GX_LIGHT7 0x080 /*!< Light 8 */
186 #define GX_MAXLIGHT 0x100 /*!< All lights */
187 #define GX_LIGHTNULL 0x000 /*!< No lights */
188 /*! @} */
190 /*! \addtogroup difffn Diffuse function
191 * @{
193 #define GX_DF_NONE 0
194 #define GX_DF_SIGNED 1
195 #define GX_DF_CLAMP 2
196 /*! @} */
198 /*! \addtogroup attenfunc Attenuation function
199 * @{
201 #define GX_AF_SPEC 0 /*!< Specular computation */
202 #define GX_AF_SPOT 1 /*!< Spot light attenuation */
203 #define GX_AF_NONE 2 /*!< No attenuation */
204 /*! @} */
206 /* pos,nrm,tex,dtt matrix */
207 /*! \addtogroup pnmtx Position-normal matrix index
208 * @{
210 #define GX_PNMTX0 0
211 #define GX_PNMTX1 3
212 #define GX_PNMTX2 6
213 #define GX_PNMTX3 9
214 #define GX_PNMTX4 12
215 #define GX_PNMTX5 15
216 #define GX_PNMTX6 18
217 #define GX_PNMTX7 21
218 #define GX_PNMTX8 24
219 #define GX_PNMTX9 27
220 /*! @} */
222 /*! \addtogroup texmtx Texture matrix index
223 * @{
225 #define GX_TEXMTX0 30
226 #define GX_TEXMTX1 33
227 #define GX_TEXMTX2 36
228 #define GX_TEXMTX3 39
229 #define GX_TEXMTX4 42
230 #define GX_TEXMTX5 45
231 #define GX_TEXMTX6 48
232 #define GX_TEXMTX7 51
233 #define GX_TEXMTX8 54
234 #define GX_TEXMTX9 57
235 #define GX_IDENTITY 60
236 /*! @} */
238 /*! \addtogroup dttmtx Post-transform texture matrix index
239 * @{
241 #define GX_DTTMTX0 64
242 #define GX_DTTMTX1 67
243 #define GX_DTTMTX2 70
244 #define GX_DTTMTX3 73
245 #define GX_DTTMTX4 76
246 #define GX_DTTMTX5 79
247 #define GX_DTTMTX6 82
248 #define GX_DTTMTX7 85
249 #define GX_DTTMTX8 88
250 #define GX_DTTMTX9 91
251 #define GX_DTTMTX10 94
252 #define GX_DTTMTX11 97
253 #define GX_DTTMTX12 100
254 #define GX_DTTMTX13 103
255 #define GX_DTTMTX14 106
256 #define GX_DTTMTX15 109
257 #define GX_DTTMTX16 112
258 #define GX_DTTMTX17 115
259 #define GX_DTTMTX18 118
260 #define GX_DTTMTX19 121
261 #define GX_DTTIDENTITY 125
262 /*! @} */
264 /* tex coord id
265 used by: XF: 0x1040,0x1050
266 BP: 0x30
268 /*! \addtogroup texcoordid texture coordinate slot
269 * @{
271 #define GX_TEXCOORD0 0x0
272 #define GX_TEXCOORD1 0x1
273 #define GX_TEXCOORD2 0x2
274 #define GX_TEXCOORD3 0x3
275 #define GX_TEXCOORD4 0x4
276 #define GX_TEXCOORD5 0x5
277 #define GX_TEXCOORD6 0x6
278 #define GX_TEXCOORD7 0x7
279 #define GX_MAXCOORD 0x8
280 #define GX_TEXCOORDNULL 0xff
281 /*! @} */
283 /* tex format */
284 #define _GX_TF_ZTF 0x10
285 #define _GX_TF_CTF 0x20
287 /*! \addtogroup texfmt Texture format
288 * @{
291 #define GX_TF_I4 0x0
292 #define GX_TF_I8 0x1
293 #define GX_TF_IA4 0x2
294 #define GX_TF_IA8 0x3
295 #define GX_TF_RGB565 0x4
296 #define GX_TF_RGB5A3 0x5
297 #define GX_TF_RGBA8 0x6
298 #define GX_TF_CI4 0x8
299 #define GX_TF_CI8 0x9
300 #define GX_TF_CI14 0xa
301 #define GX_TF_CMPR 0xE /*!< Compressed */
303 #define GX_TL_IA8 0x00
304 #define GX_TL_RGB565 0x01
305 #define GX_TL_RGB5A3 0x02
307 #define GX_CTF_R4 (0x0|_GX_TF_CTF) /*!< For copying 4 bits from red */
308 #define GX_CTF_RA4 (0x2|_GX_TF_CTF) /*!< For copying 4 bits from red, 4 bits from alpha */
309 #define GX_CTF_RA8 (0x3|_GX_TF_CTF) /*!< For copying 8 bits from red, 8 bits from alpha */
310 #define GX_CTF_YUVA8 (0x6|_GX_TF_CTF)
311 #define GX_CTF_A8 (0x7|_GX_TF_CTF) /*!< For copying 8 bits from alpha */
312 #define GX_CTF_R8 (0x8|_GX_TF_CTF) /*!< For copying 8 bits from red */
313 #define GX_CTF_G8 (0x9|_GX_TF_CTF) /*!< For copying 8 bits from green */
314 #define GX_CTF_B8 (0xA|_GX_TF_CTF) /*!< For copying 8 bits from blue */
315 #define GX_CTF_RG8 (0xB|_GX_TF_CTF) /*!< For copying 8 bits from red, 8 bits from green */
316 #define GX_CTF_GB8 (0xC|_GX_TF_CTF) /*!< For copying 8 bits from green, 8 bits from blue */
318 /*! \addtogroup ztexfmt Z Texture format
319 * @{
322 #define GX_TF_Z8 (0x1|_GX_TF_ZTF) /*!< For texture copy, specifies upper 8 bits of Z */
323 #define GX_TF_Z16 (0x3|_GX_TF_ZTF) /*!< For texture copy, specifies upper 16 bits of Z */
324 #define GX_TF_Z24X8 (0x6|_GX_TF_ZTF) /*!< For texture copy, copies 24 Z bits and 0xFF */
326 /*! @} */
328 #define GX_CTF_Z4 (0x0|_GX_TF_ZTF|_GX_TF_CTF) /*!< For copying 4 upper bits from Z */
329 #define GX_CTF_Z8M (0x9|_GX_TF_ZTF|_GX_TF_CTF) /*!< For copying the middle 8 bits of Z */
330 #define GX_CTF_Z8L (0xA|_GX_TF_ZTF|_GX_TF_CTF) /*!< For copying the lower 8 bits of Z */
331 #define GX_CTF_Z16L (0xC|_GX_TF_ZTF|_GX_TF_CTF) /*!< For copying the lower 16 bits of Z */
333 #define GX_TF_A8 GX_CTF_A8
335 /*! @} */
337 /* gx tlut size */
338 #define GX_TLUT_16 1 // number of 16 entry blocks.
339 #define GX_TLUT_32 2
340 #define GX_TLUT_64 4
341 #define GX_TLUT_128 8
342 #define GX_TLUT_256 16
343 #define GX_TLUT_512 32
344 #define GX_TLUT_1K 64
345 #define GX_TLUT_2K 128
346 #define GX_TLUT_4K 256
347 #define GX_TLUT_8K 512
348 #define GX_TLUT_16K 1024
350 /*! \addtogroup ztexop Z Texture operator
351 * @{
354 #define GX_ZT_DISABLE 0
355 #define GX_ZT_ADD 1 /*!< Add a Z texel to reference Z */
356 #define GX_ZT_REPLACE 2 /*!< Replace reference Z with Z texel */
357 #define GX_MAX_ZTEXOP 3
359 /*! @} */
362 /*! \addtogroup texgentyp Texture coordinate generation type
363 * @{
365 #define GX_TG_MTX3x4 0 /*!< 2x4 matrix multiply on the input attribute and generate S,T texture coordinates. */
366 #define GX_TG_MTX2x4 1 /*!< 3x4 matrix multiply on the input attribute and generate S,T,Q coordinates; S,T are then divided
367 * by Q to produce the actual 2D texture coordinates. */
368 #define GX_TG_BUMP0 2 /*!< Use light 0 in the bump map calculation. */
369 #define GX_TG_BUMP1 3 /*!< Use light 1 in the bump map calculation. */
370 #define GX_TG_BUMP2 4 /*!< Use light 2 in the bump map calculation. */
371 #define GX_TG_BUMP3 5 /*!< Use light 3 in the bump map calculation. */
372 #define GX_TG_BUMP4 6 /*!< Use light 4 in the bump map calculation. */
373 #define GX_TG_BUMP5 7 /*!< Use light 5 in the bump map calculation. */
374 #define GX_TG_BUMP6 8 /*!< Use light 6 in the bump map calculation. */
375 #define GX_TG_BUMP7 9 /*!< Use light 7 in the bump map calculation. */
376 #define GX_TG_SRTG 10 /*!< Coordinates generated from vertex lighting results; one of the color channel results is converted
377 * into texture coordinates. */
378 /*! @} */
380 /*! \addtogroup texgensrc Texture coordinate source
381 * @{
383 #define GX_TG_POS 0
384 #define GX_TG_NRM 1
385 #define GX_TG_BINRM 2
386 #define GX_TG_TANGENT 3
387 #define GX_TG_TEX0 4
388 #define GX_TG_TEX1 5
389 #define GX_TG_TEX2 6
390 #define GX_TG_TEX3 7
391 #define GX_TG_TEX4 8
392 #define GX_TG_TEX5 9
393 #define GX_TG_TEX6 10
394 #define GX_TG_TEX7 11
395 #define GX_TG_TEXCOORD0 12
396 #define GX_TG_TEXCOORD1 13
397 #define GX_TG_TEXCOORD2 14
398 #define GX_TG_TEXCOORD3 15
399 #define GX_TG_TEXCOORD4 16
400 #define GX_TG_TEXCOORD5 17
401 #define GX_TG_TEXCOORD6 18
402 #define GX_TG_COLOR0 19
403 #define GX_TG_COLOR1 20
404 /*! @} */
406 /*! \addtogroup compare Compare type
407 * @{
409 #define GX_NEVER 0
410 #define GX_LESS 1
411 #define GX_EQUAL 2
412 #define GX_LEQUAL 3
413 #define GX_GREATER 4
414 #define GX_NEQUAL 5
415 #define GX_GEQUAL 6
416 #define GX_ALWAYS 7
417 /*! @} */
419 /* Text Wrap Mode */
420 #define GX_CLAMP 0
421 #define GX_REPEAT 1
422 #define GX_MIRROR 2
423 #define GX_MAXTEXWRAPMODE 3
425 /*! \addtogroup blendmode Blending type
426 * @{
428 #define GX_BM_NONE 0 /*!< Write input directly to EFB */
429 #define GX_BM_BLEND 1 /*!< Blend using blending equation */
430 #define GX_BM_LOGIC 2 /*!< Blend using bitwise operation */
431 #define GX_BM_SUBTRACT 3 /*!< Input subtracts from existing pixel */
432 #define GX_MAX_BLENDMODE 4
433 /*! @} */
435 /*! \addtogroup blendfactor Blending control
436 * \details Each pixel (source or destination) is multiplied by any of these controls.
437 * @{
439 #define GX_BL_ZERO 0 /*!< 0.0 */
440 #define GX_BL_ONE 1 /*!< 1.0 */
441 #define GX_BL_SRCCLR 2 /*!< source color */
442 #define GX_BL_INVSRCCLR 3 /*!< 1.0 - (source color) */
443 #define GX_BL_SRCALPHA 4 /*!< source alpha */
444 #define GX_BL_INVSRCALPHA 5 /*!< 1.0 - (source alpha) */
445 #define GX_BL_DSTALPHA 6 /*!< framebuffer alpha */
446 #define GX_BL_INVDSTALPHA 7 /*!< 1.0 - (FB alpha) */
447 #define GX_BL_DSTCLR GX_BL_SRCCLR
448 #define GX_BL_INVDSTCLR GX_BL_INVSRCCLR
449 /*! @} */
451 /*! \addtogroup logicop Logical operation type
452 * \details Destination (dst) acquires the value of one of these operations, given in C syntax.
453 * @{
455 #define GX_LO_CLEAR 0 /*!< 0 */
456 #define GX_LO_AND 1 /*!< src & dst */
457 #define GX_LO_REVAND 2 /*!< src & ~dst */
458 #define GX_LO_COPY 3 /*!< src */
459 #define GX_LO_INVAND 4 /*!< ~src & dst */
460 #define GX_LO_NOOP 5 /*!< dst */
461 #define GX_LO_XOR 6 /*!< src ^ dst */
462 #define GX_LO_OR 7 /*!< src | dst */
463 #define GX_LO_NOR 8 /*!< ~(src | dst) */
464 #define GX_LO_EQUIV 9 /*!< ~(src ^ dst) */
465 #define GX_LO_INV 10 /*!< ~dst */
466 #define GX_LO_REVOR 11 /*!< src | ~dst */
467 #define GX_LO_INVCOPY 12 /*!< ~src */
468 #define GX_LO_INVOR 13 /*!< ~src | dst */
469 #define GX_LO_NAND 14 /*!< ~(src & dst) */
470 #define GX_LO_SET 15 /*!< 1 */
471 /*! @} */
473 /*! \addtogroup texoff Texture offset value
474 * \brief Used for texturing points or lines.
475 * @{
477 #define GX_TO_ZERO 0
478 #define GX_TO_SIXTEENTH 1
479 #define GX_TO_EIGHTH 2
480 #define GX_TO_FOURTH 3
481 #define GX_TO_HALF 4
482 #define GX_TO_ONE 5
483 #define GX_MAX_TEXOFFSET 6
484 /*! @} */
486 /*! \addtogroup tevdefmode TEV combiner operation
487 * \brief Color/Alpha combiner modes for GX_SetTevOp().
489 * \details For these equations, <i>Cv</i> is the output color for the stage, <i>Cr</i> is the output color of previous stage, and <i>Ct</i> is the texture color. <i>Av</i> is the output
490 * alpha for a stage, <i>Ar</i> is the output alpha of previous stage, and <i>At</i> is the texture alpha. As a special case, rasterized color
491 * (<tt>GX_CC_RASC</tt>) is used as <i>Cr</i> and rasterized alpha (<tt>GX_CA_RASA</tt>) is used as <i>Ar</i> at the first TEV stage because there is no previous stage.
493 * @{
496 #define GX_MODULATE 0 /*!< <i>Cv</i>=<i>CrCt</i>; <i>Av</i>=<i>ArAt</i> */
497 #define GX_DECAL 1 /*!< <i>Cv</i>=(1-<i>At</i>)<i>Cr</i> + <i>AtCt</i>; <i>Av</i>=<i>Ar</i> */
498 #define GX_BLEND 2 /*!< <i>Cv=(1-<i>Ct</i>)<i>Cr</i> + <i>Ct</i>; <i>Av</i>=<i>AtAr</i> */
499 #define GX_REPLACE 3 /*!< <i>Cv=<i>Ct</i>; <i>Ar=<i>At</i> */
500 #define GX_PASSCLR 4 /*!< <i>Cv=<i>Cr</i>; <i>Av=<i>Ar</i> */
502 /*! @} */
505 /*! \addtogroup tevcolorarg TEV color combiner input
506 * @{
509 #define GX_CC_CPREV 0 /*!< Use the color value from previous TEV stage */
510 #define GX_CC_APREV 1 /*!< Use the alpha value from previous TEV stage */
511 #define GX_CC_C0 2 /*!< Use the color value from the color/output register 0 */
512 #define GX_CC_A0 3 /*!< Use the alpha value from the color/output register 0 */
513 #define GX_CC_C1 4 /*!< Use the color value from the color/output register 1 */
514 #define GX_CC_A1 5 /*!< Use the alpha value from the color/output register 1 */
515 #define GX_CC_C2 6 /*!< Use the color value from the color/output register 2 */
516 #define GX_CC_A2 7 /*!< Use the alpha value from the color/output register 2 */
517 #define GX_CC_TEXC 8 /*!< Use the color value from texture */
518 #define GX_CC_TEXA 9 /*!< Use the alpha value from texture */
519 #define GX_CC_RASC 10 /*!< Use the color value from rasterizer */
520 #define GX_CC_RASA 11 /*!< Use the alpha value from rasterizer */
521 #define GX_CC_ONE 12
522 #define GX_CC_HALF 13
523 #define GX_CC_KONST 14
524 #define GX_CC_ZERO 15 /*!< Use to pass zero value */
526 /*! @} */
529 /*! \addtogroup tevalphaarg TEV alpha combiner input
530 * @{
533 #define GX_CA_APREV 0 /*!< Use the alpha value from previous TEV stage */
534 #define GX_CA_A0 1 /*!< Use the alpha value from the color/output register 0 */
535 #define GX_CA_A1 2 /*!< Use the alpha value from the color/output register 1 */
536 #define GX_CA_A2 3 /*!< Use the alpha value from the color/output register 2 */
537 #define GX_CA_TEXA 4 /*!< Use the alpha value from texture */
538 #define GX_CA_RASA 5 /*!< Use the alpha value from rasterizer */
539 #define GX_CA_KONST 6
540 #define GX_CA_ZERO 7 /*!< Use to pass zero value */
542 /*! @} */
545 /*! \addtogroup tevstage TEV stage
546 * \details The GameCube's Graphics Processor (GP) can use up to 16 stages to compute a texel for a particular surface.
547 * By default, each texture will use two stages, but it can be configured through various functions calls.
549 * \note This is different from \ref texmapid s, where textures are loaded into.
550 * @{
553 #define GX_TEVSTAGE0 0
554 #define GX_TEVSTAGE1 1
555 #define GX_TEVSTAGE2 2
556 #define GX_TEVSTAGE3 3
557 #define GX_TEVSTAGE4 4
558 #define GX_TEVSTAGE5 5
559 #define GX_TEVSTAGE6 6
560 #define GX_TEVSTAGE7 7
561 #define GX_TEVSTAGE8 8
562 #define GX_TEVSTAGE9 9
563 #define GX_TEVSTAGE10 10
564 #define GX_TEVSTAGE11 11
565 #define GX_TEVSTAGE12 12
566 #define GX_TEVSTAGE13 13
567 #define GX_TEVSTAGE14 14
568 #define GX_TEVSTAGE15 15
569 #define GX_MAX_TEVSTAGE 16
571 /*! @} */
574 /*! \addtogroup tevop TEV combiner operator
575 * @{
578 #define GX_TEV_ADD 0
579 #define GX_TEV_SUB 1
580 #define GX_TEV_COMP_R8_GT 8
581 #define GX_TEV_COMP_R8_EQ 9
582 #define GX_TEV_COMP_GR16_GT 10
583 #define GX_TEV_COMP_GR16_EQ 11
584 #define GX_TEV_COMP_BGR24_GT 12
585 #define GX_TEV_COMP_BGR24_EQ 13
586 #define GX_TEV_COMP_RGB8_GT 14
587 #define GX_TEV_COMP_RGB8_EQ 15
588 #define GX_TEV_COMP_A8_GT GX_TEV_COMP_RGB8_GT // for alpha channel
589 #define GX_TEV_COMP_A8_EQ GX_TEV_COMP_RGB8_EQ // for alpha channel
591 /*! @} */
594 /*! \addtogroup tevbias TEV bias value
595 * @{
598 #define GX_TB_ZERO 0
599 #define GX_TB_ADDHALF 1
600 #define GX_TB_SUBHALF 2
601 #define GX_MAX_TEVBIAS 3
603 /*! @} */
606 /*! \addtogroup tevclampmode TEV clamping mode
607 * \note These modes are used for a function which is not implementable on production (i.e. retail) GameCube hardware.
608 * @{
611 #define GX_TC_LINEAR 0
612 #define GX_TC_GE 1
613 #define GX_TC_EQ 2
614 #define GX_TC_LE 3
615 #define GX_MAX_TEVCLAMPMODE 4
617 /*! @} */
620 /*! \addtogroup tevscale TEV scale value
621 * @{
624 #define GX_CS_SCALE_1 0
625 #define GX_CS_SCALE_2 1
626 #define GX_CS_SCALE_4 2
627 #define GX_CS_DIVIDE_2 3
628 #define GX_MAX_TEVSCALE 4
630 /*! @} */
633 /*! \addtogroup tevcoloutreg TEV color/output register
634 * @{
637 #define GX_TEVPREV 0 /*!< Default register for passing results from one stage to another. */
638 #define GX_TEVREG0 1
639 #define GX_TEVREG1 2
640 #define GX_TEVREG2 3
641 #define GX_MAX_TEVREG 4
643 /*! @} */
646 /*! \addtogroup cullmode Backface culling mode
647 * @{
649 #define GX_CULL_NONE 0 /*!< Do not cull any primitives. */
650 #define GX_CULL_FRONT 1 /*!< Cull front-facing primitives. */
651 #define GX_CULL_BACK 2 /*!< Cull back-facing primitives. */
652 #define GX_CULL_ALL 3 /*!< Cull all primitives. */
653 /*! @} */
655 /*! \addtogroup texmapid texture map slot
656 * \brief Texture map slots to hold textures in.
658 * \details The GameCube's Graphics Processor (GP) can apply up to eight textures to a single surface. Those textures
659 * are assigned one of these slots. Various operations used on or with a particular texture will also take one of these
660 * items, including operations regarding texture coordinate generation (although not necessarily on the same slot).
662 * \note This is different from \ref tevstage s, which are the actual quanta for work with textures.
663 * @{
665 #define GX_TEXMAP0 0 /*!< Texture map slot 0 */
666 #define GX_TEXMAP1 1 /*!< Texture map slot 1 */
667 #define GX_TEXMAP2 2 /*!< Texture map slot 2 */
668 #define GX_TEXMAP3 3 /*!< Texture map slot 3 */
669 #define GX_TEXMAP4 4 /*!< Texture map slot 4 */
670 #define GX_TEXMAP5 5 /*!< Texture map slot 5 */
671 #define GX_TEXMAP6 6 /*!< Texture map slot 6 */
672 #define GX_TEXMAP7 7 /*!< Texture map slot 7 */
673 #define GX_MAX_TEXMAP 8
674 #define GX_TEXMAP_NULL 0xff /*!< No texmap */
675 #define GX_TEXMAP_DISABLE 0x100 /*!< Disable texmap lookup for this texmap slot (use bitwise OR with a texture map slot). */
676 /*! @} */
678 /*! \addtogroup alphaop Alpha combine control
679 * @{
681 #define GX_AOP_AND 0
682 #define GX_AOP_OR 1
683 #define GX_AOP_XOR 2
684 #define GX_AOP_XNOR 3
685 #define GX_MAX_ALPHAOP 4
686 /*! @} */
688 /*! \addtogroup tevkcolorid TEV constant color register
689 * @{
691 #define GX_KCOLOR0 0 /*!< Constant register 0 */
692 #define GX_KCOLOR1 1 /*!< Constant register 1 */
693 #define GX_KCOLOR2 2 /*!< Constant register 2 */
694 #define GX_KCOLOR3 3 /*!< Constant register 3 */
695 #define GX_KCOLOR_MAX 4
696 /*! @} */
698 /*! \addtogroup tevkcolorsel TEV constant color selection
699 * @{
701 #define GX_TEV_KCSEL_1 0x00 /*!< constant 1.0 */
702 #define GX_TEV_KCSEL_7_8 0x01 /*!< constant 7/8 */
703 #define GX_TEV_KCSEL_3_4 0x02 /*!< constant 3/4 */
704 #define GX_TEV_KCSEL_5_8 0x03 /*!< constant 5/8 */
705 #define GX_TEV_KCSEL_1_2 0x04 /*!< constant 1/2 */
706 #define GX_TEV_KCSEL_3_8 0x05 /*!< constant 3/8 */
707 #define GX_TEV_KCSEL_1_4 0x06 /*!< constant 1/4 */
708 #define GX_TEV_KCSEL_1_8 0x07 /*!< constant 1/8 */
709 #define GX_TEV_KCSEL_K0 0x0C /*!< K0[RGB] register */
710 #define GX_TEV_KCSEL_K1 0x0D /*!< K1[RGB] register */
711 #define GX_TEV_KCSEL_K2 0x0E /*!< K2[RGB] register */
712 #define GX_TEV_KCSEL_K3 0x0F /*!< K3[RGB] register */
713 #define GX_TEV_KCSEL_K0_R 0x10 /*!< K0[RRR] register */
714 #define GX_TEV_KCSEL_K1_R 0x11 /*!< K1[RRR] register */
715 #define GX_TEV_KCSEL_K2_R 0x12 /*!< K2[RRR] register */
716 #define GX_TEV_KCSEL_K3_R 0x13 /*!< K3[RRR] register */
717 #define GX_TEV_KCSEL_K0_G 0x14 /*!< K0[GGG] register */
718 #define GX_TEV_KCSEL_K1_G 0x15 /*!< K1[GGG] register */
719 #define GX_TEV_KCSEL_K2_G 0x16 /*!< K2[GGG] register */
720 #define GX_TEV_KCSEL_K3_G 0x17 /*!< K3[GGG] register */
721 #define GX_TEV_KCSEL_K0_B 0x18 /*!< K0[BBB] register */
722 #define GX_TEV_KCSEL_K1_B 0x19 /*!< K1[BBB] register */
723 #define GX_TEV_KCSEL_K2_B 0x1A /*!< K2[BBB] register */
724 #define GX_TEV_KCSEL_K3_B 0x1B /*!< K3[RBB] register */
725 #define GX_TEV_KCSEL_K0_A 0x1C /*!< K0[AAA] register */
726 #define GX_TEV_KCSEL_K1_A 0x1D /*!< K1[AAA] register */
727 #define GX_TEV_KCSEL_K2_A 0x1E /*!< K2[AAA] register */
728 #define GX_TEV_KCSEL_K3_A 0x1F /*!< K3[AAA] register */
729 /*! @} */
731 /*! \addtogroup tevkalphasel TEV constant alpha selection
732 * @{
734 #define GX_TEV_KASEL_1 0x00 /*!< constant 1.0 */
735 #define GX_TEV_KASEL_7_8 0x01 /*!< constant 7/8 */
736 #define GX_TEV_KASEL_3_4 0x02 /*!< constant 3/4 */
737 #define GX_TEV_KASEL_5_8 0x03 /*!< constant 5/8 */
738 #define GX_TEV_KASEL_1_2 0x04 /*!< constant 1/2 */
739 #define GX_TEV_KASEL_3_8 0x05 /*!< constant 3/8 */
740 #define GX_TEV_KASEL_1_4 0x06 /*!< constant 1/4 */
741 #define GX_TEV_KASEL_1_8 0x07 /*!< constant 1/8 */
742 #define GX_TEV_KASEL_K0_R 0x10 /*!< K0[R] register */
743 #define GX_TEV_KASEL_K1_R 0x11 /*!< K1[R] register */
744 #define GX_TEV_KASEL_K2_R 0x12 /*!< K2[R] register */
745 #define GX_TEV_KASEL_K3_R 0x13 /*!< K3[R] register */
746 #define GX_TEV_KASEL_K0_G 0x14 /*!< K0[G] register */
747 #define GX_TEV_KASEL_K1_G 0x15 /*!< K1[G] register */
748 #define GX_TEV_KASEL_K2_G 0x16 /*!< K2[G] register */
749 #define GX_TEV_KASEL_K3_G 0x17 /*!< K3[G] register */
750 #define GX_TEV_KASEL_K0_B 0x18 /*!< K0[B] register */
751 #define GX_TEV_KASEL_K1_B 0x19 /*!< K1[B] register */
752 #define GX_TEV_KASEL_K2_B 0x1A /*!< K2[B] register */
753 #define GX_TEV_KASEL_K3_B 0x1B /*!< K3[B] register */
754 #define GX_TEV_KASEL_K0_A 0x1C /*!< K0[A] register */
755 #define GX_TEV_KASEL_K1_A 0x1D /*!< K1[A] register */
756 #define GX_TEV_KASEL_K2_A 0x1E /*!< K2[A] register */
757 #define GX_TEV_KASEL_K3_A 0x1F /*!< K3[A] register */
758 /*! @} */
761 /*! \addtogroup tevswapsel TEV color swap table entry
762 * @{
765 #define GX_TEV_SWAP0 0
766 #define GX_TEV_SWAP1 1
767 #define GX_TEV_SWAP2 2
768 #define GX_TEV_SWAP3 3
769 #define GX_MAX_TEVSWAP 4
771 /*! @} */
774 /* tev color chan */
775 #define GX_CH_RED 0
776 #define GX_CH_GREEN 1
777 #define GX_CH_BLUE 2
778 #define GX_CH_ALPHA 3
780 /*! \addtogroup indtexstage Indirect texture stage
781 * @{
783 #define GX_INDTEXSTAGE0 0
784 #define GX_INDTEXSTAGE1 1
785 #define GX_INDTEXSTAGE2 2
786 #define GX_INDTEXSTAGE3 3
787 #define GX_MAX_INDTEXSTAGE 4
788 /*! @} */
790 /*! \addtogroup indtexformat Indirect texture format
791 * \details Bits for the indirect offsets are extracted from the high end of each component byte. Bits for the bump alpha
792 * are extraced off the low end of the byte. For <tt>GX_ITF_8</tt>, the byte is duplicated for the offset and the bump alpha.
793 * @{
795 #define GX_ITF_8 0
796 #define GX_ITF_5 1
797 #define GX_ITF_4 2
798 #define GX_ITF_3 3
799 #define GX_MAX_ITFORMAT 4
800 /*! @} */
802 /*! \addtogroup indtexbias Indirect texture bias select
803 * \brief Indicates which components of the indirect offset should receive a bias value.
805 * \details The bias is fixed at -128 for <tt>GX_ITF_8</tt> and +1 for the other formats. The bias happens prior to the indirect matrix multiply.
806 * @{
808 #define GX_ITB_NONE 0
809 #define GX_ITB_S 1
810 #define GX_ITB_T 2
811 #define GX_ITB_ST 3
812 #define GX_ITB_U 4
813 #define GX_ITB_SU 5
814 #define GX_ITB_TU 6
815 #define GX_ITB_STU 7
816 #define GX_MAX_ITBIAS 8
817 /*! @} */
819 /*! \addtogroup indtexmtx Indirect texture matrix
820 * @{
822 #define GX_ITM_OFF 0 /*!< Specifies a matrix of all zeroes. */
823 #define GX_ITM_0 1 /*!< Specifies indirect matrix 0, indirect scale 0. */
824 #define GX_ITM_1 2 /*!< Specifies indirect matrix 1, indirect scale 1. */
825 #define GX_ITM_2 3 /*!< Specifies indirect matrix 2, indirect scale 2. */
826 #define GX_ITM_S0 5 /*!< Specifies dynamic S-type matrix, indirect scale 0. */
827 #define GX_ITM_S1 6 /*!< Specifies dynamic S-type matrix, indirect scale 1. */
828 #define GX_ITM_S2 7 /*!< Specifies dynamic S-type matrix, indirect scale 2. */
829 #define GX_ITM_T0 9 /*!< Specifies dynamic T-type matrix, indirect scale 0. */
830 #define GX_ITM_T1 10 /*!< Specifies dynamic T-type matrix, indirect scale 1. */
831 #define GX_ITM_T2 11 /*!< Specifies dynamic T-type matrix, indirect scale 2. */
832 /*! @} */
834 /*! \addtogroup indtexwrap Indirect texture wrap value
835 * \brief Indicates whether the regular texture coordinate should be wrapped before being added to the offset.
837 * \details <tt>GX_ITW_OFF</tt> specifies no wrapping. <tt>GX_ITW_0</tt> will zero out the regular texture coordinate.
838 * @{
840 #define GX_ITW_OFF 0
841 #define GX_ITW_256 1
842 #define GX_ITW_128 2
843 #define GX_ITW_64 3
844 #define GX_ITW_32 4
845 #define GX_ITW_16 5
846 #define GX_ITW_0 6
847 #define GX_MAX_ITWRAP 7
848 /*! @} */
850 /*! \addtogroup indtexalphasel Indirect texture bump alpha select
851 * \brief Indicates which offset component should provide the "bump" alpha output for the given TEV stage.
853 * \note Bump alpha is not available for TEV stage 0.
854 * @{
856 #define GX_ITBA_OFF 0
857 #define GX_ITBA_S 1
858 #define GX_ITBA_T 2
859 #define GX_ITBA_U 3
860 #define GX_MAX_ITBALPHA 4
861 /*! @} */
863 /*! \addtogroup indtexscale Indirect texture scale
864 * \brief Specifies an additional scale value that may be applied to the texcoord used for an indirect initial lookup (not a TEV stage regular lookup).
866 * \details The scale value is a fraction; thus <tt>GX_ITS_32</tt> means to divide the texture coordinate values by 32.
867 * @{
869 #define GX_ITS_1 0
870 #define GX_ITS_2 1
871 #define GX_ITS_4 2
872 #define GX_ITS_8 3
873 #define GX_ITS_16 4
874 #define GX_ITS_32 5
875 #define GX_ITS_64 6
876 #define GX_ITS_128 7
877 #define GX_ITS_256 8
878 #define GX_MAX_ITSCALE 9
879 /*! @} */
881 /*! \addtogroup fogtype Fog equation control
882 * @{
884 #define GX_FOG_NONE 0
886 #define GX_FOG_PERSP_LIN 2
887 #define GX_FOG_PERSP_EXP 4
888 #define GX_FOG_PERSP_EXP2 5
889 #define GX_FOG_PERSP_REVEXP 6
890 #define GX_FOG_PERSP_REVEXP2 7
892 #define GX_FOG_ORTHO_LIN 10
893 #define GX_FOG_ORTHO_EXP 12
894 #define GX_FOG_ORTHO_EXP2 13
895 #define GX_FOG_ORTHO_REVEXP 14
896 #define GX_FOG_ORTHO_REVEXP2 15
898 #define GX_FOG_LIN GX_FOG_PERSP_LIN
899 #define GX_FOG_EXP GX_FOG_PERSP_EXP
900 #define GX_FOG_EXP2 GX_FOG_PERSP_EXP2
901 #define GX_FOG_REVEXP GX_FOG_PERSP_REVEXP
902 #define GX_FOG_REVEXP2 GX_FOG_PERSP_REVEXP2
903 /*! @} */
906 /* pixel format */
907 #define GX_PF_RGB8_Z24 0
908 #define GX_PF_RGBA6_Z24 1
909 #define GX_PF_RGB565_Z16 2
910 #define GX_PF_Z24 3
911 #define GX_PF_Y8 4
912 #define GX_PF_U8 5
913 #define GX_PF_V8 6
914 #define GX_PF_YUV420 7
916 /*! \addtogroup zfmt Compressed Z format
917 * @{
919 #define GX_ZC_LINEAR 0
920 #define GX_ZC_NEAR 1
921 #define GX_ZC_MID 2
922 #define GX_ZC_FAR 3
923 /*! @} */
925 /*! \addtogroup xfbclamp XFB clamp modes
926 * @{
929 #define GX_CLAMP_NONE 0
930 #define GX_CLAMP_TOP 1
931 #define GX_CLAMP_BOTTOM 2
933 /*! @} */
936 /*! \addtogroup gammamode Gamma values
937 * @{
940 #define GX_GM_1_0 0
941 #define GX_GM_1_7 1
942 #define GX_GM_2_2 2
944 /*! @} */
947 /*! \addtogroup copymode EFB copy mode
948 * \brief Controls whether all lines, only even lines, or only odd lines are copied from the EFB.
949 * @{
951 #define GX_COPY_PROGRESSIVE 0
952 #define GX_COPY_INTLC_EVEN 2
953 #define GX_COPY_INTLC_ODD 3
954 /*! @} */
956 /*! \addtogroup alphareadmode Alpha read mode
957 * @{
959 #define GX_READ_00 0 /*!< Always read 0x00. */
960 #define GX_READ_FF 1 /*!< Always read 0xFF. */
961 #define GX_READ_NONE 2 /*!< Always read the real alpha value. */
962 /*! @} */
964 /*! \addtogroup texcachesize Texture cache size
965 * \brief Size of texture cache regions.
966 * @{
968 #define GX_TEXCACHE_32K 0
969 #define GX_TEXCACHE_128K 1
970 #define GX_TEXCACHE_512K 2
971 #define GX_TEXCACHE_NONE 3
972 /*! @} */
974 /*! \addtogroup distattnfn Brightness decreasing function
975 * \brief Type of the brightness decreasing function by distance.
976 * @{
978 #define GX_DA_OFF 0
979 #define GX_DA_GENTLE 1
980 #define GX_DA_MEDIUM 2
981 #define GX_DA_STEEP 3
982 /*! @} */
984 /*! \addtogroup spotfn Spot illumination distribution function
985 * @{
987 #define GX_SP_OFF 0
988 #define GX_SP_FLAT 1
989 #define GX_SP_COS 2
990 #define GX_SP_COS2 3
991 #define GX_SP_SHARP 4
992 #define GX_SP_RING1 5
993 #define GX_SP_RING2 6
994 /*! @} */
996 /*! \addtogroup texfilter Texture filter types
997 * @{
999 #define GX_NEAR 0 /*!< Point sampling, no mipmap */
1000 #define GX_LINEAR 1 /*!< Bilinear filtering, no mipmap */
1001 #define GX_NEAR_MIP_NEAR 2 /*!< Point sampling, discrete mipmap */
1002 #define GX_LIN_MIP_NEAR 3 /*!< Bilinear filtering, discrete mipmap */
1003 #define GX_NEAR_MIP_LIN 4 /*!< Point sampling, linear mipmap */
1004 #define GX_LIN_MIP_LIN 5 /*!< Trilinear filtering */
1005 /*! @} */
1007 /*! \addtogroup anisotropy Maximum anisotropy filter control
1008 * @{
1010 #define GX_ANISO_1 0
1011 #define GX_ANISO_2 1
1012 #define GX_ANISO_4 2
1013 #define GX_MAX_ANISOTROPY 3
1014 /*! @} */
1016 /*! \addtogroup vcachemetrics Vertex cache performance counter
1017 * @{
1019 #define GX_VC_POS 0
1020 #define GX_VC_NRM 1
1021 #define GX_VC_CLR0 2
1022 #define GX_VC_CLR1 3
1023 #define GX_VC_TEX0 4
1024 #define GX_VC_TEX1 5
1025 #define GX_VC_TEX2 6
1026 #define GX_VC_TEX3 7
1027 #define GX_VC_TEX4 8
1028 #define GX_VC_TEX5 9
1029 #define GX_VC_TEX6 10
1030 #define GX_VC_TEX7 11
1031 #define GX_VC_ALL 15
1032 /*! @} */
1034 /*! \addtogroup perf0metrics Performance counter 0 metric
1035 * \details Performance counter 0 is used to measure attributes dealing with geometry and primitives, such as triangle counts and clipping ratios.
1037 * \note <tt>GX_PERF0_XF_*</tt> measure how many GP cycles are spent in each stage of the XF.<br><br>
1039 * \note The triangle metrics (<tt>GX_PERF0_TRIANGLES_*</tt>) allow counting triangles under specific conditions or with specific attributes.<br><br>
1041 * \note <tt>GX_PERF0_TRIANGLES_*TEX</tt> count triangles based on the number of texture coordinates supplied; <tt>GX_PERF0_TRIANGLES_*CLR</tt> count
1042 * triangles based on the number of colors supplied.<br><br>
1044 * \note The quad metrics allow you to count the number of quads (2x2 pixels) the GP processes. The term <i>coverage</i> is used to indicate how many
1045 * pixels in the quad are actually part of the triangle being rasterized. For example, a coverage of 4 means all pixels in the quad intersect the
1046 * triangle. A coverage of 1 indicates that only 1 pixel in the quad intersected the triangle.
1047 * @{
1049 #define GX_PERF0_VERTICES 0 /*!< Number of vertices processed by the GP. */
1050 #define GX_PERF0_CLIP_VTX 1 /*!< Number of vertices that were clipped by the GP. */
1051 #define GX_PERF0_CLIP_CLKS 2 /*!< Number of GP clocks spent clipping. */
1052 #define GX_PERF0_XF_WAIT_IN 3 /*!< Number of cycles the XF is waiting on input. If the XF is waiting a large percentage
1053 * of the total time, it may indicate that the CPU is not supplying data fast enough to
1054 * keep the GP busy. */
1055 #define GX_PERF0_XF_WAIT_OUT 4 /*!< Number of cycles the XF waits to send its output to the rest of the GP pipeline. If
1056 * the XF cannot output, it may indicate that the GP is currently fill-rate limited. */
1057 #define GX_PERF0_XF_XFRM_CLKS 5 /*!< Number of cycles the transform engine is busy. */
1058 #define GX_PERF0_XF_LIT_CLKS 6 /*!< Number of cycles the lighting engine is busy. */
1059 #define GX_PERF0_XF_BOT_CLKS 7 /*!< Number of cycles the bottom of the pipe (result combiner) is busy. */
1060 #define GX_PERF0_XF_REGLD_CLKS 8 /*!< Number of cycles are spent loading XF state registers. */
1061 #define GX_PERF0_XF_REGRD_CLKS 9 /*!< Number of cycles the XF reads the state registers. */
1062 #define GX_PERF0_CLIP_RATIO 10
1063 #define GX_PERF0_TRIANGLES 11 /*!< Number of triangles. */
1064 #define GX_PERF0_TRIANGLES_CULLED 12 /*!< Number of triangles that <i>failed</i> the front-face/back-face culling test. */
1065 #define GX_PERF0_TRIANGLES_PASSED 13 /*!< Number of triangles that <i>passed</i> the front-face/back-face culling test. */
1066 #define GX_PERF0_TRIANGLES_SCISSORED 14 /*!< Number of triangles that are scissored. */
1067 #define GX_PERF0_TRIANGLES_0TEX 15
1068 #define GX_PERF0_TRIANGLES_1TEX 16
1069 #define GX_PERF0_TRIANGLES_2TEX 17
1070 #define GX_PERF0_TRIANGLES_3TEX 18
1071 #define GX_PERF0_TRIANGLES_4TEX 19
1072 #define GX_PERF0_TRIANGLES_5TEX 20
1073 #define GX_PERF0_TRIANGLES_6TEX 21
1074 #define GX_PERF0_TRIANGLES_7TEX 22
1075 #define GX_PERF0_TRIANGLES_8TEX 23
1076 #define GX_PERF0_TRIANGLES_0CLR 24
1077 #define GX_PERF0_TRIANGLES_1CLR 25
1078 #define GX_PERF0_TRIANGLES_2CLR 26
1079 #define GX_PERF0_QUAD_0CVG 27 /*!< Number of quads having zero coverage. */
1080 #define GX_PERF0_QUAD_NON0CVG 28 /*!< Number of quads having coverage greater than zero. */
1081 #define GX_PERF0_QUAD_1CVG 29 /*!< Number of quads with 1 pixel coverage. */
1082 #define GX_PERF0_QUAD_2CVG 30 /*!< Number of quads with 2 pixel coverage. */
1083 #define GX_PERF0_QUAD_3CVG 31 /*!< Number of quads with 3 pixel coverage. */
1084 #define GX_PERF0_QUAD_4CVG 32 /*!< Number of quads with 4 pixel coverage. */
1085 #define GX_PERF0_AVG_QUAD_CNT 33 /*!< Average quad count; average based on what is unknown */
1086 #define GX_PERF0_CLOCKS 34 /*!< Number of GP clocks that have elapsed since the previous call to GX_ReadGP0Metric(). */
1087 #define GX_PERF0_NONE 35 /*!< Disables performance measurement for perf0 and resets the counter. */
1088 /*! @} */
1090 /*! \addtogroup perf1metrics Performance counter 1 metric
1091 * \details Performance counter 1 is used for measuring texturing and caching performance as well as FIFO performance.
1093 * \note <tt>GX_PERF1_TC_*</tt> can be used to compute the texture cache (TC) miss rate. The <tt>TC_CHECK*</tt> parameters count how many texture cache lines are
1094 * accessed for each pixel. In the worst case, for a mipmap, up to 8 cache lines may be accessed to produce one textured pixel.
1095 * <tt>GX_PERF1_TC_MISS</tt> counts how many of those accesses missed the texture cache. To compute the miss rate, divide <tt>GX_PERF1_TC_MISS</tt> by the sum of all four
1096 * <tt>GX_PERF1_TC_CHECK*</tt> values.<br><br>
1098 * \note <tt>GX_PERF1_VC_*</tt> count different vertex cache stall conditions.
1099 * @{
1101 #define GX_PERF1_TEXELS 0 /*!< Number of texels processed by the GP. */
1102 #define GX_PERF1_TX_IDLE 1 /*!< Number of clocks that the texture unit (TX) is idle. */
1103 #define GX_PERF1_TX_REGS 2 /*!< Number of GP clocks spent writing to state registers in the TX unit. */
1104 #define GX_PERF1_TX_MEMSTALL 3 /*!< Number of GP clocks the TX unit is stalled waiting for main memory. */
1105 #define GX_PERF1_TC_CHECK1_2 4
1106 #define GX_PERF1_TC_CHECK3_4 5
1107 #define GX_PERF1_TC_CHECK5_6 6
1108 #define GX_PERF1_TC_CHECK7_8 7
1109 #define GX_PERF1_TC_MISS 8 /*!< Number of texture cache misses in total? */
1110 #define GX_PERF1_VC_ELEMQ_FULL 9
1111 #define GX_PERF1_VC_MISSQ_FULL 10
1112 #define GX_PERF1_VC_MEMREQ_FULL 11
1113 #define GX_PERF1_VC_STATUS7 12
1114 #define GX_PERF1_VC_MISSREP_FULL 13
1115 #define GX_PERF1_VC_STREAMBUF_LOW 14
1116 #define GX_PERF1_VC_ALL_STALLS 15
1117 #define GX_PERF1_VERTICES 16 /*!< Number of vertices processed by the GP. */
1118 #define GX_PERF1_FIFO_REQ 17 /*!< Number of lines (32B) read from the GP FIFO. */
1119 #define GX_PERF1_CALL_REQ 18 /*!< Number of lines (32B) read from called display lists. */
1120 #define GX_PERF1_VC_MISS_REQ 19 /*!< Number vertex cache miss request. Each miss requests a 32B transfer from main memory. */
1121 #define GX_PERF1_CP_ALL_REQ 20 /*!< Counts all requests (32B/request) from the GP Command Processor (CP). It should be equal to
1122 * the sum of counts returned by <tt>GX_PERF1_FIFO_REQ</tt>, <tt>GX_PERF1_CALL_REQ</tt>, and <tt>GX_PERF1_VC_MISS_REQ</tt>. */
1123 #define GX_PERF1_CLOCKS 21 /*!< Number of GP clocks that have elapsed since the last call to GX_ReadGP1Metric(). */
1124 #define GX_PERF1_NONE 22 /*!< Disables performance measurement for perf1 and resets the counter. */
1125 /*! @} */
1127 /*! \addtogroup tlutname TLUT name
1128 * \brief Name of Texture Look-Up Table (TLUT) in texture memory.
1130 * \details Each table <tt>GX_TLUT0</tt>-<tt>GX_TLUT15</tt> contains 256 entries,16b per entry. <tt>GX_BIGTLUT0</tt>-<tt>3</tt>
1131 * contains 1024 entries, 16b per entry. Used for configuring texture memory in GX_Init().
1132 * @{
1134 #define GX_TLUT0 0
1135 #define GX_TLUT1 1
1136 #define GX_TLUT2 2
1137 #define GX_TLUT3 3
1138 #define GX_TLUT4 4
1139 #define GX_TLUT5 5
1140 #define GX_TLUT6 6
1141 #define GX_TLUT7 7
1142 #define GX_TLUT8 8
1143 #define GX_TLUT9 9
1144 #define GX_TLUT10 10
1145 #define GX_TLUT11 11
1146 #define GX_TLUT12 12
1147 #define GX_TLUT13 13
1148 #define GX_TLUT14 14
1149 #define GX_TLUT15 15
1150 #define GX_BIGTLUT0 16
1151 #define GX_BIGTLUT1 17
1152 #define GX_BIGTLUT2 18
1153 #define GX_BIGTLUT3 19
1154 /*! @} */
1156 #define GX_MAX_VTXDESC GX_VA_MAXATTR
1157 #define GX_MAX_VTXDESC_LISTSIZE (GX_VA_MAXATTR+1)
1159 #define GX_MAX_VTXATTRFMT GX_VA_MAXATTR
1160 #define GX_MAX_VTXATTRFMT_LISTSIZE (GX_VA_MAXATTR+1)
1162 #define GX_MAX_Z24 0x00ffffff
1164 #ifdef __cplusplus
1165 extern "C" {
1166 #endif /* __cplusplus */
1168 typedef union _wgpipe
1170 vu8 U8;
1171 vs8 S8;
1172 vu16 U16;
1173 vs16 S16;
1174 vu32 U32;
1175 vs32 S32;
1176 vf32 F32;
1177 } WGPipe;
1179 /*! \typedef struct _gx_color GXColor
1180 * \brief Structure used to pass colors to some GX functions.
1182 typedef struct _gx_color {
1183 u8 r; /*!< Red color component. */
1184 u8 g; /*!< Green color component. */
1185 u8 b; /*!< Blue alpha component. */
1186 u8 a; /*!< Alpha component. If a function does not use the alpha value, it is safely ignored. */
1187 } GXColor;
1189 /*! \typedef struct _gx_colors10 GXColorS10
1190 * \brief Structure used to pass signed 10-bit colors to some GX functions.
1192 typedef struct _gx_colors10 {
1193 s16 r; /*!< Red color component. */
1194 s16 g; /*!< Green color component. */
1195 s16 b; /*!< Blue color component. */
1196 s16 a; /*!< Alpha component. If a function does not use the alpha value, it is safely ignored. */
1197 } GXColorS10;
1199 /*! \typedef struct _gx_texobj GXTexObj
1200 * \brief Object containing information about a texture.
1202 * \details This structure contains precompiled register state setting commands and data. The application must use the GX_InitTexObj*()
1203 * function to initialize or change this object. The proper size of the object is returned by
1205 * \code sizeof(GXTexObj) \endcode
1207 * \details but the internal data representation is not visible to the application.
1209 typedef struct _gx_texobj {
1210 u32 val[8];
1211 } GXTexObj;
1213 /*! \typedef struct _gx_tlutobj GXTlutObj
1214 * \brief Object containing information on a TLUT.
1216 * \details This structure contains precompiled register state setting commands and data. The application must use the GX_InitTlutObj()
1217 * function to initialize or change this object. The proper size of the object is returned by
1219 * \code sizeof(GXTlutObj) \endcode
1221 * \details but the internal data representation is not visible to the application.
1223 typedef struct _gx_tlutobj {
1224 u32 val[3];
1225 } GXTlutObj;
1227 /*! \typedef struct _gx_texreg GXTexRegion
1228 * \brief Object containing information on a texture cache region.
1230 * \details This structure contains precompiled register state setting commands and data. The application must use the
1231 * GX_InitTexCacheRegion() function to initialize or change this object. The proper size of the object is returned by
1233 * \code sizeof(GXTexRegion) \endcode
1235 * \details but the internal data representation is not visible to the application.
1237 typedef struct _gx_texreg {
1238 u32 val[4];
1239 } GXTexRegion;
1241 /*! \typedef struct _gx_tlutreg GXTlutRegion
1242 * \brief Object containing information on a TLUT cache region.
1244 * \details This structure contains precompiled register state setting commands and data. The application must use the GX_InitTlutRegion()
1245 * function to initialize or change this object. The proper size of the object is returned by
1247 * \code sizeof(GXTlutRegion) \endcode
1249 * \details but the internal data representation is not visible to the application.
1251 typedef struct _gx_tlutreg {
1252 u32 val[4];
1253 } GXTlutRegion;
1255 /*! \typedef _gx_litobj GXLightObj
1256 * \brief Object containing information on a light.
1258 * \details This structure contains precompiled register state setting commands and data. The application must use the GX_InitLight*() functions
1259 * to initialize or change this object. The proper size of the object is returned by
1261 * \code sizeof(GXLightObj) \endcode
1263 * \details but the internal data representation is not visible to the application.
1265 typedef struct _gx_litobj {
1266 u32 val[16];
1267 } GXLightObj;
1269 typedef struct _vtx {
1270 f32 x,y,z;
1271 u16 s,t;
1272 u32 rgba;
1273 } Vtx;
1275 /*! \struct GXVtxDesc
1276 * \brief Structure describing how a single vertex attribute will be referenced.
1278 * \details An array of these structures can be used to describe all the attributes in a vertex. The attribute <tt>GX_VA_NULL</tt> should be
1279 * used to mark the end of the array.
1281 typedef struct {
1282 u8 attr; /*!< \ref vtxattr for this element. */
1283 u8 type; /*!< \ref vtxattrin for this element. */
1284 } GXVtxDesc;
1286 /*! \struct GXVtxAttrFmt
1287 * \brief Structure describing the attribute format for one attribute.
1289 * \details An array of these structures can be used to describe the format of all attributes in a vertex. The attribute <tt>GX_VA_NULL</tt>
1290 * should be used to mark the end of the array.
1292 typedef struct {
1293 u32 vtxattr; /*!< \ref vtxattr for this element. */
1294 u32 comptype; /*!< \ref comptype for this element. */
1295 u32 compsize; /*!< \ref compsize for this element. */
1296 u32 frac; /*!< Number of fractional bits for a fixed-point number. */
1297 } GXVtxAttrFmt;
1299 /*! \struct GXFifoObj
1300 * \brief Object describing a graphics FIFO.
1302 * \details This structure contains precompiled register state setting commands and data. The application must use the GX_InitFifo*() functions
1303 * to initialize or change this object. The proper size of the object is returned by
1305 * \code sizeof(GXFifoObj) \endcode
1307 * but the internal data representation is not visible to the application.
1309 typedef struct {
1310 u8 pad[GX_FIFO_OBJSIZE];
1311 } GXFifoObj;
1313 typedef struct {
1314 u8 dummy[4];
1315 } GXTexReg;
1317 /*! \struct GXFogAdjTbl
1318 * \brief Fog range adjustment parameter table.
1320 typedef struct {
1321 u16 r[10]; /*!< u4.8 format range parameter. */
1322 } GXFogAdjTbl;
1324 /*! \typedef void (*GXBreakPtCallback)(void)
1325 * \brief function pointer typedef for the GP breakpoint-token callback
1327 typedef void (*GXBreakPtCallback)(void);
1329 /*! \typedef void (*GXDrawDoneCallback)(void)
1330 * \brief function pointer typedef for the GP drawdone-token callback
1332 typedef void (*GXDrawDoneCallback)(void);
1334 /*! \typedef void (*GXDrawSyncCallback)(u16 token)
1335 * \brief function pointer typedef for the drawsync-token callback
1336 * \param[out] token tokenvalue most recently encountered.
1338 typedef void (*GXDrawSyncCallback)(u16 token);
1340 /*! \typedef GXTexRegion* (*GXTexRegionCallback)(GXTexObj *obj,u8 mapid)
1341 * \brief function pointer typedef for the texture region callback
1342 * \param[out] token tokenvalue most recently encountered.
1344 typedef GXTexRegion* (*GXTexRegionCallback)(GXTexObj *obj,u8 mapid);
1346 /*! \typedef GXTlutRegion* (*GXTlutRegionCallback)(u32 tlut_name)
1347 * \brief function pointer typedef for the TLUT region callback
1348 * \param[out] token tokenvalue most recently encountered.
1350 typedef GXTlutRegion* (*GXTlutRegionCallback)(u32 tlut_name);
1352 extern WGPipe* const wgPipe;
1354 * \fn GXFifoObj* GX_Init(void *base,u32 size)
1355 * \brief Initializes the graphics processor to its initial state.
1357 * \details This function sets the default state of the graphics processor and should be called before any other GX functions.
1358 * This function sets up an immediate-mode method of communicating graphics commands from the CPU to the Graphics Processor
1359 * (GP). This function will initialize a FIFO and attach it to both the CPU and GP. The CPU will write commands to the FIFO
1360 * and the GP will read the commands. This function returns a pointer to the initialized FIFO. The application must allocate
1361 * the memory for the FIFO. The parameter \a base is a pointer to the allocated main memory and must be aligned to 32B. \a size
1362 * is the size of the FIFO in bytes and must be a multiple of 32B. Refer to additional notes in GX_InitFifoBase() concerning
1363 * the FIFO memory.
1365 * \note It is also possible to override the default immediate-mode style and instead buffer the graphics for frame <i>n+1</i>
1366 * while the GP is reading the graphics for frame <i>n</i>. See GX_SetCPUFifo() and GX_SetGPFifo() for further information.<br><br>
1368 * \note This function also designates the calling thread as the default GX thread; i.e., it assumes the calling thread is the
1369 * one responsible for generating graphics data. This thread will be the thread to be suspended when the FIFO gets too full.
1370 * The current GX thread can be changed by calling GX_SetCurrentGXThread().
1372 * \param[in] base pointer to the GX FIFO buffer base address. Must be aligned on a 32 Byte boundery.
1373 * \param[in] size size of buffer. Must be a multiple of 32.
1375 * \return pointer to the intialized GXFifoObj object.
1377 GXFifoObj* GX_Init(void *base,u32 size);
1380 * \fn void GX_InitFifoBase(GXFifoObj *fifo,void *base,u32 size)
1381 * \brief Describes the area of main memory that will be used for this \a fifo.
1383 * The Graphics FIFO is the mechanism used to communicate graphics commands from the CPU to the Graphics Processor (GP). The FIFO
1384 * base pointer should be 32-byte aligned. memalign() can return 32-byte aligned pointers. The size should also be a multiple of
1385 * 32B.
1387 * The CPU's write-gather pipe is used to write data to the FIFO. Therefore, the FIFO memory area must be forced out of the CPU
1388 * cache prior to being used. DCInvalidateRange() may be used for this purpose. Due to the mechanics of flushing the write-gather
1389 * pipe, the FIFO memory area should be at least 32 bytes larger than the maximum expected amount of data stored. Up to 32 NOPs
1390 * may be written at the end during flushing.
1392 * \note GX_Init() also takes the arguments \a base and \a size and initializes a FIFO using these values and attaches the FIFO
1393 * to both the CPU and GP. The application must allocate the memory for the graphics FIFO before calling GX_Init(). Therefore, it
1394 * is not necessary to call this function unless you want to resize the default FIFO sometime after GX_Init() has been called or
1395 * you are creating a new FIFO. The minimum size is 64kB defined by <tt>GX_FIFO_MINSIZE</tt>.<br><br>
1397 * \note This function will also set the read and write pointers for the FIFO to the base address, so ordinarily it is not
1398 * necessary to call GX_InitFifoPtrs() when initializing the FIFO. In addition, This function sets the FIFO's high water mark to
1399 * (size-16kB) and the low water mark to (size/2), so it is also not necessary to call GX_InitFifoLimits().
1401 * \param[in] fifo the fifo struct to use
1402 * \param[in] base ptr to the base of allocation; must be 32-byte aligned
1403 * \param[in] size size of the FIFO in bytes; must be multiple of 32; size must be <tt>GX_FIFO_MINSIZE</tt> or larger
1405 * \return none
1407 void GX_InitFifoBase(GXFifoObj *fifo,void *base,u32 size);
1410 * \fn void GX_InitFifoLimits(GXFifoObj *fifo,u32 hiwatermark,u32 lowatermark)
1411 * \brief Sets the high and low water mark for the \a fifo.
1413 * \details The high and low water marks are used in <i>immediate-mode</i>, i.e. when the \a fifo is attached to both the CPU and
1414 * Graphics Processor (GP) (see GX_SetCPUFifo() and GX_SetGPFifo()).
1416 * The hardware keeps track of the number of bytes between the read and write pointers. This number represents how full the FIFO is,
1417 * and when it is greater than or equal to the \a hiwatermark, the hardware issues an interrupt. The GX API will suspend sending
1418 * graphics to the Graphics FIFO until it has emptied to a certain point. The \a lowatermark is used to set the point at which the
1419 * FIFO is empty enough to resume sending graphics commands to the FIFO. Both \a hiwatermark and \a lowatermark should be in
1420 * multiples of 32B. The count for \a lowatermark should be less than \a hiwatermark. Of course, \a hiwatermark and \a lowatermark
1421 * must be less than the size of the FIFO.
1423 * \note When the FIFO is only attached to the CPU or only attached to the GP, the high and low water mark interrupts are disabled.
1425 * \param[in] fifo the fifo struct to use
1426 * \param[in] hiwatermark number of bytes to be queued before libogc stops writing commands to the FIFO
1427 * \param[in] lowatermark number of bytes to be queued before libogc resumes writing commands to the FIFO
1429 * \return none
1431 void GX_InitFifoLimits(GXFifoObj *fifo,u32 hiwatermark,u32 lowatermark);
1434 * \fn void GX_InitFifoPtrs(GXFifoObj *fifo,void *rd_ptr,void *wt_ptr)
1435 * \brief Sets the \a fifo read and write pointers.
1437 * \note This is normally done only during initialization of the FIFO. After that, the graphics hardware manages the FIFO pointers.
1439 * \param[in] fifo the fifo struct to use
1440 * \param[in] rd_ptr the pointer to use for the FIFO read pointer; must be 32-byte aligned
1441 * \param[in] wt_ptr the pointer to use for the FIFO write pointer; must be 32-byte aligned
1443 * \return none
1445 void GX_InitFifoPtrs(GXFifoObj *fifo,void *rd_ptr,void *wt_ptr);
1448 * \fn void GX_GetFifoPtrs(GXFifoObj *fifo,void **rd_ptr,void **wt_ptr)
1449 * \brief Returns the current value of the Graphics FIFO read and write pointers.
1451 * \note See GX_EnableBreakPt() for an example of why you would do this.
1453 * \param[in] fifo pointer to a FIFO struct
1454 * \param[out] rd_ptr address of the FIFO read pointer
1455 * \param[out] wt_ptr address of the FIFO write pointer
1457 * \return none
1459 void GX_GetFifoPtrs(GXFifoObj *fifo,void **rd_ptr,void **wt_ptr);
1462 * \fn void GX_SetCPUFifo(GXFifoObj *fifo)
1463 * \brief Attaches a FIFO to the CPU.
1465 * \note If the FIFO being attached is one already attached to the GP, the FIFO can be considered to be in immediate mode. If not,
1466 * the CPU can write commands, and the GP will execute them when the GP attaches to this FIFO (multi-buffered mode).
1468 * \param[in] fifo fifo struct containing info on the FIFO to attach
1470 * \return none
1472 void GX_SetCPUFifo(GXFifoObj *fifo);
1475 * \fn void GX_SetGPFifo(GXFifoObj *fifo)
1476 * \brief Attaches \a fifo to the GP.
1478 * \note If the FIFO is also attached to the CPU, the system is in immediate-mode, and the fifo acts like a true FIFO. In immediate-mode,
1479 * graphics commands are fed directly from the CPU to the GP. In immediate-mode the FIFO's high and low water marks are active. The high
1480 * and low water marks implement the flow-control mechanism between the CPU and GP. When the FIFO becomes more full than the high water
1481 * mark, the CPU will stop writing graphics commands into the FIFO. When the FIFO empties to a point lower than the low water mark, the
1482 * CPU will resume writing graphics commands into the FIFO. The high and low water marks are set when intializing the FIFO using
1483 * GX_InitFifoLimits().<br><br>
1485 * \note If the FIFO is only attached to the GP, the FIFO acts like a buffer. In this case, high and low water marks are disabled, and
1486 * the GP reads the FIFO until it is empty. Before attaching a new FIFO to the GP, you should make sure the previous FIFO is empty, using
1487 * the \a cmdIdle status returned by GX_GetGPStatus().<br><br>
1489 * \note The break point mechanism can be used to force the FIFO to stop reading commands at a certain point; see GX_EnableBreakPt().
1491 * \param[in] fifo struct containing info on the FIFO to attach
1493 * \return none
1495 void GX_SetGPFifo(GXFifoObj *fifo);
1498 * \fn void GX_GetCPUFifo(GXFifoObj *fifo)
1499 * \brief Copies the information from the currently attached CPU FIFO into \a fifo.
1501 * \param[out] fifo the object to copy the current CPU FIFO object data into
1503 * \return none
1505 void GX_GetCPUFifo(GXFifoObj *fifo);
1508 * \fn void GX_GetGPFifo(GXFifoObj *fifo)
1509 * \brief Copies the information from the currently attached GP FIFO info \a fifo.
1511 * \param[out] fifo the object to copy the current GP FIFO object data into
1513 * \return none
1515 void GX_GetGPFifo(GXFifoObj *fifo);
1518 * \fn void* GX_GetFifoBase(GXFifoObj *fifo)
1519 * \brief Get the base address for a given \a fifo.
1521 * \param[in] fifo the object to get the address from
1523 * \return pointer to the base address of the FIFO in main memory.
1525 void* GX_GetFifoBase(GXFifoObj *fifo);
1528 * \fn u32 GX_GetFifoCount(GXFifoObj *fifo)
1529 * \brief Returns number of cache lines in the FIFO.
1531 * \note The count is incorrect if an overflow has occurred (i.e. you have written more data than the size of the fifo), as the
1532 * hardware cannot detect an overflow in general.
1534 * \param[in] fifo the FIFO to get the count from
1536 * \return number of cache lines in the FIFO
1538 u32 GX_GetFifoCount(GXFifoObj *fifo);
1541 * \fn u32 GX_GetFifoSize(GXFifoObj *fifo)
1542 * \brief Get the size of a given \a fifo.
1544 * \param[in] fifo the object to get the size from
1546 * \return size of the FIFO, in bytes
1548 u32 GX_GetFifoSize(GXFifoObj *fifo);
1551 * \fn u8 GX_GetFifoWrap(GXFifoObj *fifo)
1552 * \brief Returns a non-zero value if the write pointer has passed the TOP of the FIFO.
1554 * \details Returns true only if the FIFO is attached to the CPU and the FIFO write pointer has passed the top of the FIFO. Use the
1555 * return value to detect whether or not an overflow has occured by initializing the FIFO's write pointer to the base of the FIFO
1556 * before sending any commands to the FIFO.
1558 * \note If the FIFO write pointer is not explicitly set to the base of the FIFO, you cannot rely on this function to detect overflows.
1560 * \param[in] fifo the object to get the wrap status from
1562 * \return wrap value
1564 u8 GX_GetFifoWrap(GXFifoObj *fifo);
1567 * \fn GXDrawDoneCallback GX_SetDrawDoneCallback(GXDrawDoneCallback cb)
1568 * \brief Installs a callback that is invoked whenever a DrawDone command is encountered by the GP.
1570 * \details The DrawDone command is sent by GX_SetDrawDone().
1572 * \note By the time the callback is invoked, the GP will already have resumed reading from the FIFO, if there are any commands in it.
1574 * \param[in] cb callback to be invoked when DrawDone is encountered
1576 * \return pointer to the previous callback
1578 GXDrawDoneCallback GX_SetDrawDoneCallback(GXDrawDoneCallback cb);
1581 * \fn GXBreakPtCallback GX_SetBreakPtCallback(GXBreakPtCallback cb)
1582 * \brief Registers \a cb as a function to be invoked when a break point is encountered.
1584 * \warning The callback will run with interrupts disabled, so it should terminate as quickly as possible.
1586 * \param[in] cb function to be invoked when the breakpoint is encountered; NULL means no function will run
1588 * \return pointer to the previous callback function
1590 GXBreakPtCallback GX_SetBreakPtCallback(GXBreakPtCallback cb);
1593 * \fn void GX_AbortFrame()
1594 * \brief Aborts the current frame.
1596 * \details This command will reset the entire graphics pipeline, including any commands in the graphics FIFO.
1598 * \note Texture memory will not be reset, so currently loaded textures will still be valid; however, when loading texture using
1599 * GX_PreloadEntireTexture() or TLUTs using GX_LoadTlut(), you must make sure the command completed. You can use the draw sync mechanism to
1600 * do this; see GX_SetDrawSync() and GX_GetDrawSync().
1602 * \return none
1604 void GX_AbortFrame();
1607 * \fn void GX_Flush()
1608 * \brief Flushes all commands to the GP.
1610 * \details Specifically, it flushes the write-gather FIFO in the CPU to make sure that all commands are sent to the GP.
1612 * \return none
1614 void GX_Flush();
1617 * \fn void GX_SetMisc(u32 token,u32 value)
1618 * \brief Sets miscellanous settings in the GP.
1620 * \param[in] token setting to change
1621 * \param[in] value value to change the setting to
1623 * \return none
1625 void GX_SetMisc(u32 token,u32 value);
1628 * \fn void GX_SetDrawDone()
1629 * \brief Sends a DrawDone command to the GP.
1631 * \details When all previous commands have been processed and the pipeline is empty, a <i>DrawDone</i> status bit will be set,
1632 * and an interrupt will occur. You can receive notification of this event by installing a callback on the interrupt with
1633 * GX_SetDrawDoneCallback(), or you can poll the status bit with GX_WaitDrawDone(). This function also flushes the write-gather
1634 * FIFO in the CPU to make sure that all commands are sent to the graphics processor.
1636 * \note This function is normally used in multibuffer mode (see GX_SetCPUFifo()). In immediate mode, the GX_DrawDone() command
1637 * can be used, which both sends the command and stalls until the DrawDone status is true.
1639 * \return none
1641 void GX_SetDrawDone();
1644 * \fn void GX_WaitDrawDone()
1645 * \brief Stalls until <i>DrawDone</i> is encountered by the GP.
1647 * \details It means all graphics commands sent before this DrawDone command have executed and the last pixel has been written to
1648 * the frame buffer. You may want to execute some non-graphics operations between executing GX_SetDrawDone() and this function, but
1649 * if you simply want to wait and have nothing to execute, you can use GX_DrawDone().
1651 * \note This function is normally used in immediate mode (see GX_SetCPUFifo()). In multibuffer mode, sending the '<i>done</i>' command is
1652 * separated from polling the '<i>done</i>' status (see GX_SetDrawDone() and GX_WaitDrawDone()).
1654 * \return none
1656 void GX_WaitDrawDone();
1659 * \fn u16 GX_GetDrawSync()
1660 * \brief Returns the value of the token register, which is written using the GX_SetDrawSync() function.
1662 * \return the value of the token register.
1664 u16 GX_GetDrawSync();
1667 * \fn void GX_SetDrawSync(u16 token)
1668 * \brief This function sends a token into the command stream.
1670 * \details When the token register is set, an interrupt will also be received by the CPU. You can install a callback on this interrupt
1671 * with GX_SetDrawSyncCallback(). Draw syncs can be used to notify the CPU that the graphics processor is finished using a shared
1672 * resource (a vertex array for instance).
1674 * \param[in] token 16-bit value to write to the token register.
1676 * \return none
1678 void GX_SetDrawSync(u16 token);
1681 * \fn GXDrawSyncCallback GX_SetDrawSyncCallback(GXDrawSyncCallback cb)
1682 * \brief Installs a callback that is invoked whenever a DrawSync token is encountered by the graphics pipeline.
1684 * \details The callback's argument is the value of the token most recently encountered. Since it is possible to
1685 * miss tokens (graphics processing does not stop while the callback is running), your code should be
1686 * capable of deducing if any tokens have been missed.
1688 * \param[in] cb callback to be invoked when the DrawSync tokens are encountered in the graphics pipeline.
1690 * \return pointer to the previously set callback function.
1692 GXDrawSyncCallback GX_SetDrawSyncCallback(GXDrawSyncCallback cb);
1695 * \fn void GX_DisableBreakPt()
1696 * \brief Allows reads from the FIFO currently attached to the Graphics Processor (GP) to resume.
1698 * \details See GX_EnableBreakPt() for an explanation of the FIFO break point feature.
1700 * \note The breakpoint applies to the FIFO currently attached to the Graphics Processor (GP) (see GX_SetGPFifo()).
1702 * \return none
1704 void GX_DisableBreakPt();
1707 * \fn void GX_EnableBreakPt(void *break_pt)
1708 * \brief Sets a breakpoint that causes the GP to halt when encountered.
1710 * \note The break point feature allows the application to have two frames of graphics in the FIFO at the same time, overlapping
1711 * one frame's processing by the graphics processor with another frame's processing by the CPU. For example, suppose you finish
1712 * writing the graphics commands for one frame and are ready to start on the next. First, execute a GX_Flush() command to make
1713 * sure all the data in the CPU write gatherer is flushed into the FIFO. This will also align the FIFO write pointer to a 32B
1714 * boundary. Next, read the value of the current write pointer using GX_GetFifoPtrs(). Write the value of the write pointer as
1715 * the break point address using GX_EnableBreakPt(). When the FIFO read pointer reaches the break point address the hardware
1716 * will disable reads from the FIFO. The status \a brkpt, returned by GX_GetGPStatus(), can be polled to detect when the break point
1717 * is reached. The application can then decide when to disable the break point, using GX_DisableBreakPt(), which will allow the FIFO
1718 * to resume reading graphics commands.<br><br>
1720 * \note FIFO reads will stall when the GP FIFO read pointer is equal to the break point address \a break_pt. To re-enable reads of
1721 * the GP FIFO, use GX_DisableBreakPt().<br><br>
1723 * \note Use GX_SetBreakPtCallback() to set what function runs when the breakpoint is encountered.
1725 * \param[in] break_pt address for GP to break on when read.
1727 * \return none
1729 void GX_EnableBreakPt(void *break_pt);
1732 * \fn void GX_DrawDone()
1733 * \brief Sends a DrawDone command to the GP and stalls until its subsequent execution.
1735 * \note This function is equivalent to calling GX_SetDrawDone() then GX_WaitDrawDone().
1737 * \return none
1739 void GX_DrawDone();
1742 * \fn void GX_TexModeSync()
1743 * \brief Inserts a synchronization command into the graphics FIFO. When the Graphics Processor sees this command, it will
1744 * allow the texture pipeline to flush before continuing.
1746 * \details This command is necessary when changing the usage of regions of texture memory from preloaded or TLUT to cached areas.
1747 * It makes sure that the texture pipeline is finished with that area of the texture memory prior to changing its usage.
1748 * This function should be called prior to drawing any primitives that uses the texture memory region in its new mode. It is not
1749 * necessary to call this command when changing texture memory regions from cached to preloaded (or TLUT), since the commands to
1750 * load the regions with data will cause the necessary synchronization to happen automatically.
1752 * \return none
1754 void GX_TexModeSync();
1757 * \fn void GX_InvVtxCache();
1758 * \brief Invalidates the vertex cache.
1760 * \details Specifically, this functions invalidates the vertex cache tags. This function should be used whenever you relocate or modify
1761 * data that is read by, or may be cached by, the vertex cache. The invalidate is very fast, taking only two Graphics Processor (GP) clock
1762 * cycles to complete.
1764 * \note The vertex cache is used to cache indexed attribute data. Any attribute that is set to <tt>GX_INDEX8</tt> or <tt>GX_INDEX16</tt> in the current
1765 * vertex descriptor (see GX_SetVtxDesc()) is indexed. Direct data bypasses the vertex cache. Direct data is any attribute that is set to
1766 * <tt>GX_DIRECT</tt> in the current vertex descriptor.
1768 * \return none
1770 void GX_InvVtxCache();
1773 * \fn void GX_ClearVtxDesc()
1774 * \brief Clears all vertex attributes of the current vertex descriptor to GX_NONE.
1776 * \note The same functionality can be obtained using GX_SetVtxDescv(), however using GX_ClearVtxDesc() is much more efficient.
1778 * \return none
1780 void GX_ClearVtxDesc();
1783 * \fn void GX_LoadProjectionMtx(Mtx44 mt,u8 type)
1784 * \brief Sets the projection matrix.
1786 * \note Only two types of projection matrices are supported: <tt>GX_PERSPECTIVE</tt> or <tt>GX_ORTHOGRAPHIC</tt>.
1788 * \param[in] mt matrix to use for the perspective
1789 * \param[in] type which perspective type to use
1791 * \return none
1793 void GX_LoadProjectionMtx(Mtx44 mt,u8 type);
1796 * \fn void GX_SetViewport(f32 xOrig,f32 yOrig,f32 wd,f32 ht,f32 nearZ,f32 farZ)
1797 * \brief Sets the viewport rectangle in screen coordinates.
1799 * \details The screen origin (\a xOrig = 0.0f, \a yOrig = 0.0f) is at the top left corner of the display. Floating point arguments allow the
1800 * viewport to be adjusted by 1/2 line for interlaced field rendering modes; see GX_SetViewportJitter(). The viewport depth parameters are normalized coordinates
1801 * from 0.0f - 1.0f. The GX API will convert the depth range values to proper scale values depending on the type and format of the Z-buffer.
1803 * \note You should avoid using negative values for \a xOrig or \a yOrig. While this may work, it may cause problems with points and lines being clipped incorrectly. If
1804 * you need to shift the viewport up or left, consider using GX_SetScissorBoxOffset() instead.
1806 * \param[in] xOrig left-most X coordinate on the screen
1807 * \param[in] yOrig top-most Y coordinate on the screen
1808 * \param[in] wd width of the viewport
1809 * \param[in] ht height of the viewport
1810 * \param[in] nearZ value to use for near depth scale
1811 * \param[in] farZ value to use for far depth scale
1813 * \return none
1815 void GX_SetViewport(f32 xOrig,f32 yOrig,f32 wd,f32 ht,f32 nearZ,f32 farZ);
1818 * \fn void GX_SetViewportJitter(f32 xOrig,f32 yOrig,f32 wd,f32 ht,f32 nearZ,f32 farZ,u32 field)
1819 * \brief Sets the viewport and adjusts the viewport's line offset for interlaced field rendering.
1821 * \details Depending on whether the viewport starts on an even or odd line, and whether the next \a field to be rendered is
1822 * even or odd, the viewport may be adjusted by half a line. This has the same effect as slightly tilting the camera down and is necessary
1823 * for interlaced rendering. No other camera adjustment (i.e. don't change the projection matrix) is needed for interlaced field rendering.
1825 * \note To set a viewport <i>without</i> jitter, use GX_SetViewport().
1827 * \param[in] xOrig left-most X coordinate on the screen
1828 * \param[in] yOrig top-most Y coordinate on the screen
1829 * \param[in] wd width of the viewport
1830 * \param[in] ht height of the viewport
1831 * \param[in] nearZ value to use for near depth scale
1832 * \param[in] farZ value to use for far depth scale
1833 * \param[in] field whether the next field is even (0) or odd (1)
1835 * \return none
1837 void GX_SetViewportJitter(f32 xOrig,f32 yOrig,f32 wd,f32 ht,f32 nearZ,f32 farZ,u32 field);
1840 * \fn void GX_SetChanCtrl(s32 channel,u8 enable,u8 ambsrc,u8 matsrc,u8 litmask,u8 diff_fn,u8 attn_fn)
1841 * \brief Sets the lighting controls for a particular color channel.
1843 * \details The color channel can have one or more (up to 8) lights associated with it, set using \a litmask. The \a diff_fn and \a attn_fn parameters
1844 * control the lighting equation for all lights associated with this channel; the \a ambsrc and \a matsrc can be used to select whether the input
1845 * source colors come from register colors or vertex colors. When the channel \a enable is set to <tt>GX_FALSE</tt>, the material color source (set by \a matsrc)
1846 * is passed through as the channel's output color. When the channel \a enable is <tt>GX_TRUE</tt>, the output color depends on the settings of the other
1847 * controls (i.e., the lighting equation). GX_Init() sets the \a enable for all channels to <tt>GX_FALSE</tt>. This function only configures the lighting
1848 * channel; to output the result of the channel computation, use GX_SetNumChans().
1850 * \note Even though channels <tt>GX_COLOR0</tt> and <tt>GX_ALPHA0</tt> are controlled separately for lighting, they are rasterized together as one RGBA color, effectively
1851 * <tt>GX_COLOR0A0</tt>. The same is true for <tt>GX_COLOR1</tt> and <tt>GX_ALPHA1</tt>-- effectively, they are rasterized as <tt>GX_COLOR1A1</tt>. Since there is only one rasterizer for
1852 * color in the graphics hardware, you must choose which color to rasterize for each stage in the Texture Environment (TEV) unit. This is accomplished
1853 * using GX_SetTevOrder().<br><br>
1855 * \note In order to use a vertex color in channel <tt>GX_COLOR1A1</tt>, two colors per vertex must be supplied, i.e. both <tt>GX_VA_CLR0</tt> and <tt>GX_VA_CLR1</tt> must be
1856 * enabled in the current vertex descriptor. If only <tt>GX_VA_CLR0</tt> <b>or</b> <tt>GX_VA_CLR1</tt> is enabled in the current vertex descriptor, the vertex color is
1857 * directed to the channel <tt>GX_VA_COLOR0A0</tt>.<br><br>
1859 * \note When \a ambsrc is set to <tt>GX_SRC_REG</tt>, the color set by GX_SetChanAmbColor() is used as the ambient color. When \a matsrc is <tt>GX_SRC_REG</tt>, the color set
1860 * by GX_SetChanMatColor() is used as the material color.
1862 * \param[in] channel color channel to use
1863 * \param[in] enable whether or not to enable lighting for this channel
1864 * \param[in] ambsrc source for the ambient color
1865 * \param[in] matsrc source for the material color
1866 * \param[in] litmask \ref lightid or IDs to associate with this channel
1867 * \param[in] diff_fn \ref difffn to use
1868 * \param[in] attn_fn \ref attenfunc to use
1870 * \return none
1872 void GX_SetChanCtrl(s32 channel,u8 enable,u8 ambsrc,u8 matsrc,u8 litmask,u8 diff_fn,u8 attn_fn);
1875 * \fn void GX_SetChanAmbColor(s32 channel,GXColor color)
1876 * \brief Sets the ambient color register for color channel \a chan.
1878 * \details This color will be used by the channel as the ambient color if the ambient source, set by GX_SetChanCtrl(), is <tt>GX_SRC_REG</tt>.
1880 * \param[in] channel channel to set
1881 * \param[in] color color to set it to
1883 * \return none
1885 void GX_SetChanAmbColor(s32 channel,GXColor color);
1888 * \fn void GX_SetChanMatColor(s32 channel,GXColor color)
1889 * \brief Sets the material color register for color channel \a chan.
1891 * \details This color will be used by the channel as the material color if the material source, set by GX_SetChanCtrl(), is <tt>GX_SRC_REG</tt>.
1893 * \param[in] channel channel to set
1894 * \param[in] color color to set it to
1896 * \return none
1898 void GX_SetChanMatColor(s32 channel,GXColor color);
1901 * \fn void GX_SetArray(u32 attr,void *ptr,u8 stride)
1902 * \brief Sets the array base pointer and stride for a single attribute.
1904 * \details The array base and stride are used to compute the address of indexed attribute data using the equation:<br><br>
1906 * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>attr_addr</i> = \a ptr + <i>attr_idx</i> * \a stride
1908 * When drawing a graphics primitive that has been enabled to use indexed attributes (see GX_SetVtxDesc()), <i>attr_idx</i> is supplied in the vertex
1909 * data. The format and size of the data in the array must also be described using GX_SetVtxAttrFmt(). You can also index other data, such as
1910 * matrices (see GX_LoadPosMtxIdx(), GX_LoadNrmMtxIdx3x3(), and GX_LoadTexMtxIdx()), and light objects (see GX_LoadLightObjIdx()). In the case
1911 * of matrices and light objects, the size and format of the data to be loaded is implied by the function call.
1913 * There is a base pointer, \a ptr, for each type of attribute as well as for light data and matrices. Each attribute can be stored in its own
1914 * array for maximum data compression (i.e., removal of redundant attribute data). The \a stride is in byte units and is the distance between
1915 * attributes in the array.
1917 * \note Indexed data is loaded into a vertex cache in the graphics processor. The vertex cache fetches 32B of data for each cache miss;
1918 * therefore, there is a small performance benefit to aligning attribute arrays to 32B, and possibly for arranging vertex data so that it
1919 * doesn't span 32B boundaries. Conveniently enough, memalign() returns 32-byte aligned pointers. For static data arrays, you can use the
1920 * ATTRIBUTE_ALIGN(32) attribute macro to align the \a ptr to 32B.
1922 * \param[in] attr \ref vtxattr that the array is storing
1923 * \param[in] ptr pointer to the array itself
1924 * \param[in] stride stride (in bytes) between each element in the array
1926 * \return none
1928 void GX_SetArray(u32 attr,void *ptr,u8 stride);
1931 * \fn void GX_SetVtxAttrFmt(u8 vtxfmt,u32 vtxattr,u32 comptype,u32 compsize,u32 frac)
1932 * \brief Sets the attribute format (\a vtxattr) for a single attribute in the Vertex Attribute Table (VAT).
1934 * \details Each attribute format describes the data type (comptype), number of elements (compsize), and fixed point format (frac), if required. The
1935 * are eight vertex formats available in the VAT. The vertex format describes the format of all attributes in a vertex. The application can pre-program
1936 * all eight vertex formats and then select one of them during the actual drawing of geometry (See GX_Begin()). Note that all vertices used to draw a
1937 * particular graphics primitive will have the same format. The vertex format set using this function, along with the current vertex descriptor set
1938 * using GX_SetVtxDesc(), completely define the vertex data format.
1940 * \note The vertex format allows data to be sent to the graphics processor in its most <i>quantized</i> format. The graphics hardware will <i>inverse-quantize</i>
1941 * the data (into floating point format) before it is used. The vertex attribute format is used to communicate the data quantization format to the hardware.<br><br>
1943 * \note <tt>GX_VA_NRM</tt> and <tt>GX_VA_NBT</tt> attributes share the same type. Also, the frac for these attributes is fixed according to the type. The component count
1944 * (compsize) for <tt>GX_VA_NRM</tt> must be set to <tt>GX_NRM_XYZ</tt>. The component count for <tt>GX_VA_NBT</tt> must be set to <tt>GX_NRM_NBT</tt> or <tt>GX_NRM_NBT3</tt>.
1946 * \param[in] vtxfmt \ref vtxfmt
1947 * \param[in] vtxattr \ref vtxattr
1948 * \param[in] comptype \ref comptype
1949 * \param[in] compsize \ref compsize
1950 * \param[in] frac number of fractional bits in a fixed-point number
1952 * \return none
1954 void GX_SetVtxAttrFmt(u8 vtxfmt,u32 vtxattr,u32 comptype,u32 compsize,u32 frac);
1957 * \fn void GX_SetVtxAttrFmtv(u8 vtxfmt,GXVtxAttrFmt *attr_list)
1958 * \brief Sets multiple attribute formats within a single vertex format.
1960 * \details This is useful when you need to set all the attributes in a vertex format at once (e.g., during graphics initialization).
1962 * \note The constant <tt>GX_MAX_VTXATTRFMT_LISTSIZE</tt> should be used to allocate the list. You can get a current vertex format using GX_GetVtxAttrFmtv().
1964 * \param[in] vtxfmt \ref vtxfmt
1965 * \param[in] attr_list pointer to array of GXVtxAttrFmt structs to draw from
1967 * \return none
1969 void GX_SetVtxAttrFmtv(u8 vtxfmt,GXVtxAttrFmt *attr_list);
1972 * \fn void GX_SetVtxDesc(u8 attr,u8 type)
1973 * \brief Sets the \a type of a single attribute (\a attr) in the current vertex descriptor.
1975 * \details The current vertex descriptor defines which attributes are present in a vertex and how each attribute is referenced. The current
1976 * vertex descriptor is used by the Graphics Processor (GP) to interpret the graphics command stream produced by the GX API. In particular,
1977 * the current vertex descriptor is used to parse the vertex data that is present in the command stream.
1979 * \param[in] attr \ref vtxattr
1980 * \param[in] type \ref vtxattrin
1982 * \return none
1984 void GX_SetVtxDesc(u8 attr,u8 type);
1987 * \fn void GX_SetVtxDescv(GXVtxDesc *attr_list)
1988 * \brief Sets the type of multiple attributes.
1990 * \details This function is used when more than one attribute needs to be set (e.g., during initialization of geometry).
1992 * \note The constant <tt>GX_MAX_VTXATTRFMT_LISTSIZE</tt> can be used to allocate memory for \a attr_list
1994 * \param[in] attr_list array of pointers to GXVtxDesc structs; last element of the array should be <tt>GX_VA_NULL</tt>
1996 * \return none
1998 void GX_SetVtxDescv(GXVtxDesc *attr_list);
2001 * \fn void GX_GetVtxDescv(GXVtxDesc *attr_list)
2002 * \brief Gets the type of multiple attributes.
2004 * \details This function saves the attributes that are current set. This is usually used in conjunction with GX_SetVtxDescv
2006 * \note The constant <tt>GX_MAX_VTXATTRFMT_LISTSIZE</tt> must be used to allocate memory for \a attr_list
2008 * \param[in] attr_list array of pointers to GXVtxDesc structs
2010 * \return none
2012 void GX_GetVtxDescv(GXVtxDesc *attr_list);
2015 * \fn u32 GX_EndDispList()
2016 * \brief Ends a display list and resumes writing graphics commands to the CPU FIFO.
2018 * \details This function returns the size of the display list written to the display list buffer since GX_BeginDispList() was called. If
2019 * the display list size exceeds the size of the buffer allocated, a zero length size will be returned. The display list size is a
2020 * multiple of 32B and any unsed commands in the last 32B will be padded with <tt>GX_NOP</tt>. The size returned should be passed to
2021 * GX_CallDispList() when the display list needs to be executed.
2023 * \note Due to the mechanics of flushing the write-gather pipe (which is used to create the display list), the display buffer should be
2024 * at least 32 bytes larger than the maximum expected amount of data stored. This function calls GX_Flush(), and thus it is not necessary
2025 * to call GX_Flush() explicitly after creating the display list.<br><br>
2027 * \note A display list cannot be nested; i.e., no display list functions (GX_BeginDispList(), GX_EndDispList() and GX_CallDispList()) can
2028 * be called between a GX_BeginDispList() and GX_EndDispList() pair.<br><br>
2030 * \note To execute a display list, use GX_CallDispList().
2032 * \return 0 if display list size exceeds buffer, otherwise gives list size in bytes
2034 * \bug Specifying a display list buffer size for GX_BeginDispList() the exact size that the display list will be (after padding) will cause
2035 * this function to return a very large (and very incorrect) value.
2037 u32 GX_EndDispList();
2040 * \fn void GX_Begin(u8 primitve,u8 vtxfmt,u16 vtxcnt)
2041 * \brief Begins drawing of a graphics primitive.
2043 * \details To draw a graphics primitive, a stream of vertex data matching the description of both GX_SetVtxDesc() and GX_SetVtxAttrFmt() is
2044 * enclosed between GX_Begin()/GX_End() pairs. The number of vertices between GX_Begin() and GX_End() must match that specified by the \a vtxcnt
2045 * parameter. The type of the primitive will determine the minimum number of vertices required. For example, a <tt>GX_TRIANGLES</tt> primitive must
2046 * have at least 3 vertices.
2048 * \note Primitives in which the vertex order is clockwise to the viewer are considered front-facing (for culling purposes).
2050 * \param[in] primitve \ref primtype to draw
2051 * \param[in] vtxfmt \ref vtxfmt to use
2052 * \param[in] vtxcnt number of vertices being drawn; maximum is 65536
2054 void GX_Begin(u8 primitve,u8 vtxfmt,u16 vtxcnt);
2057 * \fn void GX_BeginDispList(void *list,u32 size)
2058 * \brief Begins a display list and disables writes to the FIFO currently attached to the CPU.
2060 * \details After this function is called, GX API functions that normally send command or data into the CPU FIFO will send them to the
2061 * display list buffer instead of the FIFO until GX_EndDispList() is called. Writes to the CPU FIFO will be re-enabled when the function
2062 * GX_EndDispList() executes.
2064 * Basically you can put most of GX API commands into a display list. However, since the use of display list can bypass all state
2065 * coherences controlled by GX API in run-time, sometimes it brings some state collisions or incoherences that may lead to unexpected
2066 * behavior or even graphics pipeline hang. The most recommended safe way is putting only primitives (regions enclosed by GX_Begin() and
2067 * GX_End()) that don't cause any state collisions.
2069 * \note The application is expected to allocate the memory for the display list buffer. If the display list exceeds the maximum size
2070 * of the buffer, GX_EndDispList() will return 0. The address of the buffer must be 32-byte aligned; memalign() can return 32-byte-aligned
2071 * pointers. You can use the macro ATTRIBUTE_ALIGN(32) to align statically allocated buffers.<br><br>
2073 * \note The CPU's write-gather pipe is used to write graphics commands to the display list. Therefore, the display list buffer must be
2074 * forced out of the CPU cache prior to being filled. DCInvalidateRange() may be used for this purpose. In addition, due to the mechanics
2075 * of flushing the write-gather pipe, the display list buffer should be at least 63 bytes larger than the maximum expected amount of data
2076 * stored.<br><br>
2078 * \note A display list cannot be nested; i.e., no display list functions (GX_BeginDispList(), GX_EndDispList() and GX_CallDispList()) can
2079 * be called between a GX_BeginDispList() and GX_EndDispList() pair.<br><br>
2081 * \note To execute a display list, use GX_CallDispList().
2083 * \param[in] list 32-byte aligned buffer to hold the list
2084 * \param[in] size size of the buffer, multiple of 32
2086 * \return none
2088 void GX_BeginDispList(void *list,u32 size);
2091 * \fn void GX_CallDispList(void *list,u32 nbytes)
2092 * \brief Causes the GP to execute graphics commands from the display \a list instead of from the GP FIFO.
2094 * \details When the number of bytes specified by \a nbytes have been read, the graphics processor will resume executing
2095 * commands from the graphics FIFO. Graphics commands from a display list are prefetched into a separate 4KB FIFO. This prevents
2096 * any data prefetched for the main graphics command stream from being lost during the display list call.
2098 * \note A display list cannot call another display list.<br><br>
2100 * \note The display list must be padded to a length of 32B. All the data in the display list is interpreted by the graphics
2101 * processor, so any unused memory at the end of a display list should be set to GX_NOP. If you create the display list using
2102 * GX_BeginDispList()/GX_EndDispList(), this padding will be inserted automatically.
2104 * \param[in] list 32-byte aligned pointer to the display list buffer
2105 * \param[in] nbytes number of bytes in the display list. Use the return value of GX_EndDispList() here.
2107 * \return none
2109 void GX_CallDispList(void *list,u32 nbytes);
2112 * \fn static inline void GX_End()
2113 * \brief Used to end the drawing of a graphics primitive. This does nothing in libogc.
2115 * \return none
2117 static inline void GX_End()
2121 static inline void GX_Position3f32(f32 x,f32 y,f32 z)
2123 wgPipe->F32 = x;
2124 wgPipe->F32 = y;
2125 wgPipe->F32 = z;
2128 static inline void GX_Position3u16(u16 x,u16 y,u16 z)
2130 wgPipe->U16 = x;
2131 wgPipe->U16 = y;
2132 wgPipe->U16 = z;
2135 static inline void GX_Position3s16(s16 x,s16 y,s16 z)
2137 wgPipe->S16 = x;
2138 wgPipe->S16 = y;
2139 wgPipe->S16 = z;
2142 static inline void GX_Position3u8(u8 x,u8 y,u8 z)
2144 wgPipe->U8 = x;
2145 wgPipe->U8 = y;
2146 wgPipe->U8 = z;
2149 static inline void GX_Position3s8(s8 x,s8 y,s8 z)
2151 wgPipe->S8 = x;
2152 wgPipe->S8 = y;
2153 wgPipe->S8 = z;
2156 static inline void GX_Position2f32(f32 x,f32 y)
2158 wgPipe->F32 = x;
2159 wgPipe->F32 = y;
2162 static inline void GX_Position2u16(u16 x,u16 y)
2164 wgPipe->U16 = x;
2165 wgPipe->U16 = y;
2168 static inline void GX_Position2s16(s16 x,s16 y)
2170 wgPipe->S16 = x;
2171 wgPipe->S16 = y;
2174 static inline void GX_Position2u8(u8 x,u8 y)
2176 wgPipe->U8 = x;
2177 wgPipe->U8 = y;
2180 static inline void GX_Position2s8(s8 x,s8 y)
2182 wgPipe->S8 = x;
2183 wgPipe->S8 = y;
2186 static inline void GX_Position1x8(u8 index)
2188 wgPipe->U8 = index;
2191 static inline void GX_Position1x16(u16 index)
2193 wgPipe->U16 = index;
2196 static inline void GX_Normal3f32(f32 nx,f32 ny,f32 nz)
2198 wgPipe->F32 = nx;
2199 wgPipe->F32 = ny;
2200 wgPipe->F32 = nz;
2203 static inline void GX_Normal3s16(s16 nx,s16 ny,s16 nz)
2205 wgPipe->S16 = nx;
2206 wgPipe->S16 = ny;
2207 wgPipe->S16 = nz;
2210 static inline void GX_Normal3s8(s8 nx,s8 ny,s8 nz)
2212 wgPipe->S8 = nx;
2213 wgPipe->S8 = ny;
2214 wgPipe->S8 = nz;
2217 static inline void GX_Normal1x8(u8 index)
2219 wgPipe->U8 = index;
2222 static inline void GX_Normal1x16(u16 index)
2224 wgPipe->U16 = index;
2227 static inline void GX_Color4u8(u8 r,u8 g,u8 b,u8 a)
2229 wgPipe->U8 = r;
2230 wgPipe->U8 = g;
2231 wgPipe->U8 = b;
2232 wgPipe->U8 = a;
2235 static inline void GX_Color3u8(u8 r,u8 g,u8 b)
2237 wgPipe->U8 = r;
2238 wgPipe->U8 = g;
2239 wgPipe->U8 = b;
2242 static inline void GX_Color3f32(f32 r, f32 g, f32 b)
2244 wgPipe->U8 = (u8)(r * 255.0);
2245 wgPipe->U8 = (u8)(g * 255.0);
2246 wgPipe->U8 = (u8)(b * 255.0);
2250 static inline void GX_Color1u32(u32 clr)
2252 wgPipe->U32 = clr;
2255 static inline void GX_Color1u16(u16 clr)
2257 wgPipe->U16 = clr;
2260 static inline void GX_Color1x8(u8 index)
2262 wgPipe->U8 = index;
2265 static inline void GX_Color1x16(u16 index)
2267 wgPipe->U16 = index;
2270 static inline void GX_TexCoord2f32(f32 s,f32 t)
2272 wgPipe->F32 = s;
2273 wgPipe->F32 = t;
2276 static inline void GX_TexCoord2u16(u16 s,u16 t)
2278 wgPipe->U16 = s;
2279 wgPipe->U16 = t;
2282 static inline void GX_TexCoord2s16(s16 s,s16 t)
2284 wgPipe->S16 = s;
2285 wgPipe->S16 = t;
2288 static inline void GX_TexCoord2u8(u8 s,u8 t)
2290 wgPipe->U8 = s;
2291 wgPipe->U8 = t;
2294 static inline void GX_TexCoord2s8(s8 s,s8 t)
2296 wgPipe->S8 = s;
2297 wgPipe->S8 = t;
2300 static inline void GX_TexCoord1f32(f32 s)
2302 wgPipe->F32 = s;
2305 static inline void GX_TexCoord1u16(u16 s)
2307 wgPipe->U16 = s;
2310 static inline void GX_TexCoord1s16(s16 s)
2312 wgPipe->S16 = s;
2315 static inline void GX_TexCoord1u8(u8 s)
2317 wgPipe->U8 = s;
2320 static inline void GX_TexCoord1s8(s8 s)
2322 wgPipe->S8 = s;
2325 static inline void GX_TexCoord1x8(u8 index)
2327 wgPipe->U8 = index;
2330 static inline void GX_TexCoord1x16(u16 index)
2332 wgPipe->U16 = index;
2335 static inline void GX_MatrixIndex1x8(u8 index)
2337 wgPipe->U8 = index;
2341 * \fn void GX_AdjustForOverscan(GXRModeObj *rmin,GXRModeObj *rmout,u16 hor,u16 ver)
2342 * \brief Takes a given render mode and returns a version that is reduced in size to account for overscan.
2344 * \details The number of pixels specified by \a hor is subtracted from each side of the screen, and the number of pixels specified
2345 * by \a ver is subtracted from both the top and the bottom of the screen. The active screen area is centered within what the render
2346 * mode specified before the adjustment.
2348 * \note Due to the wide possibilities of how a render mode may be configured, this function may not work in all cases. For instance,
2349 * if you use Y-scaling to create a size difference between the EFB and XFB, this function may not do the right thing. In such cases,
2350 * you should configure the desired render mode manually (or else call this function and then fix up the results).
2352 * \param[in] rmin rmode that is being copied
2353 * \param[in] rmout rmode to hold the adjusted version. Needs to be allocated but can be uninitialized.
2354 * \param[in] hor pixels to trim from each side of the screen
2355 * \param[in] ver pixels to tim from top and bottom of the screen
2357 * \returns none
2359 void GX_AdjustForOverscan(GXRModeObj *rmin,GXRModeObj *rmout,u16 hor,u16 ver);
2362 * \fn void GX_LoadPosMtxImm(Mtx mt,u32 pnidx)
2363 * \brief Used to load a 3x4 modelview matrix \a mt into matrix memory at location \a pnidx.
2365 * \details This matrix can be used to transform positions in model space to view space, either by making the matrix the current one (see
2366 * GX_SetCurrentMtx()), or by setting a matrix \a pnidx for each vertex. The parameter \a mt is a pointer to a 3x4 (row x column) matrix. The
2367 * parameter \a pnidx is used to refer to the matrix location (see \ref pnmtx) in matrix memory.
2369 * You can also load a normal matrix (GX_LoadNrmMtxImm() or GX_LoadNrmMtxIdx3x3()) to the same \a pnidx. Generally, the normal matrix
2370 * will be the inverse transpose of the position matrix. The normal matrix is used during vertex lighting. In cases where the modelview
2371 * and inverse transpose of the modelview (excluding translation) are the same, you can load the <i>same</i> matrix for both position and normal
2372 * transforms.
2374 * \note The matrix data is copied from DRAM through the CPU cache into the Graphics FIFO, so matrices loaded using this function are always
2375 * coherent with the CPU cache.
2377 * \param[in] mt the matrix to load
2378 * \param[in] pnidx \ref pnmtx to load into
2380 * \return none
2382 void GX_LoadPosMtxImm(Mtx mt,u32 pnidx);
2385 * \fn void GX_LoadPosMtxIdx(u16 mtxidx,u32 pnidx)
2386 * \brief Loads a 3x4 modelview matrix at index \a mtxidx from the array in main memory.
2388 * \details The array is set by GX_SetArray(), and the matrix is loaded into matrix memory at index \a pnidx (see \ref pnmtx). This
2389 * modelview matrix is used to transform positions in model space to view space, either by making the matrix the current one (see
2390 * GX_SetCurrentMtx()) or by setting a matrix \a pnidx for each vertex (see GX_SetVtxDesc()). The matrix will be loaded through the vertex cache.
2392 * You can also load a normal matrix (GX_LoadNrmMtxImm() or GX_LoadNrmMtxIdx3x3()) to the same \a pnidx. Generally, the normal matrix
2393 * will be the inverse transpose of the position matrix. The normal matrix is used during vertex lighting. In cases where the modelview
2394 * and inverse transpose of the modelview (excluding translation) are the same, you can load the <i>same</i> matrix for both position and normal
2395 * transforms. Since indexed matrix loads are through the vertex cache, you will only incur the main memory bandwidth load of one matrix load.
2397 * \note The matrix is loaded directly from main memory into the matrix memory thrugh the vertex cache, so it is incoherent with the CPU's cache.
2398 * It is the application's responsibility to flush any matrix data from the CPU cache (see DCStoreRange()) before calling this function.
2400 * \param[in] mtxidx index to the matrix array to load
2401 * \param[in] pnidx \ref pnmtx to load into
2403 * \return none
2405 void GX_LoadPosMtxIdx(u16 mtxidx,u32 pnidx);
2408 * \fn void GX_LoadNrmMtxImm(Mtx mt,u32 pnidx)
2409 * \brief Used to load a normal transform matrix into matrix memory at location \a pnidx from the 4x3 matrix \a mt.
2411 * \details This matrix is used to transform normals in model space to view space, either by making it the current matrix (see GX_SetCurrentMtx()),
2412 * or by setting a matrix pnidx for each vertex. The parameter \a mt is a pointer to a 3x4 (row x column) matrix. The translation terms
2413 * in the 3x4 matrix are not needed for normal rotation and are ignored during the load. The parameter \a pnidx is used to refer to the
2414 * matrix location (see \ref pnmtx) in matrix memory.
2416 * \note You can also load a position matrix (GX_LoadPosMtxImm()) to the same \a pnidx. Normally, the normal matrix will be the inverse transpose of
2417 * the position (modelview) matrix and is used during vertex lighting. In cases where the modelview and the inverse transpose of the modelview
2418 * matrix (excluding translation) are the same, the same matrix can be loaded for both normal and position matrices.<br><br>
2420 * \note The matrix data is copied from main memory or the CPU cache into the Graphics FIFO, so matrices loaded by this function are always coherent
2421 * with the CPU cache.<br><br>
2423 * \param[in] mt the matrix to load
2424 * \param[in] pnidx \ref pnmtx to load into
2426 * \return none
2428 void GX_LoadNrmMtxImm(Mtx mt,u32 pnidx);
2431 * \fn void GX_LoadNrmMtxIdx3x3(u16 mtxidx,u32 pnidx)
2432 * \brief Loads a 3x3 normal matrix into matrix memory at location \a pnidx from a 3x3 matrix located at index \a mtxidx
2433 * from the array in main memory.
2435 * \details The array is set by set by GX_SetArray(), and the matrix is loaded into matrix memory at index \a pnidx. This matrix can be used to
2436 * transform normals in model space to view space, either by making the matrix the current one (see GX_SetCurrentMtx()), or by setting a
2437 * matrix \a pnidx for each vertex (see GX_SetVtxDesc()). The matrix will be loaded through the vertex cache. You can also load a position
2438 * matrix (GX_LoadPosMtxImm() or GX_LoadPosMtxIdx()) to the same \a pnidx.
2440 * \note You cannot use an indexed load to load a 3x3 matrix from an indexed 3x4 matrix in main memory; you must use GX_LoadNrmMtxImm() for
2441 * this case.<br><br>
2443 * \note The matrix is loaded directly from main memory into the matrix memory through the vertex cache, therefore it is incoherent with the
2444 * CPU's cache. It is the application's responsibility to flush any matrix data from the CPU cache (see DCStoreRange()) before calling this
2445 * function.
2447 * \param[in] mtxidx index to the matrix array to load
2448 * \param[in] pnidx \ref pnmtx to load into
2450 * \return none
2452 void GX_LoadNrmMtxIdx3x3(u16 mtxidx,u32 pnidx);
2455 * \fn void GX_LoadTexMtxImm(Mtx mt,u32 texidx,u8 type)
2456 * \brief Loads a texture matrix \a mt into the matrix memory at location \a texidx.
2458 * \details The matrix loaded can be either a 2x4 or 3x4 matrix as indicated by \a type. You can use the loaded matrix to
2459 * transform texture coordinates, or to generate texture coordinates from position or normal vectors. Such generated texture
2460 * coordinates are used for projected textures, reflection mapping, etc. See GX_SetTexCoordGen() for more details.
2462 * Texture matrices can be either 2x4 or 3x4. <tt>GX_MTX_2x4</tt> matrices can be used for simple translations and/or rotations of texture
2463 * coordinates. <tt>GX_MTX_3x4</tt> matrices are used when projection is required.
2465 * \note The default matrix memory configuration allows for ten (3x4 or 2x4) texture matrices, and a 3x4 identity matrix. The <tt>GX_IDENTITY</tt>
2466 * matrix is preloaded by GX_Init().<br><br>
2468 * \note This function allows one to load post-transform texture matrices as well. Specifying a texidx in the range of \ref dttmtx will load a
2469 * post-transform texture matrix instead of a regular, first-pass texture matrix. Note that post-transform matrices are always 3x4. Refer to
2470 * GX_SetTexCoordGen2() for information about how to use post-transform texture matrices.
2472 * \param[in] mt the matrix to load
2473 * \param[in] texidx \ref texmtx
2474 * \param[in] type \ref mtxtype
2476 * \return none
2478 void GX_LoadTexMtxImm(Mtx mt,u32 texidx,u8 type);
2481 * \fn void GX_LoadTexMtxIdx(u16 mtxidx,u32 texidx,u8 type)
2482 * \brief Loads a texture matrix at index \a mtxidx from the array in main memory
2484 * \details The array is set by GX_SetArray(), and the matrix is loaded into matrix memory at location \a texid. The loaded matrix can be
2485 * either 2x4 or 3x4 as indicated by \a type. This matrix can be used to generate texture coordinates from positions, normals, and input
2486 * texture coordinates (see GX_SetTexCoordGen()). The matrix is loaded through the vertex cache. The size of the matrix to load is indicated by its
2487 * \a type. Texture matrices can be either 2x4 or 3x4. <tt>GX_MTX_2x4</tt> matrices can be used for simple translations and/or rotations of texture
2488 * coordinates; <tt>GX_MTX_3x4</tt> matrices are used when projection is required.
2490 * \note The matrix is loaded directly from main memory into the matrix memory through the vertex cache, so it is incoherent with the CPU's
2491 * cache. It is the application's responsibility to flush any matrix data from the CPU cache (see DCStoreRange()) before calling this function.<br><br>
2493 * \note This function allows one to load post-transform texture matrices as well. Specifying a \a texidx in the range of \ref dttmtx will load a
2494 * post-transform texture matrix instead of a regular, first-pass texture matrix. Note that post-transform matrices are always 3x4. Refer to
2495 * GX_SetTexCoordGen2() for information about how to use post-transform texture matrices.
2497 * \param[in] mtxidx index to the matrix array to load
2498 * \param[in] texidx \ref texmtx
2499 * \param[in] type \ref mtxtype
2501 * \return none
2503 void GX_LoadTexMtxIdx(u16 mtxidx,u32 texidx,u8 type);
2506 * \fn void GX_SetCurrentMtx(u32 mtx)
2507 * \brief Selects a specific matrix to use for transformations.
2509 * \details The matrix \a mtx specified will be used to select the current modelview transform matrix and normal transform matrix,
2510 * as long as a matrix index is not present in the vertex data (see GX_SetVtxDesc()). If the current vertex descriptor enables <tt>GX_VA_PTNMTXIDX</tt>,
2511 * the matrix \a mtx specified by this function will be overwritten when the vertices are drawn.
2513 * \param[in] mtx \ref pnmtx
2515 * \return none
2517 void GX_SetCurrentMtx(u32 mtx);
2520 * \fn void GX_SetTevOp(u8 tevstage,u8 mode)
2521 * \brief Simplified function to set various TEV parameters for this \a tevstage based on a predefined combiner \a mode.
2523 * \details This is a convenience function designed to make initial programming of the Texture Environment unit (TEV) easier. This function calls
2524 * GX_SetTevColorIn(), GX_SetTevColorOp(), GX_SetTevAlphaIn() and GX_SetTevAlphaOp() with predefined arguments to implement familiar texture
2525 * combining functions.
2527 * \note To enable a consecutive set of TEV stages, you must call GX_SetNumTevStages().
2529 * \param[in] tevstage \ref tevstage.
2530 * \param[in] mode \ref tevdefmode
2532 * \return none
2534 void GX_SetTevOp(u8 tevstage,u8 mode);
2537 * \fn void GX_SetTevColor(u8 tev_regid,GXColor color)
2538 * \brief Used to set one of the primary color registers in the TEV unit.
2540 * \details These registers are available to all TEV stages. At least one of these registers is used to pass the output of one TEV stage to
2541 * the next in a multi-texture configuration. The application is responsible for allocating these registers so that no collisions in usage occur.
2543 * \note This function can only set unsigned 8-bit colors. To set signed, 10-bit colors use GX_SetTevColorS10().
2545 * \param[in] tev_regid \ref tevcoloutreg.
2546 * \param[in] color Constant color value.
2548 * \return none
2550 void GX_SetTevColor(u8 tev_regid,GXColor color);
2553 * \fn void GX_SetTevColorS10(u8 tev_regid,GXColorS10 color)
2554 * \brief Used to set one of the constant color registers in the TEV unit.
2556 * \details These registers are available to all TEV stages. At least one of these registers is used to pass the output of one TEV stage to the
2557 * next in a multi-texture configuration. The application is responsible for allocating these registers so that no collisions in usage occur.
2559 * \note This function enables the color components to be signed 10-bit numbers. To set 8-bit unsigned colors (the common case), use GX_SetTevColor().
2561 * \param[in] tev_regid \ref tevcoloutreg.
2562 * \param[in] color Constant color value in S10 format.
2564 * \return none
2566 void GX_SetTevColorS10(u8 tev_regid,GXColorS10 color);
2569 * \fn void GX_SetTevColorIn(u8 tevstage,u8 a,u8 b,u8 c,u8 d)
2570 * \brief Sets the color input sources for one \a tevstage of the Texture Environment (TEV) color combiner.
2572 * \details This includes constant (register) colors and alphas, texture color/alpha, rasterized color/alpha (the result of per-vertex lighting),
2573 * and a few useful constants.
2575 * \note The input controls are independent for each TEV stage.
2577 * \param[in] tevstage \ref tevstage
2578 * \param[in] a \ref tevcolorarg
2579 * \param[in] b \ref tevcolorarg
2580 * \param[in] c \ref tevcolorarg
2581 * \param[in] d \ref tevcolorarg
2583 * \return none
2585 void GX_SetTevColorIn(u8 tevstage,u8 a,u8 b,u8 c,u8 d);
2588 * \fn void GX_SetTevAlphaIn(u8 tevstage,u8 a,u8 b,u8 c,u8 d)
2589 * \brief Sets the alpha input sources for one \a tevstage of the Texture Environment (TEV) alpha combiner.
2591 * \details There are fewer alpha inputs than color inputs, and there are no color channels available in the alpha combiner.
2593 * \note The input controls are independent for each TEV stage.
2595 * \param[in] tevstage \ref tevstage
2596 * \param[in] a \ref tevalphaarg
2597 * \param[in] b \ref tevalphaarg
2598 * \param[in] c \ref tevalphaarg
2599 * \param[in] d \ref tevalphaarg
2601 * \return none
2603 void GX_SetTevAlphaIn(u8 tevstage,u8 a,u8 b,u8 c,u8 d);
2606 * \fn void GX_SetTevColorOp(u8 tevstage,u8 tevop,u8 tevbias,u8 tevscale,u8 clamp,u8 tevregid)
2607 * \brief Sets the \a tevop, \a tevbias, \a tevscale and \a clamp-mode operation for the color combiner
2608 * for this \a tevstage of the TEV unit.
2610 * \details This function also specifies the register, \a tevregid, that will contain the result of the color combiner function. The color
2611 * combiner function is:<br><br>
2613 * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\a tevregid = (d (\a tevop) ((1.0 - c)*a + c*b) + \a tevbias) * \a tevscale;<br><br>
2616 * The input sources a,b,c and d are set using GX_SetTevColorIn().
2618 * \param[in] tevstage \ref tevstage.
2619 * \param[in] tevop \ref tevop
2620 * \param[in] tevbias \ref tevbias.
2621 * \param[in] tevscale \ref tevscale.
2622 * \param[in] clamp Clamp results when <tt>GX_TRUE</tt>.
2623 * \param[in] tevregid \ref tevcoloutreg
2625 * \return none
2627 void GX_SetTevColorOp(u8 tevstage,u8 tevop,u8 tevbias,u8 tevscale,u8 clamp,u8 tevregid);
2631 * \fn void GX_SetTevAlphaOp(u8 tevstage,u8 tevop,u8 tevbias,u8 tevscale,u8 clamp,u8 tevregid)
2632 * \brief Sets the \a tevop, \a tevbias, \a tevscale and \a clamp-mode operation for the alpha combiner
2633 * for this \a tevstage of the TEV unit.
2635 * \details This function also specifies the register, \a tevregid, that will contain the result of the alpha combiner function. The alpha
2636 * combiner function is:<br><br>
2638 * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\a tevregid = (d (\a tevop) ((1.0 - c)*a + c*b) + \a tevbias) * \a tevscale;<br><br>
2640 * The input sources a,b,c and d are set using GX_SetTevAlphaIn().
2642 * \param[in] tevstage \ref tevstage.
2643 * \param[in] tevop \ref tevop
2644 * \param[in] tevbias \ref tevbias.
2645 * \param[in] tevscale \ref tevscale.
2646 * \param[in] clamp Clamp results when <tt>GX_TRUE</tt>.
2647 * \param[in] tevregid \ref tevcoloutreg
2649 * \return none
2651 void GX_SetTevAlphaOp(u8 tevstage,u8 tevop,u8 tevbias,u8 tevscale,u8 clamp,u8 tevregid);
2654 * \fn void GX_SetNumTexGens(u32 nr)
2655 * \brief Sets the number of texture coordinates that are generated and available for use in the Texture Environment TEV stages.
2657 * \details Texture coordinates are generated from input data as described by GX_SetTexCoordGen(). The generated texture coordinates are linked to
2658 * specific textures and specific TEV stages using GX_SetTevOrder().
2660 * \note A consecutive number of texture coordinates may be generated, starting at <tt>GX_TEXCOORD0</tt>. A maximum of 8 texture coordinates may be generated.
2661 * If \a nr is set to 0, no texture coordinates will be generated. In this case, at least one color channel must be output (see GX_SetNumChans()).
2663 * \param[in] nr number of tex coords to generate, between 0 and 8 inclusive
2665 * \return none
2667 void GX_SetNumTexGens(u32 nr);
2670 * \fn void GX_SetTexCoordGen(u16 texcoord,u32 tgen_typ,u32 tgen_src,u32 mtxsrc)
2671 * \brief Specifies how texture coordinates are generated.
2673 * \details Output texture coordinates are usually the result of some transform of an input attribute; either position, normal, or texture coordinate.
2674 * You can also generate texture coordinates from the output color channel of the per-vertex lighting calculations. In C-language syntax the texture
2675 * coordinate generation function would look like this:<br><br>
2677 * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\a texcoord = \a tgen_typ(\a tgen_src, \a mtxsrc);<br><br>
2679 * The current vertex descriptor as set by GX_SetVtxDesc() only describes the data input to the graphics processor. Using this function, you can create
2680 * new output texture coordinates from the input data. The texcoord parameter is used to give the output texture coordinate a name. This texture
2681 * coordinate can be bound to a texture using GX_SetTevOrder(). GX_SetNumTexGens() specifies a consecutive number of texture coordinates, starting at
2682 * <tt>GX_TEXCOORD0</tt>, that are available to GX_SetTevOrder().
2684 * \ref texmtx defines a default set of texture matrix names that can be supplied as mtxsrc. The matrix names are actually row addresses (4 floats per
2685 * row) in the matrix memory that indicate the first row of a loaded matrix. The user may define another memory map of matrix memory to suit their
2686 * needs. Keep in mind, however, that modelview matrices (see GX_LoadPosMtxImm() and \ref pnmtx) and texture matrices share matrix memory.
2688 * \note Input texture coordinates must always go through the texture coordinate generation hardware. GX_Init() initializes the hardware (by calling
2689 * this function) so that all texture coordinates are transformed by the <tt>GX_IDENTITY</tt> matrix in order to appear as if input coordinates are passed
2690 * unchanged through to the texture hardware.
2692 * There are 8 output texture coordinates that can be referenced in any of the 16 TEV stages. There are a maximum of 8 input texture coordinates.
2694 * \param[in] texcoord \ref texcoordid
2695 * \param[in] tgen_typ \ref texgentyp
2696 * \param[in] tgen_src \ref texgensrc
2697 * \param[in] mtxsrc \ref texmtx
2699 * \return none
2701 void GX_SetTexCoordGen(u16 texcoord,u32 tgen_typ,u32 tgen_src,u32 mtxsrc);
2704 * \fn void GX_SetTexCoordGen2(u16 texcoord,u32 tgen_typ,u32 tgen_src,u32 mtxsrc,u32 normalize,u32 postmtx)
2705 * \brief An extension of GX_SetTexCoordGen(). It allows one to specify additional texgen options.
2707 * \details The first four arguments are identical to those for GX_SetTexCoordGen() and function in the same way. All requirements for the first
2708 * four arguments are the same as they are for that function as well. The new options only apply for "ordinary" texgens, where the texgen type is
2709 * <tt>GX_TG_MTX2x4</tt> or <tt>GX_TG_MTX3x4</tt>. They do not work for light-based texgens or emboss texgens.
2711 * The \a normalize argument allows the computed texcoord to be normalized after the multiplication by \a mtxsrc (the first-pass transformation).
2712 * After the optional normalization step, the texcoord is then multiplied by the 3x4 matrix \a postmtx. This matrix is refered to as the
2713 * post-transform matrix.
2715 * The result of this step is the texture coordinate that is used to look up the texture.
2717 * \note The post-transform matrices are separate from the first pass matrices. They are stored in a separate memory area in the same format as the
2718 * first pass matrices, except that all matrices have three rows.<br><br>
2720 * \note When a vertex contains only position and one texture coordinate and the texgen type is <tt>GX_TG_MTX2x4</tt>, there are certain limitations. In
2721 * this special performance case, normalization is not performed (even if specified).
2723 * \param[in] texcoord \ref texcoordid
2724 * \param[in] tgen_typ \ref texgentyp
2725 * \param[in] tgen_src \ref texgensrc
2726 * \param[in] mtxsrc \ref texmtx
2727 * \param[in] normalize if <tt>GX_TRUE</tt>, normalize tex coord after first-pass transform. Only used with <tt>GX_TG_MTX*</tt>.
2728 * \param[in] postmtx \ref dttmtx
2730 * \return none
2732 void GX_SetTexCoordGen2(u16 texcoord,u32 tgen_typ,u32 tgen_src,u32 mtxsrc,u32 normalize,u32 postmtx);
2735 * \fn void GX_SetZTexture(u8 op,u8 fmt,u32 bias)
2736 * \brief Controls Z texture operations.
2738 * \details Z textures can be used to implement image-based rendering algorithms. A composite image consisting of color and depth image planes can
2739 * be merged into the Embedded Frame Buffer (EFB).
2741 * Normally, the Z for a quad (2x2) of pixels is computed as a reference Z and two slopes. Once Z texturing is enabled, the Z is computed by adding
2742 * a Z texel to the reference Z (\a op = <tt>GX_ZT_ADD</tt>) or by replacing the reference Z with the Z texel value (\a op = <tt>GX_ZT_REPLACE</tt>).
2744 * Z textures are always the output from the last active Texture Environment (TEV) stage (see GX_SetNumTevStages()) when enabled. When Z texturing is
2745 * enabled, the texture color of the last TEV stage is not available, but all other color inputs and operations are available. The pixel color is
2746 * always output from the last active TEV stage. You cannot use the TEV to operate on the Z texture, it is fed directly into the Z texture logic.
2748 * Z texel formats can be unsigned 8-bit (<tt>GX_TF_Z8</tt>), 16-bit (<tt>GX_TF_Z16</tt>), or 24-bit (<tt>GX_TF_Z24X8</tt> (32-bit texture)) are used. The Graphics Processor
2749 * converts the Z-textures to 24-bit values by placing the texel value in the least-significant bits and inserting zero's in the remaining
2750 * most-significant bits. The 24-bit constant \a bias is added to the Z texture. If the pixel format is GX_PF_RGB565_Z16 the 24-bit result is converted
2751 * to the current 16-bit Z format before comparing with the EFB's Z.
2753 * \note The Z-texture calculation is done before the fog range calculation.<br><br>
2755 * \note GX_Init() disables Z texturing.
2757 * \param[in] op \ref ztexop to perform
2758 * \param[in] fmt \ref ztexfmt to use
2759 * \param[in] bias Bias value. Format is 24bit unsigned.
2761 * \return none
2763 void GX_SetZTexture(u8 op,u8 fmt,u32 bias);
2766 * \fn void GX_SetZMode(u8 enable,u8 func,u8 update_enable)
2767 * \brief Sets the Z-buffer compare mode.
2769 * \details The result of the Z compare is used to conditionally write color values to the Embedded Frame Buffer (EFB).
2771 * When \a enable is set to <tt>GX_DISABLE</tt>, Z buffering is disabled and the Z buffer is not updated.
2773 * The \a func parameter determines the comparison that is performed. In the comparison function, the newly rasterized Z value is on the left
2774 * while the Z value from the Z buffer is on the right. If the result of the comparison is false, the newly rasterized pixel is discarded.
2776 * The parameter \a update_enable determines whether or not the Z buffer is updated with the new Z value after a comparison is performed. This
2777 * parameter also affects whether the Z buffer is cleared during copy operations (see GX_CopyDisp() and GX_CopyTex()).
2779 * \param[in] enable Enables comparisons with source and destination Z values if <tt>GX_TRUE</tt>; disables compares otherwise.
2780 * \param[in] func \ref compare
2781 * \param[in] update_enable Enables Z-buffer updates when <tt>GX_TRUE</tt>; otherwise, Z-buffer updates are disabled, but compares may still be enabled.
2783 * \return none
2785 void GX_SetZMode(u8 enable,u8 func,u8 update_enable);
2788 * \fn void GX_SetZCompLoc(u8 before_tex)
2789 * \brief Sets whether Z buffering happens before or after texturing.
2791 * \details Normally, Z buffering should happen before texturing, as this enables better performance by not texturing pixels that are not
2792 * visible; however, when alpha compare is used, Z buffering must be done after texturing (see GX_SetAlphaCompare()).
2794 * \param[in] before_tex Enables Z-buffering before texturing when set to <tt>GX_TRUE</tt>; otherwise, Z-buffering takes place after texturing.
2796 * \return none
2798 void GX_SetZCompLoc(u8 before_tex);
2801 * \fn void GX_SetLineWidth(u8 width,u8 fmt)
2802 * \brief Sets the width of line primitives.
2804 * The parameter \a fmt is added to the texture coordinate to obtain texture coordinates at the other corners of a wide line. The \a fmt
2805 * values are added after the texture coordinate generation operation; see GX_SetTexCoordGen().
2807 * \param[in] width width of the line in 1/16th pixel increments; maximum width is 42.5 px
2808 * \param[in] fmt \ref texoff
2810 * \return none
2812 void GX_SetLineWidth(u8 width,u8 fmt);
2815 * \fn void GX_SetPointSize(u8 width,u8 fmt)
2816 * \brief Sets the size of point primitives.
2818 * \details The parameter \a fmt is added to the texture coordinate(s), if any, to obtain texture coordinates at the other corners of a point. The
2819 * \a fmts are added after the texture coordinate generation operation; see GX_SetTexCoordGen().
2821 * \param[in] width width of the point in 1/16th pixel increments; maximum width is 42.5 px
2822 * \param[in] fmt \ref texoff
2824 * \return none
2826 void GX_SetPointSize(u8 width,u8 fmt);
2829 * \fn void GX_SetBlendMode(u8 type,u8 src_fact,u8 dst_fact,u8 op)
2830 * \brief Determines how the source image, generated by the graphics processor, is blended with the Embedded Frame Buffer (EFB).
2832 * \details When \a type is set to <tt>GX_BM_NONE</tt>, the source data is written directly to the EFB. When \a type is set to <tt>GX_BM_BLEND</tt>, the source color and EFB
2833 * pixels are blended using the following equation:
2835 * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>dst_pix_clr</i> = <i>src_pix_clr</i> * \a src_fact + <i>dst_pix_clr</i> * \a dst_fact
2837 * The <tt>GX_BL_DSTALPHA</tt> / <tt>GX_BL_INVDSTALPHA</tt> can be used only when the EFB has <tt>GX_PF_RGBA6_Z24</tt> as the pixel format (see GX_SetPixelFmt()). If the pixel
2838 * format is <tt>GX_PF_RGBA6_Z24</tt> then the \a src_fact and \a dst_fact are also applied to the alpha channel. To write the alpha channel to the EFB you must
2839 * call GX_SetAlphaUpdate().
2841 * When type is set to <tt>GX_BM_LOGIC</tt>, the source and EFB pixels are blended using logical bitwise operations. When type is set to <tt>GX_BM_SUBTRACT</tt>, the destination
2842 * pixel is computed as follows:
2844 * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>dst_pix_clr</i> = <i>dst_pix_clr</i> - <i>src_pix_clr [clamped to zero]</i>
2846 * Note that \a src_fact and \a dst_fact are not part of this equation.
2848 * \note Color updates should be enabled by calling GX_SetColorUpdate().
2850 * \param[in] type \ref blendmode
2851 * \param[in] src_fact \ref blendfactor
2852 * \param[in] dst_fact \ref blendfactor
2853 * \param[in] op \ref logicop
2855 * \return none
2857 void GX_SetBlendMode(u8 type,u8 src_fact,u8 dst_fact,u8 op);
2860 * \fn void GX_SetCullMode(u8 mode)
2861 * \brief Enables or disables culling of geometry based on its orientation to the viewer.
2863 * \details Primitives in which the vertex order is clockwise to the viewer are considered front-facing.
2865 * \note GX_Init() sets this to <tt>GX_CULL_BACK</tt>.
2867 * \param[in] mode \ref cullmode
2869 * \return none
2871 void GX_SetCullMode(u8 mode);
2874 * \fn void GX_SetCoPlanar(u8 enable)
2875 * \brief Enables or disables coplanar triangle processing.
2877 * \details While coplanar mode is enabled, all subsequent triangles (called decal triangles) will have the same Z coefficients as the reference
2878 * plane. Coplanar mode should be enabled immediately after a reference triangle is drawn.
2880 * \note The reference triangle can be culled using <tt>GX_SetCullMode(GX_CULL_ALL)</tt> to create an invisible reference plane; however, the reference
2881 * triangle must not be completely out of view, i.e. trivially rejected by clipping.<br><br>
2883 * \note GX_Init() disables coplanar mode.
2885 * \param[in] enable when <tt>GX_ENABLE</tt>, coplanar mode is enabled; <tt>GX_DISABLE</tt> disables this mode
2887 * \return none
2889 void GX_SetCoPlanar(u8 enable);
2892 * \fn void GX_EnableTexOffsets(u8 coord,u8 line_enable,u8 point_enable)
2893 * \brief Enables a special texture offset feature for points and lines.
2895 * \details When a point's size is defined using GX_SetPointSize() or a line's width is described using GX_SetLineWidth(), you can also specify a second
2896 * parameter. The parameter \a fmt is added to the texture coordinate(s), if any, to obtain texture coordinates at the other corners of a
2897 * point or line. The \a fmts are added after the texture coordinate generation operation; see GX_SetTexCoordGen(). This function enables this
2898 * operation for a particular texture coordinate. Offset operations for points and lines are enabled separately. If the enables are false, the same
2899 * texture coordinate is used for every vertex of the line or point.
2901 * \param[in] coord \ref texcoordid
2902 * \param[in] line_enable enable or disable tex offset calculation for lines
2903 * \param[in] point_enable enable or disable tex offset calculation for points
2905 * \return none
2907 void GX_EnableTexOffsets(u8 coord,u8 line_enable,u8 point_enable);
2910 * \fn void GX_SetClipMode(u8 mode)
2911 * \brief Enables or disables clipping of geometry.
2913 * \details This may help performance issues that occur when objects are far-clipped; however, any near-clipped objects will be rendered incorrectly.
2915 * \note GX_Init() sets this to <tt>GX_CLIP_ENABLE</tt>.
2917 * \param[in] mode \ref clipmode
2919 * \return none
2921 void GX_SetClipMode(u8 mode);
2924 * \fn void GX_SetScissor(u32 xOrigin,u32 yOrigin,u32 wd,u32 ht)
2925 * \brief Sets the scissor rectangle.
2927 * \details The scissor rectangle specifies an area of the screen outside of which all primitives are culled. This function sets the scissor rectangle in
2928 * screen coordinates. The screen origin (\a xOrigin=0, \a yOrigin=0) is at the top left corner of the display.
2930 * The values may be within the range of 0 - 2047 inclusive. Using values that extend beyond the EFB size is allowable since the scissor box may be
2931 * repositioned within the EFB using GX_SetScissorBoxOffset().
2933 * \note By default, the scissor rectangle is set to match the viewport rectangle. GX_Init() initializes the scissor rectangle to match the viewport
2934 * given the current render mode.
2936 * \param[in] xOrigin left-most coord in screen coordinates
2937 * \param[in] yOrigin top-most coord in screen coordinates
2938 * \param[in] wd width of the scissorbox in screen coordinates
2939 * \param[in] ht height of the scissorbox in screen coordinates
2941 * \return none
2943 void GX_SetScissor(u32 xOrigin,u32 yOrigin,u32 wd,u32 ht);
2946 * \fn void GX_SetScissorBoxOffset(s32 xoffset,s32 yoffset)
2947 * \brief Repositions the scissorbox rectangle within the Embedded Frame Buffer (EFB) memory space.
2949 * \details The offsets are subtracted from the screen coordinates to determine the actual EFB coordinates where the pixels are stored. Thus with
2950 * positive offsets, the scissor box may be shifted left and/or up; and with negative offsets, the scissor box may be shifted right and/or down.
2952 * The intended use for this command is to make it easy to do two-pass antialiased rendering. To draw the top half of the screen, the scissor box is set to
2953 * the top and the offset set to zero. To draw the bottom half, the scissor box is set to the bottom, and the offset is set to shift the scissor box back up
2954 * to the top.
2956 * Another use for the offset is to displace how an image is rendered with respect to the dither matrix. Since the dither matrix is 4x4, a \a yoffset of -2
2957 * shifts the image down by 2 lines with respect to the matrix. This can be useful for field-rendering mode.
2959 * \note Achieving an offset of an odd number of lines is possible, but more difficult than just changing the scissor box: one must render and copy 2
2960 * additional lines, then skip one by adjusting the argument of VIDEO_SetNextFrameBuffer().<br><br>
2962 * \note GX_Init() initializes the scissor box offset to zero. Since the GP works on 2x2 regions of pixels, only even offsets are allowed.
2964 * \param[in] xoffset number of pixels to shift the scissorbox left, between -342 - 382 inclusive; must be even
2965 * \param[in] yoffset number of pixels to shift the scissorbox up, between -342 - 494 inclusive; must be even
2967 * \return none
2969 void GX_SetScissorBoxOffset(s32 xoffset,s32 yoffset);
2972 * \fn void GX_SetNumChans(u8 num)
2973 * \brief Sets the number of color channels that are output to the TEV stages.
2975 * \details Color channels are the mechanism used to compute per-vertex lighting effects. Color channels are controlled using GX_SetChanCtrl().
2976 * Color channels are linked to specific TEV stages using GX_SetTevOrder().
2978 * This function basically defines the number of per-vertex colors that get rasterized. If \a num is set to 0, then at least one texture coordinate
2979 * must be generated (see GX_SetNumTexGens()). If \a num is set to 1, then channel <tt>GX_COLOR0A0</tt> will be rasterized. If \a num is set to 2 (the maximum
2980 * value), then <tt>GX_COLOR0A0</tt> and <tt>GX_COLOR1A1</tt> will be rasterized.
2982 * \param[in] num number of color channels to rasterize; number must be 0, 1 or 2
2984 * \return none
2986 void GX_SetNumChans(u8 num);
2989 * \fn void GX_SetTevOrder(u8 tevstage,u8 texcoord,u32 texmap,u8 color)
2990 * \brief Specifies the texture and rasterized color that will be available as inputs to this TEV \a tevstage.
2992 * The texture coordinate \a texcoord is generated from input attributes using the GX_SetTexCoordGen() function and is used to look up the
2993 * texture map, previously loaded by GX_LoadTexObj(). The \a color to rasterize for this \a tevstage is also specified. The color
2994 * is the result of per-vertex lighting which is controlled by GX_SetChanCtrl().
2996 * This function will scale the normalized texture coordinates produced by GX_SetTexCoordGen() according to the size of the texture map in the
2997 * function call. For this reason, texture coordinates can only be broadcast to multiple texture maps if and only if the maps are the same size. In
2998 * some cases, you may want to generate a texture coordinate having a certain scale, but disable the texture lookup (this comes up when generating
2999 * texture coordinates for indirect bump mapping). To accomplish this, use the <tt>GX_TEXMAP_DISABLE</tt> flag:
3001 * \code GX_SetTevOrder(GX_TEVSTAGE1, GX_TEXCOORD0, GX_TEXMAP3 | GX_TEXMAP_DISABLE, GX_COLORNULL); \endcode
3003 * \details This will scale <tt>GX_TEXCOORD0</tt> using <tt>GX_TEXMAP3</tt> but disable the lookup of <tt>GX_TEXMAP3</tt>.
3005 * \note This function does not enable the TEV stage. To enable a consecutive number of TEV stages, starting at stage <tt>GX_TEVSTAGE0</tt>, use GX_SetNumTevStages().<br><br>
3007 * \note The operation of each TEV stage is independent. The color operations are controlled by GX_SetTevColorIn() and GX_SetTevColorOp(). The alpha
3008 * operations are controlled by GX_SetTevAlphaIn() and GX_SetTevAlphaOp().<br><br>
3010 * \note The number of texture coordinates available for all the active TEV stages is set using GX_SetNumTexGens(). The number of color channels
3011 * available for all the active TEV stages is set using GX_SetNumChans(). Active TEV stages should not reference more texture coordinates or colors
3012 * than are being generated.<br><br>
3014 * \note There are some special settings for the \a color argument. If you specify <tt>GX_COLOR_ZERO</tt>, you always get zero as rasterized color. If you specify
3015 * <tt>GX_ALPHA_BUMP</tt> or <tt>GX_ALPHA_BUMPN</tt>, you can use "Bump alpha" component from indirect texture unit as rasterized color input (see GX_SetTevIndirect()
3016 * for details about how to configure bump alpha). Since bump alpha contains only 5-bit data, <tt>GX_ALPHA_BUMP</tt> shifts them to higher bits, which makes the
3017 * value range 0-248. Meanwhile <tt>GX_ALPHA_BUMPN</tt> performs normalization and you can get the value range 0-255.
3019 * \param[in] tevstage \ref tevstage
3020 * \param[in] texcoord \ref texcoordid
3021 * \param[in] texmap \ref texmapid
3022 * \param[in] color \ref channelid
3024 * \return none
3026 void GX_SetTevOrder(u8 tevstage,u8 texcoord,u32 texmap,u8 color);
3029 * \fn void GX_SetNumTevStages(u8 num)
3030 * \brief Enables a <i>consecutive</i> number of TEV stages.
3032 * \details The output pixel color (before fogging and blending) is the result from the last stage. The last TEV stage must write to register <tt>GX_TEVPREV</tt>;
3033 * see GX_SetTevColorOp() and GX_SetTevAlphaOp(). At least one TEV stage must be enabled. If a Z-texture is enabled, the Z texture must be looked up on
3034 * the last stage; see GX_SetZTexture().
3036 * \note The association of lighting colors, texture coordinates, and texture maps with a TEV stage is set using GX)SetTevOrder(). The number of texture
3037 * coordinates available is set using GX_SetNumTexGens(). The number of color channels available is set using GX_SetNumChans().<br><br>
3039 * \note GX_Init() will set \a num to 1.
3041 * \param[in] num number of active TEV stages, between 1 and 16 inclusive
3043 * \return none
3045 void GX_SetNumTevStages(u8 num);
3048 * \fn void GX_SetAlphaCompare(u8 comp0,u8 ref0,u8 aop,u8 comp1,u8 ref1)
3049 * \brief Sets the parameters for the alpha compare function which uses the alpha output from the last active TEV stage.
3051 * \details The alpha compare operation is:<br><br>
3053 * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>alpha_pass</i> = (<i>alpha_src</i> (\a comp0) \a ref0) (\a op) (<i>alpha_src</i> (\a comp1) \a ref1)<br><br>
3055 * where <i>alpha_src</i> is the alpha from the last active TEV stage. As an example, you can implement these equations:<br><br>
3057 * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>alpha_pass</i> = (<i>alpha_src</i> \> \a ref0) <b>AND</b> (<i>alpha_src</i> \< \a ref1)
3059 * or
3061 * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>alpha_pass</i> = (<i>alpha_src</i> \> \a ref0) <b>OR</b> (<i>alpha_src</i> \< \a ref1)
3063 * \note The output alpha can be used in the blending equation (see GX_SetBlendMode()) to control how source and destination (frame buffer)
3064 * pixels are combined.<br><br>
3066 * \note The Z compare can occur either before or after texturing (see GX_SetZCompLoc()). In the case where Z compare occurs before texturing, the Z is
3067 * written based only on the Z test. The color is written if both the Z test and alpha test pass. When Z compare occurs <i>after</i> texturing, the color
3068 * and Z are written if both the Z test and alpha test pass. When using texture to make cutout shapes (like billboard trees) that need to be correctly Z
3069 * buffered, you should configure the pipeline to Z buffer after texturing.<br><br>
3071 * \note The number of active TEV stages is specified using GX_SetNumTevStages().
3073 * \param[in] comp0 \ref compare subfunction 0
3074 * \param[in] ref0 reference val for subfunction 0
3075 * \param[in] aop \ref alphaop for combining subfunctions 0 and 1; must not be <tt>GX_MAX_ALPHAOP</tt>
3076 * \param[in] comp1 \ref compare subfunction 1
3077 * \param[in] ref1 reference val for subfunction 1
3079 * \return none
3081 void GX_SetAlphaCompare(u8 comp0,u8 ref0,u8 aop,u8 comp1,u8 ref1);
3084 * \fn void GX_SetTevKColor(u8 sel, GXColor col)
3085 * \brief Sets one of the "konstant" color registers in the TEV unit.
3087 * \details These registers are available to all TEV stages. They are constant in the sense that they cannot be written to be the TEV itself.
3089 * \param[in] sel \ref tevkcolorid
3090 * \param[in] col constant color value
3092 * \return none
3094 void GX_SetTevKColor(u8 sel, GXColor col);
3097 * \fn void GX_SetTevKColorSel(u8 tevstage,u8 sel)
3098 * \brief Selects a "konstant" color input to be used in a given TEV stage.
3100 * The constant color input is used only if <tt>GX_CC_KONST</tt> is selected for an input for that TEV stage. Only one constant color selection is
3101 * available for a given TEV stage, though it may be used for more than one input.
3103 * \param[in] tevstage \ref tevstage
3104 * \param[in] sel \ref tevkcolorsel
3106 * \return none
3108 void GX_SetTevKColorSel(u8 tevstage,u8 sel);
3111 * \fn void GX_SetTevKAlphaSel(u8 tevstage,u8 sel)
3112 * \brief Selects a "konstant" alpha input to be used in a given TEV stage.
3114 * \details The constant alpha input is used only if <tt>GX_CA_KONST</tt> is selected for an input for that TEV stage. Only one constant alpha selection is
3115 * available for a given TEV stage, though it may be used for more than one input.
3117 * \param[in] tevstage \ref tevstage
3118 * \param[in] sel \ref tevkalphasel
3120 * \return none
3122 void GX_SetTevKAlphaSel(u8 tevstage,u8 sel);
3125 * \fn void GX_SetTevKColorS10(u8 sel, GXColorS10 col)
3126 * \brief Used to set one of the constant color registers in the Texture Environment (TEV) unit.
3128 * \details These registers are available to all TEV stages. At least one of these registers is used to pass the output of one TEV stage to the next
3129 * in a multi-texture configuration.
3131 * \note The application is responsible for allocating these registers so that no collisions in usage occur.<br><br>
3133 * \note This function takes 10-bit signed values as color values; use GX_SetTevColor() to give 8-bit values.
3135 * \param[in] sel \ref tevcoloutreg
3136 * \param[in] col constant color value
3138 * \return none
3140 void GX_SetTevKColorS10(u8 sel, GXColorS10 col);
3143 * \fn void GX_SetTevSwapMode(u8 tevstage,u8 ras_sel,u8 tex_sel)
3144 * \brief Selects a set of swap modes for the rasterized color and texture color for a given TEV stage.
3146 * \details This allows the color components of these inputs to be rearranged or duplicated.
3148 * \note There are four different swap mode table entries, and each entry in the table specifies how the RGBA inputs map to the RGBA outputs.
3150 * \param[in] tevstage \ref tevstage
3151 * \param[in] ras_sel selects a swap mode for the rasterized color input.
3152 * \param[in] tex_sel selects a swap mode for the texture color input.
3154 * \return none
3156 void GX_SetTevSwapMode(u8 tevstage,u8 ras_sel,u8 tex_sel);
3159 * \fn void GX_SetTevSwapModeTable(u8 swapid,u8 r,u8 g,u8 b,u8 a)
3160 * \brief Sets up the TEV color swap table.
3162 * \details The swap table allows the rasterized color and texture color to be swapped component-wise. An entry in the table specifies how the
3163 * input color components map to the output color components.
3165 * \param[in] swapid \ref tevswapsel
3166 * \param[in] r input color component that should be mapped to the red output component.
3167 * \param[in] g input color component that should be mapped to the green output component.
3168 * \param[in] b input color component that should be mapped to the blue output component.
3169 * \param[in] a input color component that should be mapped to the alpha output component.
3171 * \return none
3173 void GX_SetTevSwapModeTable(u8 swapid,u8 r,u8 g,u8 b,u8 a);
3176 * \fn void GX_SetTevIndirect(u8 tevstage,u8 indtexid,u8 format,u8 bias,u8 mtxid,u8 wrap_s,u8 wrap_t,u8 addprev,u8 utclod,u8 a)
3177 * \brief Controls how the results from an indirect lookup will be used to modify a given regular TEV stage lookup.
3179 * \param[in] tevstage \ref tevstage being affected
3180 * \param[in] indtexid \ref indtexstage results to use with this TEV stage
3181 * \param[in] format \ref indtexformat, i.e. how many bits to extract from the indirect result color to use in indirect offsets and the indirect "bump" alpha
3182 * \param[in] bias \ref indtexbias to be applied to each component of the indirect offset
3183 * \param[in] mtxid which \ref indtexmtx and scale value to multiply the offsets with
3184 * \param[in] wrap_s \ref indtexwrap to use with the S component of the regular texture coordinate
3185 * \param[in] wrap_t \ref indtexwrap to use with the T component of the regular texture coordinate
3186 * \param[in] addprev whether the tex coords results from the previous TEV stage should be added in
3187 * \param[in] utclod whether to the unmodified (<tt>GX_TRUE</tt>) or modified (<tt>GX_FALSE</tt>) tex coords for mipmap LOD computation
3188 * \param[in] a which offset component will supply the \ref indtexalphasel, if any
3190 * \return none
3192 void GX_SetTevIndirect(u8 tevstage,u8 indtexid,u8 format,u8 bias,u8 mtxid,u8 wrap_s,u8 wrap_t,u8 addprev,u8 utclod,u8 a);
3195 * \fn void GX_SetTevDirect(u8 tevstage)
3196 * \brief Used to turn off all indirect texture processing for the specified regular TEV stage.
3198 * \param[in] tevstage the \ref tevstage to change
3200 * \return none
3202 void GX_SetTevDirect(u8 tevstage);
3205 * \fn void GX_SetNumIndStages(u8 nstages)
3206 * \brief Used to set how many indirect lookups will take place.
3208 * \details The results from these indirect lookups may then be used to alter the lookups for any number of regular TEV stages.
3210 * \param[in] nstages number of indirect lookup stages
3212 * \return none
3214 void GX_SetNumIndStages(u8 nstages);
3217 * \fn void GX_SetIndTexOrder(u8 indtexstage,u8 texcoord,u8 texmap)
3218 * \brief Used to specify the \a texcoord and \a texmap to used with a given indirect lookup.
3220 * \param[in] indtexstage \ref indtexstage being affected
3221 * \param[in] texcoord \ref texcoordid to be used for this stage
3222 * \param[in] texmap \ref texmapid to be used for this stage
3224 * \return none
3226 void GX_SetIndTexOrder(u8 indtexstage,u8 texcoord,u8 texmap);
3229 * \fn void GX_SetIndTexCoordScale(u8 indtexid,u8 scale_s,u8 scale_t)
3230 * \brief Allows the sharing of a texcoord between an indirect stage and a regular TEV stage.
3232 * It allows the texture coordinates to be scaled down for use with an indirect map that is smaller than the corresponding regular map.
3234 * \param[in] indtexid \ref indtexstage being affected
3235 * \param[in] scale_s \ref indtexscale factor for the S coord
3236 * \param[in] scale_t \ref indtexscale factor for the T coord
3238 * \return none
3240 void GX_SetIndTexCoordScale(u8 indtexid,u8 scale_s,u8 scale_t);
3243 * \fn void GX_SetFog(u8 type,f32 startz,f32 endz,f32 nearz,f32 farz,GXColor col)
3244 * \brief Enables fog.
3246 * \details Using \a type, the programmer may select one of several functions to control the fog density as a function of range to a quad (2x2 pixels).
3247 * Range is cosine corrected Z in the x-z plane (eye coordinates), but is not corrected in the y direction (see GX_SetFogRangeAdj()). The parameters \a startz and
3248 * \a endz allow further control over the fog behavior. The parameters \a nearz and \a farz should be set consistent with the projection matrix parameters. Note that these
3249 * parameters are defined in eye-space. The fog color, in RGBX format (i.e. the alpha component is ignored), is set using the \a col parameter. This will be the
3250 * color of the pixel when fully fogged.
3252 * \note GX_Init() turns fog off by default.
3254 * \param[in] type \ref fogtype to use
3255 * \param[in] startz minimum Z value at which the fog function is active
3256 * \param[in] endz maximum Z value at which the fog function is active
3257 * \param[in] nearz near plane (which should match the projection matrix parameters)
3258 * \param[in] farz far plane (which should match the projection matrix parameters)
3259 * \param[in] col fog color; alpha component is ignored
3261 * \return none
3263 void GX_SetFog(u8 type,f32 startz,f32 endz,f32 nearz,f32 farz,GXColor col);
3266 * \fn void GX_SetFogRangeAdj(u8 enable,u16 center,GXFogAdjTbl *table)
3267 * \brief Enables or disables horizontal fog-range adjustment.
3269 * \details This adjustment is a factor that is multiplied by the eye-space Z used for fog computation; it is based upon the X position of the pixels being
3270 * rendered. The Y direction is not compensated. This effectively increases the fog density at the edges of the screen, making for a more realistic fog
3271 * effect. The adjustment is computed per quad (2x2 pixels), not per-pixel. The center of the viewport is specified using \a center. The range adjustment
3272 * table is specified using \a table. The range adjust function is mirrored horizontally about the \a center.
3274 * \note GX_Init() disables range adjustment.
3276 * \sa GX_InitFogAdjTable()
3278 * \param[in] enable enables adjustment when <tt>GX_ENABLE</tt> is passed; disabled with <tt>GX_DISABLE</tt>
3279 * \param[in] center centers the range adjust function; normally corresponds with the center of the viewport
3280 * \param[in] table range adjustment parameter table
3282 * \return none
3284 void GX_SetFogRangeAdj(u8 enable,u16 center,GXFogAdjTbl *table);
3287 * \fn GX_SetFogColor(GXColor color)
3288 * \brief Sets the fog color.
3290 * \details \a color is the color that a pixel will be if fully fogged. Alpha channel is ignored.
3292 * \param[in] color color to set fog to
3294 void GX_SetFogColor(GXColor color);
3297 * \fn void GX_InitFogAdjTable(GXFogAdjTbl *table,u16 width,f32 projmtx[4][4])
3298 * \brief Generates the standard range adjustment table and puts the results into \a table.
3300 * \details This table can be used by GX_SetFogRangeAdj() to adjust the eye-space Z used for fog based upon the X position of the pixels being rendered.
3301 * The Y direction is not compensated. This effectively increases the fog density at the edges of the screen, making for a more realistic fog effect. The
3302 * width of the viewport is specified using \a width. The \a projmtx parameter is the projection matrix that is used to render into the viewport. It must
3303 * be specified so that the function can compute the X extent of the viewing frustum in eye space.
3305 * \note You must allocate \a table yourself.
3307 * \param[in] table range adjustment parameter table
3308 * \param[in] width width of the viewport
3309 * \param[in] projmtx projection matrix used to render into the viewport
3311 void GX_InitFogAdjTable(GXFogAdjTbl *table,u16 width,f32 projmtx[4][4]);
3314 * \fn void GX_SetIndTexMatrix(u8 indtexmtx,f32 offset_mtx[2][3],s8 scale_exp)
3315 * \brief Sets one of the three static indirect matrices and the associated scale factor.
3317 * \details The indirect matrix and scale is used to process the results of an indirect lookup in order to produce offsets to use during a regular lookup.
3318 * The matrix is multiplied by the [S T U] offsets that have been extracted (and optionally biased) from the indirect lookup color. In this matrix-vector
3319 * multiply, the matrix is on the left and the [S T U] column vector is on the right.
3321 * \note The matrix values are stored in the hardware as a sign and 10 fractional bits (two's complement); thus the smallest number that can be stored is
3322 * -1 and the largest is (1 - 1/1024) or approximately 0.999. Since +1 cannot be stored, you may consider dividing all the matrix values by 2 (thus +1
3323 * becomes +0.5) and adding one to the scale value in order to compensate.
3325 * \param[in] indtexmtx \ref indtexmtx that is being affected
3326 * \param[in] offset_mtx values to assign to the indirect matrix
3327 * \param[in] scale_exp exponent to use for the associated scale factor
3329 * \return none
3331 void GX_SetIndTexMatrix(u8 indtexmtx,f32 offset_mtx[2][3],s8 scale_exp);
3334 * \fn void GX_SetTevIndBumpST(u8 tevstage,u8 indstage,u8 mtx_sel)
3335 * \brief Sets up an environment-mapped bump-mapped indirect lookup.
3337 * \details The indirect map specifies offsets in (S,T) space. This kind of lookup requires 3 TEV stages to compute. As a result of all this work, a simple
3338 * 2D bump map is properly oriented to the surface to which it is applied. It is used to alter a normal-based texgen which then looks up an environment map.
3339 * The environment map may be a simple light map, or else it may be a reflection map of the surrounding scenery.
3341 * \note When using this function, texture lookup should be disabled for the first two TEV stages. The third stage is where the texture lookup is actually performed.
3342 * The associated geometry must supply normal/binormal/tangent coordinates at each vertex. Appropriate texgens must supply each of these to the proper stages
3343 * (binormal to the first, tangent to the second, and normal to the third). Although a static indirect matrix is not used, one must choose a matrix slot and set up
3344 * the associated scale value to be used with this lookup.
3346 * \param[in] tevstage \ref tevstage that is being affected
3347 * \param[in] indstage \ref indtexstage results to use with this TEV stage
3348 * \param[in] mtx_sel which \ref indtexmtx to multiply the offsets with
3350 * \return none
3352 void GX_SetTevIndBumpST(u8 tevstage,u8 indstage,u8 mtx_sel);
3355 * \fn void GX_SetTevIndBumpXYZ(u8 tevstage,u8 indstage,u8 mtx_sel)
3356 * \brief Sets up an environment-mapped bump-mapped indirect lookup.
3358 * \details The indirect map specifies offsets in object (X, Y, Z) space. This kind of lookup requires only one TEV stage to compute; however, the bump map (indirect
3359 * map) used is geometry-specific. Thus there is a space/computation tradeoff between using this function and using GX_SetTevIndBumpST().
3361 * \note The indirect matrix must be loaded with a transformation for normals from object space to texture space (similar to eye space, but possibly with an inverted
3362 * Y axis). The surface geometry need only provide regular normals at each vertex. A normal-based texgen must be set up for the regular texture coordinate.
3364 * \param[in] tevstage \ref tevstage that is being affected
3365 * \param[in] indstage \ref indtexstage results to use with this TEV stage
3366 * \param[in] mtx_sel which \ref indtexmtx to multiply the offsets with
3368 * \return none
3370 void GX_SetTevIndBumpXYZ(u8 tevstage,u8 indstage,u8 mtx_sel);
3373 * \fn void GX_SetTevIndTile(u8 tevstage,u8 indtexid,u16 tilesize_x,u16 tilesize_y,u16 tilespacing_x,u16 tilespacing_y,u8 indtexfmt,u8 indtexmtx,u8 bias_sel,u8 alpha_sel)
3374 * \brief Used to implement tiled texturing using indirect textures.
3376 * \details It will set up the correct values in the given indirect matrix; you only need to specify which matrix slot to use.
3378 * \note The regular texture map contains only the tile definitions. The actual texture size to be applied to the polygon being drawn is the product of the base tile
3379 * size and the size of the indirect map. In order to set the proper texture coordinate scale, one must call GX_SetTexCoordScaleManually(). One can also use
3380 * GX_SetIndTexCoordScale() in order to use the same texcoord for the indirect stage as the regular TEV stage.
3382 * \param[in] tevstage \ref tevstage that is being affected
3383 * \param[in] indtexid \ref indtexstage results to use with this TEV stage
3384 * \param[in] tilesize_x size of the tile in the X dimension
3385 * \param[in] tilesize_y size of the tile in the Y dimension
3386 * \param[in] tilespacing_x spacing of the tiles (in the tile-definition map) in the X dimension
3387 * \param[in] tilespacing_y spacing of the tiles (in the tile-definition map) in the Y dimension
3388 * \param[in] indtexfmt \ref indtexformat to use
3389 * \param[in] indtexmtx \ref indtexmtx to multiply the offsets with
3390 * \param[in] bias_sel \ref indtexbias to indicate tile stacking direction for pseudo-3D textures
3391 * \param[in] alpha_sel which \ref indtexalphasel will supply the indirect "bump" alpha, if any (for pseudo-3D textures).
3393 * \return none
3395 void GX_SetTevIndTile(u8 tevstage,u8 indtexid,u16 tilesize_x,u16 tilesize_y,u16 tilespacing_x,u16 tilespacing_y,u8 indtexfmt,u8 indtexmtx,u8 bias_sel,u8 alpha_sel);
3398 * \fn void GX_SetTevIndRepeat(u8 tevstage)
3399 * \brief Set a given TEV stage to use the same texture coordinates as were computed in the previous stage.
3401 * \note This is only useful when the previous stage texture coordinates took more than one stage to compute, as is the case for GX_SetTevIndBumpST().
3403 * \param[in] tevstage \ref tevstage to modify
3405 * \return none
3407 void GX_SetTevIndRepeat(u8 tevstage);
3410 * \fn void GX_SetColorUpdate(u8 enable)
3411 * \brief Enables or disables color-buffer updates when rendering into the Embedded Frame Buffer (EFB).
3413 * \note This function also affects whether the color buffer is cleared during copies; see GX_CopyDisp() and GX_CopyTex().
3415 * \param[in] enable enables color-buffer updates with <tt>GX_TRUE</tt>
3417 * \return none
3419 void GX_SetColorUpdate(u8 enable);
3422 * \fn void GX_SetAlphaUpdate(u8 enable)
3423 * \brief Enables or disables alpha-buffer updates of the Embedded Frame Buffer (EFB).
3425 * \note This function also affects whether the alpha buffer is cleared during copy operations; see GX_CopyDisp() and GX_CopyTex().<br><br>
3427 * \note The only EFB pixel format supporting an alpha buffer is <tt>GX_PF_RGBA6_Z24</tt>; see GX_SetPixelFmt(). The alpha \a enable is ignored for non-alpha
3428 * pixel formats.
3430 * \param[in] enable enables alpha-buffer updates with <tt>GX_TRUE</tt>
3432 * \return none
3434 void GX_SetAlphaUpdate(u8 enable);
3437 * \fn void GX_SetPixelFmt(u8 pix_fmt,u8 z_fmt)
3438 * \brief Sets the format of pixels in the Embedded Frame Buffer (EFB).
3440 * \details There are two non-antialiased \a pix_fmts: <tt>GX_PF_RGB8_Z24</tt> and <tt>GX_PF_RGBA6_Z24</tt>. The stride of the EFB is fixed at 640 pixels. The
3441 * non-antialiased EFB has 528 lines available.
3443 * When \a pix_fmt is set to <tt>GX_PF_RGB565_Z16</tt>, multi-sample antialiasing is enabled. In order to get proper results, one must also call GX_SetCopyFilter().
3444 * The position of the subsamples and the antialiasing filter coefficients are set using GX_SetCopyFilter(). When antialiasing, three 16b color/Z
3445 * samples are computed for each pixel, and the total available number of pixels in the EFB is reduced by half (640 pixels x 264 lines). This function also sets the
3446 * compression type for 16-bit Z formats, which allows trading off Z precision for range. The following guidelines apply:<br><br>
3448 * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a) far/near ratio <= 2^16, use <tt>GX_ZC_LINEAR</tt><br>
3449 * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;b) far/near ratio <= 2^18, use <tt>GX_ZC_NEAR</tt><br>
3450 * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;c) far/near ratio <= 2^20, use <tt>GX_ZC_MID</tt><br>
3451 * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;d) far/near ratio <= 2^24, use <tt>GX_ZC_FAR</tt><br><br>
3453 * It is always best to use as little compression as possible (choice "a" is least compressed, choice "d" is most compressed). You get less precision with higher compression.
3454 * The "far" in the above list does not necessarily refer to the far clipping plane. You should think of it as the farthest object you want correct occlusion for.
3456 * \note This function also controls antialiasing (AA) mode.<br><br>
3458 * \note Since changing pixel format requires the pixel pipeline to be synchronized, the use of this function causes stall of the graphics processor as a result. Therefore,
3459 * you should avoid redundant calls of this function.
3461 * \param[in] pix_fmt <tt>GX_PF_RGB8_Z24</tt> or <tt>GX_PF_RGBA6_Z24</tt> for non-AA, <tt>GX_PF_RGB565_Z16</tt> for AA
3462 * \param[in] z_fmt \ref zfmt to use
3464 * \return none
3466 void GX_SetPixelFmt(u8 pix_fmt,u8 z_fmt);
3469 * \fn void GX_SetDither(u8 dither)
3470 * \brief Enables or disables dithering.
3472 * \details A 4x4 Bayer matrix is used for dithering.
3474 * \note Only valid when the pixel format (see GX_SetPixelFmt()) is either <tt>GX_PF_RGBA6_Z24</tt> or <tt>GX_PF_RGB565_Z16</tt>.<br><br>
3476 * \note Dithering should probably be turned off if you are planning on using the result of rendering for comparisons (e.g. outline rendering
3477 * algorithm that writes IDs to the alpha channel, copies the alpha channel to a texture, and later compares the texture in the TEV).
3479 * \param[in] dither enables dithering if <tt>GX_TRUE</tt> is given and pixel format is one of the two above, otherwise disabled
3481 * \return none
3483 void GX_SetDither(u8 dither);
3486 * \fn void GX_SetDstAlpha(u8 enable,u8 a)
3487 * \brief Sets a constant alpha value for writing to the Embedded Frame Buffer (EFB).
3489 * \note To be effective, the EFB pixel type must have an alpha channel (see GX_SetPixelFmt()). The alpha compare operation (see
3490 * GX_SetAlphaCompare()) and blending operations (see GX_SetBlendMode()) still use source alpha (output from the last TEV stage) but when
3491 * writing the pixel color, the constant alpha will replace the pixel alpha in the EFB.
3493 * \param[in] enable \a a will be written to the framebuffer if <tt>GX_ENABLE</tt> is here and frame buffer pixel format supports destination alpha
3494 * \param[in] a constant alpha value
3496 * \return none
3498 void GX_SetDstAlpha(u8 enable,u8 a);
3501 * \fn void GX_SetFieldMask(u8 even_mask,u8 odd_mask)
3502 * \brief selectively enables and disables interlacing of the frame buffer image.
3504 * \details This function is used when rendering fields to an interlaced Embedded Frame Buffer (EFB).
3506 * \note When the mask is <tt>GX_FALSE</tt>, that field will not be written to the EFB, but the other field will be computed. In other words, you pay the
3507 * fill rate price of a frame to produce a field.
3509 * \param[in] even_mask whether to write pixels with even Y coordinate
3510 * \param[in] odd_mask whether to write pixels with odd Y coordinate
3512 * \return none
3514 void GX_SetFieldMask(u8 even_mask,u8 odd_mask);
3517 * \fn void GX_SetFieldMode(u8 field_mode,u8 half_aspect_ratio)
3518 * \brief Controls various rasterization and texturing parameters that relate to field-mode and double-strike rendering.
3520 * \details In field-mode rendering, one must adjust the vertical part of the texture LOD computation to account for the fact that pixels cover only half of
3521 * the space from one rendered scan line to the next (with the other half of the space filled by a pixel from the other field). In both field-mode and
3522 * double-strike rendering, one must adjust the aspect ratio for points and lines to account for the fact that pixels will be double-height when displayed
3523 * (the pixel aspect ratio is 1/2).
3525 * \note The values set here usually come directly from the render mode. The \a field_rendering flags goes straight into \a field_mode. The \a half_aspect_ratio
3526 * parameter is true if the \a xfbHeight is half of the \a viHeight, false otherwise.<br><br>
3528 * \note GX_Init() sets both fields according to the default render mode.<br><br>
3530 * \note On production hardware (i.e. a retail GameCube), only line aspect-ratio adjustment is implemented. Points are not adjusted.
3532 * \param[in] field_mode adjusts texture LOD computation as described above if true, otherwise does not
3533 * \param[in] half_aspect_ratio adjusts line aspect ratio accordingly, otherwise does not
3535 * \return none
3537 void GX_SetFieldMode(u8 field_mode,u8 half_aspect_ratio);
3540 * \fn f32 GX_GetYScaleFactor(u16 efbHeight,u16 xfbHeight)
3541 * \brief Calculates an appropriate Y scale factor value for GX_SetDispCopyYScale() based on the height of the EFB and
3542 * the height of the XFB.
3544 * \param[in] efbHeight Height of embedded framebuffer. Range from 2 to 528. Should be a multiple of 2.
3545 * \param[in] xfbHeight Height of external framebuffer. Range from 2 to 1024. Should be equal or greater than \a efbHeight.
3547 * \return Y scale factor which can be used as argument of GX_SetDispCopyYScale().
3549 f32 GX_GetYScaleFactor(u16 efbHeight,u16 xfbHeight);
3552 * \fn u32 GX_SetDispCopyYScale(f32 yscale)
3553 * \brief Sets the vertical scale factor for the EFB to XFB copy operation.
3555 * \details The number of actual lines copied is returned, based on the current EFB height. You can use this number to allocate the proper XFB size. You
3556 * have to call GX_SetDispCopySrc() prior to this function call if you want to get the number of lines by using this function.
3558 * \param[in] yscale Vertical scale value. Range from 1.0 to 256.0.
3560 * \return Number of lines that will be copied.
3562 u32 GX_SetDispCopyYScale(f32 yscale);
3565 * \fn void GX_SetDispCopySrc(u16 left,u16 top,u16 wd,u16 ht)
3566 * \brief Sets the source parameters for the EFB to XFB copy operation.
3568 * \param[in] left left most source pixel to copy. Must be a multiple of 2 pixels.
3569 * \param[in] top top most source line to copy. Must be a multiple of 2 lines.
3570 * \param[in] wd width in pixels to copy. Must be a multiple of 2 pixels.
3571 * \param[in] ht height in lines to copy. Must be a multiple of 2 lines.
3573 * \return none
3575 void GX_SetDispCopySrc(u16 left,u16 top,u16 wd,u16 ht);
3578 * \fn void GX_SetDispCopyDst(u16 wd,u16 ht)
3579 * \brief Sets the witdth and height of the display buffer in pixels.
3581 * \details The application typical renders an image into the EFB(source) and then copies it into the XFB(destination) in main memory. \a wd
3582 * specifies the number of pixels between adjacent lines in the destination buffer and can be different than the width of the EFB.
3584 * \param[in] wd Distance between successive lines in the XFB, in pixels. Must be a multiple of 16.
3585 * \param[in] ht Height of the XFB in lines.
3587 * \return none
3589 void GX_SetDispCopyDst(u16 wd,u16 ht);
3592 * \fn void GX_SetCopyClamp(u8 clamp)
3593 * \brief Sets the vertical clamping mode to use during the EFB to XFB or texture copy.
3595 * \param[in] clamp bit-wise OR of desired \ref xfbclamp. Use <tt>GX_CLAMP_NONE</tt> for no clamping.
3597 * \return none
3599 void GX_SetCopyClamp(u8 clamp);
3602 * \fn void GX_SetDispCopyGamma(u8 gamma)
3603 * \brief Sets the gamma correction applied to pixels during EFB to XFB copy operation.
3605 * \param[in] gamma \ref gammamode
3607 * \return none
3609 void GX_SetDispCopyGamma(u8 gamma);
3612 * \fn void GX_SetCopyFilter(u8 aa,u8 sample_pattern[12][2],u8 vf,u8 vfilter[7])
3613 * \brief Sets the subpixel sample patterns and vertical filter coefficients used to filter subpixels into pixels.
3615 * \details This function normally uses the \a aa, \a sample_pattern and \a vfilter provided by the render mode struct:<br><br>
3617 * \code GXRModeObj* rmode = VIDEO_GetPreferredMode(NULL);
3618 * GX_SetCopyFilter(rmode->aa,rmode->sample_pattern,GX_TRUE,rmode->vfilter); \endcode
3620 * \note In order to make use of the \a sample_pattern, antialiasing must be enabled by setting the Embedded Frame Buffer (EFB) format to
3621 * <tt>GX_PF_RGB565_Z16</tt>; see GX_SetPixelFmt().
3623 * \param[in] aa utilizes \a sample_pattern if <tt>GX_TRUE</tt>, otherwise all sample points are centered
3624 * \param[in] sample_pattern array of coordinates for sample points; valid range is 1 - 11 inclusive
3625 * \param[in] vf use \a vfilter if <tt>GX_TRUE</tt>, otherwise use default 1-line filter
3626 * \param[in] vfilter vertical filter coefficients; valid coefficient range is 0 - 63 inclusive; sum should equal 64
3628 * \return none
3630 void GX_SetCopyFilter(u8 aa,u8 sample_pattern[12][2],u8 vf,u8 vfilter[7]);
3633 * \fn void GX_SetDispCopyFrame2Field(u8 mode)
3634 * \brief Determines which lines are read from the Embedded Frame Buffer (EFB) when using GX_CopyDisp().
3636 * \details Specifically, it determines whether all lines, only even lines, or only odd lines are read.
3638 * \note The opposite function, which determines whether all lines, only even lines or only odd lines are <i>written</i> to the EFB, is GX_SetFieldMask().<br><br>
3640 * \note Only applies to display copies, GX_CopyTex() always uses the <tt>GX_COPY_PROGRESSIVE</tt> mode.
3642 * \param[in] mode \ref copymode to determine which field to copy (or both)
3644 * \return none
3646 void GX_SetDispCopyFrame2Field(u8 mode);
3649 * \fn void GX_SetCopyClear(GXColor color,u32 zvalue)
3650 * \brief Sets color and Z value to clear the EFB to during copy operations.
3652 * \details These values are used during both display copies and texture copies.
3654 * \param[in] color RGBA color (8-bit/component) to use during clear operation.
3655 * \param[in] zvalue 24-bit Z value to use during clear operation. Use the constant <tt>GX_MAX_Z24</tt> to specify the maximum depth value.
3657 * \return none
3659 void GX_SetCopyClear(GXColor color,u32 zvalue);
3662 * \fn void GX_CopyDisp(void *dest,u8 clear)
3663 * \brief Copies the embedded framebuffer (EFB) to the external framebuffer(XFB) in main memory.
3665 * \note The stride of the XFB is set using GX_SetDispCopyDst(). The source image in the EFB is described using GX_SetDispCopySrc().<br><br>
3667 * \note The graphics processor will stall all graphics commands util the copy is complete.<br><br>
3669 * \note If the \a clear flag is true, the color and Z buffers will be cleared during the copy. They will be cleared to the constant
3670 * values set using GX_SetCopyClear().
3672 * \param[in] dest pointer to the external framebuffer. \a dest should be 32B aligned.
3673 * \param[in] clear flag that indicates framebuffer should be cleared if <tt>GX_TRUE</tt>.
3675 * \return none
3677 void GX_CopyDisp(void *dest,u8 clear);
3680 * \fn void GX_SetTexCopySrc(u16 left,u16 top,u16 wd,u16 ht)
3681 * \brief Sets the source parameters for the Embedded Frame Buffer (EFB) to texture image copy.
3683 * \param[in] left left-most source pixel to copy, multiple of two
3684 * \param[in] top top-most source line to copy, multiple of two
3685 * \param[in] wd width to copy in pixels, multiple of two
3686 * \param[in] ht height to copy in pixels, multiple of two
3688 * \return none
3690 void GX_SetTexCopySrc(u16 left,u16 top,u16 wd,u16 ht);
3693 * \fn void GX_SetTexCopyDst(u16 wd,u16 ht,u32 fmt,u8 mipmap)
3694 * \brief This function sets the width and height of the destination texture buffer in texels.
3696 * \details This function is useful when creating textures using the Graphics Processor (GP). If the \a clear flag is set to <tt>GX_TRUE</tt>, the
3697 * EFB will be cleared to the current color (see GX_SetCopyClear()) during the copy operation.
3699 * \param[in] wd pointer to the image buffer in main memory. \a dest should be 32B aligned.
3700 * \param[in] ht flag that indicates framebuffer should be cleared if <tt>GX_TRUE</tt>.
3701 * \param[in] fmt \ref texfmt
3702 * \param[in] mipmap
3704 * \return none
3706 void GX_SetTexCopyDst(u16 wd,u16 ht,u32 fmt,u8 mipmap);
3709 * \fn void GX_CopyTex(void *dest,u8 clear)
3710 * \brief Copies the embedded framebuffer (EFB) to the texture image buffer \a dest in main memory.
3712 * \details This is useful when creating textures using the Graphics Processor (GP). If the \a clear flag is set to <tt>GX_TRUE</tt>, the EFB will be cleared
3713 * to the current color(see GX_SetCopyClear()) during the copy operation.
3715 * \param[in] dest pointer to the image buffer in main memory. \a dest should be 32B aligned.
3716 * \param[in] clear flag that indicates framebuffer should be cleared if <tt>GX_TRUE</tt>.
3718 * \return none
3720 void GX_CopyTex(void *dest,u8 clear);
3723 * \fn void GX_PixModeSync()
3724 * \brief Causes the GPU to wait for the pipe to flush.
3726 * \details This function inserts a synchronization command into the graphics FIFO. When the GPU sees this command it will allow the rest of the pipe to
3727 * flush before continuing. This command is useful in certain situation such as after using GX_CopyTex() and before a primitive that uses the copied texture.
3729 * \note The command is actually implemented by writing the control register that determines the format of the embedded frame buffer (EFB). As a result, care
3730 * should be used if this command is placed within a display list.
3732 * \return none
3734 void GX_PixModeSync();
3737 * \fn void GX_ClearBoundingBox()
3738 * \brief Clears the bounding box values before a new image is drawn.
3740 * \details The graphics hardware keeps track of a bounding box of pixel coordinates that are drawn in the Embedded Frame Buffer (EFB).
3742 * \return none
3744 void GX_ClearBoundingBox();
3747 * \fn GX_PokeAlphaMode(u8 func,u8 threshold)
3748 * \brief Sets a threshold which is compared to the alpha of pixels written to the Embedded Frame Buffer (EFB) using the GX_Poke*() functions.
3750 * \details The compare function order is:<br><br>
3752 * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;src_alpha \a func \a threshold
3754 * \note The alpha compare function can be used to conditionally write pixels to the EFB using the source alpha channel as a template. If the compare function is
3755 * true, the source color will be written to the EFB based on the result of the Z compare (see GX_PokeZMode()). If the alpha compare function is false, the source
3756 * color is not written to the EFB.<br><br>
3758 * \note The alpha compare test happens before the Z compare and before blending (see GX_PokeBlendMode()).
3760 * \param[in] func \ref compare to use
3761 * \param[in] threshold to which the source alpha will be compared to
3763 * \return none
3765 void GX_PokeAlphaMode(u8 func,u8 threshold);
3768 * \fn void GX_PokeAlphaUpdate(u8 update_enable)
3769 * \brief Enables or disables alpha-buffer updates for GX_Poke*() functions.
3771 * \details The normal rendering state (set by GX_SetAlphaUpdate()) is not affected.
3773 * \param[in] update_enable enables alpha-buffer updates with <tt>GX_TRUE</tt>, otherwise does not
3775 * \return none
3777 void GX_PokeAlphaUpdate(u8 update_enable);
3780 * \fn void GX_PokeColorUpdate(u8 update_enable)
3781 * \brief Enables or disables color-buffer updates when writing the Embedded Frame Buffer (EFB) using the GX_Poke*() functions.
3783 * \param[in] update_enable enables color-buffer updates with <tt>GX_TRUE</tt>, otherwise does not
3785 * \return none
3787 void GX_PokeColorUpdate(u8 update_enable);
3790 * \fn void GX_PokeDither(u8 dither)
3791 * \brief Enables dithering when writing the Embedded Frame Buffer (EFB) using GX_Poke*() functions.
3793 * \note The \a dither enable is only valid when the pixel format (see GX_SetPixelFmt()) is either <tt>GX_PF_RGBA6_Z24</tt> or <tt>GX_PF_RGB565_Z16</tt>.<br><br>
3795 * \note A 4x4 Bayer matrix is used for dithering.
3797 * \param[in] dither if set to <tt>GX_TRUE</tt> and pixel format is one of the above, dithering is enabled; otherwise disabled
3799 * \return none
3801 void GX_PokeDither(u8 dither);
3804 * \fn void GX_PokeBlendMode(u8 type,u8 src_fact,u8 dst_fact,u8 op)
3805 * \brief Determines how the source image, is blended with the current Embedded Frame Buffer (EFB).
3807 * \details When type is set to <tt>GX_BM_NONE</tt>, no color data is written to the EFB. When type is set to <tt>GX_BM_BLEND</tt>, the source and EFB pixels
3808 * are blended using the following equation:<br><br>
3810 * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>dst_pix_clr</i> = <i>src_pix_clr</i> * \a src_fact + <i>dst_pix_clr</i> * \a dst_fact<br><br>
3812 * When type is set to <tt>GX_BM_SUBTRACT</tt>, the destination pixel is computed as follows:<br><br>
3814 * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>dst_pix_clr</i> = <i>dst_pix_clr</i> - <i>src_pix_clr [clamped to zero]</i><br><br>
3816 * Note that \a src_fact and \a dst_fact are not part of the equation.
3818 * \note \a dst_fact can be used only when the frame buffer has <tt>GX_PF_RGBA6_Z24</tt> as the pixel format (see GX_SetPixelFmt()).<br><br>
3820 * \note When type is set to <tt>GX_BM_LOGIC</tt>, the source and EFB pixels are blended using logical bitwise operations.<br><br>
3822 * \note This function does not effect the normal rendering state; see GX_SetBlendMode().
3824 * \param[in] type \ref blendmode
3825 * \param[in] src_fact source \ref blendfactor; the pixel color produced by the graphics processor is multiplied by this factor
3826 * \param[in] dst_fact destination \ref blendfactor; the current frame buffer pixel color is multiplied by this factor
3827 * \param[in] op \ref logicop to use
3829 void GX_PokeBlendMode(u8 type,u8 src_fact,u8 dst_fact,u8 op);
3832 * \fn void GX_PokeAlphaRead(u8 mode)
3833 * \brief Determines what value of alpha will be read from the Embedded Frame Buffer (EFB).
3835 * \details The mode only applies to GX_Peek*() functions.
3837 * \note This feature works no matter what pixel type (see GX_SetPixelFmt()) you are using. If you are using the EFB with alpha plane, it is
3838 * recommended that you use <tt>GX_READ_NONE</tt> so that you can read correct alpha value from the EFB. If you are using the EFB with no alpha, you should
3839 * set either of <tt>GX_READ_00</tt> or <tt>GX_READ_FF</tt> in order to get a certain value.<br><br>
3841 * \param[in] mode \ref alphareadmode that determines value of alpha read from a frame buffer with no alpha channel.
3843 * \return none
3845 void GX_PokeAlphaRead(u8 mode);
3848 * \fn void GX_PokeDstAlpha(u8 enable,u8 a)
3849 * \brief Sets a constant alpha value for writing to the Embedded Frame Buffer (EFB).
3851 * \details The EFB pixel type must have an alpha channel for this function to be effective (see GX_SetPixelFmt()). The blending operations (see
3852 * GX_PokeBlendMode()) still use source alpha but when writing the pixel color, the constant \a a will replace the pixel alpha in the EFB.
3854 * \param[in] enable if set to <tt>GX_ENABLE</tt> and pixel format supports dest alpha, \a a will be written to the framebuffer
3855 * \param[in] a constant alpha value
3857 * \return none
3859 void GX_PokeDstAlpha(u8 enable,u8 a);
3862 * \fn void GX_PokeARGB(u16 x,u16 y,GXColor color)
3863 * \brief Allows the CPU to write \a color directly to the Embedded Frame Buffer (EFB) at position \a x,\a y.
3865 * \details The alpha value in \a color can be compared with the current alpha threshold (see GX_PokeAlphaMode()). The color will be blended
3866 * into the EFB using the blend mode set by GX_PokeBlendMode().
3868 * \note For an antialiased frame buffer, all 3 subsamples of a pixel are affected by the poke.
3870 * \param[in] x coordinate, in pixels; must be 0 - 639 inclusive
3871 * \param[in] y coordinate, in lines; must be 0 - 527 inclusive
3872 * \param[in] color color to write at the location
3874 * \return none
3876 void GX_PokeARGB(u16 x,u16 y,GXColor color);
3879 * \fn void GX_PeekARGB(u16 x,u16 y,GXColor *color)
3880 * \brief Allows the CPU to read a color value directly from the Embedded Frame Buffer (EFB) at position \a x,\a y.
3882 * \note For an antialiased frame buffer, only subsample 0 of a pixel is read.
3884 * \param[in] x coordinate, in pixels; must be 0 - 639 inclusive
3885 * \param[in] y coordinate, in lines; must be 0 - 527 inclusive
3886 * \param[out] color struct to store color in
3888 * \return none
3890 void GX_PeekARGB(u16 x,u16 y,GXColor *color);
3893 * \fn void GX_PokeZ(u16 x,u16 y,u32 z)
3894 * \brief Allows the CPU to write a z value directly to the Embedded Frame Buffer (EFB) at position \a x,\a y.
3896 * \details The \a z value can be compared with the current contents of the EFB. The Z compare fuction is set using GX_PokeZMode().
3898 * \note The \a z value should be in the range of 0x00000000 <= \a z < 0x00FFFFFF in the case of non-antialiased frame buffer. For an antialiased
3899 * frame buffer, the \a z value should be in the compressed 16-bit format (0x00000000 <= \a z <= 0x0000FFFF), and the poke will affect all 3
3900 * subsamples of a pixel.
3902 * \param[in] x coordinate, in pixels; must be 0 - 639 inclusive
3903 * \param[in] y coordinate, in lines; must be 0 - 527 inclusive
3904 * \param[in] z value to write at position \a x,\a y in the EFB
3906 * \return none
3908 void GX_PokeZ(u16 x,u16 y,u32 z);
3911 * \fn void GX_PeekZ(u16 x,u16 y,u32 *z)
3912 * \brief Allows the CPU to read a z value directly from the Embedded Frame Buffer (EFB) at position x,y.
3914 * \details The z value is raw integer value from the Z buffer.
3916 * \note The value range is 24-bit when reading from non-antialiased frame buffer. When reading from an antialiased frame buffer, subsample
3917 * 0 is read and returned. The value will be compressed 16-bit form in this case.
3919 * \param[in] x coordinate, in pixels; must be 0 - 639 inclusive
3920 * \param[in] y coordinate, in lines; must be 0 - 527 inclusive
3921 * \param[out] z pointer to a returned Z value
3923 * \return none
3925 void GX_PeekZ(u16 x,u16 y,u32 *z);
3928 * \fn void GX_PokeZMode(u8 comp_enable,u8 func,u8 update_enable)
3929 * \brief Sets the Z-buffer compare mode when writing the Embedded Frame Buffer (EFB).
3931 * \details The result of the Z compare is used to conditionally write color values to the EFB. The Z value will be updated according to the
3932 * result of the compare if Z update is enabled.
3934 * When \a comp_enable is set to <tt>GX_DISABLE</tt>, poke Z buffering is disabled and the Z buffer is not updated. The \a func parameter determines the
3935 * comparison that is performed. In the comparison function, the poked Z value is on the left while the Z value from the Z buffer is on the
3936 * right. If the result of the comparison is false, the poked Z value is discarded. The parameter \a update_enable determines whether or not the
3937 * Z buffer is updated with the new Z value after a comparison is performed.
3939 * \note The normal rendering Z mode (set by GX_SetZMode()) is not affected by this function.<br><br>
3941 * \note Even if update_enable is <tt>GX_FALSE</tt>, compares may still be enabled.
3943 * \param[in] comp_enable enables comparisons with source and destination Z values if <tt>GX_TRUE</tt>
3944 * \param[in] func \ref compare function to use
3945 * \param[in] update_enable enables Z-buffer updates when <tt>GX_TRUE</tt>
3947 * \return none
3949 void GX_PokeZMode(u8 comp_enable,u8 func,u8 update_enable);
3952 * \fn u32 GX_GetTexObjFmt(GXTexObj *obj)
3953 * \brief Returns the texture format described by texture object \a obj.
3955 * \note Use GX_InitTexObj() or GX_InitTexObjCI() to initialize the texture format.
3957 * \param[in] obj ptr to a texture object
3959 * \return texture format of the given texture object
3961 u32 GX_GetTexObjFmt(GXTexObj *obj);
3964 * \fn u32 GX_GetTexObjMipMap(GXTexObj *obj)
3965 * \brief Returns the texture mipmap enable described by texture object \a obj.
3967 * \note Use GX_InitTexObj() or GX_InitTexObjCI() to initialize the texture mipmap enable.
3969 * \param[in] obj ptr to a texture object
3971 * \return mipmap enable flag
3973 u32 GX_GetTexObjMipMap(GXTexObj *obj);
3976 * \fn void* GX_GetTexObjUserData(GXTexObj *obj)
3977 * \brief Used to get a pointer to user data from the \ref GXTexObj structure.
3979 * \details You can use this function to retrieve private data structures from the texture object. This pointer is set using GX_InitTexObjUserData().
3981 * \param[in] obj ptr to object to read data from
3983 * \return Pointer to user data.
3985 void* GX_GetTexObjUserData(GXTexObj *obj);
3988 * \fn u32 GX_GetTexBufferSize(u16 wd,u16 ht,u32 fmt,u8 mipmap,u8 maxlod)
3989 * \brief Returns the amount of memory in bytes needed to store a texture of the given size and \a fmt.
3991 * \details If the \a mipmap flag is <tt>GX_TRUE</tt>, then the size of buffer needed for the mipmap pyramid up to \a maxlod will be returned.
3992 * \a maxlod will be clamped to the number of LODs possible given the map \a wd and \a ht. For mipmaps, \a wd and \a ht must be a power of two.
3994 * \note This function takes into account the tiling and padding requirements of the GameCube's native texture format. The resulting size can be used
3995 * along with memalign() to allocate texture buffers (see GX_CopyTex()).
3997 * \param[in] wd width of the texture in texels
3998 * \param[in] ht height of the texture in texels
3999 * \param[in] fmt format of the texture; use GX_TexFmt() or GX_CITexFmt() to get it
4000 * \param[in] mipmap flag indicating whether or not the texture is a mipmap
4001 * \param[in] maxlod if \a mipmap is \a GX_TRUE, texture size will include mipmap pyramid up to this value
4003 * \return number of bytes needed for the texture, including tile padding
4005 u32 GX_GetTexBufferSize(u16 wd,u16 ht,u32 fmt,u8 mipmap,u8 maxlod);
4008 * \fn void GX_InvalidateTexAll()
4009 * \brief Invalidates the current caches of the Texture Memory (TMEM).
4011 * \details It takes about 512 GP clocks to invalidate all the texture caches.
4013 * \note Preloaded textures (see GX_PreloadEntireTexture()) are not affected.
4015 * \return none
4017 void GX_InvalidateTexAll();
4020 * \fn void GX_InvalidateTexRegion(GXTexRegion *region)
4021 * \brief Invalidates the texture cache in Texture Memory (TMEM) described by \a region.
4023 * \details This function should be called when the CPU is used to modify a texture in main memory, or a new texture is loaded into main memory that
4024 * is possibly cached in the texture region.
4026 * \note In reality, this function invalidates the cache tags, forcing the texture cache to load new data. Preloaded textures (see
4027 * GX_PreloadEntireTexture()) do not use the tags.<br><br>
4029 * \note The texture hardware can invalidate 4 tags each GP clock. Each tag represents a superline or 512B of TMEM. Therefore, it takes 16
4030 * GP clocks to invalidate a 32KB texture region.
4032 * \param[in] region ptr to GXTexRegion object
4034 * \return none
4036 void GX_InvalidateTexRegion(GXTexRegion *region);
4039 * \fn void GX_InitTexCacheRegion(GXTexRegion *region,u8 is32bmipmap,u32 tmem_even,u8 size_even,u32 tmem_odd,u8 size_odd)
4040 * \brief Initializes a texture memory (TMEM) region object for cache.
4042 * \details The region is allocated by the application and can be used as a cache. An application can create many region objects and some of them can
4043 * overlap; however, no two overlapping regions can be active at the same time.
4045 * The possible sizes of a TMEM cache region are 32K, 128K or 512K.
4047 * \note For pre-loaded textures, the region must be defined by using GX_InitTexPreloadRegion().<br><br>
4049 * \note GX_Init() creates default texture regions, so it is not necessary for the application to use this function unless a different Texture Memory
4050 * configuration is desired. In that case, the application should also define a region allocator using GX_SetTexRegionCallback().<br><br>
4052 * \note The function GX_InvalidateTexRegion() can be used to force the texture in main memory associated with this region to be reloaded. This will be
4053 * necessary whenever the texture data in main memory changes. You may invalidate all cached regions at once using GX_InvalidateTexAll().
4055 * \param[in] region ptr to a GXTexRegion struct
4056 * \param[in] is32bmipmap should be set to <tt>GX_TRUE</tt> to interpret parameters according to the 32b mipmap meaning.
4057 * \param[in] tmem_even base ptr in TMEM for even LODs; must be multiple of 2KB
4058 * \param[in] size_even even \ref texcachesize other than <tt>GX_TEXCACHE_NONE</tt>
4059 * \param[in] tmem_odd base ptr in TMEM for odd LODs; must be multiple of 2KB
4060 * \param[in] size_odd odd \ref texcachesize other than <tt>GX_TEXCACHE_NONE</tt>
4062 * \return none
4064 void GX_InitTexCacheRegion(GXTexRegion *region,u8 is32bmipmap,u32 tmem_even,u8 size_even,u32 tmem_odd,u8 size_odd);
4067 * \fn void GX_InitTexPreloadRegion(GXTexRegion *region,u32 tmem_even,u32 size_even,u32 tmem_odd,u32 size_odd)
4068 * \brief Initializes a Texture Memory (TMEM) region object for preloading.
4070 * \details The region is allocated in TMEM by the application and can be used only as a pre-loaded buffer. Cache regions must be allocated
4071 * by using GX_InitTexCacheRegion(). For pre-loaded textures, the size of the region must match the size of the texture. An application can
4072 * create many region objects and some of them can overlap; however, no two overlapping regions can be active at the same time.
4074 * \note The maximum size of a region is 512K.
4076 * \warning GX_Init() creates no region for preloading, so the application should allocate appropriate regions if preloading is necessary. It
4077 * is also required to create cache regions and its allocator by using GX_InitTexCacheRegion() and GX_SetTexRegionCallback(), otherwise new
4078 * cache regions may overwrite the preloaded areas. (Alternatively, if you do not use any color-index textures, you may preload textures into
4079 * the portion of texture memory normally allocated to color-index usage by the default allocator.)
4081 * \param[in] region ptr to a GXTexRegion struct
4082 * \param[in] tmem_even base ptr in TMEM for even LODs; must be 32B aligned
4083 * \param[in] size_even size of the even cache, in bytes; should be multiple of 32B
4084 * \param[in] tmem_odd base ptr in TMEM for odd LODs; must be 32B aligned
4085 * \param[in] size_odd size of the odd cache, in bytes; should be multiple of 32B
4087 * \return none
4089 void GX_InitTexPreloadRegion(GXTexRegion *region,u32 tmem_even,u32 size_even,u32 tmem_odd,u32 size_odd);
4092 * \fn void GX_InitTexObj(GXTexObj *obj,void *img_ptr,u16 wd,u16 ht,u8 fmt,u8 wrap_s,u8 wrap_t,u8 mipmap)
4093 * \brief Used to initialize or change a texture object for non-color index textures.
4095 * \details Texture objects are used to describe all the parameters associated with a texture, including size, format, wrap modes, filter modes,
4096 * etc. It is the application's responsibility to provide memory for a texture object. Once initialized, a texture object can be associated with
4097 * one of eight active texture IDs using GX_LoadTexObj().
4099 * \note To initialize a texture object for color index format textures, use GX_InitTexObjCI().<br><br>
4101 * \note If the mipmap flag is <tt>GX_TRUE</tt>, then the texture is a mipmap and the texture will be trilerped. If the mipmap flag is <tt>GX_FALSE</tt>, the texture
4102 * is not a mipmap and the texture will be bilerped. To override the filter modes and other mipmap controls, see GX_InitTexObjLOD().
4104 * \param[out] obj ptr to a texture object
4105 * \param[in] img_ptr ptr to the image data for a texture, aligned to 32B
4106 * \param[in] wd width of the texture, or LOD level 0 for mipmaps; max value is 1024; mipmaps must be a power of two
4107 * \param[in] ht height of the texture, or LOD level 0 for mipmaps; max value is 1024; mipmaps must be a power of two
4108 * \param[in] fmt \ref texfmt
4109 * \param[in] wrap_s texture coordinate wrapping strategy in the S direction; use <tt>GX_CLAMP</tt>, <tt>GX_REPEAT</tt> or <tt>GX_MIRROR</tt>
4110 * \param[in] wrap_t texture coordinate wrapping strategy in the T direction; use <tt>GX_CLAMP</tt>, <tt>GX_REPEAT</tt> or <tt>GX_MIRROR</tt>
4111 * \param[in] mipmap trilinear filtering will be used if <tt>GX_TRUE</tt>, otherwise bilinear is used
4113 * \return none
4115 void GX_InitTexObj(GXTexObj *obj,void *img_ptr,u16 wd,u16 ht,u8 fmt,u8 wrap_s,u8 wrap_t,u8 mipmap);
4118 * \fn void GX_InitTexObjCI(GXTexObj *obj,void *img_ptr,u16 wd,u16 ht,u8 fmt,u8 wrap_s,u8 wrap_t,u8 mipmap,u32 tlut_name)
4119 * \brief Used to initialize or change a texture object when the texture is color index format.
4121 * \details Texture objects are used to describe all the parameters associated with a texture, including size, format, wrap modes, filter modes,
4122 * etc. It is the application's responsibility to provide memory for a texture object. Once initialized, a texture object can be associated with
4123 * one of eight active texture IDs using GX_LoadTexObj().
4125 * \note If the \a mipmap flag is <tt>GX_TRUE</tt>, then the texture is a mipmap and the texture will be filtered using the <tt>GX_LIN_MIP_NEAR</tt> filter mode
4126 * (color index mipmaps cannot use the <tt>GX_LIN_MIP_LIN</tt> or <tt>GX_NEAR_MIP_LIN</tt> mode). If the \a mipmap flag is <tt>GX_FALSE</tt>, the texture is not a mipmap
4127 * and the texture will be bilerped. To override the filter modes and other mipmap controls, use GX_InitTexObjLOD(). Mipmap textures should
4128 * set the width and height to a power of two, but mipmaps do not need to be square.<br><br>
4130 * \note Non-mipmap (planar) textures do not have to be a power of two. However, to use the <tt>GX_REPEAT</tt> or <tt>GX_MIRROR</tt> modes for \a wrap_s and \a wrap_t
4131 * the width and height, respectively, must be a power of two.<br><br>
4133 * \note The \a tlut_name is used to indicate which texture lookup table (TLUT) to use for the index to color conversion. To load the TLUT into
4134 * texture memory, use GX_LoadTlut().
4136 * \param[in] obj ptr to a texture object
4137 * \param[in] img_ptr ptr to the image data for a texture, aligned to 32B
4138 * \param[in] wd width of the texture, or LOD level 0 for mipmaps; max value is 1024; mipmaps must be a power of two
4139 * \param[in] ht height of the texture, or LOD level 0 for mipmaps; max value is 1024; mipmaps must be a power of two
4140 * \param[in] fmt \ref texfmt
4141 * \param[in] wrap_s texture coordinate wrapping strategy in the S direction; use <tt>GX_CLAMP</tt>, <tt>GX_REPEAT</tt> or <tt>GX_MIRROR</tt>
4142 * \param[in] wrap_t texture coordinate wrapping strategy in the T direction; use <tt>GX_CLAMP</tt>, <tt>GX_REPEAT</tt> or <tt>GX_MIRROR</tt>
4143 * \param[in] mipmap if <tt>GX_TRUE</tt>, it is a mipmap texture, else it is a planar texture
4144 * \param[in] tlut_name TLUT name to use for this texture; default texture configuration recognizes \ref tlutname
4146 * \return none
4148 void GX_InitTexObjCI(GXTexObj *obj,void *img_ptr,u16 wd,u16 ht,u8 fmt,u8 wrap_s,u8 wrap_t,u8 mipmap,u32 tlut_name);
4151 * \fn void GX_InitTexObjTlut(GXTexObj *obj,u32 tlut_name)
4152 * \brief Allows one to modify the TLUT that is associated with an existing texture object.
4154 * \param[in] obj ptr to a texture object
4155 * \param[in] tlut_name TLUT name to use for this texture; default texture configuration recognizes \ref tlutname
4157 * \return none
4159 void GX_InitTexObjTlut(GXTexObj *obj,u32 tlut_name);
4162 * \fn void GX_InitTexObjData(GXTexObj *obj,void *img_ptr)
4163 * \brief Allows one to modify the image data pointer for an existing texture object.
4165 * \note The image format and size for the new data must agree with what they were when the texture object was first initialized using
4166 * GX_InitTexObj() or GX_InitTexObjCI().
4168 * \param[in] obj ptr to a texture object
4169 * \param[in] img_ptr ptr to the texture data in main memory
4171 * \return none
4173 void GX_InitTexObjData(GXTexObj *obj,void *img_ptr);
4176 * \fn void GX_InitTexObjWrapMode(GXTexObj *obj,u8 wrap_s,u8 wrap_t)
4177 * \brief Allows one to modify the texture coordinate wrap modes for an existing texture object.
4179 * \param[in] obj ptr to a texture object
4180 * \param[in] wrap_s texture coordinate wrapping strategy in the S direction; use <tt>GX_CLAMP</tt>, <tt>GX_REPEAT</tt> or <tt>GX_MIRROR</tt>
4181 * \param[in] wrap_t texture coordinate wrapping strategy in the T direction; use <tt>GX_CLAMP</tt>, <tt>GX_REPEAT</tt> or <tt>GX_MIRROR</tt>
4183 * \return none
4185 void GX_InitTexObjWrapMode(GXTexObj *obj,u8 wrap_s,u8 wrap_t);
4188 * \fn void GX_InitTexObjFilterMode(GXTexObj *obj,u8 minfilt,u8 magfilt)
4189 * \brief Sets the filter mode for a texture.
4191 * \details When the ratio of texels for this texture to pixels is not 1:1, the filter type for \a minfilt or \a magfilt is used.
4193 * \param[in] obj texture object to set the filters for
4194 * \param[in] minfilt filter mode to use when the texel/pixel ratio is >= 1.0; needs to be one of \ref texfilter.
4195 * \param[in] magfilt filter mode to use when the texel/pixel ratio is < 1.0; needs to be \a GX_NEAR or \a GX_LINEAR
4197 void GX_InitTexObjFilterMode(GXTexObj *obj,u8 minfilt,u8 magfilt);
4200 * \fn void GX_InitTexObjMinLOD(GXTexObj *obj,f32 minlod)
4201 * \brief Sets the minimum LOD for a given texture.
4203 * \param[in] obj texture to set the minimum LOD for
4204 * \param[in] minlod minimum LOD value; the hardware will use MAX(min_lod, lod); range is 0.0 to 10.0.
4206 void GX_InitTexObjMinLOD(GXTexObj *obj,f32 minlod);
4209 * void GX_InitTexObjMaxLOD(GXTexObj *obj,f32 maxlod)
4210 * \brief Sets the maximum LOD for a given texture.
4212 * \param[in] obj texture to set the maximum LOD for
4213 * \param[in] maxlod maximum LOD value; the hardware will use MIN(max_lod, lod); range is 0.0 to 10.0.
4215 void GX_InitTexObjMaxLOD(GXTexObj *obj,f32 maxlod);
4218 * \fn void GX_InitTexObjLODBias(GXTexObj *obj,f32 lodbias)
4219 * \brief Sets the LOD bias for a given texture.
4221 * \details The LOD computed by the graphics hardware can be biased using this function. The \a lodbias is added to the computed lod and the
4222 * result is clamped between the values given to GX_InitTexObjMinLOD() and GX_InitTexObjMaxLOD(). If \a GX_ENABLE is given to
4223 * GX_InitTexObjBiasClamp(), the effect of \a lodbias will diminish as the polygon becomes more perpendicular to the view direction.
4225 * \param[in] obj texture to set the LOD bias for
4226 * \param[in] lodbias bias to add to computed LOD value
4228 void GX_InitTexObjLODBias(GXTexObj *obj,f32 lodbias);
4231 * \fn void GX_InitTexObjBiasClamp(GXTexObj *obj,u8 biasclamp)
4232 * \brief Enables bias clamping for texture LOD.
4234 * \details If \a biasclamp is \a GX_ENABLE, the sum of LOD and \a lodbias (given in GX_InitTexObjLODBias()) is clamped so that it is never
4235 * less than the minimum extent of the pixel projected in texture space. This prevents over-biasing the LOD when the polygon is perpendicular
4236 * to the view direction.
4238 * \param[in] obj texture to set the bias clamp value for
4239 * \param[in] biasclamp whether or not to enable the bias clamp
4241 void GX_InitTexObjBiasClamp(GXTexObj *obj,u8 biasclamp);
4244 * \fn void GX_InitTexObjEdgeLOD(GXTexObj *obj,u8 edgelod)
4245 * \brief Changes LOD computing mode.
4247 * \details When set to \a GX_ENABLE, the LOD is computed using adjacent texels; when \a GX_DISABLE, diagonal texels are used instead. This
4248 * should be set to \a GX_ENABLE if you use bias clamping (see GX_InitTexObjBiasClamp()) or anisotropic filtering (GX_ANISO_2 or GX_ANISO_4
4249 * for GX_InitTexObjMaxAniso() argument).
4251 * \param[in] obj texture to set the edge LOD for
4252 * \param[in] edgelod mode to set LOD computation to
4254 void GX_InitTexObjEdgeLOD(GXTexObj *obj,u8 edgelod);
4257 * \fn void GX_InitTexObjMaxAniso(GXTexObj *obj,u8 maxaniso)
4258 * \brief Sets the maximum anisotropic filter to use for a texture.
4260 * \details Anisotropic filtering is accomplished by iterating the square filter along the direction of anisotropy to better approximate the
4261 * quadralateral. This type of filtering results in sharper textures at the expense of multiple cycles per quad. The hardware will only use
4262 * multiple cycles when necessary, and the maximum number of cycles is clamped by the \a maxaniso parameter, so setting \a maxaniso to
4263 * \a GX_ANISO_2 will use at most 2 filter cycles per texture.
4265 * \note These filter cycles are internal to the texture filter hardware and do not affect the available number of TEV stages. When setting
4266 * \a maxaniso to \a GX_ANISO_2 or \a GX_ANISO_4, the \a minfilt parameter given to GX_InitTexObjFilterMode() should be set to
4267 * \a GX_LIN_MIP_LIN.
4269 * \param[in] obj texture to set the max anisotropy value to
4270 * \param[in] maxaniso the maximum anistropic filter to use; must be one of \ref anisotropy
4272 void GX_InitTexObjMaxAniso(GXTexObj *obj,u8 maxaniso);
4275 * \fn GX_InitTexObjUserData(GXTexObj *obj,void *userdata)
4276 * \brief Used to set a pointer to user data in the \ref GXTexObj structure.
4278 * \details You can use this function to attach private data structures to the texture object. This pointer can be retrieved using GX_GetTexObjUserData().
4280 * \param[in] obj ptr to a texture object
4281 * \param[in] userdata pointer to your data to attach to this texture
4283 void GX_InitTexObjUserData(GXTexObj *obj,void *userdata);
4286 * \fn void GX_LoadTexObj(GXTexObj *obj,u8 mapid)
4287 * \brief Loads the state describing a texture into one of eight hardware register sets.
4289 * \details Before this happens, the texture object \a obj should be initialized using GX_InitTexObj() or GX_InitTexObjCI(). The \a id parameter refers to
4290 * the texture state register set. Once loaded, the texture can be used in any Texture Environment (TEV) stage using GX_SetTevOrder().
4292 * \note This function will call the functions set by GX_SetTexRegionCallback() (and GX_SetTlutRegionCallback() if the texture is color-index
4293 * format) to obtain the texture regions associated with this texture object. These callbacks are set to default functions by GX_Init().
4295 * \warning If the texture is a color-index texture, you <b>must</b> load the associated TLUT (using GX_LoadTlut()) before calling GX_LoadTexObj().
4297 * \param[in] obj ptr to a texture object
4298 * \param[in] mapid \ref texmapid, <tt>GX_TEXMAP0</tt> to <tt>GX_TEXMAP7</tt> only
4300 * \return none
4302 void GX_LoadTexObj(GXTexObj *obj,u8 mapid);
4305 * \fn void GX_LoadTlut(GXTlutObj *obj,u32 tlut_name)
4306 * \brief Copies a Texture Look-Up Table (TLUT) from main memory to Texture Memory (TMEM).
4308 * \details The \a tlut_name parameter is the name of a pre-allocated area of TMEM. The callback function set by GX_SetTlutRegionCallback() converts
4309 * the \a tlut_name into a \ref GXTlutRegion pointer. The TLUT is loaded in the TMEM region described by this pointer. The TLUT object \a obj describes the
4310 * location of the TLUT in main memory, the TLUT format, and the TLUT size. \a obj should have been previously initialized using GX_InitTlutObj().
4312 * \note GX_Init() sets a default callback to convert \a tlut_names from \ref tlutname to \ref GXTlutRegion pointers. The default configuration of
4313 * TMEM has 20 TLUTs, 16 each 256 entries by 16 bits, and 4 each 1k entries by 16 bits. This configuration can be overriden by calling
4314 * GX_InitTlutRegion() and GX_InitTexCacheRegion() to allocate TMEM. Then you can define your own region allocation scheme using GX_SetTlutRegionCallback()
4315 * and GX_SetTexRegionCallback().
4317 * \param[in] obj ptr to a TLUT object; application must allocate this
4318 * \param[in] tlut_name \ref tlutname
4320 * \return none
4322 void GX_LoadTlut(GXTlutObj *obj,u32 tlut_name);
4325 * \fn void GX_LoadTexObjPreloaded(GXTexObj *obj,GXTexRegion *region,u8 mapid)
4326 * \brief Loads the state describing a preloaded texture into one of eight hardware register sets.
4328 * \details Before this happens, the texture object \a obj should be initialized using GX_InitTexObj() or GX_InitTexObjCI(). The \a mapid parameter refers to
4329 * the texture state register set. The texture should be loaded beforehand using GX_PreloadEntireTexture(). Once loaded, the texture can be used in any Texture Environment
4330 * (TEV) stage using GX_SetTevOrder().
4332 * \note GX_Init() initially calls GX_SetTevOrder() to make a simple texture pipeline that associates <tt>GX_TEXMAP0</tt> with <tt>GX_TEVSTAGE0</tt>,
4333 * <tt>GX_TEXMAP1</tt> with <tt>GX_TEVSTAGE1</tt>, etc.<br><br>
4335 * \note GX_LoadTexObjPreloaded() will not call the functions set by GX_SetTexRegionCallback() (and GX_SetTlutRegionCallback() if the texture is color
4336 * index format) because the region is set explicitly; however, these callback functions must be aware of all regions that are preloaded. The default
4337 * callbacks set by GX_Init() assume there are no preloaded regions.
4339 * \param[in] obj ptr to a texture object
4340 * \param[in] region ptr to a region object that describes an area of texture memory
4341 * \param[in] mapid \ref texmapid for reference in a TEV stage
4343 * \return none
4345 void GX_LoadTexObjPreloaded(GXTexObj *obj,GXTexRegion *region,u8 mapid);
4348 * \fn void GX_PreloadEntireTexture(GXTexObj *obj,GXTexRegion *region)
4349 * \brief Loads a given texture from DRAM into the texture memory.
4351 * \details Accesses to this texture will bypass the texture cache tag look-up and instead read the texels directly from texture memory. The
4352 * texture region must be the same size as the texture (see GX_InitTexPreloadRegion()).
4354 * \note This function loads the texture into texture memory, but to use it as a source for the Texture Environment (TEV) unit, you must first
4355 * call GX_LoadTexObjPreloaded(). The default configuration (as set by GX_Init()) of texture memory has no preloaded regions, so you must install
4356 * your own region allocator callbacks using GX_SetTexRegionCallback() and GX_SetTlutRegionCallback().
4358 * \param[in] obj ptr to object describing the texture to laod
4359 * \param[in] region TMEM texture region to load the texture into
4361 * \return none
4363 void GX_PreloadEntireTexture(GXTexObj *obj,GXTexRegion *region);
4366 * \fn void GX_InitTlutObj(GXTlutObj *obj,void *lut,u8 fmt,u16 entries)
4367 * \brief Initializes a Texture Look-Up Table (TLUT) object.
4369 * \details The TLUT object describes the location of the TLUT in main memory, its format and the number of entries. The TLUT in main
4370 * memory described by this object can be loaded into a TLUT allocated in the texture memory using the GX_LoadTlut() function.
4372 * \param[in] obj ptr to a TLUT object
4373 * \param[in] lut ptr to look-up table data; must be 32B aligned
4374 * \param[in] fmt format of the entries in the TLUt; <tt>GX_TL_IA8</tt>, <tt>GX_TL_RGB565</tt> or <tt>GX_TL_RGB5A3</tt>
4375 * \param[in] entries number of entries in this table; maximum is 16,384
4377 * \return none
4379 void GX_InitTlutObj(GXTlutObj *obj,void *lut,u8 fmt,u16 entries);
4382 * \fn void GX_InitTlutRegion(GXTlutRegion *region,u32 tmem_addr,u8 tlut_sz)
4383 * \brief Initializes a Texture Look-Up Table (TLUT) region object.
4385 * \note GX_Init() creates default TLUT regions, so the application does not need to call this function unless a new configuration
4386 * of Texture Memory is desired. In that case, the application should also set a new TLUT region allocator using GX_SetTlutRegionCallback().
4388 * \param[in] region obj ptr to a TLUT region struct; application must allocate this
4389 * \param[in] tmem_addr location of the TLU in TMEM; ptr must be aligned to table size
4390 * \param[in] tlut_sz size of the table
4392 * \return none
4394 void GX_InitTlutRegion(GXTlutRegion *region,u32 tmem_addr,u8 tlut_sz);
4397 * \fn void GX_InitTexObjLOD(GXTexObj *obj,u8 minfilt,u8 magfilt,f32 minlod,f32 maxlod,f32 lodbias,u8 biasclamp,u8 edgelod,u8 maxaniso)
4398 * \brief Sets texture Level Of Detail (LOD) controls explicitly for a texture object.
4400 * \details It is the application's responsibility to provide memory for a texture object. When initializing a texture object using GX_InitTexObj()
4401 * or GX_InitTexObjCI(), this information is set to default values based on the mipmap flag. This function allows the programmer to override those
4402 * defaults.
4404 * \note This function should be called after GX_InitTexObj() or GX_InitTexObjCI() for a particular texture object.<br><br>
4406 * \note Setting \a biasclamp prevents over-biasing the LOD when the polygon is perpendicular to the view direction.<br><br>
4408 * \note \a edgelod should be set if \a biasclamp is set or \a maxaniso is set to <tt>GX_ANISO_2</tt> or <tt>GX_ANISO_4</tt>.<br><br>
4410 * \note Theoretically, there is no performance difference amongst various magnification/minification filter settings except <tt>GX_LIN_MIP_LIN</tt> filter with
4411 * <tt>GX_TF_RGBA8</tt> texture format which takes twice as much as other formats. However, this argument is assuming an environment where texture cache always
4412 * hits. On real environments, you will see some performance differences by changing filter modes (especially minification filter) because cache-hit ratio
4413 * changes according to which filter mode is being used.
4415 * \param[in] obj ptr to a texture object
4416 * \param[in] minfilt \ref texfilter to use when the texel/pixel ratio is >= 1.0
4417 * \param[in] magfilt \ref texfilter to use when the texel/pixel ratio is < 1.0; use only <tt>GX_NEAR</tt> or <tt>GX_LINEAR</tt>
4418 * \param[in] minlod minimum LOD value from 0.0 - 10.0 inclusive
4419 * \param[in] maxlod maximum LOD value from 0.0 - 10.0 inclusive
4420 * \param[in] lodbias bias to add to computed LOD value
4421 * \param[in] biasclamp if <tt>GX_ENABLE</tt>, clamp (LOD+lodbias) so that it is never less than the minimum extent of the pixel projected in texture space
4422 * \param[in] edgelod if <tt>GX_ENABLE</tt>, compute LOD using adjacent texels
4423 * \param[in] maxaniso \ref anisotropy to use
4425 * \return none
4427 void GX_InitTexObjLOD(GXTexObj *obj,u8 minfilt,u8 magfilt,f32 minlod,f32 maxlod,f32 lodbias,u8 biasclamp,u8 edgelod,u8 maxaniso);
4430 * \fn void GX_SetTexCoordScaleManually(u8 texcoord,u8 enable,u16 ss,u16 ts)
4431 * \brief Overrides the automatic texture coordinate scaling (based upon the associated map size) and lets one manually assign the scale values that
4432 * are used for a given \a texcoord.
4434 * \details Setting the \a enable parameter to <tt>GX_TRUE</tt> gives this behavior. The given \a texcoord retains these manual scale values until this function is
4435 * called again. This function is also used to return a given texture coordinate back to normal, automatic scaling (by setting \a enable to <tt>GX_FALSE</tt>).
4437 * \note A texture coordinate is scaled after being computed by the relevant texgen and before the actual texture lookup Normally, the scale value is set
4438 * according to the texture map that is associated with the texcoord by GX_SetTevOrder(). However, there are certain cases where a different scale value is
4439 * desirable. One such case is when using indirect tiled textures (see GX_SetTevIndTile()).
4441 * \param[in] texcoord the \ref texcoordid being changed
4442 * \param[in] enable if <tt>GX_TRUE</tt>, scale will be set manually, otherwise set automatically and \a ss and \a ts ignored
4443 * \param[in] ss manual scale value for the S component of the coordinate
4444 * \param[in] ts manual scale value for the T component of the coordinate
4446 * \return none
4448 void GX_SetTexCoordScaleManually(u8 texcoord,u8 enable,u16 ss,u16 ts);
4451 * \fn void GX_SetTexCoordBias(u8 texcoord,u8 s_enable,u8 t_enable)
4452 * \brief Sets the texture coordinate bias of a particular texture.
4454 * \details Range bias is used with texture coordinates applied in <tt>GX_REPEAT</tt> wrap mode in order to increase the precision of texture coordinates
4455 * that spread out over a large range. The texture coordinate values for a primitive are biased (by an equal integer) towards zero early in the
4456 * graphics pipeline, thus preserving bits for calculation later in the pipe. Since the coordinates are repeated, this bias by an integer should
4457 * have no effect upon the actual appearance of the texture.
4459 * \note Texture coordinate range bias is something that is normally set automatically by the GX API (during GX_Begin()); however, when a texture
4460 * coordinate is being scaled manually (by using GX_SetTexCoordScaleManually()), the associated bias is no longer modified by GX. Thus,
4461 * GX_SetTexCoordBias() allows the bias to be changed while a texture coordinate is being manually controlled.
4463 * \param[in] texcoord \ref texcoordid being changed
4464 * \param[in] s_enable enable or disable range bias in the S direction with <tt>GX_ENABLE</tt>/<tt>GX_DISABLE</tt>
4465 * \param[in] t_enable enable or disable range bias in the T direction with <tt>GX_ENABLE</tt>/<tt>GX_DISABLE</tt>
4467 * \return none
4469 void GX_SetTexCoordBias(u8 texcoord,u8 s_enable,u8 t_enable);
4472 * \fn GXTexRegionCallback GX_SetTexRegionCallback(GXTexRegionCallback cb)
4473 * \brief Sets the callback function called by GX_LoadTexObj() to obtain an available texture region.
4475 * \details GX_Init() calls this function to set a default region-assignment policy. A programmer can override this default region assignment
4476 * by implementing his own callback function. A pointer to the texture object and the texture map ID that are passed
4477 * to GX_LoadTexObj() are provided to the callback function.
4479 * \param[in] cb ptr to a function that takes a pointer to a GXTexObj and a \ref texmapid as a parameter and returns a pointer to a \ref GXTexRegion.
4481 * \return pointer to the previously set callback
4483 GXTexRegionCallback GX_SetTexRegionCallback(GXTexRegionCallback cb);
4486 * \fn GXTlutRegionCallback GX_SetTlutRegionCallback(GXTlutRegionCallback cb)
4487 * \brief Sets the callback function called by GX_LoadTlut() to find the region into which to load the TLUT.
4489 * \details GX_LoadTexObj() will also call \a cb to obtain the Texture Look-up Table (TLUT) region when the texture forma
4490 * is color-index.
4492 * GX_Init() calls GX_SetTlutRegionCallback() to set a default TLUT index-to-region mapping. The name for the TLUT from the texture
4493 * object is provided as an argument to the callback. The callback should return a pointer to the \ref GXTlutRegion for this TLUT index.
4495 * \note For a given \a tlut_name (in the \ref GXTlutRegionCallback struct), \a cb must always return the same \ref GXTlutRegion; this is because
4496 * GX_LoadTlut() will initialize data into the \ref GXTlutRegion which GX_LoadTexObj() will subsequently use.
4498 * \param[in] cb ptr to a function that takes a u32 TLUT name as a parameter and returns a pointer to a \ref GXTlutRegion.
4500 * \return pointer to the previously set callback
4502 GXTlutRegionCallback GX_SetTlutRegionCallback(GXTlutRegionCallback cb);
4505 * \fn void GX_InitLightPos(GXLightObj *lit_obj,f32 x,f32 y,f32 z)
4506 * \brief Sets the position of the light in the light object.
4508 * \details The GameCube graphics hardware supports local diffuse lights. The position of the light should be in the same space as a transformed
4509 * vertex position (i.e., view space).
4511 * \note Although the hardware doesn't support parallel directional diffuse lights, it is possible to get "almost parallel" lights by setting
4512 * sufficient large values to position parameters (x, y and z) which makes the light position very far away from objects to be lit and all rays
4513 * considered almost parallel.<br><br>
4515 * \note The memory for the light object must be allocated by the application; this function does not load any hardware registers directly. To
4516 * load a light object into a hardware light, use GX_LoadLightObj() or GX_LoadLightObjIdx().
4518 * \param[in] lit_obj ptr to the light object
4519 * \param[in] x X coordinate to place the light at
4520 * \param[in] y Y coordinate to place the light at
4521 * \param[in] z Z coordinate to place the light at
4523 * \return none
4525 void GX_InitLightPos(GXLightObj *lit_obj,f32 x,f32 y,f32 z);
4528 * \fn void GX_InitLightColor(GXLightObj *lit_obj,GXColor col)
4529 * \brief Sets the color of the light in the light object.
4531 * \note The memory for the light object should be allocated by the application; this function does not load any hardware register directly. To
4532 * load a light object into a hardware light, use GX_LoadLightObj() or GX_LoadLightObjIdx().
4534 * \param[in] lit_obj ptr to the light object
4535 * \param[in] col color to set the light to
4537 * \return none
4539 void GX_InitLightColor(GXLightObj *lit_obj,GXColor col);
4542 * \fn void GX_InitLightDir(GXLightObj *lit_obj,f32 nx,f32 ny,f32 nz)
4543 * \brief Sets the direction of a light in the light object.
4545 * \details This direction is used when the light object is used as spotlight or a specular light (see the <i>attn_fn</i> parameter of GX_SetChanCtrl()).
4547 * \note The coordinate space of the light normal should be consistent with a vertex normal transformed by a normal matrix; i.e., it should be
4548 * transformed to view space.<br><br>
4550 * \note This function does not set the direction of parallel directional diffuse lights. If you want parallel diffuse lights, you may put the light
4551 * position very far from every objects to be lit. (See GX_InitLightPos() and GX_SetChanCtrl())<br><br>
4553 * \note The memory for the light object must be allocated by the application; this function does not load any hardware registers. To load a light
4554 * object into a hardware light, use GX_LoadLightObj() or GX_LoadLightObjIdx().
4556 * \param[in] lit_obj ptr to the light object
4557 * \param[in] nx X coordinate of the light normal
4558 * \param[in] ny Y coordinate of the light normal
4559 * \param[in] nz Z coordinate of the light normal
4561 * \return none
4563 void GX_InitLightDir(GXLightObj *lit_obj,f32 nx,f32 ny,f32 nz);
4566 * \fn void GX_LoadLightObj(GXLightObj *lit_obj,u8 lit_id)
4567 * \brief Loads a light object into a set of hardware registers associated with a \ref lightid.
4569 * \details This function copies the light object data into the graphics FIFO through the CPU write-gather buffer mechanism. This guarantees that
4570 * the light object is coherent with the CPU cache.
4572 * \note The light object must have been initialized first using the necessary GX_InitLight*() functions.<br><br>
4574 * \note Another way to load a light object is with GX_LoadLightObjIdx().
4576 * \param[in] lit_obj ptr to the light object to load
4577 * \param[in] lit_id \ref lightid to load this light into
4579 * \return none
4581 void GX_LoadLightObj(GXLightObj *lit_obj,u8 lit_id);
4584 * \fn void GX_LoadLightObjIdx(u32 litobjidx,u8 litid)
4585 * \brief Instructs the GP to fetch the light object at \a ltobjindx from an array.
4587 * \details The light object is retrieved from the array to which <tt>GX_SetArray(GX_VA_LIGHTARRAY, ...)</tt> points. Then it loads the object into
4588 * the hardware register associated with \ref lightid.
4590 * \note Data flows directly from the array in DRAM to the GP; therefore, the light object data may not be coherent with the CPU's cache. The
4591 * application is responsible for storing the light object data from the CPU cache (using DCStoreRange()) before calling GX_LoadLightObjIdx().
4593 * \param[in] litobjidx index to a light object
4594 * \param[in] litid \ref lightid to load this light into
4596 * \return none
4598 void GX_LoadLightObjIdx(u32 litobjidx,u8 litid);
4601 * \fn void GX_InitLightDistAttn(GXLightObj *lit_obj,f32 ref_dist,f32 ref_brite,u8 dist_fn)
4602 * \brief Sets coefficients for distance attenuation in a light object.
4604 * \details This function uses three easy-to-control parameters instead of <i>k0</i>, <i>k1</i>, and <i>k2</i> in GX_InitLightAttn().
4606 * In this function, you can specify the brightness on an assumed reference point. The parameter \a ref_distance is distance between the light
4607 * and the reference point. The parameter \a ref_brite specifies ratio of the brightness on the reference point. The value for \a ref_dist should
4608 * be greater than 0 and that for \a ref_brite should be within 0 < \a ref_brite < 1, otherwise distance attenuation feature is turned off. The
4609 * parameter \a dist_fn defines type of the brightness decreasing curve by distance; <tt>GX_DA_OFF</tt> turns distance attenuation feature off.
4611 * \note If you want more flexible control, it is better to use GX_InitLightAttn() and calculate appropriate coefficients.<br><br>
4613 * \note This function sets parameters only for distance attenuation. Parameters for angular attenuation should be set by using
4614 * GX_InitLightSpot() or GX_InitLightAttnA().<br><br>
4616 * \note This function does not load any hardware registers directly. To load a light object into a hardware light, use GX_LoadLightObj() or
4617 * GX_LoadLightObjIdx().
4619 * \param[in] lit_obj ptr to a light object
4620 * \param[in] ref_dist distance between the light and reference point
4621 * \param[in] ref_brite brightness of the reference point
4622 * \param[in] dist_fn \ref distattnfn to use
4624 * \return none
4626 void GX_InitLightDistAttn(GXLightObj *lit_obj,f32 ref_dist,f32 ref_brite,u8 dist_fn);
4629 * \fn void GX_InitLightAttn(GXLightObj *lit_obj,f32 a0,f32 a1,f32 a2,f32 k0,f32 k1,f32 k2)
4630 * \brief Sts coefficients used in the lighting attenuation calculation in a given light object.
4632 * \details The parameters \a a0, \a a1, and \a a2 are used for angular (spotlight) attenuation. The coefficients \a k0, \a k1, and \a k2 are used for
4633 * distance attenuation. The attenuation function is:
4635 * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>atten</i> = <i>clamp0</i>(\a a2^2 * <i>aattn</i>^2 + \a a1 * <i>aattn</i> + \a a0) / (\a k2 * <i>d</i>^2 + \a k1 * <i>d</i> + \a k0)
4637 * where <i>aattn</i> is the cosine of the angle between the light direction and the vector from the light position to the vertex, and <i>d</i> is
4638 * the distance from the light position to the vertex when the channel attenuation function is <tt>GX_AF_SPOT</tt>. The light color will be
4639 * multiplied by the <i>atten</i> factor when the attenuation function for the color channel referencing this light is set to <tt>GX_AF_SPOT</tt>
4640 * (see GX_SetChanCtrl()).
4642 * \note The convenience function GX_InitLightSpot() can be used to set the angle attenuation coefficents based on several spot light
4643 * types. The convenience function GX_InitLightDistAttn() can be used to set the distance attenuation coefficients using one of several
4644 * common attenuation functions.<br><br>
4646 * \note The convenience macro GX_InitLightShininess() can be used to set the attenuation parameters for specular lights.<br><br>
4648 * \note When the channel attenuation function is set to <tt>GX_AF_SPEC</tt>, the <i>aattn</i> and <i>d</i> parameter are equal to the dot product of the
4649 * eye-space vertex normal and the half-angle vector set by GX_InitSpecularDir().<br><br>
4651 * \note This function does not load any hardware registers directly. To load a light object into a hardware light, use GX_LoadLightObj()
4652 * or GX_LoadLightObjIdx().
4654 * \param[in] lit_obj ptr to a light object
4655 * \param[in] a0 angle attenuation coefficient
4656 * \param[in] a1 angle attenuation coefficient
4657 * \param[in] a2 angle attenuation coefficient
4658 * \param[in] k0 distance attenuation coefficient
4659 * \param[in] k1 distance attenuation coefficient
4660 * \param[in] k2 distance attenuation coefficient
4662 * \return none
4664 void GX_InitLightAttn(GXLightObj *lit_obj,f32 a0,f32 a1,f32 a2,f32 k0,f32 k1,f32 k2);
4667 * \fn void GX_InitLightAttnA(GXLightObj *lit_obj,f32 a0,f32 a1,f32 a2)
4668 * \brief Sets coefficients used in the lighting angle attenuation calculation in a given light object.
4670 * \details The parameters \a a0, \a a1, and \a a2 are used for angular (spotlight) attenuation. The attenuation
4671 * function is:
4673 * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>atten</i> = <i>clamp0</i>(\a a2^2 * <i>cos(theta)</i>^2 + \a a1 * <i>cos(theta)</i> + \a a0) / (\a k2 * <i>d</i>^2 + \a k1 * <i>d</i> + \a k0)
4675 * where <i>cos(theta)</i> is the cosine of the angle between the light normal and the vector from the light position to the vertex, and <i>d</i> is the distance
4676 * from the light position to the vertex. The \a k0-\a 2 coefficients can be set using GX_InitLightAttnK(). You can set both the \a a0-\a 2 and \a k0-\a 2 coefficients
4677 * can be set using GX_InitLightAttn(). The light color will be multiplied by the <i>atten</i> factor when the attenuation function for the color channel
4678 * referencing this light is set to <tt>GX_AF_SPOT</tt> (see GX_SetChanCtrl()).
4680 * \note The convenience function GX_InitLightSpot() can be used to set the angle attenuation coefficents based on several spot light types. The
4681 * convenience function GX_InitLightDistAttn() can be used to set the distance attenuation coefficients using one of several common attenuation functions.<br><br>
4683 * \note This function does not load any hardware registers directly. To load a light object into a hardware light, use GX_LoadLightObj() or GX_LoadLightObjIdx().
4685 * \param[in] lit_obj ptr to a light object
4686 * \param[in] a0 angle attenuation coefficient
4687 * \param[in] a1 angle attenuation coefficient
4688 * \param[in] a2 angle attenuation coefficient
4690 * \return none
4692 void GX_InitLightAttnA(GXLightObj *lit_obj,f32 a0,f32 a1,f32 a2);
4695 * \fn void GX_InitLightAttnK(GXLightObj *lit_obj,f32 k0,f32 k1,f32 k2)
4696 * \brief Sets coefficients used in the lighting distance attenuation calculation in a given light object.
4698 * \details The coefficients \a k0, \a k1, and \a k2 are used for distance attenuation. The attenuation function is:
4700 * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>atten</i> = <i>clamp0</i>(\a a2^2 * <i>cos(theta)</i>^2 + \a a1 * <i>cos(theta)</i> + \a a0) / (\a k2 * <i>d</i>^2 + \a k1 * <i>d</i> + \a k0)
4702 * where <i>cos(theta)</i> is the cosine of the angle between the light normal and the vector from the light position to the vertex, and <i>d</i> is the distance
4703 * from the light position to the vertex. The \a a0-\a 2 coefficients can be set using GX_InitLightAttnA(). You can set both the \a a0-\a 2 and \a k0-\a 2 coefficients
4704 * can be set using GX_InitLightAttn(). The light color will be multiplied by the <i>atten</i> factor when the attenuation function for the color channel
4705 * referencing this light is set to <tt>GX_AF_SPOT</tt> (see GX_SetChanCtrl()).
4707 * \note The convenience function GX_InitLightSpot() can be used to set the angle attenuation coefficents based on several spot light types. The convenience
4708 * function GX_InitLightDistAttn() can be used to set the distance attenuation coefficients using one of several common attenuation functions.<br><br>
4710 * \note Note that this function does not load any hardware registers directly. To load a light object into a hardware light, use GX_LoadLightObj() or
4711 * GX_LoadLightObjIdx().
4713 * \param[in] lit_obj ptr to a light object
4714 * \param[in] k0 distance attenuation coefficient
4715 * \param[in] k1 distance attenuation coefficient
4716 * \param[in] k2 distance attenuation coefficient
4718 * \return none
4720 void GX_InitLightAttnK(GXLightObj *lit_obj,f32 k0,f32 k1,f32 k2);
4723 * \fn void GX_InitSpecularDirHA(GXLightObj *lit_obj,f32 nx,f32 ny,f32 nz,f32 hx,f32 hy,f32 hz)
4724 * \brief Sets the direction and half-angle vector of a specular light in the light object.
4726 * \details These vectors are used when the light object is used only as specular light. In contrast to GX_InitSpecularDir(),
4727 * which caclulates half-angle vector automatically by assuming the view vector as (0, 0, 1), this function allows users to
4728 * specify half-angle vector directly as input arguments. It is useful to do detailed control for orientation of highlights.
4730 * \note This function does not load any hardware registers. To load a light object into a hardware light, use GX_LoadLightObj()
4731 * or GX_LoadLightObjIdx().<br><br>
4733 * \note Other notes are similar to those described in GX_InitSpecularDir().
4735 * \param[in] lit_obj ptr to a light object
4736 * \param[in] nx X coordinate of the light normal
4737 * \param[in] ny Y coordinate of the light normal
4738 * \param[in] nz Z coordinate of the light normal
4739 * \param[in] hx X coordinate of half-angle
4740 * \param[in] hy Y coordinate of half-angle
4741 * \param[in] hz Z coordinate of half-angle
4743 * \return none
4745 void GX_InitSpecularDirHA(GXLightObj *lit_obj,f32 nx,f32 ny,f32 nz,f32 hx,f32 hy,f32 hz);
4748 * \fn void GX_InitSpecularDir(GXLightObj *lit_obj,f32 nx,f32 ny,f32 nz)
4749 * \brief Sets the direction of a specular light in the light object.
4751 * \details This direction is used when the light object is used only as specular light. The coordinate space of the light normal
4752 * should be consistent with a vertex normal transformed by a normal matrix; i.e., it should be transformed to view space.
4754 * \note This function should be used if and only if the light object is used as specular light. One specifies a specular light in
4755 * GX_SetChanCtrl() by setting the \ref attenfunc to <tt>GX_AF_SPEC</tt>. Furthermore, one must not use GX_InitLightDir() or
4756 * GX_InitLightPos() to set up a light object which will be used as a specular light since these functions will destroy the information
4757 * set by GX_InitSpecularDir(). In contrast to diffuse lights (including spotlights) that are considered local lights, a specular light
4758 * is a parallel light (i.e. the specular light is infinitely far away such that all the rays of the light are parallel), and thus one
4759 * can only specify directional information.
4761 * \note This function does not load any hardware registers. To load a light object into a hardware light, use GX_LoadLightObj()
4762 * or GX_LoadLightObjIdx().
4764 * \param[in] lit_obj ptr to a light object
4765 * \param[in] nx X coordinate of the light normal
4766 * \param[in] ny Y coordinate of the light normal
4767 * \param[in] nz Z coordinate of the light normal
4769 * \return none
4771 void GX_InitSpecularDir(GXLightObj *lit_obj,f32 nx,f32 ny,f32 nz);
4774 * \fn void GX_InitLightSpot(GXLightObj *lit_obj,f32 cut_off,u8 spotfn)
4775 * \brief Sets coefficients for angular (spotlight) attenuation in light object.
4777 * \details This function uses two easy-to-control parameters instead of \a a0, \a a1, and \a a2 on GX_InitLightAttn().
4779 * \details The parameter \a cut_off specifies cutoff angle of the spotlight by degree. The spotlight works while the angle between the ray for a vertex and
4780 * the light direction given by GX_InitLightDir() is smaller than this cutoff angle. The value for \a cut_off should be within 0 < \a cut_off <= 90.0, otherwise
4781 * given light object doesn't become a spotlight.
4783 * The parameter \a spotfn defines type of the illumination distribution within cutoff angle. The value <tt>GX_SP_OFF</tt> turns spotlight feature off even if
4784 * color channel setting is using <tt>GX_AF_SPOT</tt> (see GX_SetChanCtrl()).
4786 * \note This function can generate only some kind of simple spotlights. If you want more flexible control, it is better to use GX_InitLightAttn() and calculate
4787 * appropriate coefficients.<br><br>
4789 * \note This function sets parameters only for angular attenuation. Parameters for distance attenuation should be set by using GX_InitLightDistAttn() or
4790 * GX_InitLightAttnK().<br><br>
4792 * \note This function does not load any hardware registers directly. To load a light object into a hardware light, use GX_LoadLightObj() or GX_LoadLightObjIdx().
4794 * \param[in] lit_obj ptr to a light object
4795 * \param[in] cut_off cutoff angle of the spotlight, in degrees
4796 * \param[in] spotfn \ref spotfn to use for this light
4798 * \return none
4800 void GX_InitLightSpot(GXLightObj *lit_obj,f32 cut_off,u8 spotfn);
4802 u32 GX_ReadClksPerVtx();
4803 u32 GX_GetOverflowCount();
4804 u32 GX_ResetOverflowCount();
4807 * \fn lwp_t GX_GetCurrentGXThread()
4808 * \brief Returns the current GX thread.
4810 * \details The current GX thread should be the thread that is currently responsible for generating graphics data. By default,
4811 * the GX thread is the thread that invoked GX_Init(); however, it may be changed by calling GX_SetCurrentGXThread().
4813 * \note When graphics data is being generated in immediate mode (that is, the CPU FIFO = GP FIFO, and the GP is actively consuming
4814 * data), the high watermark may be triggered. When this happens, the high watermark interrupt handler will suspend the GX thread, thus
4815 * preventing any further graphics data from being generated. The low watermark interrupt handler will resume the thread.
4817 * \return the current GX thread
4819 lwp_t GX_GetCurrentGXThread();
4822 * \fn lwp_t GX_SetCurrentGXThread()
4823 * \brief Sets the current GX thread to the calling thread.
4825 * \details The new thread should be the thread that will be responsible for generating graphics data. By default, the GX thread is
4826 * the thread that invoked GX_Init(); however, it may be changed by calling this function.
4828 * \note It is a programming error to change GX thread while the current GX thread is suspended by a high water mark interrupt. This
4829 * indicates that you have two threads about to generate GX data.<br><br>
4831 * \note When graphics data is being generated in immediate mode (that is, the CPU FIFO = GP FIFO, and the GP is actively consuming
4832 * data), the high watermark may be triggered. When this happens, the high watermark interrupt handler will suspend the GX thread, thus
4833 * preventing any further graphics data from being generated. The low watermark interrupt handler will resume the thread.
4835 * \return the previous GX thread ID
4837 lwp_t GX_SetCurrentGXThread();
4840 * \fn void GX_RestoreWriteGatherPipe()
4841 * \brief Restores the write-gather pipe.
4843 * \details The CPU fifo that was attached at the time GX_RedirectWriteGatherPipe() was called will be re-attached. If there is data pending
4844 * in the write gather pipe (e.g. if the amount of data written was not a multiple of 32 bytes), the data will be padded with zeroes and
4845 * flushed out.
4847 * \warning This function must be called between successive calls to GX_RedirectWriteGatherPipe().
4849 * \return none
4851 void GX_RestoreWriteGatherPipe();
4854 * \fn void GX_SetGPMetric(u32 perf0,u32 perf1)
4855 * \brief Sets two performance metrics to measure in the GP.
4857 * \details perf0 and perf1 are set to measure. The initial metrics measured are <tt>GX_PERF0_NONE</tt> and <tt>GX_PERF1_NONE</tt>, which return counts of zero
4858 * for the first call to GX_ReadGPMetric().
4860 * Each performance counter has a unique set of events or ratios that it can count. In some cases the same metric can be counted using both
4861 * counters, for example <tt>GX_PERF0_VERTICES</tt> and <tt>GX_PERF1_VERTICES</tt>. Ratios (the metric name ends in <tt>_RATIO</tt>) are multiplied by
4862 * 1000 (1000 = all misses/clips, etc., 0 = no misses/clips, etc.).
4864 * \note GX_ReadGPMetric() and GX_ClearGPMetric() can be used in the callback associated with the draw sync interrupt (see GX_SetDrawSyncCallback()).
4865 * This function should not be used in the draw sync callback because it will insert tokens in the GP command stream at random times.
4867 * \warning This function reads results from CPU-accessible registers in the GP, therefore, this command <i>must not</i> be used in a display list. In
4868 * addition, the performance counters in some cases are triggered by sending tokens through the Graphics FIFO to the GP. This implies that
4869 * the function should only be used in immediate mode (when the Graphics FIFO is connected to the CPU and the GP at the same time). It may
4870 * also be necessary to send a draw sync token using GX_SetDrawSync() or call GX_SetDrawDone() after GX_ReadGPMetric() to ensure that the
4871 * state has actually been processed by the GP.
4873 * \param[in] perf0 \ref perf0metrics to measure
4874 * \param[in] perf1 \ref perf1metrics to measure
4876 * \returns none
4878 void GX_SetGPMetric(u32 perf0,u32 perf1);
4881 * \fn void GX_ClearGPMetric()
4882 * \brief Clears the two virtual GP performance counters to zero.
4884 * \note The counter's function is set using GX_SetGPMetric(); the counter's value is read using GX_ReadGPMetric(). Consult these for more details.
4886 * \warning This function resets CPU accessible counters, so it should <b>not</b> be used in a display list.
4888 * \return none
4890 void GX_ClearGPMetric();
4893 * \fn void GX_InitXfRasMetric()
4894 * \brief Initialize the transformation unit (XF) rasterizer unit (RAS) to take performance measurements.
4896 * \warning This function should be avoided; use the GP performance metric functions instead.
4898 * \return none
4900 void GX_InitXfRasMetric();
4903 * \fn void GX_ReadXfRasMetric(u32 *xfwaitin,u32 *xfwaitout,u32 *rasbusy,u32 *clks)
4904 * \brief Read performance metric values from the XF and RAS units.
4906 * \warning This function should be avoided; use the GP performance metric functions instead.<br><br>
4908 * \warning The parameters for this function are a best guess based on names and existing code.
4910 * \param[out] xfwaitin Number of clocks the XF has waited for data to arrive?
4911 * \param[out] xfwaitout Number of clocks the XF has waited to push finished data down?
4912 * \param[out] rasbusy Number of clocks the RAS has spent being busy?
4913 * \param[out] clks Clocks that have passed since last count reset?
4915 * \return none
4917 void GX_ReadXfRasMetric(u32 *xfwaitin,u32 *xfwaitout,u32 *rasbusy,u32 *clks);
4920 * \fn void GX_ClearVCacheMetric()
4921 * \brief Clears the Vertex Cache performance counter.
4923 * \details This function clears the performance counter by sending a special clear token via the Graphics FIFO.
4925 * \note To set the metric for the counter, call GX_SetVCacheMetric(); to read the counter value, call GX_ReadVCacheMetric().
4927 * \return none
4929 void GX_ClearVCacheMetric();
4932 * \fn void GX_ReadVCacheMetric(u32 *check,u32 *miss,u32 *stall)
4933 * \brief Returns Vertex Cache performance counters.
4935 * \details Each call to this function resets the counter to zero. GX_SetVCacheMetric() sets the metric to be measured by
4936 * the Vertex Cache performance counter.
4938 * \warning This function reads CPU-accessible registers in the GP and so should not be called in a display list.
4940 * \param[out] check total number of accesses to the vertex cache
4941 * \param[out] miss total number of cache misses to the vertex cache
4942 * \param[out] stall number of GP clocks that the vertex cache was stalled
4944 * \return none
4946 void GX_ReadVCacheMetric(u32 *check,u32 *miss,u32 *stall);
4949 * \fn void GX_SetVCacheMetric(u32 attr)
4950 * \brief Sets the metric the Vertex Cache performance counter will measure.
4952 * \details It is possible to monitor a particular attribute or all attributes using \a attr.
4954 * \note To clear the counter, call GX_ClearVCacheMetric(); to read the counter value, call GX_ReadVCacheMetric().
4956 * \param[in] attr \ref vcachemetrics to measure
4958 * \return none
4960 void GX_SetVCacheMetric(u32 attr);
4963 * \fn void GX_GetGPStatus(u8 *overhi,u8 *underlow,u8 *readIdle,u8 *cmdIdle,u8 *brkpt)
4964 * \brief Reads the current status of the GP.
4966 * \details \a overhi and \a underlow will indicate whether or not the watermarks have been reached. If the CPU and GP FIFOs
4967 * are the same, then \a overhi will indicate whether or not the current GX thread is suspended. The value of \a brkpt can be
4968 * used to determine if a breakpoint is in progress (i.e. GP reads are suspended; they are resumed by a call to
4969 * GX_DisableBreakPt()). A callback can also be used to notify your application that the break point has been reached. (see
4970 * GX_SetBreakPtCallback())
4972 * \param[out] overhi <tt>GX_TRUE</tt> if high watermark has been passed
4973 * \param[out] underlow <tt>GX_TRUE</tt> if low watermark has been passed
4974 * \param[out] readIdle <tt>GX_TRUE</tt> if the GP read unit is idle
4975 * \param[out] cmdIdle <tt>GX_TRUE</tt> if all commands have been flushed to XF
4976 * \param[out] brkpt <tt>GX_TRUE</tt> if FIFO has reached a breakpoint and GP reads have been stopped
4978 * \return none
4980 void GX_GetGPStatus(u8 *overhi,u8 *underlow,u8 *readIdle,u8 *cmdIdle,u8 *brkpt);
4983 * \fn void GX_ReadGPMetric(u32 *cnt0,u32 *cnt1)
4984 * \brief Returns the count of the previously set performance metrics.
4986 * \note The performance metrics can be set using GX_SetGPMetric(); the counters can be cleared using GX_ClearGPMetric().<br><br>
4988 * \note GX_ReadGPMetric() and GX_ClearGPMetric() can be used in the callback associated with the draw sync interrupt (see GX_SetDrawSyncCallback()).
4989 * The function GX_SetGPMetric() should <b>not</b> be used in the draw sync callback because it will insert tokens in the GP command stream at random times.<br><br>
4991 * \warning This function reads results from CPU-accessible registers in the GP, therefore, this command <i>must not</i> be used in a display list. It
4992 * may also be necessary to send a draw sync token using GX_SetDrawSync() or GX_SetDrawDone() before GX_ReadGPMetric() is called to ensure that the
4993 * state has actually been processed by the GP.
4995 * \param[out] cnt0 current value of GP counter 0
4996 * \param[out] cnt1 current value of GP counter 1
4998 * \return none
5000 void GX_ReadGPMetric(u32 *cnt0,u32 *cnt1);
5003 * \fn void GX_ReadBoundingBox(u16 *top,u16 *bottom,u16 *left,u16 *right)
5004 * \brief Returns the bounding box of pixel coordinates that are drawn in the Embedded Framebuffer (EFB).
5006 * \details This function reads the bounding box values. GX_ClearBoundingBox() can be used reset the values of the bounding box.
5008 * \note Since the hardware can only test the bounding box in quads (2x2 pixel blocks), the result of this function may contain error
5009 * of plus or minus 1 pixel. Also because of this, <b>left</b> and <b>top</b> are always even-numbered and <b>right</b> and <b>bottom</b>
5010 * are always odd-numbered.
5012 * \param[out] top uppermost line in the bounding box
5013 * \param[out] bottom lowest line in the bounding box
5014 * \param[out] left leftmost pixel in the bounding box
5015 * \param[out] right rightmost pixel in the bounding box
5017 * \return none
5019 void GX_ReadBoundingBox(u16 *top,u16 *bottom,u16 *left,u16 *right);
5022 * \fn volatile void* GX_RedirectWriteGatherPipe(void *ptr)
5023 * \brief Temporarily points the CPU's write-gather pipe at a new location.
5025 * \details After calling this function, subsequent writes to the address returned by this function (or the WGPipe union)
5026 * will be gathered and sent to a destination buffer. The write pointer is automatically incremented by the GP. The write
5027 * gather pipe can be restored by calling GX_RestoreWriteGatherPipe(). This function cannot be called between a
5028 * GX_Begin()/GX_End() pair.
5030 * \note The destination buffer, referred to by \a ptr, must be 32 byte aligned. The amount of data written should
5031 * also be 32-byte aligned. If it is not, zeroes will be added to pad the destination buffer to 32 bytes. No part of the
5032 * destination buffer should be modified inside the CPU caches - this may introduce cache incoherency problems.<br><br>
5034 * \note The write gather pipe is one of the fastest ways to move data out of the CPU (the other being the locked cache DMA).
5035 * In general, you are compute-bound when sending data from the CPU.<br><br>
5037 * \note This function is cheaper than trying to create a fake CPU fifo around a destination buffer, which requires calls to
5038 * GX_SetCPUFifo(), GX_InitFifoBase(), etc. This function performs very light weight state saves by assuming that the CPU and
5039 * GP FIFOs never change.
5041 * \warning <b>No GX commands can be called until the write gather pipe is restored. You MUST call
5042 * GX_RestoreWriteGatherPipe() before calling this function again, or else the final call to restore the pipe will fail.</b>
5044 * \param[in] ptr to destination buffer, 32-byte aligned
5046 * \return real address of the write-gather "port". All writes to this address will be gathered by the CPU write gather pipe.
5047 * You may also use the WGPipe union. If you do not use the WGPipe union, ensure that your local variable is volatile.
5049 volatile void* GX_RedirectWriteGatherPipe(void *ptr);
5052 * \def GX_InitLightPosv(lo,vec)
5053 * \brief Sets the position of the light in the light object using a vector structure.
5055 * \note The GameCube graphics hardware supports local diffuse lights. The position of the light should be in the same space as a
5056 * transformed vertex position (i.e. view space).<br><br>
5058 * \note The memory for the light object must be allocated by the application; this function does not load any hardware registers directly. To
5059 * load a light object into a hardware light, use GX_LoadLightObj() or GX_LoadLightObjIdx().
5061 * \param[in] lo ptr to the light object
5062 * \param[in] vec struct or array of three values for the position
5064 * \return none
5066 #define GX_InitLightPosv(lo,vec) \
5067 (GX_InitLightPos((lo), *(f32*)(vec), *((f32*)(vec)+1), *((f32*)(vec)+2)))
5070 * \def GX_InitLightDirv(lo,vec)
5071 * \brief Sets the direction of a light in the light object using a vector structure.
5073 * \details This direction is used when the light object is used as a spotlight or a specular light, see the \a attn_fn parameter of
5074 * GX_SetChanCtrl().
5076 * \note The memory for the light object must be allocated by the application; this function does not load any hardware registers. To load a
5077 * light object into a hardware light, use GX_LoadLightObj() or GX_LoadLightObjIdx().<br><br>
5079 * \note The coordinate space of the light normal should be consistent with a vertex normal transformed by a normal matrix; i.e., it should be
5080 * transformed to view space.<br><br>
5082 * \note This function does not set the direction of parallel lights.
5084 * \param[in] lo ptr to the light object
5085 * \param[in] vec struct or array of three values for the direction
5087 * \return none
5089 #define GX_InitLightDirv(lo,vec) \
5090 (GX_InitLightDir((lo), *(f32*)(vec), *((f32*)(vec)+1), *((f32*)(vec)+2)))
5093 * \def GX_InitSpecularDirv(lo,vec)
5094 * \brief Sets the direction of a specular light in the light object using a vector.
5096 * \details This direction is used when the light object is used only as specular light.
5098 * \note The memory for the light object must be allocated by the application; this function does not load any hardware registers. To load a
5099 * light object into a hardware light, use GX_LoadLightObj() or GX_LoadLightObjIdx().<br><br>
5101 * \note The coordinate space of the light normal should be consistent with a vertex normal transformed by a normal matrix; i.e., it should
5102 * be transformed to view space.
5104 * \warning This function should be used if and only if the light object is used as specular light. One specifies a specular light in
5105 * GX_SetChanCtrl() by setting \a attn_fn to <tt>GX_AF_SPEC</tt>. Furthermore, one must not use GX_InitLightDir() or GX_InitLightPos() to
5106 * set up a light object which will be used as a specular light since these functions will destroy the information set by GX_InitSpecularDir().
5107 * In contrast to diffuse lights (including spotlights) that are considered <i>local</i> lights, a specular light is a <i>parallel</i> light (i.e. the
5108 * specular light is infinitely far away such that all the rays of the light are parallel), and thus one can only specify directional
5109 * information.
5111 * \param[in] lo ptr to the light object
5112 * \param[in] vec struct or array of three values for the direction
5114 * \return none
5116 #define GX_InitSpecularDirv(lo,vec) \
5117 (GX_InitSpecularDir((lo), *(f32*)(vec), *((f32*)(vec)+1), *((f32*)(vec)+2)))
5120 * \def GX_InitSpecularDirHAv(lo,vec0,vec1)
5121 * \brief Sets the direction and half-angle vector of a specular light in the light object using a vector.
5123 * \details These vectors are used when the light object is used only as specular light.
5125 * \note The memory for the light object must be allocated by the application; this function does not load any hardware registers. To load a
5126 * light object into a hardware light, use GX_LoadLightObj() or GX_LoadLightObjIdx().<br><br>
5128 * \note In contrast to GX_InitSpecularDirv(), which caclulates half-angle vector automatically by assuming the view vector as (0,0,1), this
5129 * function allows users to specify half-angle vector directly as input arguments. It is useful to do detailed control for orientation of
5130 * highlights.<br><br>
5132 * \note Other notes are similar to that described in GX_InitSpecularDirv().
5134 * \param[in] lo ptr to the light object
5135 * \param[in] vec0 struct or array of three values for the direction
5136 * \param[in] vec1 struct or array of three values for the half-angle
5138 * \return none
5140 #define GX_InitSpecularDirHAv(lo,vec0,vec1) \
5141 (GX_InitSpecularDirHA((lo), \
5142 *(f32*)(vec0), *((f32*)(vec0)+1), *((f32*)(vec0)+2), \
5143 *(f32*)(vec1), *((f32*)(vec1)+1), *((f32*)(vec1)+2)))
5146 * \def GX_InitLightShininess(lobj, shininess)
5147 * \brief Sets \a shininess of a per-vertex specular light.
5149 * \details In reality, shininess is a property of the <i>material</i> being lit, not the light. However, in the Graphics Processor, the specular
5150 * calculation is implemented by reusing the diffuse angle/distance attenuation function, so shininess is determined by the light attenuation
5151 * parameters (see GX_InitLightAttn()). Note that the equation is attempting to approximate the function (N*H)^shininess. Since the attenuation
5152 * equation is only a ratio of quadratics, a true exponential function is not possible. To enable the specular calculation, you must set the
5153 * attenuation parameter of the lighting channel to <tt>GX_AF_SPEC</tt> using GX_SetChanCtrl().
5155 * \param[in] lobj ptr to the light object
5156 * \param[in] shininess shininess parameter
5158 * \return none
5160 #define GX_InitLightShininess(lobj, shininess) \
5161 (GX_InitLightAttn(lobj, 0.0F, 0.0F, 1.0F, \
5162 (shininess)/2.0F, 0.0F, \
5163 1.0F-(shininess)/2.0F ))
5165 #ifdef __cplusplus
5167 #endif /* __cplusplus */
5169 #endif