GX.pdf

(1002 KB) Pobierz
Revolution SDK
Graphics Library (GX)
Version 1.03
© 2006-2009 Nintendo
© 2006-2009 Nintendo
CONFIDENTIAL
RVL-06-0037-001-E
Released: March 27, 2009
Graphics Library (GX)
"Confidential"
These coded instructions, statements, and computer programs contain proprietary
information of Nintendo and/or its licensed developers and are protected by national
and international copyright laws. They may not be disclosed to third parties or copied
or duplicated in any form, in whole or in part, without the prior written consent of Nin-
tendo.
© 2006-2009 Nintendo
TM and ® are trademarks of Nintendo.
Dolby, Pro Logic and the Double-D symbol are trademarks of Dolby Laboratories.
IBM is a trademark of International Business Machines Corporation.
Roland GS Sound Set is a trademark of Roland Corporation U.S.
All other trademarks and copyrights are property of their respective owners.
RVL-06-0037-001-E
Released: March 27, 2009
© 2006-2009 Nintendo
CONFIDENTIAL
i
Graphics Library (GX)
Version 1.03
Contents
1
Introduction................................................................................................................................... 1
1.1 Document Organization ...................................................................................................... 1
1.2 Syntax Notes ...................................................................................................................... 1
1.3 A Note on Pointers.............................................................................................................. 2
1.4 Useful Books....................................................................................................................... 2
Code Example: smp-onetri.c ........................................................................................................ 3
Initialization................................................................................................................................... 9
3.1 Video Initialization............................................................................................................... 9
3.2 Graphics Initialization.......................................................................................................... 9
3.3 Graphics Processor (GP).................................................................................................. 10
Vertex and Primitive Data........................................................................................................... 11
4.1 Describing the Vertex Data............................................................................................... 12
4.2 Describing Arrays ............................................................................................................. 14
4.3 Describing Attribute Data Formats.................................................................................... 15
4.4 Drawing Graphics Primitives............................................................................................. 17
4.4.1 Primitive Types ....................................................................................................... 17
4.4.2 Points and Lines ..................................................................................................... 18
4.4.3 Rasterization Rules ................................................................................................. 20
4.4.4 Using Vertex Functions ........................................................................................... 20
4.5 Vertex Data Organization ................................................................................................. 22
4.5.1 Indexed Vertex Data ............................................................................................... 25
4.5.2 Direct Vertex Data................................................................................................... 26
4.5.3 Mixture of Direct and Indexed Data......................................................................... 27
4.6 Display Lists...................................................................................................................... 27
4.6.1 Creating Display Lists ............................................................................................. 28
4.6.2 Drawing Primitives Using Display Lists ................................................................... 30
4.6.3 Effect on Machine State .......................................................................................... 30
4.7 GXDraw Functions............................................................................................................ 31
Viewing ....................................................................................................................................... 33
5.1 Loading a Modelview Matrix ............................................................................................. 34
5.2 Setting a Projection Matrix................................................................................................ 35
5.3 Culling, Clipping, and Scissoring ...................................................................................... 36
5.4 Viewport and Scissoring ................................................................................................... 37
5.5 Coordinate Systems ......................................................................................................... 38
5.6 How to Override the Default Matrix Memory Configuration .............................................. 39
Vertex Lighting............................................................................................................................ 41
6.1 Lighting Pipeline ............................................................................................................... 41
6.1.1 Diffuse Lights, Diffuse Attenuation and Vertex Normals ......................................... 41
6.1.2 Local Lights and Range Attenuation ....................................................................... 41
6.1.3 Spotlights, Directional Lights and Angle Attenuation .............................................. 41
6.2 Diffuse Lighting Equations ................................................................................................ 43
6.3 Matrix Memory .................................................................................................................. 44
6.4 Light Parameters .............................................................................................................. 44
6.4.1 Angle Attenuation.................................................................................................... 44
6.4.2 Distance Attenuation ............................................................................................... 46
2
3
4
5
6
© 2006-2009 Nintendo
CONFIDENTIAL
RVL-06-0037-001-E
Released: March 27, 2009
ii
Graphics Library (GX)
Channel Parameters......................................................................................................... 47
6.5.1 Channel Colors ....................................................................................................... 47
6.5.2 Channel Control ...................................................................................................... 47
6.5.3 Pre-lighting .............................................................................................................. 48
6.6 Specular Lighting .............................................................................................................. 49
6.7 Vertex performance .......................................................................................................... 50
6.8 Lighting Performance........................................................................................................ 51
7 Texture Coordinate Generation .................................................................................................. 53
7.1 Specifying Texgens .......................................................................................................... 53
7.2 Renormalization and “post-transform” Matrices Added for Texgens ................................ 55
7.3 Other Texture Coordinate Generation Issues................................................................... 56
7.4 Texture Coordinate Generation Performance................................................................... 56
8 Texture Mapping......................................................................................................................... 57
8.1 Example: Drawing a Textured Triangle ............................................................................ 57
8.2 Loading a Texture into Main Memory ............................................................................... 60
8.3
Describing a Texture Object ............................................................................................ 60
8.3.1 Texel Formats ......................................................................................................... 62
8.3.2 Texture Lookup Table (TLUT) Formats................................................................... 63
8.3.3 Texture Image Formats........................................................................................... 63
8.3.4 Texture Coordinate Space ...................................................................................... 64
8.3.5 Filter Modes and LOD Controls............................................................................... 66
8.4 Loading Texture Objects................................................................................................... 72
8.5 Loading Texture Lookup Tables (TLUTs) ......................................................................... 73
8.6 How to Override the Default Texture Configuration.......................................................... 73
8.6.1 Texture Regions...................................................................................................... 74
8.6.2 Cached Regions ..................................................................................................... 75
8.6.3 TLUT Regions ......................................................................................................... 76
8.6.4 Preloaded Regions ................................................................................................. 76
8.6.5 Texture Cache Allocation ........................................................................................ 82
8.6.6 TLUT Allocation ...................................................................................................... 82
8.7 Invalidating Texture Cache ............................................................................................... 83
8.8 Changing the Usage of TMEM Regions ........................................................................... 83
8.9 Creating Textures by Copying the Embedded Frame Buffer............................................ 84
8.10 Z Textures......................................................................................................................... 87
8.11 Texture Performance ........................................................................................................ 89
9 Texture Environment (TEV)........................................................................................................ 91
9.1 Description........................................................................................................................ 91
9.2 Default Texture Pipeline Configuration ............................................................................. 92
9.3 Number of Active TEV Stages .......................................................................................... 92
9.4 GXSetTevOp .................................................................................................................... 92
9.5 Color/alpha Combine Operations ..................................................................................... 93
9.5.1 Compare Mode ....................................................................................................... 95
9.6 Color Inputs ...................................................................................................................... 97
9.7 Alpha Inputs...................................................................................................................... 99
9.8 Color Component Swap Mode.......................................................................................... 99
9.9 TEV “constant” Color Registers ...................................................................................... 100
9.10 Example Settings............................................................................................................ 101
9.11 Alpha Compare Function ................................................................................................ 103
9.12 Z Textures....................................................................................................................... 104
9.13 Texture Pipeline Configuration ....................................................................................... 104
10 Indirect Texture Mapping.......................................................................................................... 107
10.1 Setting Up Indirect Texture Stages................................................................................. 109
10.2 Basic Indirect Texture Processing .................................................................................. 111
6.5
RVL-06-0037-001-E
Released: March 27, 2009
© 2006-2009 Nintendo
CONFIDENTIAL
iii
10.3 Basic Indirect Texture Functions .................................................................................... 112
10.3.1 Texture Warping ................................................................................................... 112
10.3.2 Environment-mapped Bump-mapping (EMBM) (dX,
dY, dZ)................................
113
10.4 Advanced Indirect Texture Processing ........................................................................... 114
10.4.1 Selecting “bump alpha” ......................................................................................... 114
10.4.2 Dynamic Matrices.................................................................................................. 114
10.4.3 Selecting Texture Coordinates for Texture LOD ................................................... 115
10.4.4 Adding Texture Coordinates from Previous TEV Stages ...................................... 115
10.5 Advanced Indirect Functions .......................................................................................... 115
10.5.1 Texture Tiling and Pseudo-3D Texturing .............................................................. 115
10.5.2 Environment-mapped Bump-mapping (EMBM) (dS,
dT)
...................................... 116
10.5.3 General Indirect Texturing .................................................................................... 117
11 Fog, Z-compare, Blending, and Dithering................................................................................. 119
11.1 Fog.................................................................................................................................. 119
11.1.1 Fog Curves ........................................................................................................... 120
11.1.2 Fog Parameters .................................................................................................... 122
11.2 Z-compare ...................................................................................................................... 122
11.2.1 Z Buffer Format ..................................................................................................... 123
11.3 Blending.......................................................................................................................... 124
11.3.1 Blend Equation...................................................................................................... 124
11.3.2 Blending Parameters ............................................................................................ 125
11.3.3 Logic Operations ................................................................................................... 126
11.4 Dithering ......................................................................................................................... 127
12 Video Output............................................................................................................................. 129
12.1 The Copy Pipeline .......................................................................................................... 129
12.1.1 Copy Source ......................................................................................................... 129
12.1.2 Antialiasing and Deflickering ................................................................................. 129
12.1.3 Gamma Correction................................................................................................ 130
12.1.4 RGB to YUV .......................................................................................................... 131
12.1.5 Y Scale.................................................................................................................. 131
12.1.6 Copy Destination................................................................................................... 131
12.1.7 Clear Color and Z for Next Frame......................................................................... 131
12.2 Predefined Render Modes.............................................................................................. 132
12.2.1 Double-strike, Non-antialiased Mode .................................................................... 133
12.2.2 Double-strike, Antialiased Mode ........................................................................... 133
12.2.3 Interlaced, Non-antialiased, Field-rendering Mode ............................................... 134
12.2.4 Interlaced, Antialiased, Field-rendering Mode....................................................... 134
12.2.5 Interlaced, Non-antialiased, Frame-rendering, Deflicker Mode............................. 134
12.2.6 Interlaced, Non-antialiased, Frame-rendering, Non-deflicker Mode ..................... 135
12.2.7 Interlaced, Antialiased, Frame-rendering, Deflicker Mode .................................... 135
12.2.8 Progressive Mode ................................................................................................. 136
12.2.9 Progressive, “Soft” Mode ...................................................................................... 136
12.2.10 Progressive Antialised Mode................................................................................. 136
12.3 GX API Default Render Mode......................................................................................... 137
12.4 Embedded Frame Buffer Formats .................................................................................. 137
12.4.1 48-bit Format – Non-antialiasing ........................................................................... 137
12.4.2 96-bit Super-sampling Format – Antialiasing ........................................................ 138
12.5 External Frame Buffer Format ........................................................................................ 138
13 Graphics FIFO .......................................................................................................................... 139
13.1 Description...................................................................................................................... 139
13.2 Creating a FIFO .............................................................................................................. 141
13.3 Attaching and Saving FIFOs........................................................................................... 142
13.4 FIFO Status .................................................................................................................... 143
13.5 FIFO Flow Control .......................................................................................................... 144
© 2006-2009 Nintendo
CONFIDENTIAL
RVL-06-0037-001-E
Released: March 27, 2009
Zgłoś jeśli naruszono regulamin