KallistiOS  ##version##
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
pvr.h
Go to the documentation of this file.
1 /* KallistiOS ##version##
2 
3  dc/pvr.h
4  Copyright (C) 2002 Dan Potter
5  Copyright (C) 2014 Lawrence Sebald
6 
7  Low-level PVR 3D interface for the DC
8  Note: this API does _not_ handle any sort of transformations
9  (including perspective!) so for that, you should look to KGL.
10 */
11 
12 /** \file dc/pvr.h
13  \brief Low-level PVR (3D hardware) interface.
14 
15  This file provides support for using the PVR 3D hardware in the Dreamcast.
16  Note that this does not handle any sort of perspective transformations or
17  anything of the like. This is just a very thin wrapper around the actual
18  hardware support.
19 
20  This file is used for pretty much everything related to the PVR, from memory
21  management to actual primitive rendering.
22 
23  \author Dan Potter
24  \author Roger Cattermole
25  \author Paul Boese
26  \author Brian Paul
27  \author Lawrence Sebald
28  \author Benoit Miller
29 */
30 
31 #ifndef __DC_PVR_H
32 #define __DC_PVR_H
33 
34 #include <sys/cdefs.h>
35 __BEGIN_DECLS
36 
37 #include <arch/types.h>
38 #include <dc/sq.h>
39 #include <kos/img.h>
40 
41 /* Data types ********************************************************/
42 
43 /** \brief PVR texture memory pointer.
44 
45  Unlike the old "TA" system, PVR pointers in the new system are actually SH-4
46  compatible pointers and can be used directly in place of ta_txr_map().
47 
48  Not that anyone probably even remembers the old TA system anymore... */
49 typedef void * pvr_ptr_t;
50 
51 /** \brief PVR list specification.
52 
53  Each primitive in the PVR is submitted to one of the hardware primitive
54  lists. This type is an identifier for a list.
55 
56  \see pvr_lists
57 */
59 
60 /** \brief PVR polygon context.
61 
62  You should use this more human readable format for specifying your polygon
63  contexts, and then compile them into polygon headers when you are ready to
64  start using them.
65 
66  This has embedded structures in it for two reasons; the first reason is to
67  make it easier for me to add new stuff later without breaking existing code.
68  The second reason is to make it more readable and usable.
69 
70  Unfortunately, it seems that Doxygen chokes up a little bit on this
71  structure, and others like it. The documentation should still be mostly
72  understandable though...
73 
74  \headerfile dc/pvr.h
75 */
76 typedef struct {
77  int list_type; /**< \brief Primitive list
78  \see pvr_lists */
79  struct {
80  int alpha; /**< \brief Enable or disable alpha outside modifier
81  \see pvr_alpha_switch */
82  int shading; /**< \brief Shading type
83  \see pvr_shading_types */
84  int fog_type; /**< \brief Fog type outside modifier
85  \see pvr_fog_types */
86  int culling; /**< \brief Culling mode
87  \see pvr_cull_modes */
88  int color_clamp; /**< \brief Color clamp enable/disable outside modifier
89  \see pvr_colclamp_switch */
90  int clip_mode; /**< \brief Clipping mode
91  \see pvr_clip_modes */
92  int modifier_mode; /**< \brief Modifier mode */
93  int specular; /**< \brief Offset color enable/disable outside modifier
94  \see pvr_offset_switch */
95  int alpha2; /**< \brief Enable/disable alpha inside modifier
96  \see pvr_alpha_switch */
97  int fog_type2; /**< \brief Fog type inside modifier
98  \see pvr_fog_types */
99  int color_clamp2; /**< \brief Color clamp enable/disable inside modifier
100  \see pvr_colclamp_switch */
101  } gen; /**< \brief General parameters */
102  struct {
103  int src; /**< \brief Source blending mode outside modifier
104  \see pvr_blend_modes */
105  int dst; /**< \brief Dest blending mode outside modifier
106  \see pvr_blend_modes */
107  int src_enable; /**< \brief Source blending enable outside modifier
108  \see pvr_blend_switch */
109  int dst_enable; /**< \brief Dest blending enable outside modifier
110  \see pvr_blend_switch */
111  int src2; /**< \brief Source blending mode inside modifier
112  \see pvr_blend_modes */
113  int dst2; /**< \brief Dest blending mode inside modifier
114  \see pvr_blend_modes */
115  int src_enable2; /**< \brief Source blending mode inside modifier
116  \see pvr_blend_switch */
117  int dst_enable2; /**< \brief Dest blending mode inside modifier
118  \see pvr_blend_switch */
119  } blend; /**< \brief Blending parameters */
120  struct {
121  int color; /**< \brief Color format in vertex
122  \see pvr_color_fmts */
123  int uv; /**< \brief U/V data format in vertex
124  \see pvr_uv_fmts */
125  int modifier; /**< \brief Enable or disable modifier effect
126  \see pvr_mod_switch */
127  } fmt; /**< \brief Format control */
128  struct {
129  int comparison; /**< \brief Depth comparison mode
130  \see pvr_depth_modes */
131  int write; /**< \brief Enable or disable depth writes
132  \see pvr_depth_switch */
133  } depth; /**< \brief Depth comparison/write modes */
134  struct {
135  int enable; /**< \brief Enable/disable texturing
136  \see pvr_txr_switch */
137  int filter; /**< \brief Filtering mode
138  \see pvr_filter_modes */
139  int mipmap; /**< \brief Enable/disable mipmaps
140  \see pvr_mip_switch */
141  int mipmap_bias; /**< \brief Mipmap bias
142  \see pvr_mip_bias */
143  int uv_flip; /**< \brief Enable/disable U/V flipping
144  \see pvr_uv_flip */
145  int uv_clamp; /**< \brief Enable/disable U/V clamping
146  \see pvr_uv_clamp */
147  int alpha; /**< \brief Enable/disable texture alpha
148  \see pvr_txralpha_switch */
149  int env; /**< \brief Texture color contribution
150  \see pvr_txrenv_modes */
151  int width; /**< \brief Texture width (requires a power of 2) */
152  int height; /**< \brief Texture height (requires a power of 2) */
153  int format; /**< \brief Texture format
154  \see pvr_txr_fmts */
155  pvr_ptr_t base; /**< \brief Texture pointer */
156  } txr; /**< \brief Texturing params outside modifier */
157  struct {
158  int enable; /**< \brief Enable/disable texturing
159  \see pvr_txr_switch */
160  int filter; /**< \brief Filtering mode
161  \see pvr_filter_modes */
162  int mipmap; /**< \brief Enable/disable mipmaps
163  \see pvr_mip_switch */
164  int mipmap_bias; /**< \brief Mipmap bias
165  \see pvr_mip_bias */
166  int uv_flip; /**< \brief Enable/disable U/V flipping
167  \see pvr_uv_flip */
168  int uv_clamp; /**< \brief Enable/disable U/V clamping
169  \see pvr_uv_clamp */
170  int alpha; /**< \brief Enable/disable texture alpha
171  \see pvr_txralpha_switch */
172  int env; /**< \brief Texture color contribution
173  \see pvr_txrenv_modes */
174  int width; /**< \brief Texture width (requires a power of 2) */
175  int height; /**< \brief Texture height (requires a power of 2) */
176  int format; /**< \brief Texture format
177  \see pvr_txr_fmts */
178  pvr_ptr_t base; /**< \brief Texture pointer */
179  } txr2; /**< \brief Texturing params inside modifier */
181 
182 /** \brief PVR sprite context.
183 
184  You should use this more human readable format for specifying your sprite
185  contexts, and then compile them into sprite headers when you are ready to
186  start using them.
187 
188  Unfortunately, it seems that Doxygen chokes up a little bit on this
189  structure, and others like it. The documentation should still be mostly
190  understandable though...
191 
192  \headerfile dc/pvr.h
193 */
194 typedef struct {
195  int list_type; /**< \brief Primitive list
196  \see pvr_lists */
197  struct {
198  int alpha; /**< \brief Enable or disable alpha
199  \see pvr_alpha_switch */
200  int fog_type; /**< \brief Fog type
201  \see pvr_fog_types */
202  int culling; /**< \brief Culling mode
203  \see pvr_cull_modes */
204  int color_clamp; /**< \brief Color clamp enable/disable
205  \see pvr_colclamp_switch */
206  int clip_mode; /**< \brief Clipping mode
207  \see pvr_clip_modes */
208  int specular; /**< \brief Offset color enable/disable
209  \see pvr_offset_switch */
210  } gen; /**< \brief General parameters */
211  struct {
212  int src; /**< \brief Source blending mode
213  \see pvr_blend_modes */
214  int dst; /**< \brief Dest blending mode
215  \see pvr_blend_modes */
216  int src_enable; /**< \brief Source blending enable
217  \see pvr_blend_switch */
218  int dst_enable; /**< \brief Dest blending enable
219  \see pvr_blend_switch */
220  } blend;
221  struct {
222  int comparison; /**< \brief Depth comparison mode
223  \see pvr_depth_modes */
224  int write; /**< \brief Enable or disable depth writes
225  \see pvr_depth_switch */
226  } depth; /**< \brief Depth comparison/write modes */
227  struct {
228  int enable; /**< \brief Enable/disable texturing
229  \see pvr_txr_switch */
230  int filter; /**< \brief Filtering mode
231  \see pvr_filter_modes */
232  int mipmap; /**< \brief Enable/disable mipmaps
233  \see pvr_mip_switch */
234  int mipmap_bias; /**< \brief Mipmap bias
235  \see pvr_mip_bias */
236  int uv_flip; /**< \brief Enable/disable U/V flipping
237  \see pvr_uv_flip */
238  int uv_clamp; /**< \brief Enable/disable U/V clamping
239  \see pvr_uv_clamp */
240  int alpha; /**< \brief Enable/disable texture alpha
241  \see pvr_txralpha_switch */
242  int env; /**< \brief Texture color contribution
243  \see pvr_txrenv_modes */
244  int width; /**< \brief Texture width (requires a power of 2) */
245  int height; /**< \brief Texture height (requires a power of 2) */
246  int format; /**< \brief Texture format
247  \see pvr_txr_fmts */
248  pvr_ptr_t base; /**< \brief Texture pointer */
249  } txr; /**< \brief Texturing params */
251 
252 /* Constants for the above structure; thanks to Benoit Miller for these */
253 
254 /** \defgroup pvr_lists PVR primitive list types
255 
256  Each primitive submitted to the PVR must be placed in one of these lists,
257  depending on its characteristics.
258 
259  @{
260 */
261 #define PVR_LIST_OP_POLY 0 /**< \brief Opaque polygon list */
262 #define PVR_LIST_OP_MOD 1 /**< \brief Opaque modifier list */
263 #define PVR_LIST_TR_POLY 2 /**< \brief Translucent polygon list */
264 #define PVR_LIST_TR_MOD 3 /**< \brief Translucent modifier list*/
265 #define PVR_LIST_PT_POLY 4 /**< \brief Punch-thru polygon list */
266 /** @} */
267 
268 /** \defgroup pvr_shading_types PVR shading modes
269 
270  Each polygon can define how it wants to be shaded, be it with flat or
271  Gouraud shading using these constants in the appropriate place in its
272  pvr_poly_cxt_t.
273 
274  @{
275 */
276 #define PVR_SHADE_FLAT 0 /**< \brief Use flat shading */
277 #define PVR_SHADE_GOURAUD 1 /**< \brief Use Gouraud shading */
278 /** @} */
279 
280 /** \defgroup pvr_depth_modes PVR depth comparison modes
281 
282  These set the depth function used for comparisons.
283 
284  @{
285 */
286 #define PVR_DEPTHCMP_NEVER 0 /**< \brief Never pass */
287 #define PVR_DEPTHCMP_LESS 1 /**< \brief Less than */
288 #define PVR_DEPTHCMP_EQUAL 2 /**< \brief Equal to */
289 #define PVR_DEPTHCMP_LEQUAL 3 /**< \brief Less than or equal to */
290 #define PVR_DEPTHCMP_GREATER 4 /**< \brief Greater than */
291 #define PVR_DEPTHCMP_NOTEQUAL 5 /**< \brief Not equal to */
292 #define PVR_DEPTHCMP_GEQUAL 6 /**< \brief Greater than or equal to */
293 #define PVR_DEPTHCMP_ALWAYS 7 /**< \brief Always pass */
294 /** @} */
295 
296 /** \defgroup pvr_cull_modes PVR culling modes
297 
298  These culling modes can be set by polygons to determine when they are
299  culled. They work pretty much as you'd expect them to if you've ever used
300  any 3D hardware before.
301 
302  @{
303 */
304 #define PVR_CULLING_NONE 0 /**< \brief Disable culling */
305 #define PVR_CULLING_SMALL 1 /**< \brief Cull if small */
306 #define PVR_CULLING_CCW 2 /**< \brief Cull if counterclockwise */
307 #define PVR_CULLING_CW 3 /**< \brief Cull if clockwise */
308 /** @} */
309 
310 /** \defgroup pvr_depth_switch Enable or disable PVR depth writes
311  @{
312 */
313 #define PVR_DEPTHWRITE_ENABLE 0 /**< \brief Update the Z value */
314 #define PVR_DEPTHWRITE_DISABLE 1 /**< \brief Do not update the Z value */
315 /** @} */
316 
317 /** \defgroup pvr_txr_switch Enable or disable texturing on polygons
318  @{
319 */
320 #define PVR_TEXTURE_DISABLE 0 /**< \brief Disable texturing */
321 #define PVR_TEXTURE_ENABLE 1 /**< \brief Enable texturing */
322 /** @} */
323 
324 /** \defgroup pvr_blend_modes PVR blending modes
325 
326  These are all the blending modes that can be done with regard to alpha
327  blending on the PVR.
328 
329  @{
330 */
331 #define PVR_BLEND_ZERO 0 /**< \brief None of this color */
332 #define PVR_BLEND_ONE 1 /**< \brief All of this color */
333 #define PVR_BLEND_DESTCOLOR 2 /**< \brief Destination color */
334 #define PVR_BLEND_INVDESTCOLOR 3 /**< \brief Inverse of destination color */
335 #define PVR_BLEND_SRCALPHA 4 /**< \brief Blend with source alpha */
336 #define PVR_BLEND_INVSRCALPHA 5 /**< \brief Blend with inverse source alpha */
337 #define PVR_BLEND_DESTALPHA 6 /**< \brief Blend with destination alpha */
338 #define PVR_BLEND_INVDESTALPHA 7 /**< \brief Blend with inverse destination alpha */
339 /** @} */
340 
341 /** \defgroup pvr_blend_switch Enable or disable blending
342  @{
343 */
344 #define PVR_BLEND_DISABLE 0 /**< \brief Disable blending */
345 #define PVR_BLEND_ENABLE 1 /**< \brief Enable blending */
346 /** @} */
347 
348 /** \defgroup pvr_fog_types PVR fog modes
349 
350  Each polygon can decide what fog type is used with regard to it using these
351  constants in its pvr_poly_cxt_t.
352 
353  @{
354 */
355 #define PVR_FOG_TABLE 0 /**< \brief Table fog */
356 #define PVR_FOG_VERTEX 1 /**< \brief Vertex fog */
357 #define PVR_FOG_DISABLE 2 /**< \brief Disable fog */
358 #define PVR_FOG_TABLE2 3 /**< \brief Table fog mode 2 */
359 /** @} */
360 
361 /** \defgroup pvr_clip_modes PVR clipping modes
362 
363  These control how primitives are clipped against the user clipping area.
364 
365  @{
366 */
367 #define PVR_USERCLIP_DISABLE 0 /**< \brief Disable clipping */
368 #define PVR_USERCLIP_INSIDE 2 /**< \brief Enable clipping inside area */
369 #define PVR_USERCLIP_OUTSIDE 3 /**< \brief Enable clipping outside area */
370 /** @} */
371 
372 /** \defgroup pvr_colclamp_switch Enable or disable color clamping
373 
374  Enabling color clamping will clamp colors between the minimum and maximum
375  values before any sort of fog processing.
376 
377  @{
378 */
379 #define PVR_CLRCLAMP_DISABLE 0 /**< \brief Disable color clamping */
380 #define PVR_CLRCLAMP_ENABLE 1 /**< \brief Enable color clamping */
381 /** @} */
382 
383 /** \defgroup pvr_offset_switch Enable or disable offset color
384 
385  Enabling offset color calculation allows for "specular" like effects on a
386  per-vertex basis, by providing an additive color in the calculation of the
387  final pixel colors. In vertex types with a "oargb" parameter, that's what it
388  is for.
389 
390  Note that this must be enabled for bumpmap polygons in order to allow you to
391  specify the parameters in the oargb field of the vertices.
392 
393  @{
394 */
395 #define PVR_SPECULAR_DISABLE 0 /**< \brief Disable offset colors */
396 #define PVR_SPECULAR_ENABLE 1 /**< \brief Enable offset colors */
397 /** @} */
398 
399 /** \defgroup pvr_alpha_switch Enable or disable alpha blending
400 
401  This causes the alpha value in the vertex color to be paid attention to. It
402  really only makes sense to enable this for translucent or punch-thru polys.
403 
404  @{
405 */
406 #define PVR_ALPHA_DISABLE 0 /**< \brief Disable alpha blending */
407 #define PVR_ALPHA_ENABLE 1 /**< \brief Enable alpha blending */
408 /** @} */
409 
410 /** \defgroup pvr_txralpha_switch Enable or disable texture alpha blending
411 
412  This causes the alpha value in the texel color to be paid attention to. It
413  really only makes sense to enable this for translucent or punch-thru polys.
414 
415  @{
416 */
417 #define PVR_TXRALPHA_ENABLE 0 /**< \brief Enable alpha blending */
418 #define PVR_TXRALPHA_DISABLE 1 /**< \brief Disable alpha blending */
419 /** @} */
420 
421 /** \defgroup pvr_uv_flip Enable or disable U/V flipping on the PVR
422  @{
423 */
424 #define PVR_UVFLIP_NONE 0 /**< \brief No flipped coordinates */
425 #define PVR_UVFLIP_V 1 /**< \brief Flip V only */
426 #define PVR_UVFLIP_U 2 /**< \brief Flip U only */
427 #define PVR_UVFLIP_UV 3 /**< \brief Flip U and V */
428 /** @} */
429 
430 /** \defgroup pvr_uv_clamp Enable or disable clamping of U/V on the PVR
431  @{
432 */
433 #define PVR_UVCLAMP_NONE 0 /**< \brief Disable clamping */
434 #define PVR_UVCLAMP_V 1 /**< \brief Clamp V only */
435 #define PVR_UVCLAMP_U 2 /**< \brief Clamp U only */
436 #define PVR_UVCLAMP_UV 3 /**< \brief Clamp U and V */
437 /** @} */
438 
439 /** \defgroup pvr_filter_modes PVR texture sampling modes
440  @{
441 */
442 #define PVR_FILTER_NONE 0 /**< \brief No filtering (point sample) */
443 #define PVR_FILTER_NEAREST 0 /**< \brief No filtering (point sample) */
444 #define PVR_FILTER_BILINEAR 2 /**< \brief Bilinear interpolation */
445 #define PVR_FILTER_TRILINEAR1 4 /**< \brief Trilinear interpolation pass 1 */
446 #define PVR_FILTER_TRILINEAR2 6 /**< \brief Trilinear interpolation pass 2 */
447 /** @} */
448 
449 /** \defgroup pvr_mip_bias PVR mipmap bias modes
450  @{
451 */
452 #define PVR_MIPBIAS_NORMAL PVR_MIPBIAS_1_00 /* txr_mipmap_bias */
453 #define PVR_MIPBIAS_0_25 1
454 #define PVR_MIPBIAS_0_50 2
455 #define PVR_MIPBIAS_0_75 3
456 #define PVR_MIPBIAS_1_00 4
457 #define PVR_MIPBIAS_1_25 5
458 #define PVR_MIPBIAS_1_50 6
459 #define PVR_MIPBIAS_1_75 7
460 #define PVR_MIPBIAS_2_00 8
461 #define PVR_MIPBIAS_2_25 9
462 #define PVR_MIPBIAS_2_50 10
463 #define PVR_MIPBIAS_2_75 11
464 #define PVR_MIPBIAS_3_00 12
465 #define PVR_MIPBIAS_3_25 13
466 #define PVR_MIPBIAS_3_50 14
467 #define PVR_MIPBIAS_3_75 15
468 /** @} */
469 
470 /** \defgroup pvr_txrenv_modes Texture color calculation modes
471  @{
472 */
473 #define PVR_TXRENV_REPLACE 0 /**< \brief C = Ct, A = At */
474 #define PVR_TXRENV_MODULATE 1 /**< \brief C = Cs * Ct, A = At */
475 #define PVR_TXRENV_DECAL 2 /**< \brief C = (Cs * At) + (Cs * (1-At)), A = As */
476 #define PVR_TXRENV_MODULATEALPHA 3 /**< \brief C = Cs * Ct, A = As * At */
477 /** @} */
478 
479 /** \defgroup pvr_mip_switch Enable or disable PVR mipmap processing
480  @{
481 */
482 #define PVR_MIPMAP_DISABLE 0 /**< \brief Disable mipmap processing */
483 #define PVR_MIPMAP_ENABLE 1 /**< \brief Enable mipmap processing */
484 /** @} */
485 
486 /** \defgroup pvr_txr_fmts PVR texture formats
487 
488  These are the texture formats that the PVR supports. Note that some of
489  these, you can OR together with other values.
490 
491  @{
492 */
493 #define PVR_TXRFMT_NONE 0 /**< \brief No texture */
494 #define PVR_TXRFMT_VQ_DISABLE (0 << 30) /**< \brief Not VQ encoded */
495 #define PVR_TXRFMT_VQ_ENABLE (1 << 30) /**< \brief VQ encoded */
496 #define PVR_TXRFMT_ARGB1555 (0 << 27) /**< \brief 16-bit ARGB1555 */
497 #define PVR_TXRFMT_RGB565 (1 << 27) /**< \brief 16-bit RGB565 */
498 #define PVR_TXRFMT_ARGB4444 (2 << 27) /**< \brief 16-bit ARGB4444 */
499 #define PVR_TXRFMT_YUV422 (3 << 27) /**< \brief YUV422 format */
500 #define PVR_TXRFMT_BUMP (4 << 27) /**< \brief Bumpmap format */
501 #define PVR_TXRFMT_PAL4BPP (5 << 27) /**< \brief 4BPP paletted format */
502 #define PVR_TXRFMT_PAL8BPP (6 << 27) /**< \brief 8BPP paletted format */
503 #define PVR_TXRFMT_TWIDDLED (0 << 26) /**< \brief Texture is twiddled */
504 #define PVR_TXRFMT_NONTWIDDLED (1 << 26) /**< \brief Texture is not twiddled */
505 #define PVR_TXRFMT_NOSTRIDE (0 << 21) /**< \brief Texture is not strided */
506 #define PVR_TXRFMT_STRIDE (1 << 21) /**< \brief Texture is strided */
507 
508 /* OR one of these into your texture format if you need it. Note that
509  these coincide with the twiddled/stride bits, so you can't have a
510  non-twiddled/strided texture that's paletted! */
511 /** \brief 8BPP palette selector
512  \param x The palette index */
513 #define PVR_TXRFMT_8BPP_PAL(x) ((x) << 25)
514 
515 /** \brief 4BPP palette selector
516  \param x The palette index */
517 #define PVR_TXRFMT_4BPP_PAL(x) ((x) << 21)
518 /** @} */
519 
520 /** \defgroup pvr_color_fmts PVR vertex color formats
521 
522  These control how colors are represented in polygon data.
523 
524  @{
525 */
526 #define PVR_CLRFMT_ARGBPACKED 0 /**< \brief 32-bit integer ARGB */
527 #define PVR_CLRFMT_4FLOATS 1 /**< \brief 4 floating point values */
528 #define PVR_CLRFMT_INTENSITY 2 /**< \brief Intensity color */
529 #define PVR_CLRFMT_INTENSITY_PREV 3 /**< \brief Use last intensity */
530 /** @} */
531 
532 /** \defgroup pvr_uv_fmts PVR U/V data format control
533  @{
534 */
535 #define PVR_UVFMT_32BIT 0 /**< \brief 32-bit floating point U/V */
536 #define PVR_UVFMT_16BIT 1 /**< \brief 16-bit floating point U/V */
537 /** @} */
538 
539 /** \defgroup pvr_mod_switch Enable or disable modifier effects
540  @{
541 */
542 #define PVR_MODIFIER_DISABLE 0 /**< \brief Disable modifier effects */
543 #define PVR_MODIFIER_ENABLE 1 /**< \brief Enable modifier effects */
544 /** @} */
545 
546 #define PVR_MODIFIER_CHEAP_SHADOW 0
547 #define PVR_MODIFIER_NORMAL 1
548 
549 /** \defgroup pvr_mod_modes Modifier volume mode parameters
550 
551  All triangles in a single modifier volume should be of the other poly type,
552  except for the last one. That should be either of the other two types,
553  depending on whether you want an inclusion or exclusion volume.
554 
555  @{
556 */
557 #define PVR_MODIFIER_OTHER_POLY 0 /**< \brief Not the last polygon in the volume */
558 #define PVR_MODIFIER_INCLUDE_LAST_POLY 1 /**< \brief Last polygon, inclusion volume */
559 #define PVR_MODIFIER_EXCLUDE_LAST_POLY 2 /**< \brief Last polygon, exclusion volume */
560 /** @} */
561 
562 
563 /** \brief PVR polygon header.
564 
565  This is the hardware equivalent of a rendering context; you'll create one of
566  these from your pvr_poly_cxt_t and use it for submission to the hardware.
567 
568  \headerfile dc/pvr.h
569 */
570 typedef struct {
571  uint32 cmd; /**< \brief TA command */
572  uint32 mode1; /**< \brief Parameter word 1 */
573  uint32 mode2; /**< \brief Parameter word 2 */
574  uint32 mode3; /**< \brief Parameter word 3 */
575  uint32 d1; /**< \brief Dummy value */
576  uint32 d2; /**< \brief Dummy value */
577  uint32 d3; /**< \brief Dummy value */
578  uint32 d4; /**< \brief Dummy value */
580 
581 /** \brief PVR polygon header with intensity color.
582 
583  This is the equivalent of pvr_poly_hdr_t, but for use with intensity color.
584 
585  \headerfile dc/pvr.h
586 */
587 typedef struct {
588  uint32 cmd; /**< \brief TA command */
589  uint32 mode1; /**< \brief Parameter word 1 */
590  uint32 mode2; /**< \brief Parameter word 2 */
591  uint32 mode3; /**< \brief Parameter word 3 */
592  float a; /**< \brief Face color alpha component */
593  float r; /**< \brief Face color red component */
594  float g; /**< \brief Face color green component */
595  float b; /**< \brief Face color blue component */
597 
598 /** \brief PVR polygon header to be used with modifier volumes.
599 
600  This is the equivalent of a pvr_poly_hdr_t for use when a polygon is to be
601  used with modifier volumes.
602 
603  \headerfile dc/pvr.h
604 */
605 typedef struct {
606  uint32 cmd; /**< \brief TA command */
607  uint32 mode1; /**< \brief Parameter word 1 */
608  uint32 mode2_0; /**< \brief Parameter word 2 (outside volume) */
609  uint32 mode3_0; /**< \brief Parameter word 3 (outside volume) */
610  uint32 mode2_1; /**< \brief Parameter word 2 (inside volume) */
611  uint32 mode3_1; /**< \brief Parameter word 3 (inside volume) */
612  uint32 d1; /**< \brief Dummy value */
613  uint32 d2; /**< \brief Dummy value */
615 
616 /** \brief PVR polygon header specifically for sprites.
617 
618  This is the equivalent of a pvr_poly_hdr_t for use when a quad/sprite is to
619  be rendered. Note that the color data is here, not in the vertices.
620 
621  \headerfile dc/pvr.h
622 */
623 typedef struct {
624  uint32 cmd; /**< \brief TA command */
625  uint32 mode1; /**< \brief Parameter word 1 */
626  uint32 mode2; /**< \brief Parameter word 2 */
627  uint32 mode3; /**< \brief Parameter word 3 */
628  uint32 argb; /**< \brief Sprite face color */
629  uint32 oargb; /**< \brief Sprite offset color */
630  uint32 d1; /**< \brief Dummy value */
631  uint32 d2; /**< \brief Dummy value */
633 
634 /** \brief Modifier volume header.
635 
636  This is the header that should be submitted when dealing with setting a
637  modifier volume.
638 
639  \headerfile dc/pvr.h
640 */
641 typedef struct {
642  uint32 cmd; /**< \brief TA command */
643  uint32 mode1; /**< \brief Parameter word 1 */
644  uint32 d1; /**< \brief Dummy value */
645  uint32 d2; /**< \brief Dummy value */
646  uint32 d3; /**< \brief Dummy value */
647  uint32 d4; /**< \brief Dummy value */
648  uint32 d5; /**< \brief Dummy value */
649  uint32 d6; /**< \brief Dummy value */
650 } pvr_mod_hdr_t;
651 
652 /** \brief Generic PVR vertex type.
653 
654  The PVR chip itself supports many more vertex types, but this is the main
655  one that can be used with both textured and non-textured polygons, and is
656  fairly fast.
657 
658  \headerfile dc/pvr.h
659 */
660 typedef struct {
661  uint32 flags; /**< \brief TA command (vertex flags) */
662  float x; /**< \brief X coordinate */
663  float y; /**< \brief Y coordinate */
664  float z; /**< \brief Z coordinate */
665  float u; /**< \brief Texture U coordinate */
666  float v; /**< \brief Texture V coordinate */
667  uint32 argb; /**< \brief Vertex color */
668  uint32 oargb; /**< \brief Vertex offset color */
669 } pvr_vertex_t;
670 
671 /** \brief PVR vertex type: Non-textured, packed color, affected by modifier
672  volume.
673 
674  This vertex type has two copies of colors. The second color is used when
675  enclosed within a modifier volume.
676 
677  \headerfile dc/pvr.h
678 */
679 typedef struct {
680  uint32 flags; /**< \brief TA command (vertex flags) */
681  float x; /**< \brief X coordinate */
682  float y; /**< \brief Y coordinate */
683  float z; /**< \brief Z coordinate */
684  uint32 argb0; /**< \brief Vertex color (outside volume) */
685  uint32 argb1; /**< \brief Vertex color (inside volume) */
686  uint32 d1; /**< \brief Dummy value */
687  uint32 d2; /**< \brief Dummy value */
689 
690 /** \brief PVR vertex type: Textured, packed color, affected by modifer volume.
691 
692  Note that this vertex type has two copies of colors, offset colors, and
693  texture coords. The second set of texture coords, colors, and offset colors
694  are used when enclosed within a modifer volume.
695 
696  \headerfile dc/pvr.h
697 */
698 typedef struct {
699  uint32 flags; /**< \brief TA command (vertex flags) */
700  float x; /**< \brief X coordinate */
701  float y; /**< \brief Y coordinate */
702  float z; /**< \brief Z coordinate */
703  float u0; /**< \brief Texture U coordinate (outside) */
704  float v0; /**< \brief Texture V coordinate (outside) */
705  uint32 argb0; /**< \brief Vertex color (outside) */
706  uint32 oargb0; /**< \brief Vertex offset color (outside) */
707  float u1; /**< \brief Texture U coordinate (inside) */
708  float v1; /**< \brief Texture V coordinate (inside) */
709  uint32 argb1; /**< \brief Vertex color (inside) */
710  uint32 oargb1; /**< \brief Vertex offset color (inside) */
711  uint32 d1; /**< \brief Dummy value */
712  uint32 d2; /**< \brief Dummy value */
713  uint32 d3; /**< \brief Dummy value */
714  uint32 d4; /**< \brief Dummy value */
716 
717 /** \brief PVR vertex type: Textured sprite.
718 
719  This vertex type is to be used with the sprite polygon header and the sprite
720  related commands to draw textured sprites. Note that there is no fourth Z
721  coordinate. I suppose it just gets interpolated?
722 
723  The U/V coordinates in here are in the 16-bit per coordinate form. Also,
724  like the fourth Z value, there is no fourth U or V, so it must get
725  interpolated from the others.
726 
727  \headerfile dc/pvr.h
728 */
729 typedef struct {
730  uint32 flags; /**< \brief TA command (vertex flags) */
731  float ax; /**< \brief First X coordinate */
732  float ay; /**< \brief First Y coordinate */
733  float az; /**< \brief First Z coordinate */
734  float bx; /**< \brief Second X coordinate */
735  float by; /**< \brief Second Y coordinate */
736  float bz; /**< \brief Second Z coordinate */
737  float cx; /**< \brief Third X coordinate */
738  float cy; /**< \brief Third Y coordinate */
739  float cz; /**< \brief Third Z coordinate */
740  float dx; /**< \brief Fourth X coordinate */
741  float dy; /**< \brief Fourth Y coordinate */
742  uint32 dummy; /**< \brief Dummy value */
743  uint32 auv; /**< \brief First U/V texture coordinates */
744  uint32 buv; /**< \brief Second U/V texture coordinates */
745  uint32 cuv; /**< \brief Third U/V texture coordinates */
747 
748 /** \brief PVR vertex type: Untextured sprite.
749 
750  This vertex type is to be used with the sprite polygon header and the sprite
751  related commands to draw untextured sprites (aka, quads).
752 */
753 typedef struct {
754  uint32 flags; /**< \brief TA command (vertex flags) */
755  float ax; /**< \brief First X coordinate */
756  float ay; /**< \brief First Y coordinate */
757  float az; /**< \brief First Z coordinate */
758  float bx; /**< \brief Second X coordinate */
759  float by; /**< \brief Second Y coordinate */
760  float bz; /**< \brief Second Z coordinate */
761  float cx; /**< \brief Third X coordinate */
762  float cy; /**< \brief Third Y coordinate */
763  float cz; /**< \brief Third Z coordinate */
764  float dx; /**< \brief Fourth X coordinate */
765  float dy; /**< \brief Fourth Y coordinate */
766  uint32 d1; /**< \brief Dummy value */
767  uint32 d2; /**< \brief Dummy value */
768  uint32 d3; /**< \brief Dummy value */
769  uint32 d4; /**< \brief Dummy value */
771 
772 /** \brief PVR vertex type: Modifier volume.
773 
774  This vertex type is to be used with the modifier volume header to specify
775  triangular modifier areas.
776 */
777 typedef struct {
778  uint32 flags; /**< \brief TA command (vertex flags) */
779  float ax; /**< \brief First X coordinate */
780  float ay; /**< \brief First Y coordinate */
781  float az; /**< \brief First Z coordinate */
782  float bx; /**< \brief Second X coordinate */
783  float by; /**< \brief Second Y coordinate */
784  float bz; /**< \brief Second Z coordinate */
785  float cx; /**< \brief Third X coordinate */
786  float cy; /**< \brief Third Y coordinate */
787  float cz; /**< \brief Third Z coordinate */
788  uint32 d1; /**< \brief Dummy value */
789  uint32 d2; /**< \brief Dummy value */
790  uint32 d3; /**< \brief Dummy value */
791  uint32 d4; /**< \brief Dummy value */
792  uint32 d5; /**< \brief Dummy value */
793  uint32 d6; /**< \brief Dummy value */
795 
796 /** \brief Pack four floating point color values into a 32-bit integer form.
797 
798  All of the color values should be between 0 and 1.
799 
800  \param a Alpha value
801  \param r Red value
802  \param g Green value
803  \param b Blue value
804  \return The packed color value
805 */
806 #define PVR_PACK_COLOR(a, r, g, b) ( \
807  ( ((uint8)( a * 255 ) ) << 24 ) | \
808  ( ((uint8)( r * 255 ) ) << 16 ) | \
809  ( ((uint8)( g * 255 ) ) << 8 ) | \
810  ( ((uint8)( b * 255 ) ) << 0 ) )
811 
812 /** \brief Pack two floating point coordinates into one 32-bit value,
813  truncating them to 16-bits each.
814 
815  \param u First coordinate to pack
816  \param v Second coordinate to pack
817  \return The packed coordinates
818 */
819 static inline uint32 PVR_PACK_16BIT_UV(float u, float v) {
820  return (((*((uint32 *) &u)) >> 0) & 0xFFFF0000) |
821  (((*((uint32 *) &v)) >> 16) & 0x0000FFFF);
822 }
823 
824 /** \defgroup pvr_commands TA command values
825 
826  These are are appropriate values for TA commands. Use whatever goes with the
827  primitive type you're using.
828 
829  @{
830 */
831 #define PVR_CMD_POLYHDR 0x80840000 /**< \brief PVR polygon header.
832 Striplength set to 2 */
833 #define PVR_CMD_VERTEX 0xe0000000 /**< \brief PVR vertex data */
834 #define PVR_CMD_VERTEX_EOL 0xf0000000 /**< \brief PVR vertex, end of strip */
835 #define PVR_CMD_USERCLIP 0x20000000 /**< \brief PVR user clipping area */
836 #define PVR_CMD_MODIFIER 0x80000000 /**< \brief PVR modifier volume */
837 #define PVR_CMD_SPRITE 0xA0000000 /**< \brief PVR sprite header */
838 /** @} */
839 
840 /** \defgroup pvr_bitmasks Constants and bitmasks for handling polygon
841  headers.
842 
843  Note that thanks to the arrangement of constants, this is mainly a matter of
844  bit shifting to compile headers...
845 
846  @{
847 */
848 #define PVR_TA_CMD_TYPE_SHIFT 24
849 #define PVR_TA_CMD_TYPE_MASK (7 << PVR_TA_CMD_TYPE_SHIFT)
851 #define PVR_TA_CMD_USERCLIP_SHIFT 16
852 #define PVR_TA_CMD_USERCLIP_MASK (3 << PVR_TA_CMD_USERCLIP_SHIFT)
854 #define PVR_TA_CMD_CLRFMT_SHIFT 4
855 #define PVR_TA_CMD_CLRFMT_MASK (7 << PVR_TA_CMD_CLRFMT_SHIFT)
857 #define PVR_TA_CMD_SPECULAR_SHIFT 2
858 #define PVR_TA_CMD_SPECULAR_MASK (1 << PVR_TA_CMD_SPECULAR_SHIFT)
860 #define PVR_TA_CMD_SHADE_SHIFT 1
861 #define PVR_TA_CMD_SHADE_MASK (1 << PVR_TA_CMD_SHADE_SHIFT)
863 #define PVR_TA_CMD_UVFMT_SHIFT 0
864 #define PVR_TA_CMD_UVFMT_MASK (1 << PVR_TA_CMD_UVFMT_SHIFT)
866 #define PVR_TA_CMD_MODIFIER_SHIFT 7
867 #define PVR_TA_CMD_MODIFIER_MASK (1 << PVR_TA_CMD_MODIFIER_SHIFT)
869 #define PVR_TA_CMD_MODIFIERMODE_SHIFT 6
870 #define PVR_TA_CMD_MODIFIERMODE_MASK (1 << PVR_TA_CMD_MODIFIERMODE_SHIFT)
872 #define PVR_TA_PM1_DEPTHCMP_SHIFT 29
873 #define PVR_TA_PM1_DEPTHCMP_MASK (7 << PVR_TA_PM1_DEPTHCMP_SHIFT)
875 #define PVR_TA_PM1_CULLING_SHIFT 27
876 #define PVR_TA_PM1_CULLING_MASK (3 << PVR_TA_PM1_CULLING_SHIFT)
878 #define PVR_TA_PM1_DEPTHWRITE_SHIFT 26
879 #define PVR_TA_PM1_DEPTHWRITE_MASK (1 << PVR_TA_PM1_DEPTHWRITE_SHIFT)
881 #define PVR_TA_PM1_TXRENABLE_SHIFT 25
882 #define PVR_TA_PM1_TXRENABLE_MASK (1 << PVR_TA_PM1_TXRENABLE_SHIFT)
884 #define PVR_TA_PM1_MODIFIERINST_SHIFT 29
885 #define PVR_TA_PM1_MODIFIERINST_MASK (3 << PVR_TA_PM1_MODIFIERINST_SHIFT)
887 #define PVR_TA_PM2_SRCBLEND_SHIFT 29
888 #define PVR_TA_PM2_SRCBLEND_MASK (7 << PVR_TA_PM2_SRCBLEND_SHIFT)
890 #define PVR_TA_PM2_DSTBLEND_SHIFT 26
891 #define PVR_TA_PM2_DSTBLEND_MASK (7 << PVR_TA_PM2_DSTBLEND_SHIFT)
893 #define PVR_TA_PM2_SRCENABLE_SHIFT 25
894 #define PVR_TA_PM2_SRCENABLE_MASK (1 << PVR_TA_PM2_SRCENABLE_SHIFT)
896 #define PVR_TA_PM2_DSTENABLE_SHIFT 24
897 #define PVR_TA_PM2_DSTENABLE_MASK (1 << PVR_TA_PM2_DSTENABLE_SHIFT)
899 #define PVR_TA_PM2_FOG_SHIFT 22
900 #define PVR_TA_PM2_FOG_MASK (3 << PVR_TA_PM2_FOG_SHIFT)
902 #define PVR_TA_PM2_CLAMP_SHIFT 21
903 #define PVR_TA_PM2_CLAMP_MASK (1 << PVR_TA_PM2_CLAMP_SHIFT)
905 #define PVR_TA_PM2_ALPHA_SHIFT 20
906 #define PVR_TA_PM2_ALPHA_MASK (1 << PVR_TA_PM2_ALPHA_SHIFT)
908 #define PVR_TA_PM2_TXRALPHA_SHIFT 19
909 #define PVR_TA_PM2_TXRALPHA_MASK (1 << PVR_TA_PM2_TXRALPHA_SHIFT)
911 #define PVR_TA_PM2_UVFLIP_SHIFT 17
912 #define PVR_TA_PM2_UVFLIP_MASK (3 << PVR_TA_PM2_UVFLIP_SHIFT)
914 #define PVR_TA_PM2_UVCLAMP_SHIFT 15
915 #define PVR_TA_PM2_UVCLAMP_MASK (3 << PVR_TA_PM2_UVCLAMP_SHIFT)
917 #define PVR_TA_PM2_FILTER_SHIFT 12
918 #define PVR_TA_PM2_FILTER_MASK (7 << PVR_TA_PM2_FILTER_SHIFT)
920 #define PVR_TA_PM2_MIPBIAS_SHIFT 8
921 #define PVR_TA_PM2_MIPBIAS_MASK (15 << PVR_TA_PM2_MIPBIAS_SHIFT)
923 #define PVR_TA_PM2_TXRENV_SHIFT 6
924 #define PVR_TA_PM2_TXRENV_MASK (3 << PVR_TA_PM2_TXRENV_SHIFT)
926 #define PVR_TA_PM2_USIZE_SHIFT 3
927 #define PVR_TA_PM2_USIZE_MASK (7 << PVR_TA_PM2_USIZE_SHIFT)
929 #define PVR_TA_PM2_VSIZE_SHIFT 0
930 #define PVR_TA_PM2_VSIZE_MASK (7 << PVR_TA_PM2_VSIZE_SHIFT)
932 #define PVR_TA_PM3_MIPMAP_SHIFT 31
933 #define PVR_TA_PM3_MIPMAP_MASK (1 << PVR_TA_PM3_MIPMAP_SHIFT)
935 #define PVR_TA_PM3_TXRFMT_SHIFT 0
936 #define PVR_TA_PM3_TXRFMT_MASK 0xffffffff
937 /** @} */
938 
939 /**** Register macros ***************************************************/
940 
941 /* We use these macros to do all PVR register access, so that it's
942  simple later on to hook them for debugging or whatnot. */
943 
944 /** \brief Retrieve a PVR register value
945  \param REG The register to fetch
946  \return The value of that register (32-bits)
947 */
948 #define PVR_GET(REG) (* ( (uint32*)( 0xa05f8000 + (REG) ) ) )
950 /** \brief Set a PVR register value
951  \param REG The register to set
952  \param VALUE The value to set in the register (32-bits)
953 */
954 #define PVR_SET(REG, VALUE) PVR_GET(REG) = (VALUE)
956 /* The registers themselves; these are from Maiwe's powervr-reg.txt */
957 /* Note that 2D specific registers have been excluded for now (like
958  vsync, hsync, v/h size, etc) */
959 
960 /** \defgroup pvr_regs Offsets to registers of the PVR
961  @{
962 */
963 #define PVR_ID 0x0000 /**< \brief Chip ID */
964 #define PVR_REVISION 0x0004 /**< \brief Chip revision */
965 #define PVR_RESET 0x0008 /**< \brief Reset pins */
966 #define PVR_ISP_START 0x0014 /**< \brief Start the ISP/TSP */
967 #define PVR_UNK_0018 0x0018 /**< \brief ?? */
968 #define PVR_ISP_VERTBUF_ADDR 0x0020 /**< \brief Vertex buffer address for scene rendering */
969 #define PVR_ISP_TILEMAT_ADDR 0x002c /**< \brief Tile matrix address for scene rendering */
970 #define PVR_SPANSORT_CFG 0x0030 /**< \brief ?? -- write 0x101 for now */
971 #define PVR_FB_CFG_1 0x0044 /**< \brief Framebuffer config 1 */
972 #define PVR_FB_CFG_2 0x0048 /**< \brief Framebuffer config 2 */
973 #define PVR_RENDER_MODULO 0x004c /**< \brief Render modulo */
974 #define PVR_RENDER_ADDR 0x0060 /**< \brief Render output address */
975 #define PVR_RENDER_ADDR_2 0x0064 /**< \brief Output for strip-buffering */
976 #define PVR_PCLIP_X 0x0068 /**< \brief Horizontal clipping area */
977 #define PVR_PCLIP_Y 0x006c /**< \brief Vertical clipping area */
978 #define PVR_CHEAP_SHADOW 0x0074 /**< \brief Cheap shadow control */
979 #define PVR_OBJECT_CLIP 0x0078 /**< \brief Distance for polygon culling */
980 #define PVR_UNK_007C 0x007c /**< \brief ?? -- write 0x0027df77 for now */
981 #define PVR_UNK_0080 0x0080 /**< \brief ?? -- write 7 for now */
982 #define PVR_TEXTURE_CLIP 0x0084 /**< \brief Distance for texture clipping */
983 #define PVR_BGPLANE_Z 0x0088 /**< \brief Distance for background plane */
984 #define PVR_BGPLANE_CFG 0x008c /**< \brief Background plane config */
985 #define PVR_UNK_0098 0x0098 /**< \brief ?? -- write 0x00800408 for now */
986 #define PVR_UNK_00A0 0x00a0 /**< \brief ?? -- write 0x20 for now */
987 #define PVR_UNK_00A8 0x00a8 /**< \brief ?? -- write 0x15d1c951 for now */
988 #define PVR_FOG_TABLE_COLOR 0x00b0 /**< \brief Table fog color */
989 #define PVR_FOG_VERTEX_COLOR 0x00b4 /**< \brief Vertex fog color */
990 #define PVR_FOG_DENSITY 0x00b8 /**< \brief Fog density coefficient */
991 #define PVR_COLOR_CLAMP_MAX 0x00bc /**< \brief RGB Color clamp max */
992 #define PVR_COLOR_CLAMP_MIN 0x00c0 /**< \brief RGB Color clamp min */
993 #define PVR_GUN_POS 0x00c4 /**< \brief Light gun position */
994 #define PVR_UNK_00C8 0x00c8 /**< \brief ?? -- write same as border H in 00d4 << 16 */
995 #define PVR_VPOS_IRQ 0x00cc /**< \brief Vertical position IRQ */
996 #define PVR_TEXTURE_MODULO 0x00e4 /**< \brief Output texture width modulo */
997 #define PVR_VIDEO_CFG 0x00e8 /**< \brief Misc video config */
998 #define PVR_SCALER_CFG 0x00f4 /**< \brief Smoothing scaler */
999 #define PVR_PALETTE_CFG 0x0108 /**< \brief Palette format */
1000 #define PVR_SYNC_STATUS 0x010c /**< \brief V/H blank status */
1001 #define PVR_UNK_0110 0x0110 /**< \brief ?? -- write 0x93f39 for now */
1002 #define PVR_UNK_0114 0x0114 /**< \brief ?? -- write 0x200000 for now */
1003 #define PVR_UNK_0118 0x0118 /**< \brief ?? -- write 0x8040 for now */
1004 #define PVR_TA_OPB_START 0x0124 /**< \brief Object Pointer Buffer start for TA usage */
1005 #define PVR_TA_VERTBUF_START 0x0128 /**< \brief Vertex buffer start for TA usage */
1006 #define PVR_TA_OPB_END 0x012c /**< \brief OPB end for TA usage */
1007 #define PVR_TA_VERTBUF_END 0x0130 /**< \brief Vertex buffer end for TA usage */
1008 #define PVR_TA_OPB_POS 0x0134 /**< \brief Top used memory location in OPB for TA usage */
1009 #define PVR_TA_VERTBUF_POS 0x0138 /**< \brief Top used memory location in vertbuf for TA usage */
1010 #define PVR_TILEMAT_CFG 0x013c /**< \brief Tile matrix size config */
1011 #define PVR_OPB_CFG 0x0140 /**< \brief Active lists / list size */
1012 #define PVR_TA_INIT 0x0144 /**< \brief Initialize vertex reg. params */
1013 #define PVR_YUV_ADDR 0x0148 /**< \brief YUV conversion destination */
1014 #define PVR_YUV_CFG_1 0x014c /**< \brief YUV configuration */
1015 #define PVR_UNK_0160 0x0160 /**< \brief ?? */
1016 #define PVR_TA_OPB_INIT 0x0164 /**< \brief Object pointer buffer position init */
1017 #define PVR_FOG_TABLE_BASE 0x0200 /**< \brief Base of the fog table */
1018 #define PVR_PALETTE_TABLE_BASE 0x1000 /**< \brief Base of the palette table */
1019 /** @} */
1020 
1021 /* Useful memory locations */
1022 #define PVR_TA_INPUT 0x10000000 /**< \brief TA command input */
1023 #define PVR_RAM_BASE 0xa5000000 /**< \brief PVR RAM (raw) */
1024 #define PVR_RAM_INT_BASE 0xa4000000 /**< \brief PVR RAM (interleaved) */
1026 #define PVR_RAM_SIZE (8*1024*1024) /**< \brief RAM size in bytes */
1028 #define PVR_RAM_TOP (PVR_RAM_BASE + PVR_RAM_SIZE) /**< \brief Top of raw PVR RAM */
1029 #define PVR_RAM_INT_TOP (PVR_RAM_INT_BASE + PVR_RAM_SIZE) /**< \brief Top of int PVR RAM */
1031 /* Register content defines, as needed; these will be filled in over time
1032  as the implementation requires them. There's too many to do otherwise. */
1033 
1034 /** \defgroup pvr_reset_vals Values used to reset parts of the PVR
1035 
1036  These values are written to the PVR_RESET register in order to reset the
1037  system or to take it out of reset.
1038 
1039  @{
1040 */
1041 #define PVR_RESET_ALL 0xffffffff /**< \brief Reset the wole PVR */
1042 #define PVR_RESET_NONE 0x00000000 /**< \brief Cancel reset state */
1043 #define PVR_RESET_TA 0x00000001 /**< \brief Reset only the TA */
1044 #define PVR_RESET_ISPTSP 0x00000002 /**< \brief Reset only the ISP/TSP */
1045 /** @} */
1046 
1047 #define PVR_ISP_START_GO 0xffffffff /**< \brief Write to the PVR_ISP_START register to start rendering */
1049 #define PVR_TA_INIT_GO 0x80000000 /**< \brief Write to the PVR_TA_INIT register to confirm settings */
1051 
1052 /* Initialization ****************************************************/
1053 
1054 /* Initialization and shutdown: stuff you should only ever have to do
1055  once in your program. */
1056 
1057 /** \defgroup pvr_binsizes Available sizes for primitive bins
1058  @{
1059 */
1060 #define PVR_BINSIZE_0 0 /**< \brief 0-length (disables the list) */
1061 #define PVR_BINSIZE_8 8 /**< \brief 8-word (32-byte) length */
1062 #define PVR_BINSIZE_16 16 /**< \brief 16-word (64-byte) length */
1063 #define PVR_BINSIZE_32 32 /**< \brief 32-word (128-byte) length */
1064 /** @} */
1065 
1066 /** \brief PVR initialization structure
1067 
1068  This structure defines how the PVR initializes various parts of the system,
1069  including the primitive bin sizes, the vertex buffer size, and whether
1070  vertex DMA will be enabled.
1071 
1072  You essentially fill one of these in, and pass it to pvr_init().
1073 
1074  \headerfile dc/pvr.h
1075 */
1076 typedef struct {
1077  /** \brief Bin sizes.
1078 
1079  The bins go in the following order: opaque polygons, opaque modifiers,
1080  translucent polygons, translucent modifiers, punch-thrus
1081  */
1082  int opb_sizes[5];
1084  /** \brief Vertex buffer size (should be a nice round number) */
1085  int vertex_buf_size;
1087  /** \brief Enable vertex DMA?
1088 
1089  Set to non-zero if we want to enable vertex DMA mode. Note that if this
1090  is set, then _all_ enabled lists need to have a vertex buffer assigned,
1091  even if you never use that list for anything.
1092  */
1093  int dma_enabled;
1095  /** \brief Enable horizontal scaling?
1096 
1097  Set to non-zero if horizontal scaling is to be enabled. By enabling this
1098  setting and stretching your image to double the native screen width, you
1099  can get horizontal full-screen anti-aliasing. */
1100  int fsaa_enabled;
1102  /** \brief Disable translucent polygon autosort?
1103 
1104  Set to non-zero to disable translucent polygon autosorting. By enabling
1105  this setting, the PVR acts more like a traditional Z-buffered system
1106  when rendering translucent polygons, meaning you must pre-sort them
1107  yourself if you want them to appear in the right order. */
1108  int autosort_disabled;
1111 
1112 /** \brief Initialize the PVR chip to ready status.
1113 
1114  This function enables the specified lists and uses the specified parameters.
1115  Note that bins and vertex buffers come from the texture memory pool, so only
1116  allocate what you actually need. Expects that a 2D mode was initialized
1117  already using the vid_* API.
1118 
1119  \param params The set of parameters to initialize with
1120  \retval 0 On success
1121  \retval -1 If the PVR has already been initialized or the video
1122  mode active is not suitable for 3D
1123 */
1124 int pvr_init(pvr_init_params_t *params);
1125 
1126 /** \brief Simple PVR initialization.
1127 
1128  This simpler function initializes the PVR using 16/16 for the opaque
1129  and translucent lists' bin sizes, and 0's for everything else. It sets 512KB
1130  of vertex buffer. This is equivalent to the old ta_init_defaults() for now.
1131 
1132  \retval 0 On success
1133  \retval -1 If the PVR has already been initialized or the video
1134  mode active is not suitable for 3D
1135 */
1136 int pvr_init_defaults();
1137 
1138 /** \brief Shut down the PVR chip from ready status.
1139 
1140  This essentially leaves the video system in 2D mode as it was before the
1141  init.
1142 
1143  \retval 0 On success
1144  \retval -1 If the PVR has not been initialized
1145 */
1146 int pvr_shutdown();
1147 
1148 
1149 /* Misc parameters ***************************************************/
1150 
1151 /* These are miscellaneous parameters you can set which affect the
1152  rendering process. */
1153 
1154 /** \brief Set the background plane color.
1155 
1156  This function sets the color of the area of the screen not covered by any
1157  other polygons.
1158 
1159  \param r Red component of the color to set
1160  \param g Green component of the color to set
1161  \param b Blue component of the color to set
1162 */
1163 void pvr_set_bg_color(float r, float g, float b);
1164 
1165 /** \brief Set cheap shadow parameters.
1166 
1167  This function sets up the PVR cheap shadow parameters for use. You can only
1168  specify one scale value per frame, so the effect that you can get from this
1169  is somewhat limited, but if you want simple shadows, this is the easiest way
1170  to do it.
1171 
1172  Polygons affected by a shadow modifier volume will effectively multiply
1173  their final color by the scale value set here when shadows are enabled and
1174  the polygon is inside the modifier (or outside for exclusion volumes).
1175 
1176  \param enable Set to non-zero to enable cheap shadow mode.
1177  \param scale_value Floating point value (between 0 and 1) representing
1178  how colors of polygons affected by and inside the
1179  volume will be modified by the shadow volume.
1180 */
1181 void pvr_set_shadow_scale(int enable, float scale_value);
1182 
1183 /** \brief Retrieve the current VBlank count.
1184 
1185  This function retrieves the number of VBlank interrupts that have occurred
1186  since the PVR was initialized.
1187 
1188  \return The number of VBlanks since init
1189 */
1190 int pvr_get_vbl_count();
1191 
1192 /* Statistics structure */
1193 /** \brief PVR statistics structure.
1194 
1195  This structure is used to hold various statistics about the operation of the
1196  PVR since initialization.
1197 
1198  \headerfile dc/pvr.h
1199 */
1200 typedef struct pvr_stats {
1201  uint32 enabled_list_mask; /**< \brief Which lists are enabled? */
1202  uint32 vbl_count; /**< \brief VBlank count */
1203  int frame_last_time; /**< \brief Ready-to-Ready length for the last frame in milliseconds */
1204  float frame_rate; /**< \brief Current frame rate (per second) */
1205  int reg_last_time; /**< \brief Registration time for the last frame in milliseconds */
1206  int rnd_last_time; /**< \brief Rendering time for the last frame in milliseconds */
1207  int vtx_buffer_used; /**< \brief Number of bytes used in the vertex buffer for the last frame */
1208  int vtx_buffer_used_max;/**< \brief Number of bytes used in the vertex buffer for the largest frame */
1209  int buf_last_time; /**< \brief DMA buffer file time for the last frame in milliseconds */
1210  uint32 frame_count; /**< \brief Total number of rendered/viewed frames */
1211  /* ... more later as it's implemented ... */
1212 } pvr_stats_t;
1213 
1214 /** \brief Get the current statistics from the PVR.
1215 
1216  This function fills in the pvr_stats_t structure passed in with the current
1217  statistics of the system.
1218 
1219  \param stat The statistics structure to fill in. Must not be
1220  NULL
1221  \retval 0 On success
1222  \retval -1 If the PVR is not initialized
1223 */
1224 int pvr_get_stats(pvr_stats_t *stat);
1225 
1226 
1227 /* Palette management ************************************************/
1228 
1229 /* In addition to its 16-bit truecolor modes, the PVR also supports some
1230  nice paletted modes. These aren't useful for super high quality images
1231  most of the time, but they can be useful for doing some interesting
1232  special effects, like the old cheap "worm hole". */
1233 
1234 /** \defgroup pvr_palfmts PVR palette formats
1235 
1236  Entries in the PVR's palettes can be of any of these formats. Note that you
1237  can only have one format active at a time.
1238 
1239  @{
1240 */
1241 #define PVR_PAL_ARGB1555 0 /**< \brief 16-bit ARGB1555 palette format */
1242 #define PVR_PAL_RGB565 1 /**< \brief 16-bit RGB565 palette format */
1243 #define PVR_PAL_ARGB4444 2 /**< \brief 16-bit ARGB4444 palette format */
1244 #define PVR_PAL_ARGB8888 3 /**< \brief 32-bit ARGB8888 palette format */
1245 /** @} */
1246 
1247 /** \brief Set the palette format.
1248 
1249  This function sets the currently active palette format on the PVR. Each
1250  entry in the palette table is 32-bits in length, regardless of what color
1251  format is in use.
1252 
1253  Be sure to use care when using the PVR_PAL_ARGB8888 format. Rendering speed
1254  is greatly affected (cut about in half) if you use any filtering with
1255  paletted textures with ARGB8888 entries in the palette.
1256 
1257  \param fmt The format to use
1258  \see pvr_palfmts
1259 */
1260 void pvr_set_pal_format(int fmt);
1261 
1262 /** \brief Set a palette value.
1263 
1264  Note that while the color format is variable, each entry is still 32-bits in
1265  length regardless (and you only get a total of 1024 of them). If using one
1266  of the 16-bit palette formats, only the low-order 16-bits of the entry are
1267  valid, and the high bits should be filled in with 0.
1268 
1269  \param idx The index to set to (0-1023)
1270  \param value The color value to set in that palette entry
1271 */
1272 static inline void pvr_set_pal_entry(uint32 idx, uint32 value) {
1273  PVR_SET(PVR_PALETTE_TABLE_BASE + 4 * idx, value);
1274 }
1275 
1276 
1277 /* Hardware Fog parameters *******************************************/
1278 
1279 /* Thanks to Paul Boese for figuring this stuff out */
1280 
1281 /** \brief Set the table fog color.
1282 
1283  This function sets the color of fog for table fog. 0-1 range for all colors.
1284 
1285  \param a Alpha value of the fog
1286  \param r Red value of the fog
1287  \param g Green value of the fog
1288  \param b Blue value of the fog
1289 */
1290 void pvr_fog_table_color(float a, float r, float g, float b);
1291 
1292 /** \brief Set the vertex fog color.
1293 
1294  This function sets the fog color for vertex fog. 0-1 range for all colors.
1295  This function is currently not implemented, as vertex fog is not supported
1296  by KOS. Calling this function will cause an assertion failure.
1297 
1298  \param a Alpha value of the fog
1299  \param r Red value of the fog
1300  \param g Green value of the fog
1301  \param b Blue value of the fog
1302 */
1303 void pvr_fog_vertex_color(float a, float r, float g, float b);
1304 
1305 /** \brief Set the fog far depth.
1306 
1307  This function sets the PVR_FOG_DENSITY register appropriately for the
1308  specified value.
1309 
1310  \param d The depth to set
1311 */
1312 void pvr_fog_far_depth(float d);
1313 
1314 /** \brief Initialize the fog table using an exp2 algorithm (like GL_EXP2).
1315 
1316  This function will automatically set the PVR_FOG_DENSITY register to
1317  259.999999 as a part of its processing, then set up the fog table.
1318 
1319  \param density Fog density value
1320 */
1321 void pvr_fog_table_exp2(float density);
1322 
1323 /** \brief Initialize the fog table using an exp algorithm (like GL_EXP).
1324 
1325  This function will automatically set the PVR_FOG_DENSITY register to
1326  259.999999 as a part of its processing, then set up the fog table.
1327 
1328  \param density Fog density value
1329 */
1330 void pvr_fog_table_exp(float density);
1331 
1332 /** \brief Initialize the fog table using a linear algorithm (like GL_LINEAR).
1333 
1334  This function will set the PVR_FOG_DENSITY register to the as appropriate
1335  for the end value, and initialize the fog table for perspectively correct
1336  linear fog.
1337 
1338  \param start Fog start point
1339  \param end Fog end point
1340 */
1341 void pvr_fog_table_linear(float start, float end);
1342 
1343 /** \brief Set a custom fog table from float values
1344 
1345  This function allows you to specify whatever values you need to for your fog
1346  parameters. All values should be clamped between 0 and 1, and its your
1347  responsibility to set up the PVR_FOG_DENSITY register by calling
1348  pvr_fog_far_depth() with an appropriate value. The table passed in should
1349  have 129 entries, where the 0th entry is farthest from the eye and the last
1350  entry is nearest. Higher values = heavier fog.
1351 
1352  \param tbl1 The table of fog values to set
1353 */
1354 void pvr_fog_table_custom(float tbl1[]);
1355 
1356 
1357 /* Memory management *************************************************/
1358 
1359 /* PVR memory management in KOS uses a modified dlmalloc; see the
1360  source file pvr_mem_core.c for more info. */
1361 
1362 /** \brief Allocate a chunk of memory from texture space.
1363 
1364  This function acts as the memory allocator for the PVR texture RAM pool. It
1365  acts exactly as one would expect a malloc() function to act, returning a
1366  normal pointer that can be directly written to if one desires to do so. All
1367  allocations will be aligned to a 32-byte boundary.
1368 
1369  \param size The amount of memory to allocate
1370  \return A pointer to the memory on success, NULL on error
1371 */
1372 pvr_ptr_t pvr_mem_malloc(size_t size);
1373 
1374 /** \brief Free a block of allocated memory in the PVR RAM pool.
1375 
1376  This function frees memory previously allocated with pvr_mem_malloc().
1377 
1378  \param chunk The location of the start of the block to free
1379 */
1380 void pvr_mem_free(pvr_ptr_t chunk);
1381 
1382 /** \brief Return the number of bytes available still in the PVR RAM pool.
1383  \return The number of bytes available
1384 */
1386 
1387 /** \brief Reset the PVR RAM pool.
1388 
1389  This will essentially free any blocks allocated within the pool. There's
1390  generally not many good reasons for doing this.
1391 */
1392 void pvr_mem_reset();
1393 
1394 /** \brief Print the list of allocated blocks in the PVR RAM pool.
1395 
1396  This function only works if you've enabled KM_DBG in pvr_mem.c.
1397 */
1398 void pvr_mem_print_list();
1399 
1400 /** \brief Print statistics about the PVR RAM pool.
1401 
1402  This prints out statistics like what malloc_stats() provides. Also, if
1403  KM_DBG is enabled in pvr_mem.c, it prints the list of allocated blocks.
1404 */
1405 void pvr_mem_stats();
1406 
1407 /* Scene rendering ***************************************************/
1408 
1409 /* This API is used to submit triangle strips to the PVR via the TA
1410  interace in the chip.
1411 
1412  An important side note about the PVR is that all primitive types
1413  must be submitted grouped together. If you have 10 polygons for each
1414  list type, then the PVR must receive them via the TA by list type,
1415  with a list delimiter in between.
1416 
1417  So there are two modes you can use here. The first mode allows you to
1418  submit data directly to the TA. Your data will be forwarded to the
1419  chip for processing as it is fed to the PVR module. If your data
1420  is easily sorted into the primitive types, then this is the fastest
1421  mode for submitting data.
1422 
1423  The second mode allows you to submit data via main-RAM vertex buffers,
1424  which will be queued until the proper primitive type is active. In this
1425  case, each piece of data is copied into the vertex buffer while the
1426  wrong list is activated, and when the proper list becomes activated,
1427  the data is all sent at once. Ideally this would be via DMA, right
1428  now it is by store queues. This has the advantage of allowing you to
1429  send data in any order and have the PVR functions resolve how it should
1430  get sent to the hardware, but it is slower.
1431 
1432  The nice thing is that any combination of these modes can be used. You
1433  can assign a vertex buffer for any list, and it will be used to hold the
1434  incoming vertex data until the proper list has come up. Or if the proper
1435  list is already up, the data will be submitted directly. So if most of
1436  your polygons are opaque, and you only have a couple of translucents,
1437  you can set a small buffer to gather translucent data and then it will
1438  get sent when you do a pvr_end_scene().
1439 
1440  Thanks to Mikael Kalms for the idea for this API.
1441 
1442  Another somewhat subtle point that bears mentioning is that in the normal
1443  case (interrupts enabled) an interrupt handler will automatically take
1444  care of starting a frame rendering (after scene_finish()) and also
1445  flipping pages when appropriate. */
1446 
1447 /** \brief Is vertex DMA enabled?
1448  \return Non-zero if vertex DMA was enabled at init time
1449 */
1451 
1452 /** \brief Setup a vertex buffer for one of the list types.
1453 
1454  If the specified list type already has a vertex buffer, it will be replaced
1455  by the new one. Note that each buffer should actually be twice as long as
1456  what you will need to hold two frames worth of data).
1457 
1458  You should generally not try to do this at any time besides before a frame
1459  is begun, or Bad Things May Happen.
1460 
1461  \param list The primitive list to set the buffer for.
1462  \param buffer The location of the buffer in main RAM. This must be
1463  aligned to a 32-byte boundary.
1464  \param len The length of the buffer. This must be a multiple of
1465  64, and must be at least 128 (even if you're not
1466  using the list).
1467  \return The old buffer location (if any)
1468 */
1469 void * pvr_set_vertbuf(pvr_list_t list, void * buffer, int len);
1470 
1471 /** \brief Retrieve a pointer to the current output location in the DMA buffer
1472  for the requested list.
1473 
1474  Vertex DMA must globally be enabled for this to work. Data may be added to
1475  this buffer by the user program directly; however, make sure to call
1476  pvr_vertbuf_written() to notify the system of any such changes.
1477 
1478  \param list The primitive list to get the buffer for.
1479  \return The tail of that list's buffer.
1480 */
1481 void * pvr_vertbuf_tail(pvr_list_t list);
1482 
1483 /** \brief Notify the PVR system that data have been written into the output
1484  buffer for the given list.
1485 
1486  This should always be done after writing data directly to these buffers or
1487  it will get overwritten by other data.
1488 
1489  \param list The primitive list that was modified.
1490  \param amt Number of bytes written. Must be a multiple of 32.
1491 */
1492 void pvr_vertbuf_written(pvr_list_t list, uint32 amt);
1493 
1494 /** \brief Set the translucent polygon sort mode for the next frame.
1495 
1496  This function sets the translucent polygon sort mode for the next frame of
1497  output, potentially switching between autosort and presort mode.
1498 
1499  For most programs, you'll probably want to set this at initialization time
1500  (with the autosort_disabled field in the pvr_init_params_t structure) and
1501  not mess with it per-frame. It is recommended that if you do use this
1502  function to change the mode that you should set it each frame to ensure that
1503  the mode is set properly.
1504 
1505  \param presort Set to 1 to set the presort mode for translucent
1506  polygons, set to 0 to use autosort mode.
1507 */
1508 void pvr_set_presort_mode(int presort);
1509 
1510 /** \brief Begin collecting data for a frame of 3D output to the off-screen
1511  frame buffer.
1512 
1513  You must call this function (or pvr_scene_begin_txr()) for ever frame of
1514  output.
1515 */
1516 void pvr_scene_begin();
1517 
1518 /** \brief Begin collecting data for a frame of 3D output to the specified
1519  texture.
1520 
1521  This function currently only supports outputting at the same size as the
1522  actual screen. Thus, make sure rx and ry are at least large enough for that.
1523  For a 640x480 output, rx will generally be 1024 on input and ry 512, as
1524  these are the smallest values that are powers of two and will hold the full
1525  screen sized output.
1526 
1527  \param txr The texture to render to.
1528  \param rx Width of the texture buffer (in pixels).
1529  \param ry Height of the texture buffer (in pixels).
1530 */
1531 void pvr_scene_begin_txr(pvr_ptr_t txr, uint32 *rx, uint32 *ry);
1532 
1533 /** \brief Begin collecting data for the given list type.
1534 
1535  Lists do not have to be submitted in any particular order, but all types of
1536  a list must be submitted at once (unless vertex DMA mode is enabled).
1537 
1538  Note that there is no need to call this function in DMA mode unless you want
1539  to make use of pvr_prim() for compatibility. This function will
1540  automatically call pvr_list_finish() if a list is already opened before
1541  opening the new list.
1542 
1543  \param list The list to open.
1544  \retval 0 On success.
1545  \retval -1 If the specified list has already been closed.
1546 */
1547 int pvr_list_begin(pvr_list_t list);
1548 
1549 /** \brief End collecting data for the current list type.
1550 
1551  Lists can never be opened again within a single frame once they have been
1552  closed. Thus submitting a primitive that belongs in a closed list is
1553  considered an error. Closing a list that is already closed is also an error.
1554 
1555  Note that if you open a list but do not submit any primitives, a blank one
1556  will be submitted to satisfy the hardware. If vertex DMA mode is enabled,
1557  then this simply sets the current list pointer to no list, and none of the
1558  above restrictions apply.
1559 
1560  \retval 0 On success.
1561  \retval -1 On error.
1562 */
1563 int pvr_list_finish();
1564 
1565 /** \brief Submit a primitive of the current list type.
1566 
1567  Note that any values submitted in this fashion will go directly to the
1568  hardware without any sort of buffering, and submitting a primitive of the
1569  wrong type will quite likely ruin your scene. Note that this also will not
1570  work if you haven't begun any list types (i.e., all data is queued). If DMA
1571  is enabled, the primitive will be appended to the end of the currently
1572  selected list's buffer.
1573 
1574  \param data The primitive to submit.
1575  \param size The length of the primitive, in bytes. Must be a
1576  multiple of 32.
1577  \retval 0 On success.
1578  \retval -1 On error.
1579 */
1580 int pvr_prim(void * data, int size);
1581 
1582 /** \brief Direct Rendering state variable type. */
1583 typedef uint32 pvr_dr_state_t;
1585 /** \brief Initialize a state variable for Direct Rendering.
1586 
1587  \param vtx_buf_ptr A variable of type pvr_dr_state_t to init.
1588 */
1589 #define pvr_dr_init(vtx_buf_ptr) do { \
1590  (vtx_buf_ptr) = 0; \
1591  QACR0 = ((((uint32)PVR_TA_INPUT) >> 26) << 2) & 0x1c; \
1592  QACR1 = ((((uint32)PVR_TA_INPUT) >> 26) << 2) & 0x1c; \
1593  } while (0)
1594 
1595 /** \brief Obtain the target address for Direct Rendering.
1596 
1597  \param vtx_buf_ptr State variable for Direct Rendering. Should be of
1598  type pvr_dr_state_t, and must have been initialized
1599  previously in the scene with pvr_dr_init().
1600  \return A write-only destination address where a primitive
1601  should be written to get ready to submit it to the
1602  TA in DR mode.
1603 */
1604 #define pvr_dr_target(vtx_buf_ptr) \
1605  ({ (vtx_buf_ptr) ^= 32; \
1606  (pvr_vertex_t *)(0xe0000000 | (vtx_buf_ptr)); \
1607  })
1608 
1609 /** \brief Commit a primitive written into the Direct Rendering target address.
1610 
1611  \param addr The address returned by pvr_dr_target(), after you
1612  have written the primitive to it.
1613 */
1614 #define pvr_dr_commit(addr) __asm__ __volatile__("pref @%0" : : "r" (addr))
1616 /** \brief Submit a primitive of the given list type.
1617 
1618  Data will be queued in a vertex buffer, thus one must be available for the
1619  list specified (will be asserted by the code).
1620 
1621  \param list The list to submit to.
1622  \param data The primitive to submit.
1623  \param size The size of the primitive in bytes. This must be a
1624  multiple of 32.
1625  \retval 0 On success.
1626  \retval -1 On error.
1627 */
1628 int pvr_list_prim(pvr_list_t list, void * data, int size);
1629 
1630 /** \brief Flush the buffered data of the given list type to the TA.
1631 
1632  This function is currently not implemented, and calling it will result in an
1633  assertion failure. It is intended to be used later in a "hybrid" mode where
1634  both direct and DMA TA submission is possible.
1635 
1636  \param list The list to flush.
1637  \retval -1 On error (it is not possible to succeed).
1638 */
1639 int pvr_list_flush(pvr_list_t list);
1640 
1641 /** \brief Call this after you have finished submitting all data for a frame.
1642 
1643  Once this has been called, you can not submit any more data until one of the
1644  pvr_scene_begin() or pvr_scene_begin_txr() functions is called again.
1645 
1646  \retval 0 On success.
1647  \retval -1 On error (no scene started).
1648 */
1649 int pvr_scene_finish();
1650 
1651 /** \brief Block the caller until the PVR system is ready for another frame to
1652  be submitted.
1653 
1654  The PVR system allocates enough space for two frames: one in data collection
1655  mode, and another in rendering mode. If a frame is currently rendering, and
1656  another frame has already been closed, then the caller cannot do anything
1657  else until the rendering frame completes. Note also that the new frame
1658  cannot be activated except during a vertical blanking period, so this
1659  essentially waits until a rendered frame is complete and a vertical blank
1660  happens.
1661 
1662  \retval 0 On success. A new scene can be started now.
1663  \retval -1 On error. Something is probably very wrong...
1664 */
1665 int pvr_wait_ready();
1666 
1667 /** \brief Check if the PVR system is ready for another frame to be submitted.
1668 
1669  \retval 0 If the PVR is ready for a new scene. You must call
1670  pvr_wait_ready() afterwards, before starting a new
1671  scene.
1672  \retval -1 If the PVR is not ready for a new scene yet.
1673 */
1674 int pvr_check_ready();
1675 
1676 
1677 /* Primitive handling ************************************************/
1678 
1679 /* These functions help you prepare primitives for loading into the
1680  PVR for scene processing. */
1681 
1682 /** \brief Compile a polygon context into a polygon header.
1683 
1684  This function compiles a pvr_poly_cxt_t into the form needed by the hardware
1685  for rendering. This is for use with normal polygon headers.
1686 
1687  \param dst Where to store the compiled header.
1688  \param src The context to compile.
1689 */
1691 
1692 /** \brief Fill in a polygon context for non-textured polygons.
1693 
1694  This function fills in a pvr_poly_cxt_t with default parameters appropriate
1695  for rendering a non-textured polygon in the given list.
1696 
1697  \param dst Where to store the polygon context.
1698  \param list The primitive list to be used.
1699 */
1700 void pvr_poly_cxt_col(pvr_poly_cxt_t *dst, pvr_list_t list);
1701 
1702 /** \brief Fill in a polygon context for a textured polygon.
1703 
1704  This function fills in a pvr_poly_cxt_t with default parameters appropriate
1705  for rendering a textured polygon in the given list.
1706 
1707  \param dst Where to store the polygon context.
1708  \param list The primitive list to be used.
1709  \param textureformat The format of the texture used.
1710  \param tw The width of the texture, in pixels.
1711  \param th The height of the texture, in pixels.
1712  \param textureaddr A pointer to the texture.
1713  \param filtering The type of filtering to use.
1714 
1715  \see pvr_txr_fmts
1716  \see pvr_filter_modes
1717 */
1719  int textureformat, int tw, int th, pvr_ptr_t textureaddr,
1720  int filtering);
1721 
1722 /** \brief Compile a sprite context into a sprite header.
1723 
1724  This function compiles a pvr_sprite_cxt_t into the form needed by the
1725  hardware for rendering. This is for use with sprite headers.
1726 
1727  \param dst Where to store the compiled header.
1728  \param src The context to compile.
1729 */
1731  pvr_sprite_cxt_t *src);
1732 
1733 /** \brief Fill in a sprite context for non-textured sprites.
1734 
1735  This function fills in a pvr_sprite_cxt_t with default parameters
1736  appropriate for rendering a non-textured sprite in the given list.
1737 
1738  \param dst Where to store the sprite context.
1739  \param list The primitive list to be used.
1740 */
1742 
1743 /** \brief Fill in a sprite context for a textured sprite.
1744 
1745  This function fills in a pvr_sprite_cxt_t with default parameters
1746  appropriate for rendering a textured sprite in the given list.
1747 
1748  \param dst Where to store the sprite context.
1749  \param list The primitive list to be used.
1750  \param textureformat The format of the texture used.
1751  \param tw The width of the texture, in pixels.
1752  \param th The height of the texture, in pixels.
1753  \param textureaddr A pointer to the texture.
1754  \param filtering The type of filtering to use.
1755 
1756  \see pvr_txr_fmts
1757  \see pvr_filter_modes
1758 */
1760  int textureformat, int tw, int th, pvr_ptr_t textureaddr,
1761  int filtering);
1762 
1763 /** \brief Create a modifier volume header.
1764 
1765  This function fills in a modifier volume header with the parameters
1766  specified. Note that unlike for polygons and sprites, there is no context
1767  step for modifiers.
1768 
1769  \param dst Where to store the modifier header.
1770  \param list The primitive list to be used.
1771  \param mode The mode for this modifier.
1772  \param cull The culling mode to use.
1773 
1774  \see pvr_mod_modes
1775  \see pvr_cull_modes
1776 */
1777 void pvr_mod_compile(pvr_mod_hdr_t *dst, pvr_list_t list, uint32 mode,
1778  uint32 cull);
1779 
1780 /** \brief Compile a polygon context into a polygon header that is affected by
1781  modifier volumes.
1782 
1783  This function works pretty similarly to pvr_poly_compile(), but compiles
1784  into the header type that is affected by a modifier volume. The context
1785  should have been created with either pvr_poly_cxt_col_mod() or
1786  pvr_poly_cxt_txr_mod().
1787 
1788  \param dst Where to store the compiled header.
1789  \param src The context to compile.
1790 */
1792 
1793 /** \brief Fill in a polygon context for non-textured polygons affected by a
1794  modifier volume.
1795 
1796  This function fills in a pvr_poly_cxt_t with default parameters appropriate
1797  for rendering a non-textured polygon in the given list that will be affected
1798  by modifier volumes.
1799 
1800  \param dst Where to store the polygon context.
1801  \param list The primitive list to be used.
1802 */
1804 
1805 /** \brief Fill in a polygon context for a textured polygon affected by
1806  modifier volumes.
1807 
1808  This function fills in a pvr_poly_cxt_t with default parameters appropriate
1809  for rendering a textured polygon in the given list and being affected by
1810  modifier volumes.
1811 
1812  \param dst Where to store the polygon context.
1813  \param list The primitive list to be used.
1814  \param textureformat The format of the texture used (outside).
1815  \param tw The width of the texture, in pixels (outside).
1816  \param th The height of the texture, in pixels (outside).
1817  \param textureaddr A pointer to the texture (outside).
1818  \param filtering The type of filtering to use (outside).
1819  \param textureformat2 The format of the texture used (inside).
1820  \param tw2 The width of the texture, in pixels (inside).
1821  \param th2 The height of the texture, in pixels (inside).
1822  \param textureaddr2 A pointer to the texture (inside).
1823  \param filtering2 The type of filtering to use (inside).
1824 
1825  \see pvr_txr_fmts
1826  \see pvr_filter_modes
1827 */
1829  int textureformat, int tw, int th,
1830  pvr_ptr_t textureaddr, int filtering,
1831  int textureformat2, int tw2, int th2,
1832  pvr_ptr_t textureaddr2, int filtering2);
1833 
1834 /* Texture handling **************************************************/
1835 
1836 /* Helper functions for handling texture tasks of various kinds. */
1837 
1838 /** \brief Load raw texture data from an SH-4 buffer into PVR RAM.
1839 
1840  This essentially just acts as a memcpy() from main RAM to PVR RAM, using
1841  the store queues.
1842 
1843  \param src The location in main RAM holding the texture.
1844  \param dst The location in PVR RAM to copy to.
1845  \param count The size of the texture in bytes (must be a multiple
1846  of 32).
1847 */
1848 void pvr_txr_load(void * src, pvr_ptr_t dst, uint32 count);
1849 
1850 /** \defgroup pvr_txrload_constants Texture loading constants
1851 
1852  These are constants for the flags parameter to pvr_txr_load_ex() or
1853  pvr_txr_load_kimg().
1854 
1855  @{
1856 */
1857 #define PVR_TXRLOAD_4BPP 0x01 /**< \brief 4BPP format */
1858 #define PVR_TXRLOAD_8BPP 0x02 /**< \brief 8BPP format */
1859 #define PVR_TXRLOAD_16BPP 0x03 /**< \brief 16BPP format */
1860 #define PVR_TXRLOAD_FMT_MASK 0x0f /**< \brief Bits used for basic formats */
1862 #define PVR_TXRLOAD_VQ_LOAD 0x10 /**< \brief Do VQ encoding (not supported yet, if ever) */
1863 #define PVR_TXRLOAD_INVERT_Y 0x20 /**< \brief Invert the Y axis while loading */
1864 #define PVR_TXRLOAD_FMT_VQ 0x40 /**< \brief Texture is already VQ encoded */
1865 #define PVR_TXRLOAD_FMT_TWIDDLED 0x80 /**< \brief Texture is already twiddled */
1866 #define PVR_TXRLOAD_FMT_NOTWIDDLE 0x80 /**< \brief Don't twiddle the texture while loading */
1867 #define PVR_TXRLOAD_DMA 0x8000 /**< \brief Use DMA to load the texture */
1868 #define PVR_TXRLOAD_NONBLOCK 0x4000 /**< \brief Use non-blocking loads (only for DMA) */
1869 #define PVR_TXRLOAD_SQ 0x2000 /**< \brief Use store queues to load */
1870 /** @} */
1871 
1872 /** \brief Load texture data from an SH-4 buffer into PVR RAM, twiddling it in
1873  the process.
1874 
1875  This function loads a texture to the PVR's RAM with the specified set of
1876  flags. It will currently always twiddle the data, whether you ask it to or
1877  not, and many of the parameters are just plain not supported at all...
1878  Pretty much the only supported flag, other than the format ones is the
1879  PVR_TXRLOAD_INVERT_Y one.
1880 
1881  This will be slower than using pvr_txr_load() in pretty much all cases, so
1882  unless you need to twiddle your texture, just use that instead.
1883 
1884  \param src The location to copy from.
1885  \param dst The location to copy to.
1886  \param w The width of the texture, in pixels.
1887  \param h The height of the texture, in pixels.
1888  \param flags Some set of flags, ORed together.
1889 
1890  \see pvr_txrload_constants
1891 */
1892 void pvr_txr_load_ex(void * src, pvr_ptr_t dst, uint32 w, uint32 h, uint32 flags);
1893 
1894 /** \brief Load a KOS Platform Independent Image (subject to constraint
1895  checking).
1896 
1897  This function loads a KOS Platform Independent image to the PVR's RAM with
1898  the specified set of flags. This function, unlike pvr_txr_load_ex() supports
1899  everything in the flags available, other than what's explicitly marked as
1900  not supported.
1901 
1902  \param img The image to load.
1903  \param dst The location to copy to.
1904  \param flags Some set of flags, ORed together.
1905 
1906  \see pvr_txrload_constants
1907  \note Unless you explicitly tell this function to not
1908  twiddle the texture (by ORing
1909  \ref PVR_TXRLOAD_FMT_NOTWIDDLE or it's equivalent
1910  \ref PVR_TXRLOAD_FMT_TWIDDLED with flags), this
1911  function will twiddle the texture while loading.
1912  Keep that in mind when setting the texture format in
1913  polygon headers later.
1914  \note You cannot specify both
1915  \ref PVR_TXRLOAD_FMT_NOTWIDDLE (or equivalently
1916  \ref PVR_TXRLOAD_FMT_TWIDDLED) and
1917  \ref PVR_TXRLOAD_INVERT_Y in the flags.
1918  \note DMA and Store Queue based loading is not available
1919  from this function if it twiddles the texture while
1920  loading.
1921 */
1922 void pvr_txr_load_kimg(kos_img_t *img, pvr_ptr_t dst, uint32 flags);
1923 
1924 
1925 /* PVR DMA ***********************************************************/
1926 
1927 /** \brief PVR DMA interrupt callback type.
1928 
1929  Functions that act as callbacks when DMA completes should be of this type.
1930  These functions will be called inside an interrupt context, so don't try to
1931  use anything that might stall.
1932 
1933  \param data User data passed in to the pvr_dma_transfer()
1934  function.
1935 */
1936 typedef void (*pvr_dma_callback_t)(ptr_t data);
1938 /** \brief Perform a DMA transfer to the PVR.
1939 
1940  This function copies a block of data to the PVR or its memory via DMA. There
1941  are all kinds of constraints that must be fulfilled to actually do this, so
1942  make sure to read all the fine print with the parameter list.
1943 
1944  If a callback is specified, it will be called in an interrupt context, so
1945  keep that in mind in writing the callback.
1946 
1947  \param src Where to copy from. Must be 32-byte aligned.
1948  \param dest Where to copy to. Must be 32-byte aligned.
1949  \param count The number of bytes to copy. Must be a multiple of
1950  32.
1951  \param type The type of DMA transfer to do (see list of modes).
1952  \param block Non-zero if you want the function to block until the
1953  DMA completes.
1954  \param callback A function to call upon completion of the DMA.
1955  \param cbdata Data to pass to the callback function.
1956  \retval 0 On success.
1957  \retval -1 On failure. Sets errno as appropriate.
1958 
1959  \par Error Conditions:
1960  \em EINPROGRESS - DMA already in progress \n
1961  \em EFAULT - dest is not 32-byte aligned \n
1962  \em EIO - I/O error
1963 
1964  \see pvr_dma_modes
1965 */
1966 int pvr_dma_transfer(void * src, uint32 dest, uint32 count, int type,
1967  int block, pvr_dma_callback_t callback, ptr_t cbdata);
1968 
1969 /** \defgroup pvr_dma_modes Transfer modes with PVR DMA
1970  @{
1971 */
1972 #define PVR_DMA_VRAM64 0 /**< \brief Transfer to VRAM in interleaved mode */
1973 #define PVR_DMA_VRAM32 1 /**< \brief Transfer to VRAM in linear mode */
1974 #define PVR_DMA_TA 2 /**< \brief Transfer to the tile accelerator */
1975 /** @} */
1976 
1977 /** \brief Load a texture using PVR DMA.
1978 
1979  This is essentially a convenience wrapper for pvr_dma_transfer(), so all
1980  notes that apply to it also apply here.
1981 
1982  \param src Where to copy from. Must be 32-byte aligned.
1983  \param dest Where to copy to. Must be 32-byte aligned.
1984  \param count The number of bytes to copy. Must be a multiple of
1985  32.
1986  \param block Non-zero if you want the function to block until the
1987  DMA completes.
1988  \param callback A function to call upon completion of the DMA.
1989  \param cbdata Data to pass to the callback function.
1990  \retval 0 On success.
1991  \retval -1 On failure. Sets errno as appropriate.
1992 
1993  \par Error Conditions:
1994  \em EINPROGRESS - DMA already in progress \n
1995  \em EFAULT - dest is not 32-byte aligned \n
1996  \em EIO - I/O error
1997 */
1998 int pvr_txr_load_dma(void * src, pvr_ptr_t dest, uint32 count, int block,
1999  pvr_dma_callback_t callback, ptr_t cbdata);
2000 
2001 /** \brief Load vertex data to the TA using PVR DMA.
2002 
2003  This is essentially a convenience wrapper for pvr_dma_transfer(), so all
2004  notes that apply to it also apply here.
2005 
2006  \param src Where to copy from. Must be 32-byte aligned.
2007  \param count The number of bytes to copy. Must be a multiple of
2008  32.
2009  \param block Non-zero if you want the function to block until the
2010  DMA completes.
2011  \param callback A function to call upon completion of the DMA.
2012  \param cbdata Data to pass to the callback function.
2013  \retval 0 On success.
2014  \retval -1 On failure. Sets errno as appropriate.
2015 
2016  \par Error Conditions:
2017  \em EINPROGRESS - DMA already in progress \n
2018  \em EFAULT - dest is not 32-byte aligned \n
2019  \em EIO - I/O error
2020  */
2021 int pvr_dma_load_ta(void * src, uint32 count, int block,
2022  pvr_dma_callback_t callback, ptr_t cbdata);
2023 
2024 /** \brief Is PVR DMA is inactive?
2025  \return Non-zero if there is no PVR DMA active, thus a DMA
2026  can begin or 0 if there is an active DMA.
2027 */
2028 int pvr_dma_ready();
2029 
2030 /** \brief Initialize PVR DMA. */
2031 void pvr_dma_init();
2032 
2033 /** \brief Shut down PVR DMA. */
2034 void pvr_dma_shutdown();
2035 
2036 /*********************************************************************/
2037 
2038 
2039 __END_DECLS
2040 
2041 #endif
void pvr_poly_compile(pvr_poly_hdr_t *dst, pvr_poly_cxt_t *src)
Compile a polygon context into a polygon header.
uint32 d2
Dummy value.
Definition: pvr.h:576
void pvr_fog_table_color(float a, float r, float g, float b)
Set the table fog color.
int pvr_list_flush(pvr_list_t list)
Flush the buffered data of the given list type to the TA.
int write
Enable or disable depth writes.
Definition: pvr.h:224
uint32 auv
First U/V texture coordinates.
Definition: pvr.h:743
uint32 vbl_count
VBlank count.
Definition: pvr.h:1203
int dst
Dest blending mode.
Definition: pvr.h:214
uint32 flags
TA command (vertex flags)
Definition: pvr.h:661
int pvr_check_ready()
Check if the PVR system is ready for another frame to be submitted.
int fog_type
Fog type outside modifier.
Definition: pvr.h:84
uint32 oargb
Vertex offset color.
Definition: pvr.h:668
int list_type
Primitive list.
Definition: pvr.h:77
uint32 cmd
TA command.
Definition: pvr.h:606
uint32 mode1
Parameter word 1.
Definition: pvr.h:572
Common integer types.
void pvr_fog_table_custom(float tbl1[])
Set a custom fog table from float values.
int vtx_buffer_used
Number of bytes used in the vertex buffer for the last frame.
Definition: pvr.h:1208
int src
Source blending mode outside modifier.
Definition: pvr.h:103
uint32 mode1
Parameter word 1.
Definition: pvr.h:589
float az
First Z coordinate.
Definition: pvr.h:757
uint32 frame_count
Total number of rendered/viewed frames.
Definition: pvr.h:1211
PVR statistics structure.
Definition: pvr.h:1201
uint32 mode3
Parameter word 3.
Definition: pvr.h:574
pvr_ptr_t base
Texture pointer.
Definition: pvr.h:155
void pvr_sprite_cxt_txr(pvr_sprite_cxt_t *dst, pvr_list_t list, int textureformat, int tw, int th, pvr_ptr_t textureaddr, int filtering)
Fill in a sprite context for a textured sprite.
int write
Enable or disable depth writes.
Definition: pvr.h:131
float cx
Third X coordinate.
Definition: pvr.h:761
int alpha
Enable or disable alpha.
Definition: pvr.h:198
float cz
Third Z coordinate.
Definition: pvr.h:739
int pvr_txr_load_dma(void *src, pvr_ptr_t dest, uint32 count, int block, pvr_dma_callback_t callback, ptr_t cbdata)
Load a texture using PVR DMA.
float az
First Z coordinate.
Definition: pvr.h:781
float cy
Third Y coordinate.
Definition: pvr.h:786
uint32 d3
Dummy value.
Definition: pvr.h:790
PVR vertex type: Untextured sprite.
Definition: pvr.h:753
uint32 enabled_list_mask
Which lists are enabled?
Definition: pvr.h:1202
int src
Source blending mode.
Definition: pvr.h:212
float y
Y coordinate.
Definition: pvr.h:701
uint32 d6
Dummy value.
Definition: pvr.h:649
int filter
Filtering mode.
Definition: pvr.h:137
uint32 pvr_mem_available()
Return the number of bytes available still in the PVR RAM pool.
void pvr_set_bg_color(float r, float g, float b)
Set the background plane color.
int height
Texture height (requires a power of 2)
Definition: pvr.h:245
Functions to access the SH4 Store Queues.
PVR polygon header.
Definition: pvr.h:570
Platform-independent image type.
uint32 d4
Dummy value.
Definition: pvr.h:647
static void pvr_set_pal_entry(uint32 idx, uint32 value)
Set a palette value.
Definition: pvr.h:1273
uint32 argb0
Vertex color (outside volume)
Definition: pvr.h:684
void pvr_vertbuf_written(pvr_list_t list, uint32 amt)
Notify the PVR system that data have been written into the output buffer for the given list...
uint32 d2
Dummy value.
Definition: pvr.h:712
static uint32 PVR_PACK_16BIT_UV(float u, float v)
Pack two floating point coordinates into one 32-bit value, truncating them to 16-bits each...
Definition: pvr.h:819
uint32 mode2
Parameter word 2.
Definition: pvr.h:590
int pvr_dma_ready()
Is PVR DMA is inactive?
int dst_enable
Dest blending enable.
Definition: pvr.h:218
int color
Color format in vertex.
Definition: pvr.h:121
#define PVR_PALETTE_TABLE_BASE
Base of the palette table.
Definition: pvr.h:1019
void * pvr_ptr_t
PVR texture memory pointer.
Definition: pvr.h:49
uint32 d3
Dummy value.
Definition: pvr.h:646
void pvr_fog_vertex_color(float a, float r, float g, float b)
Set the vertex fog color.
int color_clamp
Color clamp enable/disable.
Definition: pvr.h:204
int enable
Enable/disable texturing.
Definition: pvr.h:135
PVR vertex type: Non-textured, packed color, affected by modifier volume.
Definition: pvr.h:679
uint32 mode2
Parameter word 2.
Definition: pvr.h:626
int rnd_last_time
Rendering time for the last frame in milliseconds.
Definition: pvr.h:1207
uint32 cmd
TA command.
Definition: pvr.h:642
void pvr_set_pal_format(int fmt)
Set the palette format.
float ax
First X coordinate.
Definition: pvr.h:779
int dst_enable2
Dest blending mode inside modifier.
Definition: pvr.h:117
int pvr_get_stats(pvr_stats_t *stat)
Get the current statistics from the PVR.
uint32 argb0
Vertex color (outside)
Definition: pvr.h:705
int culling
Culling mode.
Definition: pvr.h:86
float cx
Third X coordinate.
Definition: pvr.h:785
float cx
Third X coordinate.
Definition: pvr.h:737
float frame_rate
Current frame rate (per second)
Definition: pvr.h:1205
uint32 d4
Dummy value.
Definition: pvr.h:769
float dy
Fourth Y coordinate.
Definition: pvr.h:741
int uv_clamp
Enable/disable U/V clamping.
Definition: pvr.h:238
void * pvr_set_vertbuf(pvr_list_t list, void *buffer, int len)
Setup a vertex buffer for one of the list types.
float dy
Fourth Y coordinate.
Definition: pvr.h:765
uint32 argb
Vertex color.
Definition: pvr.h:667
int uv_flip
Enable/disable U/V flipping.
Definition: pvr.h:143
uint32 mode2_0
Parameter word 2 (outside volume)
Definition: pvr.h:608
int pvr_vertex_dma_enabled()
Is vertex DMA enabled?
void pvr_fog_table_exp(float density)
Initialize the fog table using an exp algorithm (like GL_EXP).
int width
Texture width (requires a power of 2)
Definition: pvr.h:244
float bx
Second X coordinate.
Definition: pvr.h:734
void pvr_sprite_compile(pvr_sprite_hdr_t *dst, pvr_sprite_cxt_t *src)
Compile a sprite context into a sprite header.
int uv_clamp
Enable/disable U/V clamping.
Definition: pvr.h:145
uint32 d4
Dummy value.
Definition: pvr.h:578
void pvr_txr_load(void *src, pvr_ptr_t dst, uint32 count)
Load raw texture data from an SH-4 buffer into PVR RAM.
float by
Second Y coordinate.
Definition: pvr.h:735
int pvr_dma_transfer(void *src, uint32 dest, uint32 count, int type, int block, pvr_dma_callback_t callback, ptr_t cbdata)
Perform a DMA transfer to the PVR.
int specular
Offset color enable/disable.
Definition: pvr.h:208
uint32 d2
Dummy value.
Definition: pvr.h:631
float az
First Z coordinate.
Definition: pvr.h:733
uint32 cuv
Third U/V texture coordinates.
Definition: pvr.h:745
float x
X coordinate.
Definition: pvr.h:681
uint32 argb1
Vertex color (inside volume)
Definition: pvr.h:685
float z
Z coordinate.
Definition: pvr.h:683
int pvr_dma_load_ta(void *src, uint32 count, int block, pvr_dma_callback_t callback, ptr_t cbdata)
Load vertex data to the TA using PVR DMA.
pvr_ptr_t pvr_mem_malloc(size_t size)
Allocate a chunk of memory from texture space.
uint32 mode1
Parameter word 1.
Definition: pvr.h:643
int mipmap
Enable/disable mipmaps.
Definition: pvr.h:139
uint32 mode2
Parameter word 2.
Definition: pvr.h:573
uint32 pvr_list_t
PVR list specification.
Definition: pvr.h:58
float a
Face color alpha component.
Definition: pvr.h:592
int filter
Filtering mode.
Definition: pvr.h:230
float bz
Second Z coordinate.
Definition: pvr.h:736
uint32 mode1
Parameter word 1.
Definition: pvr.h:625
float z
Z coordinate.
Definition: pvr.h:702
uint32 cmd
TA command.
Definition: pvr.h:624
uint32 mode3_1
Parameter word 3 (inside volume)
Definition: pvr.h:611
void pvr_scene_begin()
Begin collecting data for a frame of 3D output to the off-screen frame buffer.
float bx
Second X coordinate.
Definition: pvr.h:758
PVR polygon header with intensity color.
Definition: pvr.h:587
Platform-indpendent image type.
Definition: img.h:44
uint32 d5
Dummy value.
Definition: pvr.h:648
PVR polygon header to be used with modifier volumes.
Definition: pvr.h:605
float dx
Fourth X coordinate.
Definition: pvr.h:740
uint32 flags
TA command (vertex flags)
Definition: pvr.h:680
float g
Face color green component.
Definition: pvr.h:594
pvr_ptr_t base
Texture pointer.
Definition: pvr.h:248
float bz
Second Z coordinate.
Definition: pvr.h:760
uint32 dummy
Dummy value.
Definition: pvr.h:742
int pvr_init_defaults()
Simple PVR initialization.
int pvr_list_begin(pvr_list_t list)
Begin collecting data for the given list type.
float dx
Fourth X coordinate.
Definition: pvr.h:764
uint32 d2
Dummy value.
Definition: pvr.h:767
float y
Y coordinate.
Definition: pvr.h:663
void pvr_txr_load_kimg(kos_img_t *img, pvr_ptr_t dst, uint32 flags)
Load a KOS Platform Independent Image (subject to constraint checking).
int dst2
Dest blending mode inside modifier.
Definition: pvr.h:113
void pvr_set_presort_mode(int presort)
Set the translucent polygon sort mode for the next frame.
float v1
Texture V coordinate (inside)
Definition: pvr.h:708
int reg_last_time
Registration time for the last frame in milliseconds.
Definition: pvr.h:1206
int pvr_wait_ready()
Block the caller until the PVR system is ready for another frame to be submitted. ...
void pvr_scene_begin_txr(pvr_ptr_t txr, uint32 *rx, uint32 *ry)
Begin collecting data for a frame of 3D output to the specified texture.
void pvr_set_shadow_scale(int enable, float scale_value)
Set cheap shadow parameters.
PVR polygon context.
Definition: pvr.h:76
float cy
Third Y coordinate.
Definition: pvr.h:762
uint32 flags
TA command (vertex flags)
Definition: pvr.h:730
float v0
Texture V coordinate (outside)
Definition: pvr.h:704
uint32 d2
Dummy value.
Definition: pvr.h:645
uint32 d3
Dummy value.
Definition: pvr.h:768
int specular
Offset color enable/disable outside modifier.
Definition: pvr.h:93
PVR vertex type: Textured sprite.
Definition: pvr.h:729
int alpha2
Enable/disable alpha inside modifier.
Definition: pvr.h:95
void pvr_poly_cxt_txr(pvr_poly_cxt_t *dst, pvr_list_t list, int textureformat, int tw, int th, pvr_ptr_t textureaddr, int filtering)
Fill in a polygon context for a textured polygon.
float ay
First Y coordinate.
Definition: pvr.h:756
uint32 ptr_t
Pointer arithmetic type.
Definition: types.h:47
int uv_flip
Enable/disable U/V flipping.
Definition: pvr.h:236
int comparison
Depth comparison mode.
Definition: pvr.h:129
uint32 d1
Dummy value.
Definition: pvr.h:686
int mipmap
Enable/disable mipmaps.
Definition: pvr.h:232
uint32 pvr_dr_state_t
Direct Rendering state variable type.
Definition: pvr.h:1584
int pvr_scene_finish()
Call this after you have finished submitting all data for a frame.
uint32 d1
Dummy value.
Definition: pvr.h:575
void pvr_poly_mod_compile(pvr_poly_mod_hdr_t *dst, pvr_poly_cxt_t *src)
Compile a polygon context into a polygon header that is affected by modifier volumes.
int src_enable
Source blending enable outside modifier.
Definition: pvr.h:107
uint32 oargb1
Vertex offset color (inside)
Definition: pvr.h:710
int enable
Enable/disable texturing.
Definition: pvr.h:228
float u
Texture U coordinate.
Definition: pvr.h:665
uint32 argb
Sprite face color.
Definition: pvr.h:628
uint32 d1
Dummy value.
Definition: pvr.h:644
uint32 buv
Second U/V texture coordinates.
Definition: pvr.h:744
float by
Second Y coordinate.
Definition: pvr.h:783
unsigned long uint32
32-bit unsigned integer
Definition: types.h:28
void pvr_sprite_cxt_col(pvr_sprite_cxt_t *dst, pvr_list_t list)
Fill in a sprite context for non-textured sprites.
int mipmap_bias
Mipmap bias.
Definition: pvr.h:141
void * pvr_vertbuf_tail(pvr_list_t list)
Retrieve a pointer to the current output location in the DMA buffer for the requested list...
#define PVR_SET(REG, VALUE)
Set a PVR register value.
Definition: pvr.h:955
int pvr_prim(void *data, int size)
Submit a primitive of the current list type.
int mipmap_bias
Mipmap bias.
Definition: pvr.h:234
void pvr_poly_cxt_col(pvr_poly_cxt_t *dst, pvr_list_t list)
Fill in a polygon context for non-textured polygons.
int pvr_init(pvr_init_params_t *params)
Initialize the PVR chip to ready status.
void pvr_mem_stats()
Print statistics about the PVR RAM pool.
uint32 cmd
TA command.
Definition: pvr.h:588
uint32 oargb
Sprite offset color.
Definition: pvr.h:629
uint32 d4
Dummy value.
Definition: pvr.h:714
PVR sprite context.
Definition: pvr.h:194
float ay
First Y coordinate.
Definition: pvr.h:780
PVR vertex type: Modifier volume.
Definition: pvr.h:777
Modifier volume header.
Definition: pvr.h:641
int color_clamp
Color clamp enable/disable outside modifier.
Definition: pvr.h:88
int list_type
Primitive list.
Definition: pvr.h:195
void pvr_fog_table_exp2(float density)
Initialize the fog table using an exp2 algorithm (like GL_EXP2).
PVR vertex type: Textured, packed color, affected by modifer volume.
Definition: pvr.h:698
float y
Y coordinate.
Definition: pvr.h:682
int dst
Dest blending mode outside modifier.
Definition: pvr.h:105
PVR initialization structure.
Definition: pvr.h:1077
float z
Z coordinate.
Definition: pvr.h:664
int pvr_list_finish()
End collecting data for the current list type.
int env
Texture color contribution.
Definition: pvr.h:242
float v
Texture V coordinate.
Definition: pvr.h:666
uint32 d1
Dummy value.
Definition: pvr.h:766
void pvr_mem_reset()
Reset the PVR RAM pool.
uint32 mode3
Parameter word 3.
Definition: pvr.h:627
int uv
U/V data format in vertex.
Definition: pvr.h:123
int width
Texture width (requires a power of 2)
Definition: pvr.h:151
uint32 d6
Dummy value.
Definition: pvr.h:793
float u0
Texture U coordinate (outside)
Definition: pvr.h:703
uint32 mode1
Parameter word 1.
Definition: pvr.h:607
int shading
Shading type.
Definition: pvr.h:82
uint32 d5
Dummy value.
Definition: pvr.h:792
uint32 d3
Dummy value.
Definition: pvr.h:577
void pvr_mem_free(pvr_ptr_t chunk)
Free a block of allocated memory in the PVR RAM pool.
float x
X coordinate.
Definition: pvr.h:700
uint32 d4
Dummy value.
Definition: pvr.h:791
float ay
First Y coordinate.
Definition: pvr.h:732
uint32 d2
Dummy value.
Definition: pvr.h:687
uint32 mode3
Parameter word 3.
Definition: pvr.h:591
uint32 d1
Dummy value.
Definition: pvr.h:612
uint32 oargb0
Vertex offset color (outside)
Definition: pvr.h:706
int frame_last_time
Ready-to-Ready length for the last frame in milliseconds.
Definition: pvr.h:1204
uint32 flags
TA command (vertex flags)
Definition: pvr.h:778
int pvr_list_prim(pvr_list_t list, void *data, int size)
Submit a primitive of the given list type.
float b
Face color blue component.
Definition: pvr.h:595
uint32 d1
Dummy value.
Definition: pvr.h:788
void pvr_poly_cxt_col_mod(pvr_poly_cxt_t *dst, pvr_list_t list)
Fill in a polygon context for non-textured polygons affected by a modifier volume.
int culling
Culling mode.
Definition: pvr.h:202
float x
X coordinate.
Definition: pvr.h:662
Generic PVR vertex type.
Definition: pvr.h:660
int fog_type
Fog type.
Definition: pvr.h:200
uint32 flags
TA command (vertex flags)
Definition: pvr.h:754
PVR polygon header specifically for sprites.
Definition: pvr.h:623
int height
Texture height (requires a power of 2)
Definition: pvr.h:152
uint32 flags
TA command (vertex flags)
Definition: pvr.h:699
void pvr_mem_print_list()
Print the list of allocated blocks in the PVR RAM pool.
void pvr_fog_table_linear(float start, float end)
Initialize the fog table using a linear algorithm (like GL_LINEAR).
float bx
Second X coordinate.
Definition: pvr.h:782
uint32 d1
Dummy value.
Definition: pvr.h:711
int modifier_mode
Modifier mode.
Definition: pvr.h:92
float by
Second Y coordinate.
Definition: pvr.h:759
int format
Texture format.
Definition: pvr.h:153
float ax
First X coordinate.
Definition: pvr.h:731
uint32 argb1
Vertex color (inside)
Definition: pvr.h:709
struct pvr_stats pvr_stats_t
PVR statistics structure.
void pvr_fog_far_depth(float d)
Set the fog far depth.
int clip_mode
Clipping mode.
Definition: pvr.h:206
void pvr_mod_compile(pvr_mod_hdr_t *dst, pvr_list_t list, uint32 mode, uint32 cull)
Create a modifier volume header.
float ax
First X coordinate.
Definition: pvr.h:755
int src_enable
Source blending enable.
Definition: pvr.h:216
void pvr_poly_cxt_txr_mod(pvr_poly_cxt_t *dst, pvr_list_t list, int textureformat, int tw, int th, pvr_ptr_t textureaddr, int filtering, int textureformat2, int tw2, int th2, pvr_ptr_t textureaddr2, int filtering2)
Fill in a polygon context for a textured polygon affected by modifier volumes.
int fog_type2
Fog type inside modifier.
Definition: pvr.h:97
float cz
Third Z coordinate.
Definition: pvr.h:787
uint32 mode2_1
Parameter word 2 (inside volume)
Definition: pvr.h:610
uint32 d1
Dummy value.
Definition: pvr.h:630
float u1
Texture U coordinate (inside)
Definition: pvr.h:707
float cz
Third Z coordinate.
Definition: pvr.h:763
int dst_enable
Dest blending enable outside modifier.
Definition: pvr.h:109
void pvr_dma_init()
Initialize PVR DMA.
int comparison
Depth comparison mode.
Definition: pvr.h:222
uint32 d2
Dummy value.
Definition: pvr.h:613
void(* pvr_dma_callback_t)(ptr_t data)
PVR DMA interrupt callback type.
Definition: pvr.h:1937
int src2
Source blending mode inside modifier.
Definition: pvr.h:111
void pvr_dma_shutdown()
Shut down PVR DMA.
int pvr_get_vbl_count()
Retrieve the current VBlank count.
int color_clamp2
Color clamp enable/disable inside modifier.
Definition: pvr.h:99
void pvr_txr_load_ex(void *src, pvr_ptr_t dst, uint32 w, uint32 h, uint32 flags)
Load texture data from an SH-4 buffer into PVR RAM, twiddling it in the process.
uint32 d3
Dummy value.
Definition: pvr.h:713
int env
Texture color contribution.
Definition: pvr.h:149
float cy
Third Y coordinate.
Definition: pvr.h:738
int buf_last_time
DMA buffer file time for the last frame in milliseconds.
Definition: pvr.h:1210
float bz
Second Z coordinate.
Definition: pvr.h:784
int format
Texture format.
Definition: pvr.h:246
int alpha
Enable or disable alpha outside modifier.
Definition: pvr.h:80
int clip_mode
Clipping mode.
Definition: pvr.h:90
int vtx_buffer_used_max
Number of bytes used in the vertex buffer for the largest frame.
Definition: pvr.h:1209
uint32 mode3_0
Parameter word 3 (outside volume)
Definition: pvr.h:609
uint32 cmd
TA command.
Definition: pvr.h:571
int src_enable2
Source blending mode inside modifier.
Definition: pvr.h:115
float r
Face color red component.
Definition: pvr.h:593
int pvr_shutdown()
Shut down the PVR chip from ready status.
uint32 d2
Dummy value.
Definition: pvr.h:789
int modifier
Enable or disable modifier effect.
Definition: pvr.h:125