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