12 #include "gx_struct.h"
19 #define GX_CLIP_DISABLE 1
20 #define GX_CLIP_ENABLE 0
22 #define GX_FIFO_MINSIZE (64*1024)
23 #define GX_FIFO_HIWATERMARK (16*1024)
24 #define GX_FIFO_OBJSIZE 128
26 #define GX_PERSPECTIVE 0
27 #define GX_ORTHOGRAPHIC 1
30 #define GX_MT_XF_FLUSH 1
31 #define GX_MT_DL_SAVE_CTX 2
33 #define GX_XF_FLUSH_NONE 0
34 #define GX_XF_FLUSH_SAFE 1
43 #define GX_COLORZERO 6
46 #define GX_COLORNULL 0xff
52 /*! \addtogroup vtxfmt Vertex format index
63 #define GX_MAXVTXFMT 8
68 /*! \addtogroup vtxattrin Vertex data input type
71 #define GX_NONE 0 /*!< Input data is not used */
72 #define GX_DIRECT 1 /*!< Input data is set direct */
73 #define GX_INDEX8 2 /*!< Input data is set by a 8bit index */
74 #define GX_INDEX16 3 /*!< Input data is set by a 16bit index */
104 #define GX_VA_PTNMTXIDX 0
105 #define GX_VA_TEX0MTXIDX 1
106 #define GX_VA_TEX1MTXIDX 2
107 #define GX_VA_TEX2MTXIDX 3
108 #define GX_VA_TEX3MTXIDX 4
109 #define GX_VA_TEX4MTXIDX 5
110 #define GX_VA_TEX5MTXIDX 6
111 #define GX_VA_TEX6MTXIDX 7
112 #define GX_VA_TEX7MTXIDX 8
115 #define GX_VA_CLR0 11
116 #define GX_VA_CLR1 12
117 #define GX_VA_TEX0 13
118 #define GX_VA_TEX1 14
119 #define GX_VA_TEX2 15
120 #define GX_VA_TEX3 16
121 #define GX_VA_TEX4 17
122 #define GX_VA_TEX5 18
123 #define GX_VA_TEX6 19
124 #define GX_VA_TEX7 20
125 #define GX_POSMTXARRAY 21
126 #define GX_NRMMTXARRAY 22
127 #define GX_TEXMTXARRAY 23
128 #define GX_LITMTXARRAY 24
130 #define GX_VA_MAXATTR 26
131 #define GX_VA_NULL 0xff
133 #define GX_POINTS 0xB8
134 #define GX_LINES 0xA8
135 #define GX_LINESTRIP 0xB0
136 #define GX_TRIANGLES 0x90
137 #define GX_TRIANGLESTRIP 0x98
138 #define GX_TRIANGLEFAN 0xA0
139 #define GX_QUADS 0x80
144 #define GX_LIGHT0 0x001
145 #define GX_LIGHT1 0x002
146 #define GX_LIGHT2 0x004
147 #define GX_LIGHT3 0x008
148 #define GX_LIGHT4 0x010
149 #define GX_LIGHT5 0x020
150 #define GX_LIGHT6 0x040
151 #define GX_LIGHT7 0x080
152 #define GX_MAXLIGHT 0x100
153 #define GX_LIGHTNULL 0x000
156 #define GX_DF_SIGNED 1
157 #define GX_DF_CLAMP 2
163 /* pos,nrm,tex,dtt matrix */
174 #define GX_TEXMTX0 30
175 #define GX_TEXMTX1 33
176 #define GX_TEXMTX2 36
177 #define GX_TEXMTX3 39
178 #define GX_TEXMTX4 42
179 #define GX_TEXMTX5 45
180 #define GX_TEXMTX6 48
181 #define GX_TEXMTX7 51
182 #define GX_TEXMTX8 54
183 #define GX_TEXMTX9 57
184 #define GX_IDENTITY 60
185 #define GX_DTTMTX0 64
186 #define GX_DTTMTX1 67
187 #define GX_DTTMTX2 70
188 #define GX_DTTMTX3 73
189 #define GX_DTTMTX4 76
190 #define GX_DTTMTX5 79
191 #define GX_DTTMTX6 82
192 #define GX_DTTMTX7 85
193 #define GX_DTTMTX8 88
194 #define GX_DTTMTX9 91
195 #define GX_DTTMTX10 94
196 #define GX_DTTMTX11 97
197 #define GX_DTTMTX12 100
198 #define GX_DTTMTX13 103
199 #define GX_DTTMTX14 106
200 #define GX_DTTMTX15 109
201 #define GX_DTTMTX16 112
202 #define GX_DTTMTX17 115
203 #define GX_DTTMTX18 118
204 #define GX_DTTMTX19 121
205 #define GX_DTTIDENTITY 125
208 used by: XF: 0x1040,0x1050
211 #define GX_TEXCOORD0 0x0
212 #define GX_TEXCOORD1 0x1
213 #define GX_TEXCOORD2 0x2
214 #define GX_TEXCOORD3 0x3
215 #define GX_TEXCOORD4 0x4
216 #define GX_TEXCOORD5 0x5
217 #define GX_TEXCOORD6 0x6
218 #define GX_TEXCOORD7 0x7
219 #define GX_MAXCOORD 0x8
220 #define GX_TEXCOORDNULL 0xff
223 #define _GX_TF_ZTF 0x10
224 #define _GX_TF_CTF 0x20
226 /*! \addtogroup texfmt Texture format
232 #define GX_TF_IA4 0x2
233 #define GX_TF_IA8 0x3
234 #define GX_TF_RGB565 0x4
235 #define GX_TF_RGB5A3 0x5
236 #define GX_TF_RGBA8 0x6
237 #define GX_TF_CI4 0x8
238 #define GX_TF_CI8 0x9
239 #define GX_TF_CI14 0xa
240 #define GX_TF_CMPR 0xE
242 #define GX_TL_IA8 0x00
243 #define GX_TL_RGB565 0x01
244 #define GX_TL_RGB5A3 0x02
246 #define GX_CTF_R4 (0x0|_GX_TF_CTF)
247 #define GX_CTF_RA4 (0x2|_GX_TF_CTF)
248 #define GX_CTF_RA8 (0x3|_GX_TF_CTF)
249 #define GX_CTF_YUVA8 (0x6|_GX_TF_CTF)
250 #define GX_CTF_A8 (0x7|_GX_TF_CTF)
251 #define GX_CTF_R8 (0x8|_GX_TF_CTF)
252 #define GX_CTF_G8 (0x9|_GX_TF_CTF)
253 #define GX_CTF_B8 (0xA|_GX_TF_CTF)
254 #define GX_CTF_RG8 (0xB|_GX_TF_CTF)
255 #define GX_CTF_GB8 (0xC|_GX_TF_CTF)
257 /*! \addtogroup ztexfmt Z Texture format
261 #define GX_TF_Z8 (0x1|_GX_TF_ZTF)
262 #define GX_TF_Z16 (0x3|_GX_TF_ZTF)
263 #define GX_TF_Z24X8 (0x6|_GX_TF_ZTF)
269 #define GX_CTF_Z4 (0x0|_GX_TF_ZTF|_GX_TF_CTF)
270 #define GX_CTF_Z8M (0x9|_GX_TF_ZTF|_GX_TF_CTF)
271 #define GX_CTF_Z8L (0xA|_GX_TF_ZTF|_GX_TF_CTF)
272 #define GX_CTF_Z16L (0xC|_GX_TF_ZTF|_GX_TF_CTF)
274 #define GX_TF_A8 GX_CTF_A8
277 #define GX_TLUT_16 1 // number of 16 entry blocks.
280 #define GX_TLUT_128 8
281 #define GX_TLUT_256 16
282 #define GX_TLUT_512 32
283 #define GX_TLUT_1K 64
284 #define GX_TLUT_2K 128
285 #define GX_TLUT_4K 256
286 #define GX_TLUT_8K 512
287 #define GX_TLUT_16K 1024
289 /*! \addtogroup ztexop Z Texture operator
293 #define GX_ZT_DISABLE 0
295 #define GX_ZT_REPLACE 2
296 #define GX_MAX_ZTEXOP 3
302 #define GX_TG_MTX3x4 0
303 #define GX_TG_MTX2x4 1
304 #define GX_TG_BUMP0 2
305 #define GX_TG_BUMP1 3
306 #define GX_TG_BUMP2 4
307 #define GX_TG_BUMP3 5
308 #define GX_TG_BUMP4 6
309 #define GX_TG_BUMP5 7
310 #define GX_TG_BUMP6 8
311 #define GX_TG_BUMP7 9
312 #define GX_TG_SRTG 10
317 #define GX_TG_BINRM 2
318 #define GX_TG_TANGENT 3
325 #define GX_TG_TEX6 10
326 #define GX_TG_TEX7 11
327 #define GX_TG_TEXCOORD0 12
328 #define GX_TG_TEXCOORD1 13
329 #define GX_TG_TEXCOORD2 14
330 #define GX_TG_TEXCOORD3 15
331 #define GX_TG_TEXCOORD4 16
332 #define GX_TG_TEXCOORD5 17
333 #define GX_TG_TEXCOORD6 18
334 #define GX_TG_COLOR0 19
335 #define GX_TG_COLOR1 20
351 #define GX_MAXTEXWRAPMODE 3
355 #define GX_BM_BLEND 1
356 #define GX_BM_LOGIC 2
357 #define GX_BM_SUBSTRACT 3
358 #define GX_MAX_BLENDMODE 4
363 #define GX_BL_SRCCLR 2
364 #define GX_BL_INVSRCCLR 3
365 #define GX_BL_SRCALPHA 4
366 #define GX_BL_INVSRCALPHA 5
367 #define GX_BL_DSTALPHA 6
368 #define GX_BL_INVDSTALPHA 7
369 #define GX_BL_DSTCLR GX_BL_SRCCLR
370 #define GX_BL_INVDSTCLR GX_BL_INVSRCCLR
373 #define GX_LO_CLEAR 0
375 #define GX_LO_REVAND 2
377 #define GX_LO_INVAND 4
382 #define GX_LO_EQUIV 9
384 #define GX_LO_REVOR 11
385 #define GX_LO_INVCOPY 12
386 #define GX_LO_INVOR 13
387 #define GX_LO_NAND 14
392 #define GX_TO_SIXTEENTH 1
393 #define GX_TO_EIGHTH 2
394 #define GX_TO_FOURTH 3
397 #define GX_MAX_TEXOFFSET 6
399 /*! \addtogroup tevdefmode TEV combiner operation
400 * Color/Alpha combiner modes for GX_SetTevOp().
405 #define GX_MODULATE 0
414 /*! \addtogroup tevcolorarg TEV color combiner input
418 #define GX_CC_CPREV 0 /*!< Use the color value from previous TEV stage */
419 #define GX_CC_APREV 1 /*!< Use the alpha value from previous TEV stage */
420 #define GX_CC_C0 2 /*!< Use the color value from the color/output register 0 */
421 #define GX_CC_A0 3 /*!< Use the alpha value from the color/output register 0 */
422 #define GX_CC_C1 4 /*!< Use the color value from the color/output register 1 */
423 #define GX_CC_A1 5 /*!< Use the alpha value from the color/output register 1 */
424 #define GX_CC_C2 6 /*!< Use the color value from the color/output register 2 */
425 #define GX_CC_A2 7 /*!< Use the alpha value from the color/output register 2 */
426 #define GX_CC_TEXC 8 /*!< Use the color value from texture */
427 #define GX_CC_TEXA 9 /*!< Use the alpha value from texture */
428 #define GX_CC_RASC 10 /*!< Use the color value from rasterizer */
429 #define GX_CC_RASA 11 /*!< Use the alpha value from rasterizer */
431 #define GX_CC_HALF 13
432 #define GX_CC_KONST 14
433 #define GX_CC_ZERO 15 /*!< Use to pass zero value */
438 /*! \addtogroup tevalphaarg TEV alpha combiner input
442 #define GX_CA_APREV 0 /*!< Use the alpha value from previous TEV stage */
443 #define GX_CA_A0 1 /*!< Use the alpha value from the color/output register 0 */
444 #define GX_CA_A1 2 /*!< Use the alpha value from the color/output register 1 */
445 #define GX_CA_A2 3 /*!< Use the alpha value from the color/output register 2 */
446 #define GX_CA_TEXA 4 /*!< Use the alpha value from texture */
447 #define GX_CA_RASA 5 /*!< Use the alpha value from rasterizer */
448 #define GX_CA_KONST 6
449 #define GX_CA_ZERO 7 /*!< Use to pass zero value */
454 /*! \addtogroup tevstage TEV stage
458 #define GX_TEVSTAGE0 0
459 #define GX_TEVSTAGE1 1
460 #define GX_TEVSTAGE2 2
461 #define GX_TEVSTAGE3 3
462 #define GX_TEVSTAGE4 4
463 #define GX_TEVSTAGE5 5
464 #define GX_TEVSTAGE6 6
465 #define GX_TEVSTAGE7 7
466 #define GX_TEVSTAGE8 8
467 #define GX_TEVSTAGE9 9
468 #define GX_TEVSTAGE10 10
469 #define GX_TEVSTAGE11 11
470 #define GX_TEVSTAGE12 12
471 #define GX_TEVSTAGE13 13
472 #define GX_TEVSTAGE14 14
473 #define GX_TEVSTAGE15 15
474 #define GX_MAX_TEVSTAGE 16
479 /*! \addtogroup tevop TEV combiner operator
485 #define GX_TEV_COMP_R8_GT 8
486 #define GX_TEV_COMP_R8_EQ 9
487 #define GX_TEV_COMP_GR16_GT 10
488 #define GX_TEV_COMP_GR16_EQ 11
489 #define GX_TEV_COMP_BGR24_GT 12
490 #define GX_TEV_COMP_BGR24_EQ 13
491 #define GX_TEV_COMP_RGB8_GT 14
492 #define GX_TEV_COMP_RGB8_EQ 15
493 #define GX_TEV_COMP_A8_GT GX_TEV_COMP_RGB8_GT // for alpha channel
494 #define GX_TEV_COMP_A8_EQ GX_TEV_COMP_RGB8_EQ // for alpha channel
499 /*! \addtogroup tevbias TEV bias value
504 #define GX_TB_ADDHALF 1
505 #define GX_TB_SUBHALF 2
506 #define GX_MAX_TEVBIAS 3
511 /*! \addtogroup tevbias TEV clamp mode value
515 #define GX_TC_LINEAR 0
519 #define GX_MAX_TEVCLAMPMODE 4
524 /*! \addtogroup tevscale TEV scale value
528 #define GX_CS_SCALE_1 0
529 #define GX_CS_SCALE_2 1
530 #define GX_CS_SCALE_4 2
531 #define GX_CS_DIVIDE_2 3
532 #define GX_MAX_TEVSCALE 4
537 /*! \addtogroup tevcoloutreg TEV color/output register
545 #define GX_MAX_TEVREG 4
551 #define GX_CULL_NONE 0
552 #define GX_CULL_FRONT 1
553 #define GX_CULL_BACK 2
554 #define GX_CULL_ALL 3
565 #define GX_MAX_TEXMAP 8
566 #define GX_TEXMAP_NULL 0xff
567 #define GX_TEXMAP_DISABLE 0x100
573 #define GX_AOP_XNOR 3
574 #define GX_MAX_ALPHAOP 4
576 /* tev const color reg id */
581 #define GX_KCOLOR_MAX 4
583 /* tev const color sel */
584 #define GX_TEV_KCSEL_1 0x00
585 #define GX_TEV_KCSEL_7_8 0x01
586 #define GX_TEV_KCSEL_3_4 0x02
587 #define GX_TEV_KCSEL_5_8 0x03
588 #define GX_TEV_KCSEL_1_2 0x04
589 #define GX_TEV_KCSEL_3_8 0x05
590 #define GX_TEV_KCSEL_1_4 0x06
591 #define GX_TEV_KCSEL_1_8 0x07
592 #define GX_TEV_KCSEL_K0 0x0C
593 #define GX_TEV_KCSEL_K1 0x0D
594 #define GX_TEV_KCSEL_K2 0x0E
595 #define GX_TEV_KCSEL_K3 0x0F
596 #define GX_TEV_KCSEL_K0_R 0x10
597 #define GX_TEV_KCSEL_K1_R 0x11
598 #define GX_TEV_KCSEL_K2_R 0x12
599 #define GX_TEV_KCSEL_K3_R 0x13
600 #define GX_TEV_KCSEL_K0_G 0x14
601 #define GX_TEV_KCSEL_K1_G 0x15
602 #define GX_TEV_KCSEL_K2_G 0x16
603 #define GX_TEV_KCSEL_K3_G 0x17
604 #define GX_TEV_KCSEL_K0_B 0x18
605 #define GX_TEV_KCSEL_K1_B 0x19
606 #define GX_TEV_KCSEL_K2_B 0x1A
607 #define GX_TEV_KCSEL_K3_B 0x1B
608 #define GX_TEV_KCSEL_K0_A 0x1C
609 #define GX_TEV_KCSEL_K1_A 0x1D
610 #define GX_TEV_KCSEL_K2_A 0x1E
611 #define GX_TEV_KCSEL_K3_A 0x1F
613 /* tev const alpha sel */
614 #define GX_TEV_KASEL_1 0x00
615 #define GX_TEV_KASEL_7_8 0x01
616 #define GX_TEV_KASEL_3_4 0x02
617 #define GX_TEV_KASEL_5_8 0x03
618 #define GX_TEV_KASEL_1_2 0x04
619 #define GX_TEV_KASEL_3_8 0x05
620 #define GX_TEV_KASEL_1_4 0x06
621 #define GX_TEV_KASEL_1_8 0x07
622 #define GX_TEV_KASEL_K0_R 0x10
623 #define GX_TEV_KASEL_K1_R 0x11
624 #define GX_TEV_KASEL_K2_R 0x12
625 #define GX_TEV_KASEL_K3_R 0x13
626 #define GX_TEV_KASEL_K0_G 0x14
627 #define GX_TEV_KASEL_K1_G 0x15
628 #define GX_TEV_KASEL_K2_G 0x16
629 #define GX_TEV_KASEL_K3_G 0x17
630 #define GX_TEV_KASEL_K0_B 0x18
631 #define GX_TEV_KASEL_K1_B 0x19
632 #define GX_TEV_KASEL_K2_B 0x1A
633 #define GX_TEV_KASEL_K3_B 0x1B
634 #define GX_TEV_KASEL_K0_A 0x1C
635 #define GX_TEV_KASEL_K1_A 0x1D
636 #define GX_TEV_KASEL_K2_A 0x1E
637 #define GX_TEV_KASEL_K3_A 0x1F
640 /*! \addtogroup tevswapsel TEV color swap table entry
644 #define GX_TEV_SWAP0 0
645 #define GX_TEV_SWAP1 1
646 #define GX_TEV_SWAP2 2
647 #define GX_TEV_SWAP3 3
648 #define GX_MAX_TEVSWAP 4
655 #define GX_CH_GREEN 1
657 #define GX_CH_ALPHA 3
659 /* ind tex stage id */
660 #define GX_INDTEXSTAGE0 0
661 #define GX_INDTEXSTAGE1 1
662 #define GX_INDTEXSTAGE2 2
663 #define GX_INDTEXSTAGE3 3
664 #define GX_MAX_INDTEXSTAGE 4
671 #define GX_MAX_ITFORMAT 4
673 /* ind tex bias sel */
674 #define GX_ITB_NONE 0
682 #define GX_MAX_ITBIAS 8
684 /* ind tex mtx idx */
704 #define GX_MAX_ITWRAP 7
706 /* ind tex alpha sel */
707 #define GX_ITBA_OFF 0
711 #define GX_MAX_ITBALPHA 4
713 /* ind tex coord scale */
723 #define GX_MAX_ITSCALE 9
726 #define GX_FOG_NONE 0
728 #define GX_FOG_PERSP_LIN 2
729 #define GX_FOG_PERSP_EXP 4
730 #define GX_FOG_PERSP_EXP2 5
731 #define GX_FOG_PERSP_REVEXP 6
732 #define GX_FOG_PERSP_REVEXP2 7
734 #define GX_FOG_ORTHO_LIN 10
735 #define GX_FOG_ORTHO_EXP 12
736 #define GX_FOG_ORTHO_EXP2 13
737 #define GX_FOG_ORTHO_REVEXP 14
738 #define GX_FOG_ORTHO_REVEXP2 15
740 #define GX_FOG_LIN GX_FOG_PERSP_LIN
741 #define GX_FOG_EXP GX_FOG_PERSP_EXP
742 #define GX_FOG_EXP2 GX_FOG_PERSP_EXP2
743 #define GX_FOG_REVEXP GX_FOG_PERSP_REVEXP
744 #define GX_FOG_REVEXP2 GX_FOG_PERSP_REVEXP2
748 #define GX_PF_RGB8_Z24 0
749 #define GX_PF_RGBA6_Z24 1
750 #define GX_PF_RGB565_Z16 2
755 #define GX_PF_YUV420 7
758 #define GX_ZC_LINEAR 0
763 /*! \addtogroup xfbclamp XFB clamp modes
767 #define GX_CLAMP_NONE 0
768 #define GX_CLAMP_TOP 1
769 #define GX_CLAMP_BOTTOM 2
774 /*! \addtogroup gammamode Gamma values
786 #define GX_COPY_PROGRESSIVE 0
787 #define GX_COPY_INTLC_EVEN 2
788 #define GX_COPY_INTLC_ODD 3
790 /* alpha read mode */
793 #define GX_READ_NONE 2
796 #define GX_TEXCACHE_32K 0
797 #define GX_TEXCACHE_128K 1
798 #define GX_TEXCACHE_512K 2
799 #define GX_TEXCACHE_NONE 3
803 #define GX_DA_GENTLE 1
804 #define GX_DA_MEDIUM 2
805 #define GX_DA_STEEP 3
812 #define GX_SP_SHARP 4
813 #define GX_SP_RING1 5
814 #define GX_SP_RING2 6
819 #define GX_NEAR_MIP_NEAR 2
820 #define GX_LIN_MIP_NEAR 3
821 #define GX_NEAR_MIP_LIN 4
822 #define GX_LIN_MIP_LIN 5
828 #define GX_MAX_ANISOTROPY 3
830 /* vcache metric settings */
841 #define GX_VC_TEX6 10
842 #define GX_VC_TEX7 11
845 /* perf0 counter sets */
846 #define GX_PERF0_VERTICES 0
847 #define GX_PERF0_CLIP_VTX 1
848 #define GX_PERF0_CLIP_CLKS 2
849 #define GX_PERF0_XF_WAIT_IN 3
850 #define GX_PERF0_XF_WAIT_OUT 4
851 #define GX_PERF0_XF_XFRM_CLKS 5
852 #define GX_PERF0_XF_LIT_CLKS 6
853 #define GX_PERF0_XF_BOT_CLKS 7
854 #define GX_PERF0_XF_REGLD_CLKS 8
855 #define GX_PERF0_XF_REGRD_CLKS 9
856 #define GX_PERF0_CLIP_RATIO 10
857 #define GX_PERF0_TRIANGLES 11
858 #define GX_PERF0_TRIANGLES_CULLED 12
859 #define GX_PERF0_TRIANGLES_PASSED 13
860 #define GX_PERF0_TRIANGLES_SCISSORED 14
861 #define GX_PERF0_TRIANGLES_0TEX 15
862 #define GX_PERF0_TRIANGLES_1TEX 16
863 #define GX_PERF0_TRIANGLES_2TEX 17
864 #define GX_PERF0_TRIANGLES_3TEX 18
865 #define GX_PERF0_TRIANGLES_4TEX 19
866 #define GX_PERF0_TRIANGLES_5TEX 20
867 #define GX_PERF0_TRIANGLES_6TEX 21
868 #define GX_PERF0_TRIANGLES_7TEX 22
869 #define GX_PERF0_TRIANGLES_8TEX 23
870 #define GX_PERF0_TRIANGLES_0CLR 24
871 #define GX_PERF0_TRIANGLES_1CLR 25
872 #define GX_PERF0_TRIANGLES_2CLR 26
873 #define GX_PERF0_QUAD_0CVG 27
874 #define GX_PERF0_QUAD_NON0CVG 28
875 #define GX_PERF0_QUAD_1CVG 29
876 #define GX_PERF0_QUAD_2CVG 30
877 #define GX_PERF0_QUAD_3CVG 31
878 #define GX_PERF0_QUAD_4CVG 32
879 #define GX_PERF0_AVG_QUAD_CNT 33
880 #define GX_PERF0_CLOCKS 34
881 #define GX_PERF0_NONE 35
883 /* perf1 counter sets */
884 #define GX_PERF1_TEXELS 0
885 #define GX_PERF1_TX_IDLE 1
886 #define GX_PERF1_TX_REGS 2
887 #define GX_PERF1_TX_MEMSTALL 3
888 #define GX_PERF1_TC_CHECK1_2 4
889 #define GX_PERF1_TC_CHECK3_4 5
890 #define GX_PERF1_TC_CHECK5_6 6
891 #define GX_PERF1_TC_CHECK7_8 7
892 #define GX_PERF1_TC_MISS 8
893 #define GX_PERF1_VC_ELEMQ_FULL 9
894 #define GX_PERF1_VC_MISSQ_FULL 10
895 #define GX_PERF1_VC_MEMREQ_FULL 11
896 #define GX_PERF1_VC_STATUS7 12
897 #define GX_PERF1_VC_MISSREP_FULL 13
898 #define GX_PERF1_VC_STREAMBUF_LOW 14
899 #define GX_PERF1_VC_ALL_STALLS 15
900 #define GX_PERF1_VERTICES 16
901 #define GX_PERF1_FIFO_REQ 17
902 #define GX_PERF1_CALL_REQ 18
903 #define GX_PERF1_VC_MISS_REQ 19
904 #define GX_PERF1_CP_ALL_REQ 20
905 #define GX_PERF1_CLOCKS 21
906 #define GX_PERF1_NONE 22
925 #define GX_BIGTLUT0 16
926 #define GX_BIGTLUT1 17
927 #define GX_BIGTLUT2 18
928 #define GX_BIGTLUT3 19
930 #define GX_MAX_VTXDESC GX_VA_MAXATTR
931 #define GX_MAX_VTXDESC_LISTSIZE (GX_VA_MAXATTR+1)
933 #define GX_MAX_VTXATTRFMT GX_VA_MAXATTR
934 #define GX_MAX_VTXATTRFMT_LISTSIZE (GX_VA_MAXATTR+1)
936 #define GX_MAX_Z24 0x00ffffff
940 #endif /* __cplusplus */
942 typedef union _wgpipe
953 typedef struct _gx_color
{
960 typedef struct _gx_colors10
{
967 typedef struct _gx_texobj
{
971 typedef struct _gx_tlutobj
{
975 typedef struct _gx_texreg
{
979 typedef struct _gx_tlutreg
{
983 typedef struct _gx_litobj
{
987 typedef struct _vtx
{
1006 u8 pad
[GX_FIFO_OBJSIZE
];
1017 typedef void (*GXBreakPtCallback
)(void);
1018 typedef void (*GXDrawDoneCallback
)(void);
1020 /*! \typedef void (*GXDrawSyncCallback)(u16 token)
1021 \brief function pointer typedef for the drawsync-token callback
1022 \param[out] token tokenvalue most recently encountered.
1024 typedef void (*GXDrawSyncCallback
)(u16 token
);
1026 /*! \typedef GXTexRegion* (*GXTexRegionCallback)(GXTexObj *obj,u8 mapid)
1027 \brief function pointer typedef for the texture region callback
1028 \param[out] token tokenvalue most recently encountered.
1030 typedef GXTexRegion
* (*GXTexRegionCallback
)(GXTexObj
*obj
,u8 mapid
);
1032 /*! \typedef GXTlutRegion* (*GXTlutRegionCallback)(u32 tlut_name)
1033 \brief function pointer typedef for the TLUT region callback
1034 \param[out] token tokenvalue most recently encountered.
1036 typedef GXTlutRegion
* (*GXTlutRegionCallback
)(u32 tlut_name
);
1038 extern WGPipe
* const wgPipe
;
1040 * \fn GXFifoObj* GX_Init(void *base,u32 size)
1041 * \brief Initializes the graphics processor to its initial state and should be called before any other GX functions.
1043 * \param[in] base pointer to the GX fifo buffer base address. Must be aligned on a 32 Byte boundery.
1044 * \param[in] size size of buffer. Must be a multiple of 32.
1046 * \return pointer to the intialized GXFifoObj object.
1048 GXFifoObj
* GX_Init(void *base
,u32 size
);
1050 void GX_InitFifoBase(GXFifoObj
*fifo
,void *base
,u32 size
);
1051 void GX_InitFifoLimits(GXFifoObj
*fifo
,u32 hiwatermark
,u32 lowatermark
);
1052 void GX_InitFifoPtrs(GXFifoObj
*fifo
,void *rd_ptr
,void *wt_ptr
);
1053 void GX_SetCPUFifo(GXFifoObj
*fifo
);
1054 void GX_SetGPFifo(GXFifoObj
*fifo
);
1055 void GX_GetCPUFifo(GXFifoObj
*fifo
);
1056 void GX_GetGPFifo(GXFifoObj
*fifo
);
1057 GXDrawDoneCallback
GX_SetDrawDoneCallback(GXDrawDoneCallback cb
);
1058 GXBreakPtCallback
GX_SetBreakPtCallback(GXBreakPtCallback cb
);
1060 void GX_AbortFrame();
1062 void GX_SetMisc(u32 token
,u32 value
);
1063 void GX_SetDrawDone();
1064 void GX_WaitDrawDone();
1067 * \fn u16 GX_GetDrawSync()
1068 * \brief Returns the value of the token register, which is written using the GX_SetDrawSync() function.
1070 * \return the value of the token register, u16.
1072 u16
GX_GetDrawSync();
1075 * \fn void GX_SetDrawSync(u16 token)
1076 * \brief This function sends a token into the command stream.
1077 * When the token register is set, an interrupt will also be received by the CPU. You can install a callback on this interrupt
1078 * with GX_SetDrawSyncCallback(). Draw syncs can be used to notify the CPU that the graphics processor is finished using a shared
1079 * resource (a vertex array for instance).
1081 * \param[in] token 16-bit value to write to the token register.
1085 void GX_SetDrawSync(u16 token
);
1088 * \fn GXDrawSyncCallback GX_SetDrawSyncCallback(GXDrawSyncCallback cb)
1089 * \brief Installs a callback that is invoked whenever a DrawSync token is encountered by the graphics pipeline. The callbacks argument is
1090 * is the value of the token most recently encountered. Since it is possible to miss tokens(graphics processing does not stop while
1091 * the callback is running), your code should be capable of deducing if any tokens have been missed.
1093 * \param[in] cb callback to be invoked when the DrawSnyc tokens are encountered in the graphics pipeline.
1095 * \return pointer to the previously set callback function.
1097 GXDrawSyncCallback
GX_SetDrawSyncCallback(GXDrawSyncCallback cb
);
1099 void GX_DisableBreakPt();
1100 void GX_EnableBreakPt(void *break_pt
);
1102 void GX_TexModeSync();
1103 void GX_InvVtxCache();
1104 void GX_ClearVtxDesc();
1105 void GX_LoadProjectionMtx(Mtx44 mt
,u8 type
);
1106 void GX_SetViewport(f32 xOrig
,f32 yOrig
,f32 wd
,f32 ht
,f32 nearZ
,f32 farZ
);
1107 void GX_SetViewportJitter(f32 xOrig
,f32 yOrig
,f32 wd
,f32 ht
,f32 nearZ
,f32 farZ
,u32 field
);
1108 void GX_SetChanCtrl(s32 channel
,u8 enable
,u8 ambsrc
,u8 matsrc
,u8 litmask
,u8 diff_fn
,u8 attn_fn
);
1109 void GX_SetChanAmbColor(s32 channel
,GXColor color
);
1110 void GX_SetChanMatColor(s32 channel
,GXColor color
);
1111 void GX_SetArray(u32 attr
,void *ptr
,u8 stride
);
1114 * \fn void GX_SetVtxAttrFmt(u8 vtxfmt,u32 vtxattr,u32 comptype,u32 compsize,u32 frac)
1115 * \brief Installs a callback that is invoked whenever a DrawSync token is encountered by the graphics pipeline. The callbacks argument is
1116 * is the value of the token most recently encountered. Since it is possible to miss tokens(graphics processing does not stop while
1117 * the callback is running), your code should be capable of deducing if any tokens have been missed.
1119 * \param[in] vtxfmt \ref vtxfmt
1120 * \param[in] vtxattr to be invoked when the DrawSnyc tokens are encountered in the graphics pipeline.
1121 * \param[in] comptype to be invoked when the DrawSnyc tokens are encountered in the graphics pipeline.
1122 * \param[in] compsize to be invoked when the DrawSnyc tokens are encountered in the graphics pipeline.
1123 * \param[in] frac to be invoked when the DrawSnyc tokens are encountered in the graphics pipeline.
1127 void GX_SetVtxAttrFmt(u8 vtxfmt
,u32 vtxattr
,u32 comptype
,u32 compsize
,u32 frac
);
1128 void GX_SetVtxAttrFmtv(u8 vtxfmt
,GXVtxAttrFmt
*attr_list
);
1129 void GX_SetVtxDesc(u8 attr
,u8 type
);
1130 void GX_SetVtxDescv(GXVtxDesc
*attr_list
);
1132 u32
GX_EndDispList();
1133 void GX_Begin(u8 primitve
,u8 vtxfmt
,u16 vtxcnt
);
1134 void GX_BeginDispList(void *list
,u32 size
);
1135 void GX_CallDispList(void *list
,u32 nbytes
);
1137 static inline void GX_End()
1141 static inline void GX_Position3f32(f32 x
,f32 y
,f32 z
)
1148 static inline void GX_Position3u16(u16 x
,u16 y
,u16 z
)
1155 static inline void GX_Position3s16(s16 x
,s16 y
,s16 z
)
1162 static inline void GX_Position3u8(u8 x
,u8 y
,u8 z
)
1169 static inline void GX_Position3s8(s8 x
,s8 y
,s8 z
)
1176 static inline void GX_Position2f32(f32 x
,f32 y
)
1182 static inline void GX_Position2u16(u16 x
,u16 y
)
1188 static inline void GX_Position2s16(s16 x
,s16 y
)
1194 static inline void GX_Position2u8(u8 x
,u8 y
)
1200 static inline void GX_Position2s8(s8 x
,s8 y
)
1206 static inline void GX_Position1x8(u8 index
)
1211 static inline void GX_Position1x16(u16 index
)
1213 wgPipe
->U16
= index
;
1216 static inline void GX_Normal3f32(f32 nx
,f32 ny
,f32 nz
)
1223 static inline void GX_Normal3s16(s16 nx
,s16 ny
,s16 nz
)
1230 static inline void GX_Normal3s8(s8 nx
,s8 ny
,s8 nz
)
1237 static inline void GX_Normal1x8(u8 index
)
1242 static inline void GX_Normal1x16(u16 index
)
1244 wgPipe
->U16
= index
;
1247 static inline void GX_Color4u8(u8 r
,u8 g
,u8 b
,u8 a
)
1255 static inline void GX_Color3u8(u8 r
,u8 g
,u8 b
)
1262 static inline void GX_Color3f32(f32 r
, f32 g
, f32 b
)
1264 wgPipe
->U8
= (u8
)(r
* 255.0);
1265 wgPipe
->U8
= (u8
)(g
* 255.0);
1266 wgPipe
->U8
= (u8
)(b
* 255.0);
1270 static inline void GX_Color1u32(u32 clr
)
1275 static inline void GX_Color1u16(u16 clr
)
1280 static inline void GX_Color1x8(u8 index
)
1285 static inline void GX_Color1x16(u16 index
)
1287 wgPipe
->U16
= index
;
1290 static inline void GX_TexCoord2f32(f32 s
,f32 t
)
1296 static inline void GX_TexCoord2u16(u16 s
,u16 t
)
1302 static inline void GX_TexCoord2s16(s16 s
,s16 t
)
1308 static inline void GX_TexCoord2u8(u8 s
,u8 t
)
1314 static inline void GX_TexCoord2s8(s8 s
,s8 t
)
1320 static inline void GX_TexCoord1f32(f32 s
)
1325 static inline void GX_TexCoord1u16(u16 s
)
1330 static inline void GX_TexCoord1s16(s16 s
)
1335 static inline void GX_TexCoord1u8(u8 s
)
1340 static inline void GX_TexCoord1s8(s8 s
)
1345 static inline void GX_TexCoord1x8(u8 index
)
1350 static inline void GX_TexCoord1x16(u16 index
)
1352 wgPipe
->U16
= index
;
1355 static inline void GX_MatrixIndex1x8(u8 index
)
1360 void GX_AdjustForOverscan(GXRModeObj
*rmin
,GXRModeObj
*rmout
,u16 hor
,u16 ver
);
1361 void GX_LoadPosMtxImm(Mtx mt
,u32 pnidx
);
1362 void GX_LoadPosMtxIdx(u16 mtxidx
,u32 pnidx
);
1363 void GX_LoadNrmMtxImm(Mtx mt
,u32 pnidx
);
1364 void GX_LoadNrmMtxIdx3x3(u16 mtxidx
,u32 pnidx
);
1365 void GX_LoadTexMtxImm(Mtx mt
,u32 texidx
,u8 type
);
1366 void GX_LoadTexMtxIdx(u16 mtxidx
,u32 texidx
,u8 type
);
1367 void GX_SetCurrentMtx(u32 mtx
);
1370 * \fn void GX_SetTevOp(u8 tevstage,u8 mode)
1371 * \brief Simplified function to set GX_SetTevColorIn(), GX_SetTevAlphaIn(), GX_SetTevColorOp() and GX_SetTevAlphaOp() for
1372 * this <b><i>tevstage</i></b> based on a predefined combiner <b><i>mode</i></b>.
1374 * \param[in] tevstage \ref tevstage.
1375 * \param[in] mode \ref tevdefmode
1379 void GX_SetTevOp(u8 tevstage
,u8 mode
);
1382 * \fn void GX_SetTevColor(u8 tev_regid,GXColor color)
1383 * \brief Sets the vertical clamping mode to use during the EFB to XFB or texture copy.
1385 * \param[in] tev_regid \ref tevcoloutreg.
1386 * \param[in] color Constant color value.
1390 void GX_SetTevColor(u8 tev_regid
,GXColor color
);
1393 * \fn void GX_SetTevColorS10(u8 tev_regid,GXColor color)
1394 * \brief Sets the vertical clamping mode to use during the EFB to XFB or texture copy.
1396 * \param[in] tev_regid \ref tevcoloutreg.
1397 * \param[in] color Constant color value in S10 format.
1401 void GX_SetTevColorS10(u8 tev_regid
,GXColorS10 color
);
1404 * \fn void GX_SetTevColorIn(u8 tevstage,u8 a,u8 b,u8 c,u8 d)
1405 * \brief Sets the color input sources for one <b><i>tevstage</i></b> of the Texture Environment (TEV) color combiner.
1406 * This includes constant (register) colors and alphas, texture color/alpha, rasterized color/alpha (the result
1407 * of per-vertex lighting), and a few useful constants.<br><br>
1408 * <b><i>Note:</i></b> The input controls are independent for each TEV stage.
1410 * \param[in] tevstage \ref tevstage
1411 * \param[in] a \ref tevcolorarg
1412 * \param[in] b \ref tevcolorarg
1413 * \param[in] c \ref tevcolorarg
1414 * \param[in] d \ref tevcolorarg
1418 void GX_SetTevColorIn(u8 tevstage
,u8 a
,u8 b
,u8 c
,u8 d
);
1421 * \fn void GX_SetTevAlphaIn(u8 tevstage,u8 a,u8 b,u8 c,u8 d)
1422 * \brief Sets the alpha input sources for one <b><i>tevstage</i></b> of the Texture Environment (TEV) alpha combiner.
1423 * There are fewer alpha inputs than color inputs, and there are no color channels available in the alpha combiner.<br><br>
1424 * <b><i>Note:</i></b> The input controls are independent for each TEV stage.
1426 * \param[in] tevstage \ref tevstage
1427 * \param[in] a \ref tevalphaarg
1428 * \param[in] b \ref tevalphaarg
1429 * \param[in] c \ref tevalphaarg
1430 * \param[in] d \ref tevalphaarg
1434 void GX_SetTevAlphaIn(u8 tevstage
,u8 a
,u8 b
,u8 c
,u8 d
);
1437 * \fn void GX_SetTevColorOp(u8 tevstage,u8 tevop,u8 tevbias,u8 tevscale,u8 clamp,u8 tevregid)
1438 * \brief Sets the <b><i>tevop</i></b>, <b><i>tevbias</i></b>, <b><i>tevscale</i></b> and <b><i>clamp</i></b>-mode operation for the color combiner
1439 * for this <b><i>tevstage</i></b> of the Texture Environment (TEV) unit. This function also specifies the register, <b><i>tevregid</i></b>, that
1440 * will contain the result of the color combiner function. The color combiner function is:<br><br>
1441 * <b><i>tevregid</i></b> = (d (<b><i>tevop</i></b>) ((1.0 - c)*a + c*b) + <b><i>tevbias</i></b>) * <b><i>tevscale</i></b>;<br><br>
1442 * The input sources a,b,c and d are set using GX_SetTevColorIn().
1444 * \param[in] tevstage \ref tevstage.
1445 * \param[in] tevop \ref tevop
1446 * \param[in] tevbias \ref tevbias.
1447 * \param[in] tevscale \ref tevscale.
1448 * \param[in] clamp Clamp results when GX_TRUE.
1449 * \param[in] tevregid \ref tevcoloutreg
1453 void GX_SetTevColorOp(u8 tevstage
,u8 tevop
,u8 tevbias
,u8 tevscale
,u8 clamp
,u8 tevregid
);
1457 * \fn void GX_SetTevAlphaOp(u8 tevstage,u8 tevop,u8 tevbias,u8 tevscale,u8 clamp,u8 tevregid)
1458 * \brief Sets the <b><i>tevop</i></b>, <b><i>tevbias</i></b>, <b><i>tevscale</i></b> and <b><i>clamp</i></b>-mode operation for the alpha combiner
1459 * for this <b><i>tevstage</i></b> of the Texture Environment (TEV) unit. This function also specifies the register, <b><i>tevregid</i></b>, that
1460 * will contain the result of the alpha combiner function. The alpha combiner function is:<br><br>
1461 * <b><i>tevregid</i></b> = (d (<b><i>tevop</i></b>) ((1.0 - c)*a + c*b) + <b><i>tevbias</i></b>) * <b><i>tevscale</i></b>;<br><br>
1462 * The input sources a,b,c and d are set using GX_SetTevAlphaIn().
1464 * \param[in] tevstage \ref tevstage.
1465 * \param[in] tevop \ref tevop
1466 * \param[in] tevbias \ref tevbias.
1467 * \param[in] tevscale \ref tevscale.
1468 * \param[in] clamp Clamp results when GX_TRUE.
1469 * \param[in] tevregid \ref tevcoloutreg
1473 void GX_SetTevAlphaOp(u8 tevstage
,u8 tevop
,u8 tevbias
,u8 tevscale
,u8 clamp
,u8 tevregid
);
1474 void GX_SetNumTexGens(u32 nr
);
1475 void GX_SetTexCoordGen(u16 texcoord
,u32 tgen_typ
,u32 tgen_src
,u32 mtxsrc
);
1476 void GX_SetTexCoordGen2(u16 texcoord
,u32 tgen_typ
,u32 tgen_src
,u32 mtxsrc
,u32 normalize
,u32 postmtx
);
1479 * \fn void GX_SetZTexture(u8 op,u8 fmt,u32 bias)
1480 * \brief Sets the vertical clamping mode to use during the EFB to XFB or texture copy.
1482 * \param[in] op \ref ztexop
1483 * \param[in] fmt \ref ztexfmt
1484 * \param[in] bias Bias value. Format is 24bit unsigned.
1488 void GX_SetZTexture(u8 op
,u8 fmt
,u32 bias
);
1489 void GX_SetZMode(u8 enable
,u8 func
,u8 update_enable
);
1490 void GX_SetZCompLoc(u8 before_tex
);
1491 void GX_SetLineWidth(u8 width
,u8 fmt
);
1492 void GX_SetPointSize(u8 width
,u8 fmt
);
1494 void GX_SetBlendMode(u8 type
,u8 src_fact
,u8 dst_fact
,u8 op
);
1495 void GX_SetCullMode(u8 mode
);
1496 void GX_SetCoPlanar(u8 enable
);
1497 void GX_EnableTexOffsets(u8 coord
,u8 line_enable
,u8 point_enable
);
1498 void GX_SetClipMode(u8 mode
);
1499 void GX_SetScissor(u32 xOrigin
,u32 yOrigin
,u32 wd
,u32 ht
);
1500 void GX_SetScissorBoxOffset(s32 xoffset
,s32 yoffset
);
1501 void GX_SetNumChans(u8 num
);
1503 void GX_SetTevOrder(u8 tevstage
,u8 texcoord
,u32 texmap
,u8 color
);
1504 void GX_SetNumTevStages(u8 num
);
1506 void GX_SetAlphaCompare(u8 comp0
,u8 ref0
,u8 aop
,u8 comp1
,u8 ref1
);
1507 void GX_SetTevKColor(u8 sel
, GXColor col
);
1508 void GX_SetTevKColorSel(u8 tevstage
,u8 sel
);
1509 void GX_SetTevKAlphaSel(u8 tevstage
,u8 sel
);
1510 void GX_SetTevKColorS10(u8 sel
, GXColorS10 col
);
1513 * \fn void GX_SetTevSwapMode(u8 tevstage,u8 ras_sel,u8 tex_sel)
1514 * \brief Selects a set of swap modes for the rasterized color and texture color for a given TEV stage. This allows the
1515 * color components of these inputs to be rearranged or duplicated.
1516 * There are four different swap mode table entries and each entry in the table specifies how the RGBA inputs map
1517 * to the RGBA outputs. See GX_SetTevSwapModeTable() for more information.
1519 * \param[in] tevstage \ref tevstage
1520 * \param[in] ras_sel selects a swap mode for the rasterized color input.
1521 * \param[in] tex_sel selects a swap mode for the texture color input.
1525 void GX_SetTevSwapMode(u8 tevstage
,u8 ras_sel
,u8 tex_sel
);
1528 * \fn void GX_SetTevSwapModeTable(u8 swapid,u8 r,u8 g,u8 b,u8 a)
1529 * \brief Sets up the TEV color swap table. The swap table allows the rasterized color and texture color to be swapped component-wise.
1530 * An entry in the table specifies how the input color components map to the output color components.
1532 * \param[in] swapid \ref tevswapsel
1533 * \param[in] r input color component that should be mapped to the red output component.
1534 * \param[in] g input color component that should be mapped to the green output component.
1535 * \param[in] b input color component that should be mapped to the blue output component.
1536 * \param[in] a input color component that should be mapped to the alpha output component.
1540 void GX_SetTevSwapModeTable(u8 swapid
,u8 r
,u8 g
,u8 b
,u8 a
);
1541 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
);
1542 void GX_SetTevDirect(u8 tevstage
);
1543 void GX_SetNumIndStages(u8 nstages
);
1544 void GX_SetIndTexOrder(u8 indtexstage
,u8 texcoord
,u8 texmap
);
1545 void GX_SetIndTexCoordScale(u8 indtexid
,u8 scale_s
,u8 scale_t
);
1546 void GX_SetFog(u8 type
,f32 startz
,f32 endz
,f32 nearz
,f32 farz
,GXColor col
);
1547 void GX_SetFogRangeAdj(u8 enable
,u16 center
,GXFogAdjTbl
*table
);
1548 void GX_SetIndTexMatrix(u8 indtexmtx
,f32 offset_mtx
[2][3],s8 scale_exp
);
1549 void GX_SetTevIndBumpST(u8 tevstage
,u8 indstage
,u8 mtx_sel
);
1550 void GX_SetTevIndBumpXYZ(u8 tevstage
,u8 indstage
,u8 mtx_sel
);
1551 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
);
1553 void GX_SetColorUpdate(u8 enable
);
1554 void GX_SetAlphaUpdate(u8 enable
);
1555 void GX_SetPixelFmt(u8 pix_fmt
,u8 z_fmt
);
1556 void GX_SetDither(u8 dither
);
1557 void GX_SetDstAlpha(u8 enable
,u8 a
);
1558 void GX_SetFieldMask(u8 even_mask
,u8 odd_mask
);
1559 void GX_SetFieldMode(u8 field_mode
,u8 half_aspect_ratio
);
1562 * \fn f32 GX_GetYScaleFactor(u16 efbHeight,u16 xfbHeight)
1563 * \brief Calculates an appropriate Y scale factor value for GX_SetDispCopyYScale based on the height of the EFB and
1564 * the height of the XFB.
1566 * \param[in] efbHeight Height of embedded framebuffer. Range from 2 to 528. Should be a multiple of 2.
1567 * \param[in] xfbHeight Height of external framebuffer. Range from 2 to 1024. Should be equal or greater than efbHeight.
1569 * \return Y scale factor which can be used as argument of GX_SetDispCopyYScale().
1571 f32
GX_GetYScaleFactor(u16 efbHeight
,u16 xfbHeight
);
1574 * \fn u32 GX_SetDispCopyYScale(f32 yscale)
1575 * \brief Sets the vertical scale factor for the EFB to XFB copy operation. The number of actual lines copied is returned, based on the current EFB height.
1576 * You can use this number to allocate the proper XFB size. You have to call GX_SetDispCopySrc() prior to this function call if you want to get the
1577 * number of lines by using this function. There is also another way (GX_GetNumXfbLines) to calculate this number.
1579 * \param[in] yscale Vertical scale value. Range from 1.0 to 256.0.
1581 * \return Number of lines that will be copied.
1583 u32
GX_SetDispCopyYScale(f32 yscale
);
1586 * \fn void GX_SetDispCopySrc(u16 left,u16 top,u16 wd,u16 ht)
1587 * \brief Sets the source parameters for the EFB to XFB copy operation.
1589 * \param[in] left left most source pixel to copy. Must be a multiple of 2 pixels.
1590 * \param[in] top top most source line to copy. Must be a multiple of 2 lines.
1591 * \param[in] wd width in pixels to copy. Must be a multiple of 2 pixels.
1592 * \param[in] ht height in lines to copy. Must be a multiple of 2 lines.
1596 void GX_SetDispCopySrc(u16 left
,u16 top
,u16 wd
,u16 ht
);
1599 * \fn void GX_SetDispCopyDst(u16 wd,u16 ht)
1600 * \brief Sets the witdth and height of the display buffer in pixels. The application typical renders an image into the EFB(source) and
1601 * then copies it into the XFB(destination) in main memory. The <b><i>wd</i></b> specifies the number of pixels between adjacent lines in the
1602 * destination buffer and can be different than the width of the EFB.
1604 * \param[in] wd Distance between successive lines in the XFB, in pixels. Must be a multiple of 16.
1605 * \param[in] ht Height of the XFB in lines.
1609 void GX_SetDispCopyDst(u16 wd
,u16 ht
);
1612 * \fn void GX_SetCopyClamp(u8 clamp)
1613 * \brief Sets the vertical clamping mode to use during the EFB to XFB or texture copy.
1615 * \param[in] clamp clamp mode. bit-wise OR of \ref xfbclamp. Use GX_CLAMP_NONE for no clamping.
1619 void GX_SetCopyClamp(u8 clamp
);
1622 * \fn void GX_SetDispCopyGamma(u8 gamma)
1623 * \brief Sets the gamma correction applied to pixels during EFB to XFB copy operation.
1625 * \param[in] gamma \ref gammamode
1629 void GX_SetDispCopyGamma(u8 gamma
);
1631 void GX_SetCopyFilter(u8 aa
,u8 sample_pattern
[12][2],u8 vf
,u8 vfilter
[7]);
1632 void GX_SetDispCopyFrame2Field(u8 mode
);
1635 * \fn void GX_SetCopyClear(GXColor color,u32 zvalue)
1636 * \brief Sets color and Z value to clear the EFB to, during copy operations. These values are used during both display copies and texture copies.
1638 * \param[in] color RGBA color (8-bit/component) to use during clear operation.
1639 * \param[in] zvalue 24-bit Z value to use during clear operation. Use the constant GX_MAX_Z24 to specify the maximum depth value.
1643 void GX_SetCopyClear(GXColor color
,u32 zvalue
);
1646 * \fn void GX_CopyDisp(void *dest,u8 clear)
1647 * \brief Copies the embedded framebuffer(XFB) to the external framebuffer(XFB) in main memory. The stride of
1648 * the XFB is set using GX_SetDispCopyDst(). The source image in the EFB is described using GX_SetDispCopySrc().
1650 * The graphics processor will stall all graphics commands util the copy is complete.
1652 * If the <b><i>clear</i></b> flag is true, the color and Z buffers will be cleared during the copy. They will be
1653 * cleared to the constant values set using GX_SetCopyClear().
1655 * \param[in] dest pointer to the external framebuffer. <b><i>dest</i></b> should be 32B aligned.
1656 * \param[in] clear flag that indicates framebuffer should be cleared if GX_TRUE.
1660 void GX_CopyDisp(void *dest
,u8 clear
);
1662 void GX_SetTexCopySrc(u16 left
,u16 top
,u16 wd
,u16 ht
);
1665 * \fn void GX_SetTexCopyDst(u16 wd,u16 ht,u32 fmt,u8 mipmap)
1666 * \brief Copies the embedded framebuffer(XFB) to the texture image buffer <b><i>dest</i></b> in main memory. This is useful
1667 * when creating textures using the Graphics Processor(CP).
1668 * If the <b><i>clear</i></b> flag is set to GX_TRUE, the EFB will be cleared to the current color(see GX_SetCopyClear())
1669 * during the copy operation.
1671 * \param[in] wd pointer to the image buffer in main memory. <b><i>dest</i></b> should be 32B aligned.
1672 * \param[in] ht flag that indicates framebuffer should be cleared if GX_TRUE.
1673 * \param[in] fmt \ref texfmt
1678 void GX_SetTexCopyDst(u16 wd
,u16 ht
,u32 fmt
,u8 mipmap
);
1681 * \fn void GX_CopyTex(void *dest,u8 clear)
1682 * \brief Copies the embedded framebuffer(XFB) to the texture image buffer <b><i>dest</i></b> in main memory. This is useful
1683 * when creating textures using the Graphics Processor(CP).
1684 * If the <b><i>clear</i></b> flag is set to GX_TRUE, the EFB will be cleared to the current color(see GX_SetCopyClear())
1685 * during the copy operation.
1687 * \param[in] dest pointer to the image buffer in main memory. <b><i>dest</i></b> should be 32B aligned.
1688 * \param[in] clear flag that indicates framebuffer should be cleared if GX_TRUE.
1692 void GX_CopyTex(void *dest
,u8 clear
);
1695 * \fn void GX_PixModeSync()
1696 * \brief Inserts a synchronization command into the graphics FIFO. When the GPU sees this command it will allow the
1697 * rest of the pipe to flush before continuing. This command is useful in certain situation such as after a GX_CopyTex()
1698 * command and before a primitive that uses the copied texture.
1702 void GX_PixModeSync();
1705 * \fn void GX_ClearBoundingBox()
1706 * \brief Clears the bounding box values before a new image is drawn.
1707 * The graphics hardware keeps track of a bounding box of pixel coordinates that are drawn in the EFB.
1711 void GX_ClearBoundingBox();
1712 void GX_PokeAlphaMode(u8 func
,u8 threshold
);
1713 void GX_PokeAlphaUpdate(u8 update_enable
);
1714 void GX_PokeColorUpdate(u8 update_enable
);
1715 void GX_PokeDither(u8 dither
);
1716 void GX_PokeBlendMode(u8 type
,u8 src_fact
,u8 dst_fact
,u8 op
);
1717 void GX_PokeAlphaRead(u8 mode
);
1718 void GX_PokeDstAlpha(u8 enable
,u8 a
);
1719 void GX_PokeARGB(u16 x
,u16 y
,GXColor color
);
1720 void GX_PeekARGB(u16 x
,u16 y
,GXColor
*color
);
1721 void GX_PokeZ(u16 x
,u16 y
,u32 z
);
1722 void GX_PeekZ(u16 x
,u16 y
,u32
*z
);
1723 void GX_PokeZMode(u8 comp_enable
,u8 func
,u8 update_enable
);
1725 u32
GX_GetTexObjFmt(GXTexObj
*obj
);
1726 u32
GX_GetTexObjMipMap(GXTexObj
*obj
);
1728 u8
GX_GetTexFmt(GXTexObj
*obj
);
1729 u32
GX_GetTexBufferSize(u16 wd
,u16 ht
,u32 fmt
,u8 mipmap
,u8 maxlod
);
1730 void GX_InvalidateTexAll();
1731 void GX_InvalidateTexRegion(GXTexRegion
*region
);
1732 void GX_InitTexCacheRegion(GXTexRegion
*region
,u8 is32bmipmap
,u32 tmem_even
,u8 size_even
,u32 tmem_odd
,u8 size_odd
);
1733 void GX_InitTexPreloadRegion(GXTexRegion
*region
,u32 tmem_even
,u32 size_even
,u32 tmem_odd
,u32 size_odd
);
1734 void GX_InitTexObj(GXTexObj
*obj
,void *img_ptr
,u16 wd
,u16 ht
,u8 fmt
,u8 wrap_s
,u8 wrap_t
,u8 mipmap
);
1735 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
);
1736 void GX_InitTexObjTlut(GXTexObj
*obj
,u32 tlut_name
);
1737 void GX_InitTexObjData(GXTexObj
*obj
,void *img_ptr
);
1738 void GX_InitTexObjWrapMode(GXTexObj
*obj
,u8 wrap_s
,u8 wrap_t
);
1739 void GX_InitTexObjFilterMode(GXTexObj
*obj
,u8 minfilt
,u8 magfilt
);
1740 void GX_InitTexObjMinLOD(GXTexObj
*obj
,f32 minlod
);
1741 void GX_InitTexObjMaxLOD(GXTexObj
*obj
,f32 maxlod
);
1742 void GX_InitTexObjLODBias(GXTexObj
*obj
,f32 lodbias
);
1743 void GX_InitTexObjBiasClamp(GXTexObj
*obj
,u8 biasclamp
);
1744 void GX_InitTexObjEdgeLOD(GXTexObj
*obj
,u8 edgelod
);
1745 void GX_InitTexObjMaxAniso(GXTexObj
*obj
,u8 maxaniso
);
1746 void GX_LoadTexObj(GXTexObj
*obj
,u8 mapid
);
1747 void GX_LoadTlut(GXTlutObj
*obj
,u32 tlut_name
);
1748 void GX_LoadTexObjPreloaded(GXTexObj
*obj
,GXTexRegion
*region
,u8 mapid
);
1749 void GX_PreloadEntireTex(GXTexObj
*obj
,GXTexRegion
*region
);
1750 void GX_InitTlutObj(GXTlutObj
*obj
,void *lut
,u8 fmt
,u16 entries
);
1751 void GX_InitTlutRegion(GXTlutRegion
*region
,u32 tmem_addr
,u8 tlut_sz
);
1752 void GX_InitTexObjLOD(GXTexObj
*obj
,u8 minfilt
,u8 magfilt
,f32 minlod
,f32 maxlod
,f32 lodbias
,u8 biasclamp
,u8 edgelod
,u8 maxaniso
);
1753 void GX_SetTexCoorScaleManually(u8 texcoord
,u8 enable
,u16 ss
,u16 ts
);
1754 void GX_SetTexCoordBias(u8 texcoord
,u8 s_enable
,u8 t_enable
);
1755 GXTexRegionCallback
GX_SetTexRegionCallback(GXTexRegionCallback cb
);
1756 GXTlutRegionCallback
GX_SetTlutRegionCallback(GXTlutRegionCallback cb
);
1758 void GX_InitLightPos(GXLightObj
*lit_obj
,f32 x
,f32 y
,f32 z
);
1759 void GX_InitLightColor(GXLightObj
*lit_obj
,GXColor col
);
1760 void GX_InitLightDir(GXLightObj
*lit_obj
,f32 nx
,f32 ny
,f32 nz
);
1761 void GX_LoadLightObj(GXLightObj
*lit_obj
,u8 lit_id
);
1762 void GX_LoadLightObjIdx(u32 litobjidx
,u8 litid
);
1763 void GX_InitLightDistAttn(GXLightObj
*lit_obj
,f32 ref_dist
,f32 ref_brite
,u8 dist_fn
);
1764 void GX_InitLightAttn(GXLightObj
*lit_obj
,f32 a0
,f32 a1
,f32 a2
,f32 k0
,f32 k1
,f32 k2
);
1765 void GX_InitLightAttnA(GXLightObj
*lit_obj
,f32 a0
,f32 a1
,f32 a2
);
1766 void GX_InitLightAttnK(GXLightObj
*lit_obj
,f32 k0
,f32 k1
,f32 k2
);
1767 void GX_InitSpecularDirHA(GXLightObj
*lit_obj
,f32 nx
,f32 ny
,f32 nz
,f32 hx
,f32 hy
,f32 hz
);
1768 void GX_InitSpecularDir(GXLightObj
*lit_obj
,f32 nx
,f32 ny
,f32 nz
);
1769 void GX_InitLightSpot(GXLightObj
*lit_obj
,f32 cut_off
,u8 spotfn
);
1771 u32
GX_ReadClksPerVtx();
1772 u32
GX_GetOverflowCount();
1773 u32
GX_ResetOverflowCount();
1774 lwp_t
GX_GetCurrentGXThread();
1775 lwp_t
GX_SetCurrentGXThread();
1776 void GX_RestoreWriteGatherPipe();
1777 void GX_SetGPMetric(u32 perf0
,u32 perf1
);
1778 void GX_ClearGPMetric();
1779 void GX_InitXfRasMetric();
1780 void GX_ReadXfRasMetric(u32
*xfwaitin
,u32
*xfwaitout
,u32
*rasbusy
,u32
*clks
);
1781 void GX_ClearVCacheMetric();
1782 void GX_ReadVCacheMetric(u32
*check
,u32
*miss
,u32
*stall
);
1783 void GX_SetVCacheMetric(u32 attr
);
1784 void GX_GetGPStatus(u8
*overhi
,u8
*underlow
,u8
*readIdle
,u8
*cmdIdle
,u8
*brkpt
);
1785 void GX_ReadGPMetric(u32
*cnt0
,u32
*cnt1
);
1786 void GX_GetFifoPtrs(GXFifoObj
*fifo
,void **rd_ptr
,void **wt_ptr
);
1787 volatile void* GX_RedirectWriteGatherPipe(void *ptr
);
1789 #define GX_InitLightPosv(lo,vec) \
1790 (GX_InitLightPos((lo), *(f32*)(vec), *((f32*)(vec)+1), *((f32*)(vec)+2)))
1792 #define GX_InitLightDirv(lo,vec) \
1793 (GX_InitLightDir((lo), *(f32*)(vec), *((f32*)(vec)+1), *((f32*)(vec)+2)))
1795 #define GX_InitSpecularDirv(lo,vec) \
1796 (GX_InitSpecularDir((lo), *(f32*)(vec), *((f32*)(vec)+1), *((f32*)(vec)+2)))
1798 #define GX_InitSpecularDirHAv(lo,vec0,vec1) \
1799 (GX_InitSpecularDirHA((lo), \
1800 *(f32*)(vec0), *((f32*)(vec0)+1), *((f32*)(vec0)+2), \
1801 *(f32*)(vec1), *((f32*)(vec1)+1), *((f32*)(vec1)+2)))
1803 #define GX_InitLightShininess(lobj, shininess) \
1804 (GX_InitLightAttn(lobj, 0.0F, 0.0F, 1.0F, \
1805 (shininess)/2.0F, 0.0F, \
1806 1.0F-(shininess)/2.0F ))
1810 #endif /* __cplusplus */