gspTurbo3D.3p
10.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
.TH gspTurbo3D 3P local "Silicon Graphics, Inc."
.SH NAME
.upperok
gspTurbo3D, gspTurbo3D.dram, gspTurbo3D.fifo
\- reduced-feature, reduced-precision, optimized, 3D polygonal geometry
RSP microcode.
.SH DESCRIPTION
This is the optimized, reduced-featured 3D polygonal geometry RSP microcode.
The low precision and reduced features make this ucode most suitable for
"characters" or objects which always appear near the center of the
viewing frustum.
.PP
The
.I dram
version of the microcode directs the output (RDP display list) to
a memory buffer, instead of sending it to the RDP.
.PP
The
.I fifo
version of the microcode uses a DRAM FIFO to send data to the RDP.
.PP
All computations are performed with low precision,
in order to have the fastest processing time. This may result in
visible artifacts.
.PP
The following features are not supported:
.TP
.I clipping
the application program is responsible for not
sending any geometry which does not appear on
the screen. Scissoring is supported using DP commands.
.TP
.I lighting
no dynamic lighting calculations are performed
in this ucode.
.TP
.I perspective-corrected textures
texture coordinates are
.I
not
perspective-corrected.
.TP
.I matrix stack
there is no matrix stack; a single matrix is part of the object state.
This is used to transform vertices.
.TP
.I anti-aliasing
the reduced-precision calculations make this feature less-useful.
(anti-aliasing
.I is
performed on all edges, but because the vertex positioning has less
precision, the anti-aliasing is not as sucessful)
.SH TURBO DISPLAY LISTS
The turbo ucode uses a simpler display list format that is not
compatible with any other microcode.
.PP
A turbo display list is a linear list of object structures,
terminated by a NULL object (an object whose object state is NULL):
.PP
.nf
\f3#include "gt.h"
/*
* This structure is a turbo 'object', the turbo display list is
* simply a list of these. (4 pointers = 16 bytes)
*
*/
typedef struct {
gtGlobState *gstatep; /* global state, usually NULL */
gtState *statep; /* if this is NULL, end object processing */
Vtx *vtxp; /* if this is NULL, use points in buffer */
gtTriN *trip; /* if this is NULL, don't draw anything */
} gtGfx_t;
typedef union {
gtGfx_t obj;
long long int force_structure_alignment;
} gtGfx;
\fP
.fi
.PP
Each object structure contains four pointers; one each to the
.I global state, object state, vertex list,
and
.I triangle list.
.PP
If the global state pointer or the vertex list pointer is NULL,
the current contents in DMEM are used. If the triangle list
pointer is NULL, no triangles will be generated. If the object
state pointer is NULL, it is interpreted as the end of the display
list.
.SH TURBO GLOBAL STATE
The turbo global state structure:
.PP
.nf
\f3#include "gt.h"
/*
* This is the global state structure. It's definition carefully
* matches the ucode, so if this structure changes, you must
* also change the ucode.
*/
typedef struct {
u16 perspNorm; /* persp normalization */
u16 pad0;
u32 flag;
Gfx rdpOthermode;
u32 segBases[16]; /* segment base addrs (SEE NOTE!) */
Vp viewport; /* the viewport to use */
Gfx *rdpCmds; /* block of RDP data, process if !NULL
* block terminated by
* gDPEndDisplayList()
*/
} gtGlobState_t;
/* NOTE:
* Although there are 16 segment table entries, the first one
* (segment 0) is reserved for physical memory mapping. You
* should not use segment 0.
*/
typedef union {
gtGlobState_t sp;
long long int force_structure_alignment;
} gtGlobState;
\fP
.fi
.PP
The global state contains data not likely to change on a per-object
basis. The format of the global state structure is exactly the
same as the DMEM, this structure is simply copied into DMEM.
.PP
The
.I perspNorm
field is used during vertex transformations (see
.I gSPPerspNormalize (3P)).
.PP
The
.I rdpOthermode
field contains a DP SetOtherMode command which is sent first
before any other DP commands.
.PP
The
.I segBases
array contains the 16 segment base addresses. Entry 0 is reserved
for physical memory mapping and should not be used.
.PP
The
.I viewport
is used during vertex transformations (see
.I gSPViewport (3P)).
.PP
.I rdpCmds
points to a block of DP commands. If this pointer is non-NULL,
these commands are sent to the RDP. See the list below for
DP commands which should not be used in this command block.
This list must be terminated by a
.I gDPEndDisplay (3P)
command.
.PP
.SH TURBO OBJECT STATE
The turbo object state structure:
.PP
.nf
\f3#include "gt.h"
/*
* This is the 'state' structure associated with each object
* to be rendered. It's definition carefully matches the
* ucode, so if this structure changes, you must also change
* the gtoff.c tool and the ucode.
*/
typedef struct {
u32 renderState; /* render state */
u32 textureState; /* texture state */
u8 vtxCount; /* how many verts? */
u8 vtxV0; /* where to load verts? */
u8 triCount; /* how many tris? */
u8 flag;
Gfx *rdpCmds;
Gfx rdpOthermode;
Mtx transform; /* the transform matrix to use */
} gtState_t;
typedef union {
gtState_t sp;
long long int force_structure_alignment;
} gtState;
/* gtStateLite : same as gtState, but no matrix (see flags below) */
/* this structure must track gtState! */
typedef struct {
u32 renderState; /* render state */
u32 textureState; /* texture state */
u8 vtxCount; /* how many verts? */
u8 vtxV0; /* where to load verts? */
u8 triCount; /* how many tris? */
u8 flag;
Gfx *rdpCmds; /* ptr (segment address) to RDP DL */
Gfx rdpOthermode;
} gtStateL_t;
typedef union {
gtStateL_t sp;
long long int force_structure_alignment;
} gtStateL;
\fP
.fi
.PP
The
.I gtStateL
version of the state structure can be used if a new matrix is not needed.
This is useful for larger objects which must be broken up among several
turbo objects (due to size or convex complexity). All of the pieces could
use the same transformation matrix, saving DRAM space and computational
time. See
.I GT_FLAG_NOMTX
below.
.PP
The
.I renderState
field is similar to the geometry mode in gbi.h, and is composed
of the following flags, or'd together:
.PP
.nf
.ta 5 28
GT_ZBUFFER turn on z-buffering.
GT_TEXTURE turn on texture mapping.
GT_CULL_BACK turn on backface triangle rejection.
GT_SHADING_SMOOTH perform smooth shading (as opposed to
flat (faceted) shading).
.fi
.PP
The
.I textureState
holds the texture tile number in the lower 3 bits of this field.
All primitives in an object are drawn with the same tile.
.PP
.I vtxCount
is the size of the vertex list.
.PP
.I vtxV0
load vertices starting at index v0 (0-63) in the vertex buffer.
.PP
.I triCount
is the size of the triangle list.
.PP
.I flags
a group of bits that control state processing. The flag
.I GT_FLAG_NOMTX
must be set when using the gtStateL structure; in this case
the matrix will not be loaded and the previous matrix will
be used to transform the points.
.PP
.I rdpCmds
points to a block of DP commands. If this pointer is non-NULL,
these commands are sent to the RDP. See the list below for
DP commands which should not be used in this command block.
This list must be terminated by a
.I gDPEndDisplay (3P)
command.
.PP
The
.I rdpOthermode
field contains a DP SetOtherMode command which is sent first
before any other DP commands.
.PP
.I transform
is the matrix to use to transform the vertices.
.PP
.SH TURBO VERTICES
The vertex list is an array of vertex structures, using the same
vertex format as in
.I gbi.h.
See
.I gSPVertex (3P)
for more details.
.PP
The vertex cache in the turbo ucode is 64 vertices. Vertices are
transformed when they are loaded.
.PP
.SH TURBO TRIANGLE LISTS
The triangle list is an array of these structures:
.PP
.nf
\f3#include "gt.h"
/*
* This structure represents a single triangle, part of the
* triangle list of the object to be rendered.
*
* NOTE: The triangle list MUST be aligned to an 8-byte boundary.
* Since this structure is only 4 bytes, we are REQUIRING that
* this structure only be used as an array of triangles, and we
* depend on the MIPS C compiler (which always aligns arrays to
* 8-byte boundaries). THIS IS DANGEROUS!!!!
*
*/
typedef struct {
u8 v0, v1, v2, flag; /* flag is which one for flat shade */
} gtTriN;
\fP
.fi
.PP
This array has a maximum of 64 triangles and must be aligned to an
8-byte boundary.
.SH GBI
The turbo ucode uses a completely different display list format
and processing strategy; in that sense
.I none
of the GBI commands are supported.
.PP
However, blocks of DP commands are supported within the global and
object state. These commands are the same format (and use the
same macros) as in gbi.h. Some DP commands are not supported
because they either manipulate DP state that is irrelevant to
the turbo geometry or they interfere with the turbo display list
processing.
.PP
The following DP GBI commands are
.I not
supported with this microcode:
.nf
.ta 5 28
.sp
.I gDPPipelineMode
.I gDPSetCycleType
.I gDPSetTexturePersp
.I gDPSetTextureDetail
.I gDPSetTextureLOD
.I gDPSetTextureLUT
.I gDPSetTextureFilter
.I gDPSetTextureConvert
.I gDPSetCombineKey
.I gDPSetColorDither
.I gDPSetAlphaDither
.I gDPSetAlphaCompare
.I gDPSetDepthSource
.I gDPSetRenderMode
.fi
.PP
Many of these (those that make sense for the reduced feature set) can
be set using the
.I gtStateSetOthermode (3P)
interface.
.SH PERFORMANCE
In order from fastest to slowest, the following types of triangles can
be generated by this ucode:
.PP
.nf
.ta 5 20
.I Filled Flat Shaded
(must set primitive color in DP appropriately)
.I Gouraud Shaded
.I Gouraud Shaded, Textured
.I Gouraud Shaded, Z-buffered
.I Gouraud Shaded, Textured, Z-buffered
.fi
.PP
Triangle attribute computation is heavily vectorized, so
generation of Gouraud shading attributes is essentially free,
if you are generating any other attributes.
.PP
Z-buffered triangles require a little additional processing.
.PP
Vertex transformations are heavily
vectorized, so it is best to operate on as many vertices
as possible. Vertices are processed in groups of four, so
loads that are a multiple of four would be the most efficient.
.PP
The RCP is designed to draw high-quality textured primitives.
Where possible, you should use texture-mapping to achieve visual
complexity rather than additional geometry.
.SH BUGS
None
.SH SEE ALSO
.IR gtStateSetOthermode (3P),
.IR gDPClearOtherMode (3P),
.IR gDPEndDisplayList (3P),
.IR gspFast3D (3P),
.IR gspLine3D (3P)